No need for apply button, just update colours when events occur
authoramwaterhouse <Andrew Waterhouse>
Mon, 30 Jan 2006 15:33:08 +0000 (15:33 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 30 Jan 2006 15:33:08 +0000 (15:33 +0000)
src/jalview/gui/AnnotationColourChooser.java

index 71cf688..71582e5 100755 (executable)
@@ -42,7 +42,7 @@ public class AnnotationColourChooser
     frame = new JInternalFrame();\r
     frame.setContentPane(this);\r
     frame.setLayer(JLayeredPane.PALETTE_LAYER);\r
-    Desktop.addInternalFrame(frame, "Colour by Annotation", 480, 110);\r
+    Desktop.addInternalFrame(frame, "Colour by Annotation", 470, 110, false);\r
 \r
     try{\r
       jbInit();\r
@@ -51,20 +51,23 @@ public class AnnotationColourChooser
     if(av.alignment.getAlignmentAnnotation()==null)\r
       return;\r
 \r
-    for(int i=0; i<av.alignment.getAlignmentAnnotation().length; i++)\r
+    if(oldcs instanceof AnnotationColourGradient)\r
     {\r
-      annotations.addItem(av.alignment.getAlignmentAnnotation()[i].label);\r
-    }\r
-\r
-  //  if(av.getGlobalColourScheme() instanceof AnnotationColourGradient)\r
-    {\r
-    //  minColour.\r
+      AnnotationColourGradient acg = (AnnotationColourGradient)oldcs;\r
+      minColour.setBackground( acg.getMinColour() );\r
+      maxColour.setBackground( acg.getMaxColour() );\r
     }\r
-  //  else\r
+    else\r
     {\r
       minColour.setBackground(Color.orange);\r
       maxColour.setBackground(Color.red);\r
     }\r
+\r
+    for (int i = 0; i < av.alignment.getAlignmentAnnotation().length; i++)\r
+    {\r
+      annotations.addItem(av.alignment.getAlignmentAnnotation()[i].label);\r
+    }\r
+\r
   }\r
 \r
   public AnnotationColourChooser()\r
@@ -108,14 +111,11 @@ public class AnnotationColourChooser
     thresholdCheck.setSelectedIcon(null);\r
     thresholdCheck.setText("Above Threshold");\r
     thresholdCheck.setBounds(new Rectangle(329, 6, 109, 23));\r
-    apply.setOpaque(false);\r
-    apply.setSelectedIcon(null);\r
-    apply.setText("Apply");\r
-    apply.addActionListener(new ActionListener()\r
+    thresholdCheck.addActionListener(new ActionListener()\r
     {\r
       public void actionPerformed(ActionEvent e)\r
       {\r
-        apply_actionPerformed(e);\r
+        thresholdCheck_actionPerformed(e);\r
       }\r
     });\r
     ok.setOpaque(false);\r
@@ -139,9 +139,15 @@ public class AnnotationColourChooser
     this.setLayout(borderLayout1);\r
     jPanel2.setLayout(null);\r
     annotations.setBounds(new Rectangle(5, 7, 135, 21));\r
+    annotations.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        annotations_actionPerformed(e);\r
+      }\r
+    });\r
     jPanel1.setBackground(Color.white);\r
     jPanel2.setBackground(Color.white);\r
-    jPanel1.add(apply);\r
     jPanel1.add(ok);\r
     jPanel1.add(cancel);\r
     jPanel2.add(annotations);\r
@@ -156,16 +162,12 @@ public class AnnotationColourChooser
   JButton minColour = new JButton();\r
   JButton maxColour = new JButton();\r
   JCheckBox thresholdCheck = new JCheckBox();\r
-  JButton apply = new JButton();\r
   JButton ok = new JButton();\r
   JButton cancel = new JButton();\r
   JPanel jPanel1 = new JPanel();\r
   JPanel jPanel2 = new JPanel();\r
   BorderLayout borderLayout1 = new BorderLayout();\r
-  public void apply_actionPerformed(ActionEvent e)\r
-  {\r
-    changeColour();\r
-  }\r
+\r
 \r
   public void minColour_actionPerformed(ActionEvent e)\r
   {\r
@@ -175,6 +177,7 @@ public class AnnotationColourChooser
     if (col != null)\r
       minColour.setBackground(col);\r
     minColour.repaint();\r
+    changeColour();\r
   }\r
 \r
   public void maxColour_actionPerformed(ActionEvent e)\r
@@ -185,6 +188,7 @@ public class AnnotationColourChooser
     if (col != null)\r
       maxColour.setBackground(col);\r
     maxColour.repaint();\r
+    changeColour();\r
   }\r
 \r
   void changeColour()\r
@@ -222,4 +226,14 @@ public class AnnotationColourChooser
     }catch(Exception ex){}\r
   }\r
 \r
+  public void thresholdCheck_actionPerformed(ActionEvent e)\r
+  {\r
+    changeColour();\r
+  }\r
+\r
+  public void annotations_actionPerformed(ActionEvent e)\r
+  {\r
+    changeColour();\r
+  }\r
+\r
 }\r