all can threshold
[jalview.git] / src / jalview / schemes / ResidueColourScheme.java
1 package jalview.schemes;\r
2 \r
3 import java.util.*;\r
4 import java.awt.*;\r
5 \r
6 public class ResidueColourScheme implements ColourSchemeI{\r
7     Color    [] colors;\r
8     int       threshold = 0;\r
9     public Vector   consensus;\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 void setConsensus(Vector consensus)\r
20     {\r
21       this.consensus = consensus;\r
22     }\r
23 \r
24     public Color findColour(String aa)\r
25     {\r
26       return colors[((Integer)(ResidueProperties.aaHash.get(aa))).intValue()];\r
27     }\r
28 \r
29     public Color findColour(String s, int j) {\r
30 \r
31        if( threshold==0 || aboveThreshold(s,j))\r
32           return colors[((Integer)(ResidueProperties.aaHash.get(s))).intValue()];\r
33        else\r
34           return Color.white;\r
35 \r
36     }\r
37 \r
38     public int getThreshold() {\r
39         return threshold;\r
40     }\r
41 \r
42     public void setThreshold(int ct) {\r
43         threshold = ct;\r
44     }\r
45 \r
46     public boolean aboveThreshold(String s, int j)\r
47     {\r
48         Hashtable hash = (Hashtable)consensus.elementAt(j);\r
49 \r
50         if ( ( (Integer) hash.get("maxCount")).intValue() != -1 && hash.contains(s))\r
51         {\r
52                ////  resCount////////////////////                  ///////////////seq count////////////\r
53           double sc = ( (Integer) hash.get(s)).intValue()  * 100.0 / ( (Integer) hash.get("size")).intValue();\r
54 \r
55           if (sc >= threshold)\r
56             return true;\r
57 \r
58         }\r
59 \r
60         return false;\r
61     }\r
62 }\r