Merge branch 'bug/JAL-2983negativeSliderMin' into develop
[jalview.git] / src / jalview / gui / AnnotationColourChooser.java
index 7ed178b..ad013f5 100644 (file)
@@ -24,6 +24,7 @@ import jalview.bin.Cache;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.GraphLine;
 import jalview.datamodel.SequenceGroup;
+import jalview.gui.JalviewColourChooser.ColourChooserListener;
 import jalview.schemes.AnnotationColourGradient;
 import jalview.schemes.ColourSchemeI;
 import jalview.util.MessageManager;
@@ -42,7 +43,6 @@ import java.util.Vector;
 import javax.swing.BorderFactory;
 import javax.swing.JButton;
 import javax.swing.JCheckBox;
-import javax.swing.JColorChooser;
 import javax.swing.JComboBox;
 import javax.swing.JInternalFrame;
 import javax.swing.JLayeredPane;
@@ -61,9 +61,9 @@ public class AnnotationColourChooser extends AnnotationRowFilter
 
   private JCheckBox useOriginalColours = new JCheckBox();
 
-  private JPanel minColour = new JPanel();
+  JPanel minColour = new JPanel();
 
-  private JPanel maxColour = new JPanel();
+  JPanel maxColour = new JPanel();
 
   private JCheckBox thresholdIsMin = new JCheckBox();
 
@@ -173,7 +173,7 @@ public class AnnotationColourChooser extends AnnotationRowFilter
       {
         if (minColour.isEnabled())
         {
-          minColour_actionPerformed();
+          showColourChooser(minColour, "label.select_colour_minimum_value");
         }
       }
     });
@@ -188,7 +188,7 @@ public class AnnotationColourChooser extends AnnotationRowFilter
       {
         if (maxColour.isEnabled())
         {
-          maxColour_actionPerformed();
+          showColourChooser(maxColour, "label.select_colour_maximum_value");
         }
       }
     });
@@ -287,30 +287,21 @@ public class AnnotationColourChooser extends AnnotationRowFilter
             Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX", Color.red));
   }
 
-  public void minColour_actionPerformed()
+  protected void showColourChooser(JPanel colourPanel, String titleKey)
   {
-    Color col = JColorChooser.showDialog(this,
-            MessageManager.getString("label.select_colour_minimum_value"),
-            minColour.getBackground());
-    if (col != null)
+    String ttl = MessageManager.getString(titleKey);
+    ColourChooserListener listener = new ColourChooserListener()
     {
-      minColour.setBackground(col);
-    }
-    minColour.repaint();
-    updateView();
-  }
-
-  public void maxColour_actionPerformed()
-  {
-    Color col = JColorChooser.showDialog(this,
-            MessageManager.getString("label.select_colour_maximum_value"),
-            maxColour.getBackground());
-    if (col != null)
-    {
-      maxColour.setBackground(col);
-    }
-    maxColour.repaint();
-    updateView();
+      @Override
+      public void colourSelected(Color c)
+      {
+        colourPanel.setBackground(c);
+        colourPanel.repaint();
+        updateView();
+      }
+    };
+    JalviewColourChooser.showColourChooser(Desktop.getDesktop(), ttl,
+            colourPanel.getBackground(), listener);
   }
 
   @Override