From: tcofoegbu Date: Fri, 12 Jun 2015 16:50:02 +0000 (+0100) Subject: JAL-1627 removed extra spaces at end of tooltip X-Git-Tag: Release_2_10_0~609^2~3^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=872491e84ca43e8ec17ef8c0395d1b7a45e6b5d4;p=jalview.git JAL-1627 removed extra spaces at end of tooltip --- diff --git a/src/jalview/gui/JvSwingUtils.java b/src/jalview/gui/JvSwingUtils.java index e4cbf61..b6f85b3 100644 --- a/src/jalview/gui/JvSwingUtils.java +++ b/src/jalview/gui/JvSwingUtils.java @@ -20,8 +20,6 @@ */ package jalview.gui; -import jalview.util.MessageManager; - import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; @@ -39,6 +37,8 @@ import javax.swing.JPanel; import javax.swing.JScrollBar; import javax.swing.SwingConstants; +import jalview.util.MessageManager; + /** * useful functions for building Swing GUIs * @@ -60,15 +60,34 @@ public final class JvSwingUtils public static String wrapTooltip(boolean enclose, String ttext) { ttext = ttext.trim(); - if (ttext.length() < 60) + boolean maxLenghtExceeded = false; + + if (ttext.contains("
")) + { + String[] htmllines = ttext.split("
"); + for (String line : htmllines) + { + maxLenghtExceeded = line.length() > 60; + if (maxLenghtExceeded) + { + break; + } + } + } + else + { + maxLenghtExceeded = ttext.length() > 60; + } + + if (!maxLenghtExceeded) { return enclose ? "" + ttext + "" : ttext; } else { - return (enclose ? "" : "") - + "
" + ttext - + "
" + ((enclose ? "" : "")); + return (enclose ? "
" + : "") + + ttext + ((enclose ? "
" : "")); } }