1 package jalview.schemes;
\r
3 import jalview.datamodel.*;
\r
4 import jalview.jbgui.*;
\r
9 public class ResidueColourScheme implements ColourSchemeI {
\r
13 public ResidueColourScheme(Color[] colors, int threshold) {
\r
14 this.colors = colors;
\r
15 this.threshold = threshold;
\r
18 public ResidueColourScheme() {
\r
21 public Color findColour(String aa)
\r
23 return colors[((Integer)(ResidueProperties.aaHash.get(aa))).intValue()];
\r
26 public Color findColour(SequenceI seq,String s, int j, Vector aa) {
\r
28 return colors[((Integer)(ResidueProperties.aaHash.get(s))).intValue()];
\r
29 } catch (Exception e) {
\r
34 // aa should maybe be a class
\r
35 public Color getColour(SequenceI seq, int j,Vector aa) {
\r
37 Color c = Color.white;
\r
38 String s = seq.getSequence(j,j+1);
\r
40 if (threshold > 0 && aa != null)
\r
42 if (aboveThreshold(aa,seq,j,threshold))
\r
43 c = findColour(seq,s,j,aa);
\r
46 c = findColour(seq,s,j,aa);
\r
51 public int getThreshold() {
\r
55 public void setThreshold(int ct) {
\r
59 public Vector getColours(SequenceI s, Vector aa) {
\r
60 Vector colours = new Vector();
\r
62 for (int j = 0; j < s.getLength(); j++)
\r
63 colours.addElement(getColour(s,j,aa));
\r
68 public Vector getColours(SequenceGroup sg, Vector aa) {
\r
69 Vector colours = new Vector();
\r
71 for (int j = 0; j < sg.getSize(); j++) {
\r
72 SequenceI s = sg.getSequenceAt(j);
\r
74 for (int i = 0; i < s.getLength();i++) {
\r
75 colours.addElement(getColour(s,i,aa));
\r
81 public boolean aboveThreshold(Vector aa,SequenceI seq, int j, int threshold) {
\r
82 String s = seq.getSequence(j,j+1);
\r
83 Hashtable hash = (Hashtable)aa.elementAt(j);
\r
85 if (j < aa.size()) {
\r
86 String maxRes = (String)hash.get("maxResidue");
\r
90 if (((Integer)hash.get("maxCount")).intValue() != -1 && hash.contains(s)) {
\r
91 int maxCount = ((Integer)hash.get("maxCount")).intValue();
\r
92 int resCount = ((Integer)hash.get(s)).intValue();
\r
94 sc = resCount * 100.0 / resCount;
\r
96 // This should be isGap somewhere
\r
97 if ( !s.equals("-") && !s.equals(".") && !s.equals(" ")) {
\r
98 if (sc >= (double)threshold) {
\r
107 public boolean canThreshold() {
\r
110 public boolean isUserDefinable() {
\r