Check conensus is not null
[jalview.git] / src / jalview / schemes / ResidueColourScheme.java
index a993802..64fd62e 100755 (executable)
@@ -41,7 +41,7 @@ public class ResidueColourScheme implements ColourSchemeI
     int threshold = 0;\r
 \r
     /* Set when threshold colouring to either pid_gaps or pid_nogaps*/\r
-    protected String ignoreGaps = "pid_gaps";\r
+    protected String ignoreGaps = AAFrequency.PID_GAPS;\r
 \r
     /** Consenus as a hashtable array */\r
     Hashtable [] consensus;\r
@@ -83,7 +83,7 @@ public class ResidueColourScheme implements ColourSchemeI
     */\r
    public Color findColour(String aa)\r
    {\r
-       return colors[((Integer) (ResidueProperties.aaHash.get(aa))).intValue()];\r
+       return colors[ResidueProperties.aaIndex[aa.charAt(0)]];\r
    }\r
 \r
 \r
@@ -91,7 +91,7 @@ public class ResidueColourScheme implements ColourSchemeI
    public Color findColour(String s, int j)\r
    {\r
 \r
-       int index = ((Integer) (ResidueProperties.aaHash.get(s))).intValue();\r
+       int index = ResidueProperties.aaIndex[s.charAt(0)];\r
 \r
        if ((threshold == 0) || aboveThreshold(ResidueProperties.aa[index], j))\r
        {\r
@@ -129,9 +129,9 @@ public class ResidueColourScheme implements ColourSchemeI
     {\r
         threshold = ct;\r
         if(ignoreGaps)\r
-          this.ignoreGaps = "pid_nogaps";\r
+          this.ignoreGaps = AAFrequency.PID_NOGAPS;\r
         else\r
-          this.ignoreGaps = "pid_gaps";\r
+          this.ignoreGaps = AAFrequency.PID_GAPS;\r
     }\r
 \r
     /**\r
@@ -153,14 +153,16 @@ public class ResidueColourScheme implements ColourSchemeI
           s = String.valueOf(c);\r
         }\r
 \r
+        if (consensus == null || consensus[j] == null)\r
+          return false;\r
 \r
-      if ((((Integer) consensus[j].get("maxCount")).intValue() != -1) &&\r
-                consensus[j].contains(s))\r
+        if ( ( ( (Integer) consensus[j].get(AAFrequency.MAXCOUNT)).intValue() != -1) &&\r
+            consensus[j].contains(s))\r
         {\r
-            if (((Float)consensus[j].get(ignoreGaps)).floatValue() >= threshold)\r
-            {\r
-                return true;\r
-            }\r
+          if ( ( (Float) consensus[j].get(ignoreGaps)).floatValue() >= threshold)\r
+          {\r
+            return true;\r
+          }\r
         }\r
 \r
         return false;\r