Conservation colour scheme is no more
authoramwaterhouse <Andrew Waterhouse>
Mon, 22 Aug 2005 09:15:52 +0000 (09:15 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 22 Aug 2005 09:15:52 +0000 (09:15 +0000)
25 files changed:
src/jalview/appletgui/APopupMenu.java
src/jalview/appletgui/AlignFrame.java
src/jalview/appletgui/AlignViewport.java
src/jalview/appletgui/AlignmentPanel.java
src/jalview/appletgui/SeqPanel.java
src/jalview/appletgui/SliderPanel.java
src/jalview/appletgui/TreeCanvas.java
src/jalview/datamodel/SequenceGroup.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java
src/jalview/gui/AlignmentPanel.java
src/jalview/gui/Jalview2XML.java
src/jalview/gui/PopupMenu.java
src/jalview/gui/SeqPanel.java
src/jalview/gui/SliderPanel.java
src/jalview/gui/TreeCanvas.java
src/jalview/schemes/Blosum62ColourScheme.java
src/jalview/schemes/ClustalxColourScheme.java
src/jalview/schemes/ColourSchemeI.java
src/jalview/schemes/ColourSchemeProperty.java
src/jalview/schemes/ConservationColourScheme.java [deleted file]
src/jalview/schemes/NucleotideColourScheme.java
src/jalview/schemes/PIDColourScheme.java
src/jalview/schemes/ResidueColourScheme.java
src/jalview/schemes/ScoreColourScheme.java

index 0cfa537..abd76d6 100755 (executable)
@@ -385,23 +385,15 @@ public class APopupMenu
                                                ap.av.alignment.getWidth()));\r
       int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs,\r
           getGroup().getName());\r
-      if (sg.cs instanceof ResidueColourScheme)\r
-      {\r
-        ( (ResidueColourScheme) sg.cs).setThreshold(threshold, ap.av.getIgnoreGapsConsensus());\r
-      }\r
-      else if (sg.cs instanceof ScoreColourScheme)\r
-      {\r
-        ( (ScoreColourScheme) sg.cs).setThreshold(threshold, ap.av.getIgnoreGapsConsensus());\r
-      }\r
+\r
+      sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());\r
 \r
       SliderPanel.showPIDSlider();\r
 \r
     }\r
     else // remove PIDColouring\r
     {\r
-      ResidueColourScheme rcs = (ResidueColourScheme) sg.cs;\r
-      rcs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
-      sg.cs = rcs;\r
+      sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
     }\r
 \r
     refresh();\r
@@ -454,17 +446,15 @@ public class APopupMenu
 \r
       c.calculate();\r
       c.verdict(false, ap.av.ConsPercGaps);\r
-      ConservationColourScheme ccs = new ConservationColourScheme(c, sg.cs);\r
 \r
-      sg.cs = ccs;\r
+      sg.cs.setConservation(c);\r
 \r
-      SliderPanel.setConservationSlider(ap, ccs, sg.getName());\r
+      SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());\r
       SliderPanel.showConservationSlider();\r
     }\r
     else // remove ConservationColouring\r
     {\r
-      ConservationColourScheme ccs = (ConservationColourScheme) sg.cs;\r
-      sg.cs = ccs.cs;\r
+      sg.cs.setConservation(null);\r
     }\r
 \r
     refresh();\r
index f1ecd6a..6138257 100755 (executable)
@@ -491,7 +491,7 @@ public class AlignFrame
     sg.setEndRes(viewport.alignment.getWidth());\r
     viewport.setSelectionGroup(sg);\r
     alignPanel.repaint();\r
-    PaintRefresher.Refresh(null);\r
+    PaintRefresher.Refresh(null, viewport.alignment);\r
   }\r
 \r
   public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e)\r
@@ -499,7 +499,7 @@ public class AlignFrame
     viewport.setSelectionGroup(null);\r
     viewport.getColumnSelection().clear();\r
     viewport.setSelectionGroup(null);\r
-    PaintRefresher.Refresh(null);\r
+    PaintRefresher.Refresh(null, viewport.alignment);\r
   }\r
 \r
   public void invertSequenceMenuItem_actionPerformed(ActionEvent e)\r
@@ -510,7 +510,7 @@ public class AlignFrame
       sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false);\r
     }\r
 \r
-    PaintRefresher.Refresh(null);\r
+    PaintRefresher.Refresh(null, viewport.alignment);\r
   }\r
 \r
   public void remove2LeftMenuItem_actionPerformed(ActionEvent e)\r
@@ -808,21 +808,17 @@ public class AlignFrame
     {\r
       threshold = SliderPanel.setPIDSliderSource(alignPanel, cs, "Background");\r
 \r
-      if (cs instanceof ResidueColourScheme)\r
-      {\r
-        ( (ResidueColourScheme) cs).setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
-      }\r
+      cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
 \r
       viewport.setGlobalColourScheme(cs);\r
     }\r
-    else if (cs instanceof ResidueColourScheme)\r
+    else\r
     {\r
-      ( (ResidueColourScheme) cs).setThreshold(0, viewport.getIgnoreGapsConsensus());\r
+      cs.setThreshold(0, viewport.getIgnoreGapsConsensus());\r
     }\r
 \r
     if (viewport.getConservationSelected())\r
     {\r
-      ConservationColourScheme ccs = null;\r
 \r
       Alignment al = (Alignment) viewport.alignment;\r
       Conservation c = new Conservation("All",\r
@@ -833,13 +829,13 @@ public class AlignFrame
       c.calculate();\r
       c.verdict(false, viewport.ConsPercGaps);\r
 \r
-      ccs = new ConservationColourScheme(c, cs);\r
+      cs.setConservation(c);\r
 \r
       // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!\r
-      ccs.setConsensus(viewport.vconsensus);\r
-      viewport.setGlobalColourScheme(ccs);\r
+      cs.setConsensus(viewport.vconsensus);\r
+      viewport.setGlobalColourScheme(cs);\r
 \r
-      SliderPanel.setConservationSlider(alignPanel, ccs, "Background");\r
+      SliderPanel.setConservationSlider(alignPanel, cs, "Background");\r
 \r
     }\r
     else\r
@@ -885,10 +881,7 @@ public class AlignFrame
 \r
         if (viewport.getAbovePIDThreshold())\r
         {\r
-          if (sg.cs instanceof ResidueColourScheme)\r
-          {\r
-            ( (ResidueColourScheme) sg.cs).setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
-          }\r
+          sg.cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
 \r
           sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, sg.getWidth()));\r
         }\r
@@ -901,11 +894,10 @@ public class AlignFrame
                                             viewport.alignment.getWidth() - 1);\r
           c.calculate();\r
           c.verdict(false, viewport.ConsPercGaps);\r
-          ConservationColourScheme ccs = new ConservationColourScheme(c, sg.cs);\r
 \r
           // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!\r
-          ccs.setConsensus(AAFrequency.calculate(sg.sequences, 0, sg.getWidth()));\r
-          sg.cs = ccs;\r
+          cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, sg.getWidth()));\r
+          sg.cs = cs;\r
         }\r
         else\r
         {\r
@@ -959,15 +951,7 @@ public class AlignFrame
     viewport.setAbovePIDThreshold(false);\r
     abovePIDThreshold.setState(false);\r
 \r
-    ColourSchemeI cs = viewport.getGlobalColourScheme();\r
-    if (cs instanceof ConservationColourScheme)\r
-    {\r
-      changeColour( ( (ConservationColourScheme) cs).cs);\r
-    }\r
-    else\r
-    {\r
-      changeColour(cs);\r
-    }\r
+    changeColour(viewport.getGlobalColourScheme());\r
 \r
     modifyConservation_actionPerformed(null);\r
   }\r
@@ -979,16 +963,7 @@ public class AlignFrame
     conservationMenuItem.setState(false);\r
     viewport.setConservationSelected(false);\r
 \r
-    ColourSchemeI cs = viewport.getGlobalColourScheme();\r
-\r
-    if (cs instanceof ConservationColourScheme)\r
-    {\r
-      changeColour( ( (ConservationColourScheme) cs).cs);\r
-    }\r
-    else\r
-    {\r
-      changeColour(cs);\r
-    }\r
+    changeColour(viewport.getGlobalColourScheme());\r
 \r
     modifyPID_actionPerformed(null);\r
   }\r
index e7cae44..e513829 100755 (executable)
@@ -653,10 +653,9 @@ public class AlignViewport
   {\r
     ignoreGapsInConsensusCalculation = b;\r
     updateConsensus();\r
-    if (globalColourScheme!=null && globalColourScheme instanceof ResidueColourScheme)\r
+    if (globalColourScheme!=null)\r
     {\r
-      ( (ResidueColourScheme) globalColourScheme).setThreshold(\r
-          ( (ResidueColourScheme) globalColourScheme).getThreshold(),\r
+      globalColourScheme.setThreshold(globalColourScheme.getThreshold(),\r
           ignoreGapsInConsensusCalculation);\r
 \r
     }\r
index 5e09da7..b46876a 100755 (executable)
@@ -288,29 +288,6 @@ public class AlignmentPanel
 \r
   }\r
 \r
-  public void setColourScheme()\r
-  {\r
-    ColourSchemeI cs = av.getGlobalColourScheme();\r
-\r
-    if (av.getConservationSelected())\r
-    {\r
-\r
-      Alignment al = (Alignment) av.getAlignment();\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, av.ConsPercGaps);\r
-      ConservationColourScheme ccs = new ConservationColourScheme(c, cs);\r
-\r
-      av.setGlobalColourScheme(ccs);\r
-\r
-    }\r
-\r
-    repaint();\r
-  }\r
 \r
   int hextent = 0;\r
   int vextent = 0;\r
index 080dc22..ebde2cf 100755 (executable)
@@ -454,10 +454,9 @@ public class SeqPanel
 \r
     // Y O Y CLUSTALX\r
     ColourSchemeI cs = av.getGlobalColourScheme();\r
-    if (cs instanceof ConservationColourScheme)\r
+    if (cs.conservationApplied())\r
     {\r
-      ConservationColourScheme ccs = (ConservationColourScheme) cs;\r
-      if (ccs.cs instanceof ClustalxColourScheme)\r
+      if (cs instanceof ClustalxColourScheme)\r
       {\r
         jalview.analysis.Conservation c = new jalview.analysis.Conservation\r
             ("All",\r
@@ -467,10 +466,9 @@ public class SeqPanel
         c.calculate();\r
         c.verdict(false, av.ConsPercGaps);\r
 \r
-        ClustalxColourScheme cxs = (ClustalxColourScheme) ccs.cs;\r
-        cxs.resetClustalX(av.alignment.getSequences(), av.alignment.getWidth());\r
-        ccs = new ConservationColourScheme(c, cxs);\r
-        av.setGlobalColourScheme(ccs);\r
+        ((ClustalxColourScheme)cs).resetClustalX(av.alignment.getSequences(), av.alignment.getWidth());\r
+        cs.setConservation(c);\r
+        av.setGlobalColourScheme(cs);\r
       }\r
     }\r
 \r
@@ -604,19 +602,19 @@ public class SeqPanel
       return;\r
     }\r
 \r
-    if (stretchGroup.cs instanceof ConservationColourScheme)\r
-    {\r
-      ConservationColourScheme ccs = (ConservationColourScheme) stretchGroup.cs;\r
-      stretchGroup.cs = ccs;\r
-      SliderPanel.setConservationSlider(ap, stretchGroup.cs,\r
-                                        stretchGroup.getName());\r
-    }\r
-    else\r
+    if(stretchGroup.cs!=null)\r
     {\r
+      if (stretchGroup.cs.conservationApplied())\r
+      {\r
+        SliderPanel.setConservationSlider(ap, stretchGroup.cs,\r
+                                          stretchGroup.getName());\r
+      }\r
+      else\r
+      {\r
         SliderPanel.setPIDSliderSource(ap, stretchGroup.cs,\r
                                        stretchGroup.getName());\r
+      }\r
     }\r
-\r
     changeEndRes = false;\r
     changeStartRes = false;\r
     stretchGroup = null;\r
index d2eeff3..3e23728 100755 (executable)
@@ -42,11 +42,10 @@ public class SliderPanel
                                           String source)\r
   {\r
     SliderPanel sp = null;\r
-    ConservationColourScheme ccs = (ConservationColourScheme) cs;\r
 \r
     if (conservationSlider == null)\r
     {\r
-      sp = new SliderPanel(ap, ccs.inc, true, cs);\r
+      sp = new SliderPanel(ap, cs.getConservationInc(), true, cs);\r
       conservationSlider = new Frame();\r
       conservationSlider.add(sp);\r
     }\r
@@ -217,14 +216,11 @@ public class SliderPanel
 \r
       if (forConservation)\r
       {\r
-        if (toChange instanceof ConservationColourScheme)\r
-        {\r
-          ( (ConservationColourScheme) toChange).inc = i;\r
-        }\r
+        toChange.setConservationInc(i);\r
       }\r
       else\r
       {\r
-        ( (ResidueColourScheme) toChange).setThreshold(i, ap.av.getIgnoreGapsConsensus());\r
+        toChange.setThreshold(i, ap.av.getIgnoreGapsConsensus());\r
       }\r
 \r
       groupIndex--;\r
index 15c4bfa..a6bc5df 100755 (executable)
@@ -490,10 +490,8 @@ System.out.println("called here");
                                                false, 0, av.alignment.getWidth());\r
 \r
 \r
-          if (av.getGlobalColourScheme() instanceof ConservationColourScheme)\r
+          if (av.getGlobalColourScheme().conservationApplied())\r
           {\r
-            ConservationColourScheme ccs = (ConservationColourScheme) av.\r
-                getGlobalColourScheme();\r
             Conservation c = new Conservation("Group",\r
                                               ResidueProperties.propHash, 3,\r
                                               sg.sequences, sg.getStartRes(),\r
@@ -501,9 +499,9 @@ System.out.println("called here");
 \r
             c.calculate();\r
             c.verdict(false, av.ConsPercGaps);\r
-            ccs = new ConservationColourScheme(c, ccs.cs);\r
+            cs.setConservation(c);\r
 \r
-            sg.cs = ccs;\r
+            sg.cs = cs;\r
 \r
           }\r
 \r
index 054896b..6de42b9 100755 (executable)
@@ -235,29 +235,31 @@ public class SequenceGroup
      */\r
     public void recalcConservation()\r
     {\r
-        if (cs != null)\r
-        {\r
-            cs.setConsensus(AAFrequency.calculate(sequences, 0, getWidth()));\r
-        }\r
+        if(cs == null)\r
+          return;\r
+\r
+        cs.setConsensus(AAFrequency.calculate(sequences, 0, getWidth()));\r
+\r
 \r
         if (cs instanceof ClustalxColourScheme)\r
         {\r
             ((ClustalxColourScheme) cs).resetClustalX(sequences, getWidth());\r
         }\r
 \r
-        if (cs instanceof ConservationColourScheme)\r
+\r
+        if (cs.conservationApplied())\r
         {\r
             Conservation c = new Conservation(groupName,\r
                     ResidueProperties.propHash, 3, sequences, 0, getWidth());\r
             c.calculate();\r
             c.verdict(false, 25);\r
 \r
-            ConservationColourScheme ccs = (ConservationColourScheme) cs;\r
-            ccs.conserve = c;\r
 \r
-            if (ccs.cs instanceof ClustalxColourScheme)\r
+            cs.setConservation(c);\r
+\r
+            if (cs instanceof ClustalxColourScheme)\r
             {\r
-                ((ClustalxColourScheme) ccs.cs).resetClustalX(sequences,\r
+                ((ClustalxColourScheme) cs).resetClustalX(sequences,\r
                     getWidth());\r
             }\r
         }\r
index 88ff3e8..fc59062 100755 (executable)
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.\r
  *\r
  * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
+ * along with this program; if not, write to the Free Softwarechang\r
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
  */\r
 package jalview.gui;\r
@@ -1371,65 +1371,50 @@ public class AlignFrame
   {\r
     int threshold = 0;\r
 \r
-    if (viewport.getAbovePIDThreshold())\r
+    if(cs!=null)\r
     {\r
-      threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,\r
-                                                 "Background");\r
-\r
-      if (cs instanceof ResidueColourScheme)\r
+      if (viewport.getAbovePIDThreshold())\r
       {\r
-        ( (ResidueColourScheme) cs).setThreshold(threshold,\r
-                                                 viewport.\r
-                                                 getIgnoreGapsConsensus());\r
+        threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,\r
+                                                   "Background");\r
+\r
+        cs.setThreshold(threshold,\r
+                        viewport.getIgnoreGapsConsensus());\r
+\r
+        viewport.setGlobalColourScheme(cs);\r
       }\r
-      else if (cs instanceof ScoreColourScheme)\r
+      else\r
       {\r
-        ( (ScoreColourScheme) cs).setThreshold(threshold,\r
-                                               viewport.getIgnoreGapsConsensus());\r
+        cs.setThreshold(0, viewport.getIgnoreGapsConsensus());\r
       }\r
 \r
-      viewport.setGlobalColourScheme(cs);\r
-    }\r
-    else if (cs instanceof ResidueColourScheme)\r
-    {\r
-      ( (ResidueColourScheme) cs).setThreshold(0,\r
-                                               viewport.getIgnoreGapsConsensus());\r
-    }\r
-\r
-\r
-    if (viewport.getConservationSelected())\r
-    {\r
-      ConservationColourScheme ccs = null;\r
-\r
-      Alignment al = (Alignment) viewport.alignment;\r
-      Conservation c = new Conservation("All",\r
-                                        ResidueProperties.propHash, 3,\r
-                                        al.getSequences(), 0,\r
-                                        al.getWidth() - 1);\r
-\r
-      c.calculate();\r
-      c.verdict(false, viewport.ConsPercGaps);\r
+      if (viewport.getConservationSelected())\r
+      {\r
 \r
-      ccs = new ConservationColourScheme(c, cs);\r
+        Alignment al = (Alignment) viewport.alignment;\r
+        Conservation c = new Conservation("All",\r
+                                          ResidueProperties.propHash, 3,\r
+                                          al.getSequences(), 0,\r
+                                          al.getWidth() - 1);\r
 \r
-      ccs.setConsensus(viewport.vconsensus);\r
+        c.calculate();\r
+        c.verdict(false, viewport.ConsPercGaps);\r
 \r
-      viewport.setGlobalColourScheme(ccs);\r
+        cs.setConservation(c);\r
 \r
-      ccs.inc = SliderPanel.setConservationSlider(alignPanel, ccs,\r
-                                                  "Background");\r
-    }\r
-    else\r
-    {\r
-      // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!\r
-      if (cs != null)\r
+        cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel, cs,\r
+            "Background"));\r
+      }\r
+      else\r
       {\r
-        cs.setConsensus(viewport.vconsensus);\r
+        cs.setConservation(null);\r
       }\r
 \r
-      viewport.setGlobalColourScheme(cs);\r
+      cs.setConsensus(viewport.vconsensus);\r
     }\r
 \r
+    viewport.setGlobalColourScheme(cs);\r
+\r
     if (viewport.getColourAppliesToAllGroups())\r
     {\r
       Vector groups = viewport.alignment.getGroups();\r
@@ -1441,8 +1426,10 @@ public class AlignFrame
         if (cs == null)\r
         {\r
           sg.cs = null;\r
+          continue;\r
         }\r
-        else if (cs instanceof ClustalxColourScheme)\r
+\r
+        if (cs instanceof ClustalxColourScheme)\r
         {\r
           sg.cs = new ClustalxColourScheme(sg.sequences, sg.getWidth());\r
         }\r
@@ -1463,15 +1450,15 @@ public class AlignFrame
 \r
         if (viewport.getAbovePIDThreshold())\r
         {\r
-          if (sg.cs instanceof ResidueColourScheme)\r
-          {\r
-            ( (ResidueColourScheme) sg.cs).setThreshold(threshold,\r
+         sg.cs.setThreshold(threshold,\r
                 viewport.getIgnoreGapsConsensus());\r
-          }\r
 \r
           sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0,\r
               sg.getWidth()));\r
         }\r
+        else\r
+          sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());\r
+\r
 \r
         if (viewport.getConservationSelected())\r
         {\r
@@ -1481,21 +1468,10 @@ public class AlignFrame
                                             viewport.alignment.getWidth() - 1);\r
           c.calculate();\r
           c.verdict(false, viewport.ConsPercGaps);\r
-\r
-          ConservationColourScheme ccs = new ConservationColourScheme(c,\r
-              sg.cs);\r
-\r
-          // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!\r
-          ccs.setConsensus(AAFrequency.calculate(sg.sequences, 0,\r
-                                                 sg.getWidth()));\r
-          sg.cs = ccs;\r
-        }\r
-        else if (cs != null)\r
-        {\r
-          // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!\r
-          sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0,\r
-              sg.getWidth()));\r
+          sg.cs.setConservation(c);\r
         }\r
+        else\r
+          sg.cs.setConservation(null);\r
       }\r
     }\r
 \r
@@ -1514,7 +1490,7 @@ public class AlignFrame
    */\r
   protected void modifyPID_actionPerformed(ActionEvent e)\r
   {\r
-    if (viewport.getAbovePIDThreshold())\r
+    if (viewport.getAbovePIDThreshold() && viewport.globalColourScheme!=null)\r
     {\r
       SliderPanel.setPIDSliderSource(alignPanel,\r
                                      viewport.getGlobalColourScheme(),\r
@@ -1530,7 +1506,7 @@ public class AlignFrame
    */\r
   protected void modifyConservation_actionPerformed(ActionEvent e)\r
   {\r
-    if (viewport.getConservationSelected())\r
+    if (viewport.getConservationSelected() && viewport.globalColourScheme!=null)\r
     {\r
       SliderPanel.setConservationSlider(alignPanel,\r
                                         viewport.globalColourScheme,\r
@@ -1551,16 +1527,7 @@ public class AlignFrame
     viewport.setAbovePIDThreshold(false);\r
     abovePIDThreshold.setSelected(false);\r
 \r
-    ColourSchemeI cs = viewport.getGlobalColourScheme();\r
-\r
-    if (cs instanceof ConservationColourScheme)\r
-    {\r
-      changeColour( ( (ConservationColourScheme) cs).cs);\r
-    }\r
-    else\r
-    {\r
-      changeColour(cs);\r
-    }\r
+    changeColour(viewport.getGlobalColourScheme());\r
 \r
     modifyConservation_actionPerformed(null);\r
   }\r
@@ -1579,14 +1546,7 @@ public class AlignFrame
 \r
     ColourSchemeI cs = viewport.getGlobalColourScheme();\r
 \r
-    if (cs instanceof ConservationColourScheme)\r
-    {\r
-      changeColour( ( (ConservationColourScheme) cs).cs);\r
-    }\r
-    else\r
-    {\r
-      changeColour(cs);\r
-    }\r
+    changeColour(viewport.getGlobalColourScheme());\r
 \r
     modifyPID_actionPerformed(null);\r
   }\r
index dd3f980..f951792 100755 (executable)
@@ -1039,12 +1039,9 @@ public class AlignViewport
     {\r
       ignoreGapsInConsensusCalculation = b;\r
       updateConsensus();\r
-      if(globalColourScheme!=null && globalColourScheme instanceof ResidueColourScheme)\r
+      if(globalColourScheme!=null)\r
       {\r
-        ((ResidueColourScheme) globalColourScheme).setThreshold(\r
-            ((ResidueColourScheme) globalColourScheme).getThreshold(), ignoreGapsInConsensusCalculation);\r
-\r
-\r
+        globalColourScheme.setThreshold(globalColourScheme.getThreshold(), ignoreGapsInConsensusCalculation);\r
       }\r
 \r
     }\r
index 7aff9ab..12c1cbd 100755 (executable)
@@ -295,30 +295,6 @@ public class AlignmentPanel extends GAlignmentPanel
         repaint();\r
     }\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     */\r
-    public void setColourScheme()\r
-    {\r
-        ColourSchemeI cs = av.getGlobalColourScheme();\r
-\r
-        if (av.getConservationSelected())\r
-        {\r
-            Alignment al = (Alignment) av.getAlignment();\r
-            Conservation c = new Conservation("All",\r
-                    ResidueProperties.propHash, 3, al.getSequences(), 0,\r
-                    al.getWidth());\r
-\r
-            c.calculate();\r
-            c.verdict(false, av.ConsPercGaps);\r
-\r
-            ConservationColourScheme ccs = new ConservationColourScheme(c, cs);\r
-\r
-            av.setGlobalColourScheme(ccs);\r
-        }\r
-\r
-        repaint();\r
-    }\r
 \r
     // return value is true if the scroll is valid\r
     public boolean scrollUp(boolean up)\r
index 69ba482..a8fb28d 100755 (executable)
@@ -295,14 +295,13 @@ public class Jalview2XML
                 groups[i].setEnd(sg.getEndRes());\r
                 groups[i].setName(sg.getName());\r
 \r
-                if (sg.cs instanceof ConservationColourScheme)\r
+                if (sg.cs.conservationApplied())\r
                 {\r
-                  ConservationColourScheme ccs = (ConservationColourScheme) sg.cs;\r
-                  groups[i].setConsThreshold(ccs.inc);\r
+                  groups[i].setConsThreshold(sg.cs.getConservationInc());\r
 \r
-                  if (ccs.cs instanceof jalview.schemes.UserColourScheme)\r
+                  if (sg.cs instanceof jalview.schemes.UserColourScheme)\r
                   {\r
-                    groups[i].setColour(SetUserColourScheme(ccs.cs, userColours,\r
+                    groups[i].setColour(SetUserColourScheme(sg.cs, userColours,\r
                                                             jms));\r
                   }\r
                   else\r
@@ -322,12 +321,8 @@ public class Jalview2XML
                       sg.cs));\r
                 }\r
 \r
-                if (sg.cs instanceof ResidueColourScheme)\r
-                {\r
-                    groups[i].setPidThreshold(((ResidueColourScheme) sg.cs).getThreshold());\r
-                }\r
-\r
 \r
+                groups[i].setPidThreshold( sg.cs.getThreshold() );\r
 \r
                 groups[i].setOutlineColour(sg.getOutlineColour().getRGB());\r
                 groups[i].setDisplayBoxes(sg.getDisplayBoxes());\r
@@ -368,17 +363,16 @@ public class Jalview2XML
 \r
         ColourSchemeI cs = av.getGlobalColourScheme();\r
 \r
-        if (cs instanceof ConservationColourScheme)\r
+        if (cs.conservationApplied())\r
         {\r
-            ConservationColourScheme ccs = (ConservationColourScheme)cs;\r
-            view.setConsThreshold(ccs.inc);\r
-            if(ccs.cs instanceof jalview.schemes.UserColourScheme)\r
-              view.setBgColour(SetUserColourScheme(ccs.cs, userColours, jms));\r
+            view.setConsThreshold(cs.getConservationInc());\r
+            if(cs instanceof jalview.schemes.UserColourScheme)\r
+              view.setBgColour(SetUserColourScheme(cs, userColours, jms));\r
         }\r
 \r
         if (cs instanceof ResidueColourScheme)\r
         {\r
-            view.setPidThreshold(((ResidueColourScheme) cs).getThreshold());\r
+            view.setPidThreshold( cs.getThreshold() );\r
         }\r
 \r
         view.setConservationSelected(av.getConservationSelected());\r
@@ -638,10 +632,7 @@ public class Jalview2XML
                                 groups[i].getColour());\r
                     }\r
 \r
-                    if (cs instanceof ResidueColourScheme)\r
-                    {\r
-                        ((ResidueColourScheme) cs).setThreshold(groups[i].getPidThreshold(), true);\r
-                    }\r
+                    cs.setThreshold(groups[i].getPidThreshold(), true);\r
                 }\r
 \r
                 Vector seqs = new Vector();\r
@@ -668,8 +659,7 @@ public class Jalview2XML
                             sg.getWidth() - 1);\r
                     c.calculate();\r
                     c.verdict(false, 25);\r
-                    cs = new ConservationColourScheme(c, cs);\r
-                    sg.cs = cs;\r
+                    sg.cs.setConservation(c);\r
                 }\r
 \r
                 al.addGroup(sg);\r
@@ -734,10 +724,7 @@ public class Jalview2XML
                 cs = ColourSchemeProperty.getColour(al, view.getBgColour());\r
             }\r
 \r
-            if (cs instanceof ResidueColourScheme)\r
-            {\r
-                ((ResidueColourScheme) cs).setThreshold(view.getPidThreshold(), true);\r
-            }\r
+           cs.setThreshold(view.getPidThreshold(), true);\r
 \r
             if(cs!=null)\r
               cs.setConsensus(af.viewport.vconsensus);\r
@@ -749,7 +736,7 @@ public class Jalview2XML
         af.changeColour(af.viewport.getGlobalColourScheme());\r
         if (view.getConservationSelected())\r
         {\r
-          ( (ConservationColourScheme) af.viewport.getGlobalColourScheme()).inc = view.getConsThreshold();\r
+          af.viewport.getGlobalColourScheme().setConservationInc(view.getConsThreshold());\r
         }\r
 \r
         af.viewport.setColourAppliesToAllGroups(true);\r
index 40c51cb..137ca14 100755 (executable)
@@ -172,7 +172,7 @@ public class PopupMenu extends JPopupMenu
                 noColourmenuItem.setSelected(true);\r
             }\r
 \r
-            if (sg.cs instanceof ConservationColourScheme)\r
+            if (sg.cs!=null && sg.cs.conservationApplied())\r
             {\r
                 conservationMenuItem.setSelected(true);\r
             }\r
@@ -615,22 +615,13 @@ public class PopupMenu extends JPopupMenu
             int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs,\r
                     getGroup().getName());\r
 \r
-            if (sg.cs instanceof ResidueColourScheme)\r
-            {\r
-                ((ResidueColourScheme) sg.cs).setThreshold(threshold, ap.av.getIgnoreGapsConsensus());\r
-            }\r
-            else if (sg.cs instanceof ScoreColourScheme)\r
-            {\r
-                ((ScoreColourScheme) sg.cs).setThreshold(threshold, ap.av.getIgnoreGapsConsensus());\r
-            }\r
+           sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());\r
 \r
             SliderPanel.showPIDSlider();\r
         }\r
         else // remove PIDColouring\r
         {\r
-            ResidueColourScheme rcs = (ResidueColourScheme) sg.cs;\r
-            rcs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
-            sg.cs = rcs;\r
+            sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
         }\r
 \r
         refresh();\r
@@ -715,17 +706,14 @@ public class PopupMenu extends JPopupMenu
             c.calculate();\r
             c.verdict(false, ap.av.ConsPercGaps);\r
 \r
-            ConservationColourScheme ccs = new ConservationColourScheme(c, sg.cs);\r
-\r
-            sg.cs = ccs;\r
+            sg.cs.setConservation(c);\r
 \r
-            SliderPanel.setConservationSlider(ap, ccs, sg.getName());\r
+            SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());\r
             SliderPanel.showConservationSlider();\r
         }\r
         else // remove ConservationColouring\r
         {\r
-            ConservationColourScheme ccs = (ConservationColourScheme) sg.cs;\r
-            sg.cs = ccs.cs;\r
+            sg.cs.setConservation(null);\r
         }\r
 \r
         refresh();\r
index db120e1..c98322e 100755 (executable)
@@ -553,27 +553,26 @@ public class SeqPanel extends JPanel
             av.getSelectionGroup().recalcConservation();\r
         }\r
 \r
-        if (cs instanceof ConservationColourScheme)\r
+        if (cs.conservationApplied())\r
         {\r
-            ConservationColourScheme ccs = (ConservationColourScheme) cs;\r
             Conservation c = new Conservation("All",\r
                     ResidueProperties.propHash, 3, av.alignment.getSequences(),\r
                     0, av.alignment.getWidth() - 1);\r
             c.calculate();\r
             c.verdict(false, av.ConsPercGaps);\r
 \r
-            if (ccs.cs instanceof ClustalxColourScheme)\r
+            if (cs instanceof ClustalxColourScheme)\r
             {\r
-                ClustalxColourScheme cxs = (ClustalxColourScheme) ccs.cs;\r
+                ClustalxColourScheme cxs = (ClustalxColourScheme) cs;\r
                 cxs.resetClustalX(av.alignment.getSequences(),\r
                     av.alignment.getWidth());\r
-                ccs = new ConservationColourScheme(c, cxs);\r
-                av.setGlobalColourScheme(ccs);\r
+                cs.setConservation(c);\r
+                av.setGlobalColourScheme(cs);\r
             }\r
             else\r
             {\r
-                ccs = new ConservationColourScheme(c, ccs.cs);\r
-                av.setGlobalColourScheme(ccs);\r
+                cs.setConservation(c);\r
+                av.setGlobalColourScheme(cs);\r
             }\r
         }\r
 \r
@@ -707,25 +706,26 @@ public class SeqPanel extends JPanel
             return;\r
         }\r
 \r
-        if (stretchGroup.cs instanceof ClustalxColourScheme)\r
+        if(stretchGroup.cs!=null)\r
         {\r
-            ((ClustalxColourScheme) stretchGroup.cs).resetClustalX(stretchGroup.sequences,\r
+          if (stretchGroup.cs instanceof ClustalxColourScheme)\r
+          {\r
+            ( (ClustalxColourScheme) stretchGroup.cs).resetClustalX(stretchGroup.\r
+                sequences,\r
                 stretchGroup.getWidth());\r
-        }\r
+          }\r
 \r
-        if (stretchGroup.cs instanceof ConservationColourScheme)\r
-        {\r
-            ConservationColourScheme ccs = (ConservationColourScheme) stretchGroup.cs;\r
-            stretchGroup.cs = ccs;\r
+          if (stretchGroup.cs.conservationApplied())\r
+          {\r
             SliderPanel.setConservationSlider(ap, stretchGroup.cs,\r
-                stretchGroup.getName());\r
-        }\r
-        else\r
-        {\r
+                                              stretchGroup.getName());\r
+          }\r
+          else\r
+          {\r
             SliderPanel.setPIDSliderSource(ap, stretchGroup.cs,\r
-                stretchGroup.getName());\r
+                                           stretchGroup.getName());\r
+          }\r
         }\r
-\r
         changeEndRes = false;\r
         changeStartRes = false;\r
         stretchGroup = null;\r
index a9020c3..5b177d4 100755 (executable)
@@ -102,11 +102,10 @@ public class SliderPanel extends GSliderPanel
         ColourSchemeI cs, String source)\r
     {\r
         SliderPanel sp = null;\r
-        ConservationColourScheme ccs = (ConservationColourScheme) cs;\r
 \r
         if (conservationSlider == null)\r
         {\r
-            sp = new SliderPanel(ap, ccs.inc, true, cs);\r
+            sp = new SliderPanel(ap, cs.getConservationInc(), true, cs);\r
             conservationSlider = new JInternalFrame();\r
             conservationSlider.setContentPane(sp);\r
             conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER);\r
@@ -176,16 +175,7 @@ public class SliderPanel extends GSliderPanel
     {\r
         SliderPanel pid = null;\r
 \r
-        int threshold = 50;\r
-\r
-        if (cs instanceof ResidueColourScheme)\r
-        {\r
-            threshold = (((ResidueColourScheme) cs).getThreshold());\r
-        }\r
-        else if (cs instanceof ScoreColourScheme)\r
-        {\r
-            threshold = (((ScoreColourScheme) cs).getThreshold());\r
-        }\r
+        int threshold = cs.getThreshold();\r
 \r
         if (PIDSlider == null)\r
         {\r
@@ -253,10 +243,12 @@ public class SliderPanel extends GSliderPanel
     public void valueChanged(int i)\r
     {\r
         if (cs == null)\r
-        {\r
+        {System.out.println("cs is null");\r
             return;\r
         }\r
 \r
+\r
+\r
         ColourSchemeI toChange = null;\r
         Vector allGroups = null;\r
         int groupIndex = 0;\r
@@ -271,6 +263,7 @@ public class SliderPanel extends GSliderPanel
             toChange = cs;\r
         }\r
 \r
+\r
         while (groupIndex > -1)\r
         {\r
             if (allGroups != null)\r
@@ -287,14 +280,14 @@ public class SliderPanel extends GSliderPanel
 \r
             if (forConservation)\r
             {\r
-                if (toChange instanceof ConservationColourScheme)\r
+                if (toChange.conservationApplied())\r
                 {\r
-                    ((ConservationColourScheme) toChange).inc = i;\r
+                    toChange.setConservationInc(i);\r
                 }\r
             }\r
             else\r
             {\r
-                ((ResidueColourScheme) toChange).setThreshold(i, ap.av.getIgnoreGapsConsensus());\r
+                toChange.setThreshold(i, ap.av.getIgnoreGapsConsensus());\r
             }\r
 \r
             groupIndex--;\r
index d05aee1..e923792 100755 (executable)
@@ -715,21 +715,18 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
 \r
                     if (sg.cs != null)\r
                     {\r
-                        ((ResidueColourScheme) sg.cs).setThreshold(25, av.getIgnoreGapsConsensus());\r
+                        sg.cs.setThreshold(25, av.getIgnoreGapsConsensus());\r
                     }\r
 \r
-                    if (av.getGlobalColourScheme() instanceof ConservationColourScheme)\r
+                    if (av.getGlobalColourScheme().conservationApplied())\r
                     {\r
-                        ConservationColourScheme ccs = (ConservationColourScheme) av.getGlobalColourScheme();\r
                         Conservation c = new Conservation("Group",\r
                                 ResidueProperties.propHash, 3, sg.sequences,\r
                                 sg.getStartRes(), sg.getEndRes());\r
 \r
                         c.calculate();\r
                         c.verdict(false, av.ConsPercGaps);\r
-                        ccs = new ConservationColourScheme(c, ccs.cs);\r
-\r
-                        sg.cs = ccs;\r
+                        sg.cs.setConservation(c);\r
                     }\r
 \r
                     av.alignment.addGroup(sg);\r
index 5e86263..6e91e0b 100755 (executable)
@@ -34,6 +34,7 @@ public class Blosum62ColourScheme
     char res = s.charAt(0);\r
     if ('a' <= res && res <= 'z' )\r
     {\r
+       // TO UPPERCASE !!!\r
        s = String.valueOf( res -= ('a' - 'A') );\r
     }\r
 \r
@@ -49,7 +50,7 @@ public class Blosum62ColourScheme
 \r
       if (max.indexOf(s) > -1)\r
       {\r
-        return new Color(154, 154, 255);\r
+        currentColour = new Color(154, 154, 255);\r
       }\r
       else\r
       {\r
@@ -66,17 +67,22 @@ public class Blosum62ColourScheme
 \r
         if (c > 0)\r
         {\r
-          return new Color(204, 204, 255);\r
+          currentColour = new Color(204, 204, 255);\r
         }\r
         else\r
         {\r
-          return Color.white;\r
+          currentColour = Color.white;\r
         }\r
       }\r
+\r
+      if(conservationColouring)\r
+         applyConservation(j);\r
     }\r
     else\r
     {\r
       return Color.white;\r
     }\r
+\r
+    return currentColour;\r
   }\r
 }\r
index addf00f..353accf 100755 (executable)
@@ -255,18 +255,18 @@ public class ClustalxColourScheme
 \r
     int i = ( (Integer) ResidueProperties.aaHash.get(s)).intValue();\r
 \r
-    Color c = Color.white;\r
+    currentColour = Color.white;\r
 \r
     if (i > 19)\r
     {\r
-      return c;\r
+      return currentColour;\r
     }\r
 \r
     for (int k = 0; k < ResidueColour[i].conses.length; k++)\r
     {\r
       if (ResidueColour[i].conses[k].isConserved(cons2, j, size))\r
       {\r
-        c = ResidueColour[i].c;\r
+        currentColour = ResidueColour[i].c;\r
       }\r
     }\r
 \r
@@ -274,11 +274,14 @@ public class ClustalxColourScheme
     {\r
       if (conses[27].isConserved(cons2, j, size))\r
       {\r
-        c = (Color) colhash.get("PINK");\r
+        currentColour = (Color) colhash.get("PINK");\r
       }\r
     }\r
 \r
-    return c;\r
+    if(conservationColouring)\r
+         applyConservation(j);\r
+\r
+    return currentColour;\r
   }\r
 }\r
 \r
index 9cc74f1..8f0f3c5 100755 (executable)
@@ -18,8 +18,6 @@
  */\r
 package jalview.schemes;\r
 \r
-import java.util.*;\r
-\r
 import java.awt.*;\r
 \r
 public interface ColourSchemeI\r
@@ -28,5 +26,19 @@ public interface ColourSchemeI
 \r
   public Color findColour(String s, int j);\r
 \r
-  public void setConsensus(Vector v);\r
+  public void setConsensus(java.util.Vector v);\r
+\r
+  public void setConservation(jalview.analysis.Conservation c);\r
+\r
+  public boolean conservationApplied();\r
+\r
+  public void setConservationInc(int i);\r
+\r
+  public int getConservationInc();\r
+\r
+  public int getThreshold();\r
+\r
+  public void setThreshold(int ct, boolean ignoreGaps);\r
+\r
+\r
 }\r
index 012c3a9..c8a1322 100755 (executable)
@@ -139,10 +139,6 @@ public class ColourSchemeProperty
      */\r
     public static String getColourName(ColourSchemeI cs)\r
     {\r
-        if (cs instanceof ConservationColourScheme)\r
-        {\r
-            cs = ((ConservationColourScheme) cs).cs;\r
-        }\r
 \r
         int index = 12;\r
 \r
diff --git a/src/jalview/schemes/ConservationColourScheme.java b/src/jalview/schemes/ConservationColourScheme.java
deleted file mode 100755 (executable)
index b47b01a..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/*\r
-* Jalview - A Sequence Alignment Editor and Viewer\r
-* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
-*\r
-* This program is free software; you can redistribute it and/or\r
-* modify it under the terms of the GNU General Public License\r
-* as published by the Free Software Foundation; either version 2\r
-* of the License, or (at your option) any later version.\r
-*\r
-* This program is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with this program; if not, write to the Free Software\r
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
-*/\r
-package jalview.schemes;\r
-\r
-import jalview.analysis.*;\r
-\r
-import java.awt.*;\r
-\r
-import java.util.Vector;\r
-\r
-\r
-/**\r
- * DOCUMENT ME!\r
- *\r
- * @author $author$\r
- * @version $Revision$\r
- */\r
-public class ConservationColourScheme extends ResidueColourScheme\r
-{\r
-    /** DOCUMENT ME!! */\r
-    public Conservation conserve;\r
-\r
-    /** DOCUMENT ME!! */\r
-    public ColourSchemeI cs;\r
-\r
-    /** DOCUMENT ME!! */\r
-    public int inc = 30;\r
-\r
-    /**\r
-     * Creates a new ConservationColourScheme object.\r
-     *\r
-     * @param cons DOCUMENT ME!\r
-     * @param oldcs DOCUMENT ME!\r
-     */\r
-    public ConservationColourScheme(Conservation cons, ColourSchemeI oldcs)\r
-    {\r
-        super();\r
-        conserve = cons;\r
-        cs = oldcs;\r
-    }\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param consensus DOCUMENT ME!\r
-     */\r
-    public void setConsensus(Vector consensus)\r
-    {\r
-        super.setConsensus(consensus);\r
-\r
-        if (cs != null)\r
-        {\r
-            cs.setConsensus(consensus);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param s DOCUMENT ME!\r
-     * @param i DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    public Color findColour(String s, int i)\r
-    {\r
-        Color c = Color.white;\r
-\r
-        if (cs == null)\r
-        {\r
-            return c;\r
-        }\r
-\r
-        char ch = conserve.getConsSequence().getSequence().charAt(i);\r
-\r
-        if ((ch == '*') || (ch == '+'))\r
-        {\r
-            c = cs.findColour(s, i);\r
-        }\r
-        else\r
-        {\r
-            int tmp = 10;\r
-            int t = 0;\r
-\r
-            if (!jalview.util.Comparison.isGap(ch))\r
-            {\r
-                t = Integer.parseInt(ch + "");\r
-            }\r
-\r
-            c = cs.findColour(s, i);\r
-\r
-            while (tmp >= t)\r
-            {\r
-                c = lighter(c, inc);\r
-                tmp--;\r
-            }\r
-        }\r
-\r
-        return c;\r
-    }\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param c DOCUMENT ME!\r
-     * @param inc DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    public Color lighter(Color c, int inc)\r
-    {\r
-        int red = c.getRed();\r
-        int blue = c.getBlue();\r
-        int green = c.getGreen();\r
-\r
-        if (red < (255 - inc))\r
-        {\r
-            red = red + inc;\r
-        }\r
-        else\r
-        {\r
-            red = 255;\r
-        }\r
-\r
-        if (blue < (255 - inc))\r
-        {\r
-            blue = blue + inc;\r
-        }\r
-        else\r
-        {\r
-            blue = 255;\r
-        }\r
-\r
-        if (green < (255 - inc))\r
-        {\r
-            green = green + inc;\r
-        }\r
-        else\r
-        {\r
-            green = 255;\r
-        }\r
-\r
-        return new Color(red, green, blue);\r
-    }\r
-}\r
index 8785954..942e55b 100755 (executable)
@@ -64,7 +64,7 @@ public class NucleotideColourScheme extends ResidueColourScheme
         {\r
             try\r
             {\r
-                return colors[((Integer) (ResidueProperties.nucleotideHash.get(n))).intValue()];\r
+                currentColour = colors[((Integer) (ResidueProperties.nucleotideHash.get(n))).intValue()];\r
             }\r
             catch (Exception ex)\r
             {\r
@@ -75,5 +75,10 @@ public class NucleotideColourScheme extends ResidueColourScheme
         {\r
             return Color.white;\r
         }\r
+\r
+        if(conservationColouring)\r
+         applyConservation(j);\r
+\r
+       return currentColour;\r
     }\r
 }\r
index 3d1c18b..66f180b 100755 (executable)
@@ -49,9 +49,7 @@ public class PIDColourScheme
       return Color.white;\r
     }\r
 \r
-\r
-\r
-    Color c = Color.white;\r
+    currentColour = Color.white;\r
 \r
     double sc = 0;\r
 \r
@@ -66,7 +64,7 @@ public class PIDColourScheme
         {\r
           if (sc > thresholds[i])\r
           {\r
-            c = pidColours[i];\r
+            currentColour = pidColours[i];\r
 \r
             break;\r
           }\r
@@ -74,6 +72,9 @@ public class PIDColourScheme
       }\r
     }\r
 \r
-    return c;\r
+    if(conservationColouring)\r
+         applyConservation(j);\r
+\r
+    return currentColour;\r
   }\r
 }\r
index 785d22d..c435f7d 100755 (executable)
@@ -18,6 +18,8 @@
 */\r
 package jalview.schemes;\r
 \r
+import jalview.analysis.*;\r
+\r
 import java.awt.*;\r
 \r
 import java.util.*;\r
@@ -31,14 +33,31 @@ import java.util.*;
  */\r
 public class ResidueColourScheme implements ColourSchemeI\r
 {\r
+\r
+    boolean conservationColouring = false;\r
+    boolean consensusColouring = false;\r
+\r
     Color[] colors;\r
     int threshold = 0;\r
 \r
     /* Set when threshold colouring to either pid_gaps or pid_nogaps*/\r
     protected String ignoreGaps = "pid_gaps";\r
 \r
-    /** DOCUMENT ME!! */\r
-    public Hashtable [] consensus;\r
+    /** Consenus as a hashtable array */\r
+    Hashtable [] consensus;\r
+\r
+    /** Conservation string as a char array */\r
+   char [] conservation;\r
+\r
+   /** DOCUMENT ME!! */\r
+   int inc = 30;\r
+\r
+   /**\r
+    * The colour to be calculated, manipulated and returned\r
+    */\r
+   Color currentColour = null;\r
+\r
+\r
 \r
     /**\r
      * Creates a new ResidueColourScheme object.\r
@@ -46,9 +65,9 @@ public class ResidueColourScheme implements ColourSchemeI
      * @param colors DOCUMENT ME!\r
      * @param threshold DOCUMENT ME!\r
      */\r
-    public ResidueColourScheme(Color[] colors, int threshold)\r
+    public ResidueColourScheme(Color[] colours, int threshold)\r
     {\r
-        this.colors = colors;\r
+        this.colors = colours;\r
         this.threshold = threshold;\r
     }\r
 \r
@@ -60,56 +79,41 @@ public class ResidueColourScheme implements ColourSchemeI
     }\r
 \r
     /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param consensus DOCUMENT ME!\r
-     */\r
-    public void setConsensus(Vector vconsensus)\r
-    {\r
-       int i, iSize=vconsensus.size();\r
-       consensus = new Hashtable[iSize];\r
-       for(i=0; i<iSize; i++)\r
-        consensus[i] = (Hashtable)vconsensus.elementAt(i);\r
-    }\r
+    * Find a colour without an index in a sequence\r
+    */\r
+   public Color findColour(String aa)\r
+   {\r
+       return colors[((Integer) (ResidueProperties.aaHash.get(aa))).intValue()];\r
+   }\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param aa DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    public Color findColour(String aa)\r
-    {\r
-        return colors[((Integer) (ResidueProperties.aaHash.get(aa))).intValue()];\r
-    }\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param s DOCUMENT ME!\r
-     * @param j DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    public Color findColour(String s, int j)\r
-    {\r
-        int index = ((Integer) (ResidueProperties.aaHash.get(s))).intValue();\r
 \r
-        if ((threshold == 0) || aboveThreshold(ResidueProperties.aa[index], j))\r
-        {\r
-            return colors[index];\r
-        }\r
-        else\r
-        {\r
-            return Color.white;\r
-        }\r
-    }\r
+   public Color findColour(String s, int j)\r
+   {\r
+\r
+       int index = ((Integer) (ResidueProperties.aaHash.get(s))).intValue();\r
+\r
+       if ((threshold == 0) || aboveThreshold(ResidueProperties.aa[index], j))\r
+       {\r
+           currentColour = colors[index];\r
+       }\r
+       else\r
+       {\r
+           currentColour = Color.white;\r
+       }\r
+\r
+       if(conservationColouring)\r
+         applyConservation(j);\r
+\r
+\r
+       return currentColour;\r
+   }\r
+\r
 \r
     /**\r
-     * DOCUMENT ME!\r
+     * Get the percentage threshold for this colour scheme\r
      *\r
-     * @return DOCUMENT ME!\r
+     * @return Returns the percentage threshold\r
      */\r
     public int getThreshold()\r
     {\r
@@ -143,9 +147,7 @@ public class ResidueColourScheme implements ColourSchemeI
         if ((((Integer) consensus[j].get("maxCount")).intValue() != -1) &&\r
                 consensus[j].contains(s))\r
         {\r
-            float ratio =  ((Float)consensus[j].get(ignoreGaps)).floatValue();\r
-\r
-            if (ratio >= threshold)\r
+            if (((Float)consensus[j].get(ignoreGaps)).floatValue() >= threshold)\r
             {\r
                 return true;\r
             }\r
@@ -153,4 +155,128 @@ public class ResidueColourScheme implements ColourSchemeI
 \r
         return false;\r
     }\r
+\r
+\r
+    public boolean conservationApplied()\r
+    {\r
+      return conservationColouring;\r
+    }\r
+\r
+    public void setConservationInc(int i)\r
+    {\r
+      inc = i;\r
+    }\r
+\r
+    public int getConservationInc()\r
+    {\r
+      return inc;\r
+    }\r
+\r
+    /**\r
+     * DOCUMENT ME!\r
+     *\r
+     * @param consensus DOCUMENT ME!\r
+     */\r
+    public void setConsensus(Vector vconsensus)\r
+    {\r
+       int i, iSize=vconsensus.size();\r
+       consensus = new Hashtable[iSize];\r
+       for(i=0; i<iSize; i++)\r
+        consensus[i] = (Hashtable)vconsensus.elementAt(i);\r
+    }\r
+\r
+\r
+    public void setConservation(Conservation cons)\r
+    {\r
+      if(cons==null)\r
+      {\r
+        conservationColouring = false;\r
+        conservation = null;\r
+      }\r
+      else\r
+      {\r
+        conservationColouring = true;\r
+        int i, iSize = cons.getConsSequence().getLength();\r
+        conservation = new char[iSize];\r
+        for (i = 0; i < iSize; i++)\r
+          conservation[i] = cons.getConsSequence().getCharAt(i);\r
+      }\r
+\r
+    }\r
+\r
+\r
+    /**\r
+    * DOCUMENT ME!\r
+    *\r
+    * @param s DOCUMENT ME!\r
+    * @param i DOCUMENT ME!\r
+    *\r
+    * @return DOCUMENT ME!\r
+    */\r
+   void applyConservation(int i)\r
+   {\r
+       if ((conservation[i] != '*') && (conservation[i] != '+'))\r
+       {\r
+           int tmp = 10;\r
+           int t = 0;\r
+\r
+           if (!jalview.util.Comparison.isGap(conservation[i]))\r
+           {\r
+               t = conservation[i]-'0';\r
+           }\r
+\r
+           while (tmp >= t)\r
+           {\r
+               lighter(inc);\r
+               tmp--;\r
+           }\r
+       }\r
+\r
+   }\r
+\r
+    /**\r
+    * DOCUMENT ME!\r
+    *\r
+    * @param c DOCUMENT ME!\r
+    * @param inc DOCUMENT ME!\r
+    *\r
+    * @return DOCUMENT ME!\r
+    */\r
+   void lighter(int inc)\r
+   {\r
+       int red = currentColour.getRed();\r
+       int blue = currentColour.getBlue();\r
+       int green = currentColour.getGreen();\r
+\r
+       if (red < (255 - inc))\r
+       {\r
+           red = red + inc;\r
+       }\r
+       else\r
+       {\r
+           red = 255;\r
+       }\r
+\r
+       if (blue < (255 - inc))\r
+       {\r
+           blue = blue + inc;\r
+       }\r
+       else\r
+       {\r
+           blue = 255;\r
+       }\r
+\r
+       if (green < (255 - inc))\r
+       {\r
+           green = green + inc;\r
+       }\r
+       else\r
+       {\r
+           green = 255;\r
+       }\r
+\r
+       currentColour = new Color(red, green, blue);\r
+   }\r
+\r
+\r
 }\r
index b69e536..c11e1ec 100755 (executable)
@@ -52,6 +52,26 @@ public class ScoreColourScheme extends ResidueColourScheme
         this.scores = scores;\r
         this.min = min;\r
         this.max = max;\r
+\r
+        // Make colours in constructor\r
+        // Why wasn't this done earlier?\r
+        int i, iSize=scores.length;\r
+        colors = new Color[scores.length];\r
+        for (i = 0; i < iSize; i++)\r
+        {\r
+          float red = (float) (scores[i] - (float) min) / (float) (max - min);\r
+\r
+          if (red > 1.0f)\r
+          {\r
+            red = 1.0f;\r
+          }\r
+\r
+          if (red < 0.0f)\r
+          {\r
+            red = 0.0f;\r
+          }\r
+          colors[i] = makeColour(red);\r
+        }\r
     }\r
 \r
     /**\r
@@ -72,19 +92,6 @@ public class ScoreColourScheme extends ResidueColourScheme
             }\r
         }\r
 \r
-        float red = (float) (scores[((Integer) ResidueProperties.aaHash.get(s)).intValue()] -\r
-            (float) min) / (float) (max - min);\r
-\r
-        if (red > 1.0f)\r
-        {\r
-            red = 1.0f;\r
-        }\r
-\r
-        if (red < 0.0f)\r
-        {\r
-            red = 0.0f;\r
-        }\r
-\r
         char c = s.charAt(0);\r
 \r
         if (jalview.util.Comparison.isGap((c)))\r
@@ -92,8 +99,12 @@ public class ScoreColourScheme extends ResidueColourScheme
             return Color.white;\r
         }\r
 \r
-        // This isn';t great - pool of colours in here?\r
-        return makeColour(red);\r
+        currentColour = colors[((Integer) ResidueProperties.aaHash.get(s)).intValue()];\r
+\r
+        if(conservationColouring)\r
+         applyConservation(j);\r
+\r
+        return currentColour;\r
     }\r
 \r
     /**\r