Called from AnnotationColourChooser and Feature Settings
authoramwaterhouse <Andrew Waterhouse>
Fri, 24 Mar 2006 15:26:37 +0000 (15:26 +0000)
committeramwaterhouse <Andrew Waterhouse>
Fri, 24 Mar 2006 15:26:37 +0000 (15:26 +0000)
src/jalview/appletgui/UserDefinedColours.java

index 6544993..eb454d7 100755 (executable)
@@ -38,9 +38,10 @@ public class UserDefinedColours
   ColourSchemeI oldColourScheme;\r
   Frame frame;\r
   MCview.AppletPDBCanvas pdbcanvas;\r
-  FeatureSettings featureSettings;\r
-  String feature;\r
-  Color originalFeatureCol;\r
+\r
+  Component caller;\r
+  String originalLabel;\r
+  Color originalColour;\r
 \r
   int R = 0, G = 0, B = 0;\r
 \r
@@ -73,19 +74,20 @@ public class UserDefinedColours
     init();\r
   }\r
 \r
-  public UserDefinedColours(FeatureSettings featureSettings,\r
-                            String feature,\r
-                            Color col)\r
+  public UserDefinedColours(Component caller,\r
+                            String label,\r
+                            Color colour)\r
   {\r
-    this.featureSettings = featureSettings;\r
-    this.feature = feature;\r
+    this.caller = caller;\r
+    originalColour = colour;\r
+    originalLabel = label;\r
     init();\r
     remove(buttonPanel);\r
-    originalFeatureCol = col;\r
-    setTargetColour(col);\r
+\r
+    setTargetColour(colour);\r
 \r
     okcancelPanel.setBounds(new Rectangle(0, 113, 400, 35));\r
-    frame.setTitle("User Defined Colours - "+feature);\r
+    frame.setTitle("User Defined Colours - "+label);\r
     frame.setSize(420, 200);\r
   }\r
 \r
@@ -275,12 +277,24 @@ public class UserDefinedColours
 \r
   protected void applyButton_actionPerformed()\r
   {\r
-    if (featureSettings != null)\r
+    if (caller != null)\r
     {\r
-      featureSettings.setUserColour(feature, new Color(R,G,B));\r
+      if(caller instanceof FeatureSettings)\r
+        ((FeatureSettings)caller).setUserColour\r
+            (originalLabel, new Color(R,G,B));\r
+      else if(caller instanceof AnnotationColourChooser)\r
+      {\r
+        if (originalLabel.equals("Min Colour"))\r
+          ( (AnnotationColourChooser) caller).minColour_actionPerformed\r
+              (new Color(R, G, B));\r
+        else\r
+          ( (AnnotationColourChooser) caller).maxColour_actionPerformed\r
+              (new Color(R, G, B));\r
+      }\r
       return;\r
     }\r
 \r
+\r
     Color[] newColours = new Color[24];\r
     for (int i = 0; i < 24; i++)\r
     {\r
@@ -315,9 +329,20 @@ public class UserDefinedColours
 \r
   protected void cancelButton_actionPerformed()\r
   {\r
-    if(featureSettings!=null)\r
+    if (caller != null)\r
     {\r
-      featureSettings.setUserColour(feature, originalFeatureCol);\r
+      if(caller instanceof FeatureSettings)\r
+        ((FeatureSettings)caller).setUserColour\r
+            (originalLabel, originalColour);\r
+      else if (caller instanceof AnnotationColourChooser)\r
+      {\r
+        if (originalLabel.equals("Min Colour"))\r
+          ( (AnnotationColourChooser) caller).minColour_actionPerformed\r
+              (originalColour);\r
+        else\r
+          ( (AnnotationColourChooser) caller).maxColour_actionPerformed\r
+              (originalColour);\r
+      }\r
       frame.setVisible(false);\r
       return;\r
     }\r