Various color bugs sorted out
authoramwaterhouse <Andrew Waterhouse>
Fri, 14 Jan 2005 15:46:53 +0000 (15:46 +0000)
committeramwaterhouse <Andrew Waterhouse>
Fri, 14 Jan 2005 15:46:53 +0000 (15:46 +0000)
src/jalview/gui/AlignFrame.java

index ede7eac..f7b4ac5 100755 (executable)
@@ -459,6 +459,8 @@ public class AlignFrame extends GAlignFrame
   public void clustalColour_actionPerformed(ActionEvent e)\r
   {\r
     viewport.setGlobalColourScheme(new ClustalxColourScheme( ));\r
+    conservationMenuItem.setSelected(false);\r
+    abovePIDThreshold.setSelected(false);\r
     changeColour();\r
   }\r
 \r
@@ -511,110 +513,125 @@ public class AlignFrame extends GAlignFrame
   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
+     alignPanel.seqPanel.seqCanvas.paintFlag = true;\r
+     alignPanel.repaint();\r
   }\r
 \r
-  protected  void conservationMenuItem_actionPerformed(ActionEvent e)\r
+  void addConservationOrPIDColour()\r
   {\r
-    viewport.setConservationSelected(conservationMenuItem.isSelected());\r
+    int x=0, y=0, threshold = 70;\r
 \r
-    alignPanel.setColourScheme();\r
-    ColourSchemeI oldCs = viewport.getGlobalColourScheme();\r
+    if(sliderFrame!=null)\r
+       try\r
+       {\r
+         x = sliderFrame.getX();\r
+         y = sliderFrame.getY();\r
+         SliderPanel sp = (SliderPanel) sliderFrame.getContentPane();\r
+         threshold = sp.getValue();\r
+         sliderFrame.setClosed(true);\r
+       }\r
+       catch (Exception ex)\r
+       {    ex.printStackTrace();   }\r
 \r
-    if(conservationMenuItem.isSelected())\r
-    {\r
-      if(sliderPanel!=null)\r
-      {\r
-        sliderPanel.cs = oldCs;\r
-      }\r
+     ColourSchemeI oldCs = viewport.getGlobalColourScheme();\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
+     ConservationColourScheme ccs = null;\r
+     if (oldCs instanceof ConservationColourScheme)\r
+       ccs = (ConservationColourScheme) oldCs;\r
 \r
-  }\r
+     if(conservationMenuItem.isSelected())\r
+     {\r
+       Alignment al = (Alignment)viewport.alignment;\r
+       Conservation c = new Conservation("All",\r
+                            ResidueProperties.propHash, 3, al.getSequences(), 0,\r
+                            al.getWidth() );\r
 \r
-  SliderPanel sliderPanel;\r
-  public void abovePIDThreshold_actionPerformed(ActionEvent e)\r
-  {\r
-    ColourSchemeI oldCs = viewport.getGlobalColourScheme();\r
-    int threshold = 0;\r
+       c.calculate();\r
+       c.verdict(false, 100);\r
 \r
-    if(abovePIDThreshold.isSelected())\r
-    {\r
-      if(sliderPanel!=null)\r
-        sliderPanel.cs = oldCs;\r
+       if(ccs!=null)\r
+         ccs = new ConservationColourScheme(c, ccs.cs);\r
+       else\r
+         ccs = new ConservationColourScheme(c, 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
+        viewport.setGlobalColourScheme( ccs );\r
 \r
-      }\r
+     }\r
+     else if(oldCs instanceof ConservationColourScheme)\r
+     {\r
+       oldCs = ccs.cs;\r
+       viewport.setGlobalColourScheme( oldCs );\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
+     if( conservationMenuItem.isSelected() || abovePIDThreshold.isSelected() )\r
+     {\r
+       sliderFrame = new JInternalFrame();\r
+       sliderFrame.setMaximizable(false);\r
+       sliderFrame.setResizable(false);\r
+\r
+       SliderPanel sp = null;\r
+       if (conservationMenuItem.isSelected())\r
+       {\r
+        if(threshold > 50)\r
+          threshold = 30;\r
+        sp = new SliderPanel(alignPanel, threshold, true,ccs);\r
+        Desktop.addInternalFrame(sliderFrame, "Conservation Colour Increment  (Global colour)", 400, 90);\r
+        threshold = 0;\r
+       }\r
+       else if (abovePIDThreshold.isSelected())\r
+       {\r
+         sp = new SliderPanel(alignPanel, threshold, false, oldCs);\r
+         sp.cs = oldCs;\r
+         Desktop.addInternalFrame(sliderFrame, "Percentage Identity Threshold (Global colour)", 400, 90);\r
+       }\r
+\r
+       sliderFrame.setContentPane(sp);\r
+       if(x!=0 && y!=0)\r
+               sliderFrame.setLocation(x,y);\r
 \r
-    alignPanel.setColourScheme();\r
+     }\r
+     else\r
+       threshold = 0;\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.seqPanel.seqCanvas.paintFlag = true;\r
+     alignPanel.repaint();\r
+\r
+  }\r
+\r
+  protected  void conservationMenuItem_actionPerformed(ActionEvent e)\r
+  {\r
+   if(abovePIDThreshold.isSelected())\r
+    abovePIDThreshold.setSelected(false);\r
+\r
+   viewport.setConservationSelected(conservationMenuItem.isSelected());\r
+\r
+   addConservationOrPIDColour();\r
+  }\r
+\r
+  JInternalFrame sliderFrame;\r
+  public void abovePIDThreshold_actionPerformed(ActionEvent e)\r
+  {\r
+      if(conservationMenuItem.isSelected())\r
+        conservationMenuItem.setSelected(false);\r
 \r
+      addConservationOrPIDColour();\r
   }\r
 \r
 \r