isGap method implemented in utils, and optimized
[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 \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(String s, int j, Vector aa) {\r
25 \r
26        if( threshold==0 || aboveThreshold(aa,s,j))\r
27           return colors[((Integer)(ResidueProperties.aaHash.get(s))).intValue()];\r
28        else\r
29           return Color.white;\r
30 \r
31     }\r
32 \r
33     public int getThreshold() {\r
34         return threshold;\r
35     }\r
36 \r
37     public void setThreshold(int ct) {\r
38         threshold = ct;\r
39     }\r
40 \r
41     public boolean aboveThreshold(Vector aa,String s, int j)\r
42     {\r
43 \r
44         Hashtable hash = (Hashtable)aa.elementAt(j);\r
45 \r
46         if ( ( (Integer) hash.get("maxCount")).intValue() != -1 && hash.contains(s))\r
47         {\r
48                ////  resCount////////////////////                  ///////////////seq count////////////\r
49           double sc = ( (Integer) hash.get(s)).intValue()  * 100.0 / ( (Integer) hash.get("size")).intValue();\r
50 \r
51           if (sc >= threshold)\r
52             return true;\r
53 \r
54         }\r
55 \r
56         return false;\r
57     }\r
58 \r
59     public boolean canThreshold() {\r
60         return true;\r
61     }\r
62     public boolean isUserDefinable() {\r
63         return false;\r
64     }\r
65 }\r