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
49 public int getThreshold() {
\r
53 public void setThreshold(int ct) {
\r
57 public Vector getColours(SequenceI s, Vector aa) {
\r
58 Vector colours = new Vector();
\r
60 for (int j = 0; j < s.getLength(); j++)
\r
61 colours.addElement(getColour(s,j,aa));
\r
66 public Vector getColours(SequenceGroup sg, Vector aa) {
\r
67 Vector colours = new Vector();
\r
69 for (int j = 0; j < sg.getSize(); j++) {
\r
70 SequenceI s = sg.getSequenceAt(j);
\r
72 for (int i = 0; i < s.getLength();i++) {
\r
73 colours.addElement(getColour(s,i,aa));
\r
79 public boolean aboveThreshold(Vector aa,SequenceI seq, int j, int threshold) {
\r
80 String s = seq.getSequence(j,j+1);
\r
81 Hashtable hash = (Hashtable)aa.elementAt(j);
\r
83 if (j < aa.size()) {
\r
84 String maxRes = (String)hash.get("maxResidue");
\r
88 if (((Integer)hash.get("maxCount")).intValue() != -1 && hash.contains(s)) {
\r
89 int maxCount = ((Integer)hash.get("maxCount")).intValue();
\r
90 int resCount = ((Integer)hash.get(s)).intValue();
\r
92 sc = resCount * 100.0 / resCount;
\r
94 // This should be isGap somewhere
\r
95 if ( !s.equals("-") && !s.equals(".") && !s.equals(" ")) {
\r
96 if (sc >= (double)threshold) {
\r
105 public boolean canThreshold() {
\r
108 public boolean isUserDefinable() {
\r