JAL-4059 Revert libjs/MiGLayout as new miglayout transpile of 4.0 includes reference...
[jalview.git] / src / jalview / gui / JvSwingUtils.java
index c00be98..f0fd3a8 100644 (file)
@@ -70,26 +70,33 @@ public final class JvSwingUtils
   {
     Objects.requireNonNull(ttext,
             "Tootip text to format must not be null!");
-    ttext = ttext.trim();
+    if (enclose)
+    {
+      ttext = ttext.trim();
+    }
     boolean maxLengthExceeded = false;
 
     boolean hasBr = false;
     for (String br : new String[] { "<br>", "<br/>" })
     {
-      hasBr = true;
       if (ttext.contains(br))
       {
+        hasBr = true;
         String[] htmllines = ttext.split(br);
         StringBuilder sb = new StringBuilder();
         for (String line : htmllines)
         {
-          line = line.replaceAll("\\s+", " ");
-          line = line.trim();
+          if (enclose)
+          {
+            line = line.replaceAll("\\s+", " ");
+            line = line.trim();
+          }
           if (line.length() == 0 || line.equals(" "))
           {
             continue;
           }
-          maxLengthExceeded = line.length() > 60;
+          String linetext = line.replaceAll("<[^>]+>", "");
+          maxLengthExceeded = linetext.length() > 60;
           if (sb.length() > 0)
           {
             sb.append(br);
@@ -99,10 +106,13 @@ public final class JvSwingUtils
         ttext = sb.toString();
       }
     }
-    if (!hasBr)
+    if (enclose)
     {
       ttext = ttext.replaceAll("\\s+", " ");
       ttext = ttext.trim();
+    }
+    if (!hasBr)
+    {
       maxLengthExceeded = ttext.length() > 60;
     }