1 package jalview.schemes;
\r
3 import jalview.datamodel.*;
\r
7 public class ResidueColourScheme implements ColourSchemeI{
\r
11 public ResidueColourScheme(Color[] colors, int threshold) {
\r
12 this.colors = colors;
\r
13 this.threshold = threshold;
\r
16 public ResidueColourScheme() {
\r
19 public Color findColour(String aa)
\r
21 return colors[((Integer)(ResidueProperties.aaHash.get(aa))).intValue()];
\r
24 public Color findColour(SequenceI seq,String s, int j, Vector aa) {
\r
26 return colors[((Integer)(ResidueProperties.aaHash.get(s))).intValue()];
\r
27 } catch (Exception e) {
\r
32 // aa should maybe be a class
\r
33 /* public Color getColour(SequenceI seq, int j,Vector aa) {
\r
35 Color c = Color.white;
\r
36 String s = seq.getSequence(j,j+1);
\r
38 if (threshold > 0 && aa != null)
\r
40 if (aboveThreshold(aa,seq,j,threshold))
\r
41 c = findColour(seq,s,j,aa);
\r
44 c = findColour(seq,s,j,aa);
\r
50 public int getThreshold() {
\r
54 public void setThreshold(int ct) {
\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
62 if (j < aa.size()) {
\r
63 String maxRes = (String)hash.get("maxResidue");
\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
71 sc = resCount * 100.0 / resCount;
\r
73 // This should be isGap somewhere
\r
74 if ( !s.equals("-") && !s.equals(".") && !s.equals(" ")) {
\r
75 if (sc >= (double)threshold) {
\r
84 public boolean canThreshold() {
\r
87 public boolean isUserDefinable() {
\r