lower case available
[jalview.git] / src / jalview / schemes / UserColourScheme.java
index 0e03797..bd70c5d 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
@@ -24,6 +24,8 @@ import java.util.StringTokenizer;
 public class UserColourScheme\r
     extends ResidueColourScheme\r
 {\r
+  Color [] lowerCaseColours;\r
+\r
   protected String schemeName;\r
 \r
   public UserColourScheme()\r
@@ -54,6 +56,11 @@ public class UserColourScheme
     return colors;\r
   }\r
 \r
+  public Color[] getLowerCaseColours()\r
+  {\r
+    return lowerCaseColours;\r
+  }\r
+\r
   public void setName(String name)\r
   {\r
     schemeName = name;\r
@@ -138,11 +145,38 @@ public class UserColourScheme
         st2 = new StringTokenizer(residues, " ,");\r
         while (st2.hasMoreTokens())\r
         {\r
+          token = st2.nextToken();\r
+\r
+          if (ResidueProperties.aaHash.get(token) == null)\r
+            continue;\r
+\r
           int colIndex =\r
               ( (Integer) ResidueProperties.aaHash.\r
-               get(st2.nextToken())).intValue();\r
-\r
-          colors[colIndex] = getColourFromString(colour);\r
+               get(token)).intValue();\r
+\r
+           //AW - LOWER CASE DISABLED IN 2.1.01 bug fix release\r
+\r
+          if(token.equalsIgnoreCase("lowerCase"))\r
+          {\r
+            if (lowerCaseColours == null)\r
+              lowerCaseColours = new Color[23];\r
+            for (int i = 0; i < 23; i++)\r
+              if (lowerCaseColours[i] == null)\r
+                lowerCaseColours[i] = getColourFromString(colour);\r
+\r
+              continue;\r
+          }\r
+\r
+          if(token.equals(token.toLowerCase()))\r
+          {\r
+            if(lowerCaseColours==null)\r
+            {\r
+              lowerCaseColours = new Color[23];\r
+            }\r
+            lowerCaseColours[colIndex] = getColourFromString(colour);\r
+          }\r
+          else\r
+            colors[colIndex] = getColourFromString(colour);\r
         }\r
       }\r
     }\r
@@ -154,4 +188,35 @@ public class UserColourScheme
 \r
   }\r
 \r
+\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
+       //AW - LOWER CASE DISABLED IN 2.1.01 bug fix release\r
+        if(lowerCaseColours!=null && 'a' <= s.charAt(0) && s.charAt(0) <= 'z')\r
+          currentColour = lowerCaseColours[index];\r
+        else\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
+   public void setLowerCaseColours(Color [] lcolours)\r
+   {\r
+     lowerCaseColours = lcolours;\r
+   }\r
+\r
 }\r