add applytoallgroups colouring option
authoramwaterhouse <Andrew Waterhouse>
Tue, 15 Feb 2005 10:45:46 +0000 (10:45 +0000)
committeramwaterhouse <Andrew Waterhouse>
Tue, 15 Feb 2005 10:45:46 +0000 (10:45 +0000)
src/jalview/gui/AlignFrame.java
src/jalview/jbgui/GAlignFrame.java

index 3a38769..686ecbc 100755 (executable)
@@ -635,171 +635,187 @@ public class AlignFrame extends GAlignFrame
 \r
   protected void noColourmenuItem_actionPerformed(ActionEvent e)\r
   {\r
-    viewport.setGlobalColourScheme( null );\r
-    changeColour();\r
+    changeColour( null );\r
   }\r
 \r
 \r
   public void clustalColour_actionPerformed(ActionEvent e)\r
   {\r
-    viewport.setGlobalColourScheme(\r
-      new ClustalxColourScheme(viewport.alignment.getSequences(), viewport.alignment.getWidth()));\r
     abovePIDThreshold.setSelected(false);\r
-    changeColour();\r
+    changeColour(new ClustalxColourScheme(viewport.alignment.getSequences(), viewport.alignment.getWidth()));\r
   }\r
 \r
   public void zappoColour_actionPerformed(ActionEvent e)\r
   {\r
-    viewport.setGlobalColourScheme(new ZappoColourScheme() );\r
-    changeColour();\r
+    changeColour(new ZappoColourScheme());\r
   }\r
 \r
   public void taylorColour_actionPerformed(ActionEvent e)\r
   {\r
-    viewport.setGlobalColourScheme(new TaylorColourScheme() );\r
-    changeColour();\r
+    changeColour(new TaylorColourScheme());\r
   }\r
 \r
 \r
   public void hydrophobicityColour_actionPerformed(ActionEvent e)\r
   {\r
-    viewport.setGlobalColourScheme( new HydrophobicColourScheme() );\r
-    changeColour();\r
+    changeColour( new HydrophobicColourScheme() );\r
   }\r
 \r
   public void helixColour_actionPerformed(ActionEvent e)\r
   {\r
-    viewport.setGlobalColourScheme( new HelixColourScheme()  );\r
-    changeColour();\r
+    changeColour(new HelixColourScheme() );\r
   }\r
 \r
 \r
   public void strandColour_actionPerformed(ActionEvent e)\r
   {\r
-    viewport.setGlobalColourScheme(new StrandColourScheme() );\r
-    changeColour();\r
+    changeColour(new StrandColourScheme());\r
   }\r
 \r
 \r
   public void turnColour_actionPerformed(ActionEvent e)\r
   {\r
-    viewport.setGlobalColourScheme(new TurnColourScheme() );\r
-    changeColour();\r
+    changeColour(new TurnColourScheme());\r
   }\r
 \r
 \r
   public void buriedColour_actionPerformed(ActionEvent e)\r
   {\r
-    viewport.setGlobalColourScheme( new BuriedColourScheme() );\r
-    changeColour();\r
+    changeColour(new BuriedColourScheme() );\r
   }\r
 \r
   public void nucleotideColour_actionPerformed(ActionEvent e)\r
   {\r
-    viewport.setGlobalColourScheme( new NucleotideColourScheme() );\r
-    changeColour();\r
+    changeColour(new NucleotideColourScheme());\r
   }\r
 \r
 \r
-  void changeColour()\r
+  protected void applyToAllGroups_actionPerformed(ActionEvent e)\r
   {\r
-    if(abovePIDThreshold.isSelected())\r
-      abovePIDThreshold_actionPerformed(null);\r
-    else if(conservationMenuItem.isSelected())\r
-      conservationMenuItem_actionPerformed(null);\r
-\r
-    alignPanel.RefreshPanels();\r
+    viewport.setColourAppliesToAllGroups(applyToAllGroups.isSelected());\r
   }\r
 \r
 \r
-  protected  void conservationMenuItem_actionPerformed(ActionEvent e)\r
+\r
+  void changeColour(ColourSchemeI cs)\r
   {\r
-   if(abovePIDThreshold.isSelected())\r
-   {\r
-     abovePIDThreshold.setSelected(false);\r
-     Desktop.hidePIDSlider();\r
-   }\r
 \r
-   viewport.setConservationSelected(conservationMenuItem.isSelected());\r
+    if(viewport.getColourAppliesToAllGroups())\r
+    {\r
+      Vector groups = viewport.alignment.getGroups();\r
+      for(int i=0; i<groups.size(); i++)\r
+      {\r
+        SequenceGroup sg = (SequenceGroup)groups.elementAt(i);\r
+        sg.cs = cs;\r
+\r
+        if(abovePIDThreshold.isSelected())\r
+          abovePIDThreshold_actionPerformed(null);\r
+        else if( viewport.getConservationSelected() )\r
+        {\r
+          Conservation c = new Conservation("Group",\r
+                                            ResidueProperties.propHash, 3,\r
+                                            sg.sequences, sg.getStartRes(),\r
+                                            sg.getEndRes());\r
+          c.calculate();\r
+          c.verdict(false, 100);\r
+          ConservationColourScheme ccs = new ConservationColourScheme(c, sg.cs);\r
+\r
+          sg.cs = ccs;\r
+        }\r
+\r
+      }\r
+    }\r
+\r
+\r
+    if ( viewport.getAbovePIDThreshold())\r
+    {\r
+      int threshold = 0;\r
+      threshold = Desktop.setPIDSliderSource(alignPanel, cs, "Background");\r
+      Desktop.hideConservationSlider();\r
+\r
+      if (cs instanceof ResidueColourScheme)\r
+        ( (ResidueColourScheme) cs).setThreshold(threshold);\r
+      else if (cs instanceof ScoreColourScheme)\r
+        ( (ScoreColourScheme) cs).setThreshold(threshold);\r
+\r
+      viewport.setGlobalColourScheme(cs);\r
+\r
+    }\r
+    else\r
+    if (cs instanceof ResidueColourScheme)\r
+      ( (ResidueColourScheme) cs).setThreshold(0);\r
+    else if (cs instanceof ScoreColourScheme)\r
+      ( (ScoreColourScheme) cs).setThreshold(0);\r
+\r
+\r
 \r
-   ColourSchemeI oldCs = viewport.getGlobalColourScheme();\r
 \r
+if ( viewport.getConservationSelected() )\r
+ {\r
    ConservationColourScheme ccs = null;\r
-   if (oldCs instanceof ConservationColourScheme)\r
-         ccs = (ConservationColourScheme) oldCs;\r
 \r
-       if (conservationMenuItem.isSelected())\r
-       {\r
-         Alignment al = (Alignment) viewport.alignment;\r
-         Conservation c = new Conservation("All",\r
-                                           ResidueProperties.propHash, 3,\r
-                                           al.getSequences(), 0,\r
-                                           al.getWidth());\r
+   Alignment al = (Alignment) viewport.alignment;\r
+   Conservation c = new Conservation("All",\r
+                                     ResidueProperties.propHash, 3,\r
+                                     al.getSequences(), 0,\r
+                                     al.getWidth());\r
 \r
-         c.calculate();\r
-         c.verdict(false, 100);\r
+   c.calculate();\r
+   c.verdict(false, 100);\r
 \r
-         if (ccs != null)\r
-           ccs = new ConservationColourScheme(c, ccs.cs);\r
-         else\r
-           ccs = new ConservationColourScheme(c, oldCs);\r
+   ccs = new ConservationColourScheme(c, cs);\r
 \r
+   int threshold = Desktop.setConservationSliderSource(alignPanel, ccs,\r
+       "Background");\r
 \r
-         int threshold = Desktop.setConservationSliderSource(alignPanel, ccs, "Background");\r
+   ccs.inc = threshold;\r
 \r
-         ccs.inc = threshold;\r
+   viewport.setGlobalColourScheme(ccs);\r
 \r
-         if (ccs.cs instanceof ResidueColourScheme)\r
-           ((ResidueColourScheme) ccs.cs).setThreshold(0);\r
-         else if (ccs.cs instanceof ScoreColourScheme)\r
-           ((ScoreColourScheme)ccs.cs).setThreshold(0);\r
+  }\r
+  else\r
+       viewport.setGlobalColourScheme( cs );\r
 \r
-         viewport.setGlobalColourScheme(ccs);\r
+    alignPanel.RefreshPanels();\r
+  }\r
 \r
 \r
-       }\r
-       else if (oldCs instanceof ConservationColourScheme)\r
-       {\r
-         /// ie, if we remove ConservationColourScheme from backgroundColour\r
-         oldCs = ccs.cs;\r
-         viewport.setGlobalColourScheme(oldCs);\r
-         Desktop.hideConservationSlider();\r
-       }\r
+  protected  void conservationMenuItem_actionPerformed(ActionEvent e)\r
+  {\r
+    viewport.setConservationSelected(conservationMenuItem.isSelected());\r
 \r
-       if(e!=null)\r
-         alignPanel.RefreshPanels();\r
+    viewport.setAbovePIDThreshold(false);\r
+    abovePIDThreshold.setSelected(false);\r
+    Desktop.hidePIDSlider();\r
+    if(!viewport.getConservationSelected())\r
+      Desktop.hideConservationSlider();\r
+\r
+   ColourSchemeI cs = viewport.getGlobalColourScheme();\r
+   if(cs instanceof ConservationColourScheme )\r
+     changeColour( ((ConservationColourScheme)cs).cs );\r
+    else\r
+      changeColour( cs );\r
   }\r
 \r
 \r
   public void abovePIDThreshold_actionPerformed(ActionEvent e)\r
   {\r
-      if(conservationMenuItem.isSelected())\r
-        conservationMenuItem.setSelected(false);\r
+    viewport.setAbovePIDThreshold(abovePIDThreshold.isSelected());\r
 \r
-      ColourSchemeI oldCs = viewport.getGlobalColourScheme();\r
-      int threshold = 0;\r
-      if (oldCs instanceof ConservationColourScheme)\r
-     {\r
-       ConservationColourScheme ccs = (ConservationColourScheme) oldCs;\r
-       oldCs = ccs.cs;\r
-     }\r
+    conservationMenuItem.setSelected(false);\r
+    viewport.setConservationSelected(false);\r
+    Desktop.hideConservationSlider();\r
 \r
-     if(abovePIDThreshold.isSelected())\r
-     {\r
-       threshold = Desktop.setPIDSliderSource(alignPanel, oldCs, "Background");\r
-       Desktop.hideConservationSlider();\r
-     }\r
-     else\r
-       Desktop.hidePIDSlider();\r
+    if(!viewport.getAbovePIDThreshold())\r
+      Desktop.hidePIDSlider();\r
 \r
-      if (oldCs instanceof ResidueColourScheme)\r
-          ((ResidueColourScheme) oldCs).setThreshold(threshold);\r
-      else if (oldCs instanceof ScoreColourScheme)\r
-          ((ScoreColourScheme)oldCs).setThreshold(threshold);\r
 \r
-    viewport.setGlobalColourScheme(oldCs);\r
-     if(e!=null)\r
-        alignPanel.RefreshPanels();\r
+    ColourSchemeI cs = viewport.getGlobalColourScheme();\r
+    if(cs instanceof ConservationColourScheme )\r
+        changeColour( ((ConservationColourScheme)cs).cs );\r
+    else\r
+        changeColour( cs );\r
+\r
   }\r
 \r
 \r
@@ -817,15 +833,13 @@ public class AlignFrame extends GAlignFrame
 \r
   public void PIDColour_actionPerformed(ActionEvent e)\r
   {\r
-    viewport.setGlobalColourScheme( new PIDColourScheme() );\r
-    alignPanel.setColourScheme( );\r
+    changeColour( new PIDColourScheme() );\r
   }\r
 \r
 \r
   public void BLOSUM62Colour_actionPerformed(ActionEvent e)\r
   {\r
-    viewport.setGlobalColourScheme( new Blosum62ColourScheme(viewport)  );\r
-    changeColour();\r
+    changeColour(new Blosum62ColourScheme(viewport) );\r
   }\r
 \r
 \r
index 11d1ff3..093c233 100755 (executable)
@@ -89,6 +89,7 @@ public class GAlignFrame extends JInternalFrame
   JMenu jMenu1 = new JMenu();\r
   JMenuItem pasteNew = new JMenuItem();\r
   JMenuItem pasteThis = new JMenuItem();\r
+  protected JCheckBoxMenuItem applyToAllGroups = new JCheckBoxMenuItem();\r
   public GAlignFrame()\r
   {\r
 \r
@@ -670,6 +671,15 @@ public class GAlignFrame extends JInternalFrame
         pasteThis_actionPerformed(e);\r
       }\r
     });\r
+    applyToAllGroups.setText("Apply colour to all groups");\r
+    applyToAllGroups.setState(true);\r
+    applyToAllGroups.addActionListener(new java.awt.event.ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        applyToAllGroups_actionPerformed(e);\r
+      }\r
+    });\r
     alignFrameMenuBar.add(fileMenu);\r
     alignFrameMenuBar.add(editMenu);\r
     alignFrameMenuBar.add(searchMenu);\r
@@ -717,6 +727,7 @@ public class GAlignFrame extends JInternalFrame
     viewMenu.add(consensusGraphMenuItem);\r
     viewMenu.add(overviewMenuItem);\r
     viewMenu.add(sequenceFeatures);\r
+    colourMenu.add(applyToAllGroups);\r
     colourMenu.add(noColourmenuItem);\r
     colourMenu.add(clustalColour);\r
     colourMenu.add(zappoColour);\r
@@ -1091,6 +1102,11 @@ public class GAlignFrame extends JInternalFrame
 \r
   }\r
 \r
+  protected void applyToAllGroups_actionPerformed(ActionEvent e)\r
+  {\r
+\r
+  }\r
+\r
 \r
 \r
 }\r