Max width for tooltip
authoramwaterhouse <Andrew Waterhouse>
Mon, 7 May 2007 13:58:46 +0000 (13:58 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 7 May 2007 13:58:46 +0000 (13:58 +0000)
src/jalview/gui/IdPanel.java

index aa91354..4ca622d 100755 (executable)
@@ -70,50 +70,62 @@ public class IdPanel
   public void mouseMoved(MouseEvent e)\r
   {\r
     int seq = Math.max(0, alignPanel.seqPanel.findSeq(e));\r
+    String tmp;\r
     if (seq > -1 && seq < av.alignment.getHeight())\r
     {\r
       SequenceI sequence = av.alignment.getSequenceAt(seq);\r
-      StringBuffer tip = new StringBuffer("<html>");\r
-      tip.append(sequence.getDisplayId(true));\r
+      StringBuffer tip = new StringBuffer();\r
+\r
+      int maxWidth = 0;\r
       if (sequence.getDescription() != null)\r
       {\r
-        tip.append("<table width=250 border=0><tr><td><i>");\r
-        tip.append(sequence.getDescription());\r
+        tmp = sequence.getDescription();\r
+        tip.append(tmp);\r
+        maxWidth = Math.max(maxWidth, tmp.length());\r
+      }\r
 \r
-        DBRefEntry[] dbrefs = sequence.getDatasetSequence().getDBRef();\r
-        if (dbrefs != null)\r
+      DBRefEntry[] dbrefs = sequence.getDatasetSequence().getDBRef();\r
+      if (dbrefs != null)\r
+      {\r
+        tip.append("<i>");\r
+        for (int i = 0; i < dbrefs.length; i++)\r
         {\r
-          tip.append("<i>");\r
-          for (int i = 0; i < dbrefs.length; i++)\r
-          {\r
-            tip.append("<br>");\r
-            tip.append(dbrefs[i].getSource() + " "\r
-                       + dbrefs[i].getAccessionId());\r
-          }\r
-          tip.append("</i>");\r
+          tip.append("<br>");\r
+          tmp = dbrefs[i].getSource() + " " + dbrefs[i].getAccessionId();\r
+          tip.append(tmp);\r
+          maxWidth = Math.max(maxWidth, tmp.length());\r
         }\r
+        tip.append("</i>");\r
+      }\r
 \r
-        //ADD NON POSITIONAL SEQUENCE INFO\r
-        SequenceFeature[] features = sequence.getDatasetSequence().\r
-            getSequenceFeatures();\r
-        if (features != null)\r
+\r
+      //ADD NON POSITIONAL SEQUENCE INFO\r
+      SequenceFeature[] features = sequence.getDatasetSequence().\r
+          getSequenceFeatures();\r
+      if (features != null)\r
+      {\r
+        for (int i = 0; i < features.length; i++)\r
         {\r
-          for (int i = 0; i < features.length; i++)\r
+          if (features[i].begin == 0 && features[i].end == 0)\r
           {\r
-            if (features[i].begin == 0 && features[i].end == 0)\r
-            {\r
-              tip.append("<br>" + features[i].featureGroup\r
-                         + " " + features[i].getType() + " " +\r
-                         features[i].description);\r
-            }\r
+            tmp = features[i].featureGroup\r
+                       + " " + features[i].getType() + " " +\r
+                       features[i].description;\r
+            tip.append("<br>" + tmp);\r
+            maxWidth = Math.max(maxWidth, tmp.length());\r
           }\r
         }\r
-        tip.append("</i></td></tr></table>");\r
       }\r
 \r
+      if(maxWidth > 60)\r
+      {\r
+         tip.insert(0, "<table width=350 border=0><tr><td><i>");\r
+         tip.append("</i></td></tr></table>");\r
+      }\r
 \r
       tip.append("</html>");\r
-      setToolTipText(tip.toString());\r
+\r
+      setToolTipText("<html>"+sequence.getDisplayId(true)+tip.toString());\r
     }\r
   }\r
 \r