X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FResidueColourScheme.java;h=b905c452ba87dcce2683ded2f74c2ec0fdc5cd36;hb=d640a8ce605b836b2e6eb1771994d3baef5c31a0;hp=0d2db232b6f5724aadfbb50c62a1c78cd73c906a;hpb=174230b4233d9ce80f94527768d2cd2f76da11ab;p=jalview.git diff --git a/src/jalview/schemes/ResidueColourScheme.java b/src/jalview/schemes/ResidueColourScheme.java index 0d2db23..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; } /** @@ -144,13 +138,25 @@ public class ResidueColourScheme implements ColourSchemeI */ public boolean aboveThreshold(String s, int j) { - if ((((Integer) consensus[j].get("maxCount")).intValue() != -1) && - consensus[j].contains(s)) + char c = s.charAt(0); + if ('a' <= c && c <= 'z') { - if (((Float)consensus[j].get(ignoreGaps)).floatValue() >= threshold) - { - return true; - } + // 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(AAFrequency.MAXCOUNT)).intValue() != -1) && + consensus[j].contains(s)) + { + if ( ( (Float) consensus[j].get(ignoreGaps)).floatValue() >= threshold) + { + return true; + } } return false; @@ -177,18 +183,16 @@ public class ResidueColourScheme implements ColourSchemeI * * @param consensus DOCUMENT ME! */ - public void setConsensus(Vector vconsensus) + public void setConsensus(Hashtable [] consensus) { - if(vconsensus==null) + if(consensus==null) return; - int i, iSize=vconsensus.size(); - consensus = new Hashtable[iSize]; - for(i=0; i