*/
public final class JvSwingUtils
{
+ public static final String HTML_PREFIX = "<html><div style=\"width:350px;white-space:pre-wrap;padding:2px;overflow-wrap:break-word;\">";
+
/**
* wrap a bare html safe string to around 60 characters per line using a CSS
* style class specifying word-wrap and break-word
}
// BH 2018,2019
return (enclose
- ? "<html><div style=\"width:350px;white-space:pre-wrap;padding:2px;overflow-wrap:break-word;\">"
+ ? HTML_PREFIX
+ ttext
+ "</div></html>"
: ttext);
public void testWrapTooltip_longText()
{
String tip = "Now is the winter of our discontent made glorious summer by this sun of York";
- String expected = "<style> div.ttip {width:350px;white-space:pre-wrap;padding:2px;overflow-wrap:break-word;}</style>"
- + "<div class=\"ttip\">" + tip + " </div>";
- assertEquals("<html>" + expected + "</html>",
+ String expected = JvSwingUtils.HTML_PREFIX + tip + " </div></html>";
+ assertEquals(expected,
JvSwingUtils.wrapTooltip(true, tip));
assertEquals(expected, JvSwingUtils.wrapTooltip(false, tip));
}
// String expected = "<html><style> p.ttip {width: 350; text-align: justify;
// word-wrap: break-word;}</style><p class=\"ttip\">"
// + s + "<br/>Jmol/secondary structure<br/>PDB/Temp</p></html>";
- String expected = "<html><style> div.ttip {width:350px;white-space:pre-wrap;padding:2px;overflow-wrap:break-word;}</style>"
- + "<div class=\"ttip\">" + s
- + "<br/>Jmol/secondary structure<br/>PDB/Temp </div></html>";
+ String expected = JvSwingUtils.HTML_PREFIX + s
+ + "<br/>Jmol/secondary structure<br/>PDB/Temp</div></html>";
assertEquals(expected, menu.getToolTipText());
}
// String expected = "<html><style> p.ttip {width: 350; text-align: justify;
// word-wrap: break-word;}</style><p class=\"ttip\">"
// + s + "<br/>Jmol/secondary structure<br/>PDB/Temp</p></html>";
- String expected = "<html><style> div.ttip {width:350px;white-space:pre-wrap;padding:2px;overflow-wrap:break-word;}</style>"
- + "<div class=\"ttip\">Add annotations for<br/>Jmol/secondary structure<br/>PDB/Temp </div></html>";
+ String expected = JvSwingUtils.HTML_PREFIX
+ + "Add annotations for<br/>Jmol/secondary structure<br/>PDB/Temp</div></html>";
assertEquals(expected, menu.getToolTipText());
}