X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FJvSwingUtils.java;h=052c3145a6fc0552da876cac47869d1fafc45aaf;hb=f931c557266d95b3f4ab5b64bd108123c90e85ab;hp=a9d0e7540b57ea938f8bb67613fc024ee3944527;hpb=2e2e69270705be9d26a6f9b44de3cedcef2b9042;p=jalview.git diff --git a/src/jalview/gui/JvSwingUtils.java b/src/jalview/gui/JvSwingUtils.java index a9d0e75..052c314 100644 --- a/src/jalview/gui/JvSwingUtils.java +++ b/src/jalview/gui/JvSwingUtils.java @@ -49,12 +49,12 @@ import javax.swing.SwingConstants; public final class JvSwingUtils { /** - * wrap a bare html safe string to around 60 characters per line using a - * - * - * field - * @param enclose TODO - * @param ttext + * 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 + * @param ttext * * @return */ @@ -62,15 +62,15 @@ public final class JvSwingUtils { Objects.requireNonNull(ttext, "Tootip text to format must not be null!"); ttext = ttext.trim(); - boolean maxLenghtExceeded = false; + boolean maxLengthExceeded = false; if (ttext.contains("
")) { String[] htmllines = ttext.split("
"); for (String line : htmllines) { - maxLenghtExceeded = line.length() > 60; - if (maxLenghtExceeded) + maxLengthExceeded = line.length() > 60; + if (maxLengthExceeded) { break; } @@ -78,19 +78,18 @@ public final class JvSwingUtils } else { - maxLenghtExceeded = ttext.length() > 60; + maxLengthExceeded = ttext.length() > 60; } - if (!maxLenghtExceeded) + if (!maxLengthExceeded) { return enclose ? "" + ttext + "" : ttext; } - else - { - return enclose ? "

" - + ttext + "

" - : ttext; - } + + return (enclose ? "" : "") + + "

" + + ttext + "

" + ((enclose ? "" : "")); + } public static JButton makeButton(String label, String tooltip,