CurrentColour must not be accessed by multiple sequence renderers
[jalview.git] / src / jalview / schemes / Blosum62ColourScheme.java
index 356e3fe..f2d2c98 100755 (executable)
@@ -1,6 +1,6 @@
 /*\r
  * Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * Copyright (C) 2006 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
@@ -20,6 +20,7 @@ package jalview.schemes;
 \r
 \r
 import java.awt.*;\r
+import jalview.analysis.AAFrequency;\r
 \r
 public class Blosum62ColourScheme\r
     extends ResidueColourScheme\r
@@ -31,19 +32,31 @@ public class Blosum62ColourScheme
 \r
   public Color findColour(String s, int j)\r
   {\r
-    if ( (threshold != 0) && !aboveThreshold(s, j))\r
+\r
+    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
+    if (consensus == null ||\r
+        j >= consensus.length ||\r
+        consensus[j] == null ||\r
+        (threshold != 0 && !aboveThreshold(s, j)))\r
     {\r
       return Color.white;\r
     }\r
 \r
+    Color currentColour;\r
 \r
-    if (!jalview.util.Comparison.isGap( (s.charAt(0))))\r
+    if (!jalview.util.Comparison.isGap( res ))\r
     {\r
-      String max = (String) consensus[j].get("maxResidue");\r
+      String max = (String) consensus[j].get(AAFrequency.MAXRESIDUE);\r
 \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
@@ -60,17 +73,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
+       currentColour =  applyConservation(currentColour, j);\r
     }\r
     else\r
     {\r
       return Color.white;\r
     }\r
+\r
+    return currentColour;\r
   }\r
 }\r