consensus held in residueColour
[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 = 0;\r
10     public Vector   consensus;\r
11 \r
12     public ResidueColourScheme(Color[] colors, int threshold) {\r
13         this.colors    = colors;\r
14         this.threshold = threshold;\r
15     }\r
16 \r
17     public ResidueColourScheme()\r
18     {   }\r
19 \r
20     public void setConsensus(Vector consensus)\r
21     {\r
22       this.consensus = consensus;\r
23     }\r
24 \r
25     public Color findColour(String aa)\r
26     {\r
27       return colors[((Integer)(ResidueProperties.aaHash.get(aa))).intValue()];\r
28     }\r
29 \r
30     public Color findColour(String s, int j) {\r
31 \r
32        if( threshold==0 || aboveThreshold(s,j))\r
33           return colors[((Integer)(ResidueProperties.aaHash.get(s))).intValue()];\r
34        else\r
35           return Color.white;\r
36 \r
37     }\r
38 \r
39     public int getThreshold() {\r
40         return threshold;\r
41     }\r
42 \r
43     public void setThreshold(int ct) {\r
44         threshold = ct;\r
45     }\r
46 \r
47     public boolean aboveThreshold(String s, int j)\r
48     {\r
49         Hashtable hash = (Hashtable)consensus.elementAt(j);\r
50 \r
51         if ( ( (Integer) hash.get("maxCount")).intValue() != -1 && hash.contains(s))\r
52         {\r
53                ////  resCount////////////////////                  ///////////////seq count////////////\r
54           double sc = ( (Integer) hash.get(s)).intValue()  * 100.0 / ( (Integer) hash.get("size")).intValue();\r
55 \r
56           if (sc >= threshold)\r
57             return true;\r
58 \r
59         }\r
60 \r
61         return false;\r
62     }\r
63 \r
64     public boolean canThreshold() {\r
65         return true;\r
66     }\r
67     public boolean isUserDefinable() {\r
68         return false;\r
69     }\r
70 }\r