X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FResidueColourScheme.java;h=b905c452ba87dcce2683ded2f74c2ec0fdc5cd36;hb=4966d9f4569d7f2b46aca6ff4629e9a1b1120c98;hp=a99380273980c9dc077088ce6497e9a3547aac6f;hpb=7be3a744db5213f49e70178ade126d1cc797c762;p=jalview.git diff --git a/src/jalview/schemes/ResidueColourScheme.java b/src/jalview/schemes/ResidueColourScheme.java index a993802..b905c45 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. @@ -83,15 +77,15 @@ public class ResidueColourScheme implements ColourSchemeI */ public Color findColour(String aa) { - return colors[((Integer) (ResidueProperties.aaHash.get(aa))).intValue()]; + return colors[ResidueProperties.aaIndex[aa.charAt(0)]]; } public Color findColour(String s, int j) { - - int index = ((Integer) (ResidueProperties.aaHash.get(s))).intValue(); + Color currentColour; + int index = ResidueProperties.aaIndex[s.charAt(0)]; if ((threshold == 0) || aboveThreshold(ResidueProperties.aa[index], j)) { @@ -103,7 +97,7 @@ public class ResidueColourScheme implements ColourSchemeI } if(conservationColouring) - applyConservation(j); + currentColour = applyConservation(currentColour, j); return currentColour; @@ -129,9 +123,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; } /** @@ -153,14 +147,16 @@ public class ResidueColourScheme implements ColourSchemeI 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(s)) { - if (((Float)consensus[j].get(ignoreGaps)).floatValue() >= threshold) - { - return true; - } + if ( ( (Float) consensus[j].get(ignoreGaps)).floatValue() >= threshold) + { + return true; + } } return false; @@ -225,7 +221,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 +235,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 +260,7 @@ public class ResidueColourScheme implements ColourSchemeI currentColour = new Color(red, green, blue); } } + return currentColour; }