JAL-3049 corrected code and unit tests
[jalview.git] / src / jalview / gui / FeatureSettings.java
index c0097cd..37258e4 100644 (file)
@@ -81,8 +81,6 @@ import javax.swing.Icon;
 import javax.swing.JButton;
 import javax.swing.JCheckBox;
 import javax.swing.JCheckBoxMenuItem;
-import javax.swing.JColorChooser;
-import javax.swing.JDialog;
 import javax.swing.JInternalFrame;
 import javax.swing.JLabel;
 import javax.swing.JLayeredPane;
@@ -94,6 +92,7 @@ import javax.swing.JSlider;
 import javax.swing.JTable;
 import javax.swing.ListSelectionModel;
 import javax.swing.SwingConstants;
+import javax.swing.ToolTipManager;
 import javax.swing.border.Border;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
@@ -220,7 +219,7 @@ public class FeatureSettings extends JPanel
         case COLOUR_COLUMN:
           FeatureColourI colour = (FeatureColourI) table.getValueAt(row,
                   column);
-          tip = getColorTooltip(colour);
+          tip = getColorTooltip(colour, true);
           break;
         case FILTER_COLUMN:
           FeatureMatcherSet o = (FeatureMatcherSet) table.getValueAt(row,
@@ -236,7 +235,7 @@ public class FeatureSettings extends JPanel
       }
 
       /**
-       * Position the tooltip at the bottom edge of, and half way across, the
+       * Position the tooltip near the bottom edge of, and half way across, the
        * current cell
        */
       @Override
@@ -246,12 +245,13 @@ public class FeatureSettings extends JPanel
         int column = table.columnAtPoint(point);
         int row = table.rowAtPoint(point);
         Rectangle r = getCellRect(row, column, false);
-        Point loc = new Point(r.x + r.width / 2, r.y + r.height);
+        Point loc = new Point(r.x + r.width / 2, r.y + r.height - 3);
         return loc;
       }
     };
     table.getTableHeader().setFont(new Font("Verdana", Font.PLAIN, 12));
     table.setFont(new Font("Verdana", Font.PLAIN, 12));
+    ToolTipManager.sharedInstance().registerComponent(table);
 
     // table.setDefaultRenderer(Color.class, new ColorRenderer());
     // table.setDefaultEditor(Color.class, new ColorEditor(this));
@@ -1360,9 +1360,12 @@ public class FeatureSettings extends JPanel
    * Answers a suitable tooltip to show on the colour cell of the table
    * 
    * @param fcol
+   * @param withHint
+   *          if true include 'click to edit' and similar text
    * @return
    */
-  public static String getColorTooltip(FeatureColourI fcol)
+  public static String getColorTooltip(FeatureColourI fcol,
+          boolean withHint)
   {
     if (fcol == null)
     {
@@ -1370,13 +1373,16 @@ public class FeatureSettings extends JPanel
     }
     if (fcol.isSimpleColour())
     {
-      return BASE_TOOLTIP;
+      return withHint ? BASE_TOOLTIP : null;
     }
     String description = fcol.getDescription();
     description = description.replaceAll("<", "&lt;");
     description = description.replaceAll(">", "&gt;");
     StringBuilder tt = new StringBuilder(description);
-    tt.append("<br>").append(BASE_TOOLTIP).append("</br>");
+    if (withHint)
+    {
+      tt.append("<br>").append(BASE_TOOLTIP).append("</br>");
+    }
     return JvSwingUtils.wrapTooltip(true, tt.toString());
   }