Out of bounds check
[jalview.git] / src / jalview / schemes / PIDColourScheme.java
index cfc9f94..1575a6a 100755 (executable)
@@ -18,8 +18,6 @@
  */\r
 package jalview.schemes;\r
 \r
-import java.util.*;\r
-\r
 import java.awt.*;\r
 \r
 import jalview.datamodel.*;\r
@@ -39,38 +37,47 @@ public class PIDColourScheme
 \r
   public Color findColour(String s, int j)\r
   {\r
+    char res = s.charAt(0);\r
+    if ('a' <= res && res <= 'z')\r
+    {\r
+      s = String.valueOf(res -= ('a' - 'A'));\r
+    }\r
+\r
+\r
     if ( (threshold != 0) && !aboveThreshold(s, j))\r
     {\r
       return Color.white;\r
     }\r
 \r
-    Color c = Color.white;\r
-    Hashtable hash = (Hashtable) consensus.elementAt(j);\r
+    currentColour = Color.white;\r
 \r
     double sc = 0;\r
 \r
-    if ( (Integer.parseInt(hash.get("maxCount").toString()) != -1) &&\r
-        hash.contains(s))\r
-    {\r
-      sc = ( ( (Integer) hash.get(s)).intValue() * 100.0) /\r
-          ( (Integer) hash.get(\r
-              "size")).intValue();\r
+    if(consensus.length<=j)\r
+      return Color.white;\r
 \r
-      // MC Should be isGap\r
-      if (!jalview.util.Comparison.isGap( (s.charAt(0))))\r
+      if ( (Integer.parseInt(consensus[j].get("maxCount").toString()) != -1) &&\r
+          consensus[j].contains(s))\r
       {\r
-        for (int i = 0; i < thresholds.length; i++)\r
+        sc = ( (Float) consensus[j].get(ignoreGaps)).floatValue();\r
+\r
+        if (!jalview.util.Comparison.isGap(res))\r
         {\r
-          if (sc > thresholds[i])\r
+          for (int i = 0; i < thresholds.length; i++)\r
           {\r
-            c = pidColours[i];\r
+            if (sc > thresholds[i])\r
+            {\r
+              currentColour = pidColours[i];\r
 \r
-            break;\r
+              break;\r
+            }\r
           }\r
         }\r
       }\r
-    }\r
 \r
-    return c;\r
+    if(conservationColouring)\r
+         applyConservation(j);\r
+\r
+    return currentColour;\r
   }\r
 }\r