Getcolours is not needed ????
[jalview.git] / src / jalview / schemes / ResidueColourScheme.java
1 package jalview.schemes;\r
2 \r
3 import jalview.datamodel.*;\r
4 import java.util.*;\r
5 import java.awt.*;\r
6 \r
7 public class ResidueColourScheme implements ColourSchemeI{\r
8     Color    [] colors;\r
9     int         threshold = 90;\r
10 \r
11     public ResidueColourScheme(Color[] colors, int threshold) {\r
12         this.colors    = colors;\r
13         this.threshold = threshold;\r
14     }\r
15 \r
16     public ResidueColourScheme() {\r
17     }\r
18 \r
19     public Color findColour(String aa)\r
20     {\r
21       return colors[((Integer)(ResidueProperties.aaHash.get(aa))).intValue()];\r
22     }\r
23 \r
24     public Color findColour(SequenceI seq,String s, int j, Vector aa) {\r
25   try {\r
26             return colors[((Integer)(ResidueProperties.aaHash.get(s))).intValue()];\r
27         } catch (Exception e) {\r
28             return Color.white;\r
29         }\r
30     }\r
31 \r
32     // aa should maybe be a class\r
33   /*  public Color getColour(SequenceI seq, int j,Vector aa) {\r
34 \r
35         Color  c       = Color.white;\r
36         String s       = seq.getSequence(j,j+1);\r
37 \r
38         if (threshold > 0 && aa != null)\r
39         {\r
40             if (aboveThreshold(aa,seq,j,threshold))\r
41                 c = findColour(seq,s,j,aa);\r
42         }\r
43         else\r
44             c = findColour(seq,s,j,aa);\r
45 \r
46 \r
47       return c;\r
48     }*/\r
49 \r
50     public int getThreshold() {\r
51         return threshold;\r
52     }\r
53 \r
54     public void setThreshold(int ct) {\r
55         threshold = ct;\r
56     }\r
57 \r
58     public boolean aboveThreshold(Vector aa,SequenceI seq, int j, int threshold) {\r
59         String    s    = seq.getSequence(j,j+1);\r
60         Hashtable hash = (Hashtable)aa.elementAt(j);\r
61 \r
62         if (j < aa.size()) {\r
63             String maxRes = (String)hash.get("maxResidue");\r
64 \r
65             double sc = 0;\r
66 \r
67             if (((Integer)hash.get("maxCount")).intValue() != -1  && hash.contains(s)) {\r
68                 int maxCount = ((Integer)hash.get("maxCount")).intValue();\r
69                 int resCount = ((Integer)hash.get(s)).intValue();\r
70 \r
71                 sc = resCount * 100.0 / resCount;\r
72 \r
73                 // This should be isGap somewhere\r
74                 if  ( !s.equals("-")  && !s.equals(".") && !s.equals(" ")) {\r
75                     if (sc >= (double)threshold) {\r
76                         return true;\r
77                     }\r
78                 }\r
79             }\r
80         }\r
81         return false;\r
82     }\r
83 \r
84     public boolean canThreshold() {\r
85         return true;\r
86     }\r
87     public boolean isUserDefinable() {\r
88         return false;\r
89     }\r
90 }\r