Maintain PID or conservation status when changing colour
authoramwaterhouse <Andrew Waterhouse>
Thu, 13 Jan 2005 18:11:16 +0000 (18:11 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 13 Jan 2005 18:11:16 +0000 (18:11 +0000)
src/jalview/gui/AlignFrame.java

index 3336bb6..ede7eac 100755 (executable)
@@ -452,95 +452,173 @@ public class AlignFrame extends GAlignFrame
   protected void noColourmenuItem_actionPerformed(ActionEvent e)\r
   {\r
     viewport.setGlobalColourScheme( null );\r
-    alignPanel.setColourScheme();\r
+    changeColour();\r
   }\r
 \r
 \r
   public void clustalColour_actionPerformed(ActionEvent e)\r
   {\r
     viewport.setGlobalColourScheme(new ClustalxColourScheme( ));\r
-    alignPanel.setColourScheme(  );\r
+    changeColour();\r
   }\r
 \r
   public void zappoColour_actionPerformed(ActionEvent e)\r
   {\r
     viewport.setGlobalColourScheme(new ZappoColourScheme() );\r
-    alignPanel.setColourScheme(  );\r
+    changeColour();\r
   }\r
 \r
   public void taylorColour_actionPerformed(ActionEvent e)\r
   {\r
     viewport.setGlobalColourScheme(new TaylorColourScheme() );\r
-    alignPanel.setColourScheme(  );\r
+    changeColour();\r
   }\r
 \r
 \r
   public void hydrophobicityColour_actionPerformed(ActionEvent e)\r
   {\r
     viewport.setGlobalColourScheme( new HydrophobicColourScheme() );\r
-    alignPanel.setColourScheme( );\r
+    changeColour();\r
   }\r
 \r
   public void helixColour_actionPerformed(ActionEvent e)\r
   {\r
     viewport.setGlobalColourScheme( new HelixColourScheme()  );\r
-    alignPanel.setColourScheme();\r
+    changeColour();\r
   }\r
 \r
 \r
   public void strandColour_actionPerformed(ActionEvent e)\r
   {\r
     viewport.setGlobalColourScheme(new StrandColourScheme() );\r
-    alignPanel.setColourScheme(  );\r
+    changeColour();\r
   }\r
 \r
 \r
   public void turnColour_actionPerformed(ActionEvent e)\r
   {\r
     viewport.setGlobalColourScheme(new TurnColourScheme() );\r
-    alignPanel.setColourScheme(  );\r
+    changeColour();\r
   }\r
 \r
 \r
   public void buriedColour_actionPerformed(ActionEvent e)\r
   {\r
     viewport.setGlobalColourScheme( new BuriedColourScheme() );\r
-    alignPanel.setColourScheme( );\r
+    changeColour();\r
   }\r
 \r
+  void changeColour()\r
+  {\r
+    if(abovePIDThreshold.isSelected())\r
+    {\r
+      abovePIDThreshold_actionPerformed(null);\r
+      alignPanel.setColourScheme( );\r
+    }\r
+    else if(conservationMenuItem.isSelected())\r
+      conservationMenuItem_actionPerformed(null);\r
+    else\r
+      alignPanel.setColourScheme( );\r
+\r
+  }\r
 \r
   protected  void conservationMenuItem_actionPerformed(ActionEvent e)\r
   {\r
     viewport.setConservationSelected(conservationMenuItem.isSelected());\r
+\r
     alignPanel.setColourScheme();\r
+    ColourSchemeI oldCs = viewport.getGlobalColourScheme();\r
 \r
     if(conservationMenuItem.isSelected())\r
     {\r
-      SliderPanel sp = new SliderPanel(alignPanel, 30, true, viewport.getGlobalColourScheme());\r
-      JInternalFrame frame = new JInternalFrame();\r
-      frame.setContentPane(sp);\r
-      Desktop.addInternalFrame(frame, "Conservation Colour Increment", 400, 90);\r
-      frame.setMaximizable(false);\r
-      frame.setResizable(false);\r
+      if(sliderPanel!=null)\r
+      {\r
+        sliderPanel.cs = oldCs;\r
+      }\r
+\r
+      else\r
+      {\r
+        sliderPanel = new SliderPanel(alignPanel, 30, true,\r
+                                      viewport.getGlobalColourScheme());\r
+        JInternalFrame frame = new JInternalFrame();\r
+        frame.setContentPane(sliderPanel);\r
+        Desktop.addInternalFrame(frame, "Conservation Colour Increment", 400,\r
+                                 90);\r
+        frame.setMaximizable(false);\r
+        frame.setResizable(false);\r
+        frame.addInternalFrameListener(new javax.swing.event.\r
+                                       InternalFrameAdapter()\r
+        {\r
+          public void internalFrameClosed(javax.swing.event.InternalFrameEvent\r
+                                          evt)\r
+          {\r
+            sliderPanel = null;\r
+          };\r
+        });\r
+      }\r
+    }\r
+    else\r
+    {\r
+        if(oldCs instanceof ConservationColourScheme)\r
+        {\r
+          ConservationColourScheme ccs = (ConservationColourScheme)oldCs;\r
+          viewport.setGlobalColourScheme( ccs.cs );\r
+        }\r
+        alignPanel.setColourScheme();\r
     }\r
-  }\r
 \r
+  }\r
 \r
+  SliderPanel sliderPanel;\r
   public void abovePIDThreshold_actionPerformed(ActionEvent e)\r
   {\r
+    ColourSchemeI oldCs = viewport.getGlobalColourScheme();\r
+    int threshold = 0;\r
+\r
     if(abovePIDThreshold.isSelected())\r
     {\r
-      SliderPanel sp = new SliderPanel(alignPanel, 70, false,\r
-                                       viewport.getGlobalColourScheme());\r
-      JInternalFrame frame = new JInternalFrame();\r
-      frame.setContentPane(sp);\r
-      Desktop.addInternalFrame(frame, "Percentage Identity Threshold", 400, 90);\r
-      frame.setMaximizable(false);\r
-      frame.setResizable(false);\r
+      if(sliderPanel!=null)\r
+        sliderPanel.cs = oldCs;\r
+\r
+      else\r
+      {\r
+        sliderPanel = new SliderPanel(alignPanel, 70, false, oldCs);\r
+        JInternalFrame frame = new JInternalFrame();\r
+        frame.setContentPane(sliderPanel);\r
+        Desktop.addInternalFrame(frame, "Percentage Identity Threshold", 400,\r
+                                 90);\r
+        frame.setMaximizable(false);\r
+        frame.setResizable(false);\r
+        frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()\r
+        {\r
+          public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt)\r
+          {\r
+            sliderPanel = null;\r
+          };\r
+        });\r
+\r
+      }\r
+\r
+      threshold = sliderPanel.getValue();\r
+    }\r
+\r
+    if (oldCs instanceof ResidueColourScheme)\r
+    {\r
+      ResidueColourScheme rcs = (ResidueColourScheme) oldCs;\r
+      rcs.setThreshold(threshold);\r
     }\r
+    else if (oldCs instanceof ScoreColourScheme)\r
+    {\r
+      ScoreColourScheme scs = (ScoreColourScheme) oldCs;\r
+      scs.setThreshold(threshold);\r
+    }\r
+\r
+    alignPanel.setColourScheme();\r
+\r
   }\r
 \r
 \r
+\r
   public void userDefinedColour_actionPerformed(ActionEvent e)\r
   {\r
     JInternalFrame frame = new JInternalFrame();\r