X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FResidueColourScheme.java;h=df905006fe4f1fe03ac5112a1b15e13799258a84;hb=baa67039bb8cd4236ac4565a62291c0ba6366c07;hp=a99380273980c9dc077088ce6497e9a3547aac6f;hpb=7be3a744db5213f49e70178ade126d1cc797c762;p=jalview.git diff --git a/src/jalview/schemes/ResidueColourScheme.java b/src/jalview/schemes/ResidueColourScheme.java index a993802..df90500 100755 --- a/src/jalview/schemes/ResidueColourScheme.java +++ b/src/jalview/schemes/ResidueColourScheme.java @@ -41,7 +41,7 @@ public class ResidueColourScheme implements ColourSchemeI int threshold = 0; /* Set when threshold colouring to either pid_gaps or pid_nogaps*/ - protected String ignoreGaps = "pid_gaps"; + protected String ignoreGaps = AAFrequency.PID_GAPS; /** Consenus as a hashtable array */ Hashtable [] consensus; @@ -52,12 +52,6 @@ public class ResidueColourScheme implements ColourSchemeI /** DOCUMENT ME!! */ int inc = 30; - /** - * The colour to be calculated, manipulated and returned - */ - Color currentColour = null; - - /** * Creates a new ResidueColourScheme object. @@ -81,21 +75,20 @@ public class ResidueColourScheme implements ColourSchemeI /** * Find a colour without an index in a sequence */ - public Color findColour(String aa) + public Color findColour(char c) { - return colors[((Integer) (ResidueProperties.aaHash.get(aa))).intValue()]; + return colors[ResidueProperties.aaIndex[c]]; } - public Color findColour(String s, int j) + public Color findColour(char c, int j) { + Color currentColour; - int index = ((Integer) (ResidueProperties.aaHash.get(s))).intValue(); - - if ((threshold == 0) || aboveThreshold(ResidueProperties.aa[index], j)) + if ((threshold == 0) || aboveThreshold(c, j)) { - currentColour = colors[index]; + currentColour = colors[ResidueProperties.aaIndex[c]]; } else { @@ -103,7 +96,7 @@ public class ResidueColourScheme implements ColourSchemeI } if(conservationColouring) - applyConservation(j); + currentColour = applyConservation(currentColour, j); return currentColour; @@ -129,9 +122,9 @@ public class ResidueColourScheme implements ColourSchemeI { threshold = ct; if(ignoreGaps) - this.ignoreGaps = "pid_nogaps"; + this.ignoreGaps = AAFrequency.PID_NOGAPS; else - this.ignoreGaps = "pid_gaps"; + this.ignoreGaps = AAFrequency.PID_GAPS; } /** @@ -142,25 +135,25 @@ public class ResidueColourScheme implements ColourSchemeI * * @return DOCUMENT ME! */ - public boolean aboveThreshold(String s, int j) + public boolean aboveThreshold(char c, int j) { - char c = s.charAt(0); if ('a' <= c && c <= 'z') { // TO UPPERCASE !!! //Faster than toUpperCase c -= ('a' - 'A'); - s = String.valueOf(c); } + if (consensus == null || consensus[j] == null) + return false; - if ((((Integer) consensus[j].get("maxCount")).intValue() != -1) && - consensus[j].contains(s)) + if ( ( ( (Integer) consensus[j].get(AAFrequency.MAXCOUNT)).intValue() != -1) && + consensus[j].contains(String.valueOf(c))) { - if (((Float)consensus[j].get(ignoreGaps)).floatValue() >= threshold) - { - return true; - } + if ( ( (Float) consensus[j].get(ignoreGaps)).floatValue() >= threshold) + { + return true; + } } return false; @@ -225,7 +218,7 @@ public class ResidueColourScheme implements ColourSchemeI * @return DOCUMENT ME! */ - void applyConservation(int i) + Color applyConservation(Color currentColour, int i) { if ((conservation[i] != '*') && (conservation[i] != '+')) @@ -239,8 +232,7 @@ public class ResidueColourScheme implements ColourSchemeI float t = 11 - (conservation[i] - '0'); if(t==0) { - currentColour = Color.white; - return; + return Color.white; } int red = currentColour.getRed(); @@ -265,6 +257,7 @@ public class ResidueColourScheme implements ColourSchemeI currentColour = new Color(red, green, blue); } } + return currentColour; }