merge from 2_4_Release branch
[jalview.git] / src / jalview / appletgui / Tooltip.java
index 7de5193..0bbe98b 100755 (executable)
@@ -1,22 +1,21 @@
 /*\r
- * Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
- *\r
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)\r
+ * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * \r
  * This program is free software; you can redistribute it and/or\r
  * modify it under the terms of the GNU General Public License\r
  * as published by the Free Software Foundation; either version 2\r
  * of the License, or (at your option) any later version.\r
- *\r
+ * \r
  * This program is distributed in the hope that it will be useful,\r
  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
  * GNU General Public License for more details.\r
- *\r
+ * \r
  * You should have received a copy of the GNU General Public License\r
  * along with this program; if not, write to the Free Software\r
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
  */\r
-\r
 package jalview.appletgui;\r
 \r
 import java.applet.*;\r
@@ -25,21 +24,25 @@ import java.util.*;
 import java.awt.*;\r
 import java.awt.event.*;\r
 \r
-public class Tooltip\r
-    extends Canvas implements MouseListener,\r
-    MouseMotionListener\r
+public class Tooltip extends Canvas implements MouseListener,\r
+        MouseMotionListener\r
 {\r
   private String[] tip;\r
+\r
   private String lastTip = "";\r
+\r
   private boolean setPosition = false;\r
+\r
   protected Component owner;\r
 \r
   private Container mainContainer;\r
+\r
   private LayoutManager mainLayout;\r
 \r
   private boolean shown;\r
 \r
   private final int VERTICAL_OFFSET = 20;\r
+\r
   private final int HORIZONTAL_ENLARGE = 10;\r
 \r
   int fontHeight = 0;\r
@@ -77,15 +80,15 @@ public class Tooltip
       {\r
         if (lindex > 0)\r
         {\r
-          g.drawString(tip[i].substring(0, lindex), 3, (i + 1) * fontHeight - 3);\r
+          g.drawString(tip[i].substring(0, lindex), 3, (i + 1) * fontHeight\r
+                  - 3);\r
           x += fm.stringWidth(tip[i].substring(0, lindex) + 3);\r
         }\r
         g.drawImage(linkImage, x, i * fontHeight + 1, this);\r
         if (lindex + 6 < tip[i].length())\r
         {\r
-          g.drawString(tip[i].substring(lindex + 6),\r
-                       x + linkImage.getWidth(this),\r
-                       (i + 1) * fontHeight - 3);\r
+          g.drawString(tip[i].substring(lindex + 6), x\r
+                  + linkImage.getWidth(this), (i + 1) * fontHeight - 3);\r
         }\r
       }\r
       else\r
@@ -128,8 +131,7 @@ public class Tooltip
       index++;\r
     }\r
 \r
-    setSize(longestLine + HORIZONTAL_ENLARGE,\r
-            fontHeight * this.tip.length);\r
+    setSize(longestLine + HORIZONTAL_ENLARGE, fontHeight * this.tip.length);\r
 \r
     repaint();\r
 \r
@@ -137,21 +139,21 @@ public class Tooltip
 \r
   void setTipLocation(MouseEvent evt)\r
   {\r
-    if(mainContainer==null || owner==null)\r
+    if (mainContainer == null || owner == null)\r
     {\r
       return;\r
     }\r
-    setLocation( (owner.getLocationOnScreen().x\r
-                  - mainContainer.getLocationOnScreen().x) + evt.getX(),\r
-                (owner.getLocationOnScreen().y -\r
-                 mainContainer.getLocationOnScreen().y\r
-                 + VERTICAL_OFFSET) + evt.getY());\r
+    setLocation((owner.getLocationOnScreen().x - mainContainer\r
+            .getLocationOnScreen().x)\r
+            + evt.getX(), (owner.getLocationOnScreen().y\r
+            - mainContainer.getLocationOnScreen().y + VERTICAL_OFFSET)\r
+            + evt.getY());\r
 \r
     // correction, whole tool tip must be visible\r
     if (mainContainer.getSize().width < (getLocation().x + getSize().width))\r
     {\r
       setLocation(mainContainer.getSize().width - getSize().width,\r
-                  getLocation().y);\r
+              getLocation().y);\r
     }\r
   }\r
 \r
@@ -171,7 +173,7 @@ public class Tooltip
     Container parent = owner.getParent();\r
     while (true)\r
     {\r
-      if ( (parent instanceof Applet) || (parent instanceof Frame))\r
+      if ((parent instanceof Applet) || (parent instanceof Frame))\r
       {\r
         mainContainer = parent;\r
         break;\r
@@ -200,10 +202,12 @@ public class Tooltip
   }\r
 \r
   public void mouseReleased(MouseEvent me)\r
-  {}\r
+  {\r
+  }\r
 \r
   public void mouseClicked(MouseEvent me)\r
-  {}\r
+  {\r
+  }\r
 \r
   public void mouseMoved(MouseEvent me)\r
   {\r
@@ -224,5 +228,6 @@ public class Tooltip
   }\r
 \r
   public void mouseDragged(MouseEvent me)\r
-  {}\r
+  {\r
+  }\r
 }\r