X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FJvSwingUtils.java;h=fc2ecdea44e94b336750a9ac4bc33f41ef3a48c9;hb=ead01b555e8b1d6322cecdf7780222c73143a03a;hp=d44080a09cbd9cba0f7ea109cf824bbf44920b6a;hpb=9d74e358a8496d97f08ac44ad4dc879125016d94;p=jalview.git diff --git a/src/jalview/gui/JvSwingUtils.java b/src/jalview/gui/JvSwingUtils.java index d44080a..fc2ecde 100644 --- a/src/jalview/gui/JvSwingUtils.java +++ b/src/jalview/gui/JvSwingUtils.java @@ -56,12 +56,15 @@ import javax.swing.border.TitledBorder; */ public final class JvSwingUtils { + static final String HTML_PREFIX = "
"; + /** * wrap a bare html safe string to around 60 characters per line using a CSS * style class specifying word-wrap and break-word * * @param enclose - * if true, add <html> wrapper tags + * if true, add <html> wrapper tags (currently false for only + * two references -- both in Jws2Discoverer -- * @param ttext * * @return @@ -72,8 +75,19 @@ public final class JvSwingUtils "Tootip text to format must not be null!"); ttext = ttext.trim(); boolean maxLengthExceeded = false; - - if (ttext.contains("
")) + boolean isHTML = ttext.startsWith(""); + if (isHTML) + { + ttext = ttext.substring(6); + } + if (ttext.endsWith("")) + { + isHTML = true; + ttext = ttext.substring(0, ttext.length() - 7); + } + boolean hasBR = ttext.contains("
"); + enclose |= isHTML || hasBR; + if (hasBR) { String[] htmllines = ttext.split("
"); for (String line : htmllines) @@ -94,21 +108,8 @@ public final class JvSwingUtils { return enclose ? "" + ttext + "" : ttext; } - - return (enclose ? "" : "") - - // BH 2018 - - + "
" - -// + "

" - - + ttext - - + "

" -// + "

" - + ((enclose ? "" : "")); + // BH 2018,2019 + return (enclose ? HTML_PREFIX + ttext + "
" : ttext); } @@ -352,6 +353,7 @@ public final class JvSwingUtils combo.setToolTipText(tooltips.get(j)); } } + @Override public void mouseExited(MouseEvent e) {