X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FResidueColourScheme.java;h=df905006fe4f1fe03ac5112a1b15e13799258a84;hb=2e699d341f8e64868e3c279f9c02af617c4e9b44;hp=78ebab04388ae4b825c59f49226c7ba56a1d1275;hpb=95ebd2cf76003f52476a7802c99831dfa98945f7;p=jalview.git diff --git a/src/jalview/schemes/ResidueColourScheme.java b/src/jalview/schemes/ResidueColourScheme.java index 78ebab0..df90500 100755 --- a/src/jalview/schemes/ResidueColourScheme.java +++ b/src/jalview/schemes/ResidueColourScheme.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle +* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -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,15 +135,25 @@ public class ResidueColourScheme implements ColourSchemeI * * @return DOCUMENT ME! */ - public boolean aboveThreshold(String s, int j) + public boolean aboveThreshold(char c, int j) { - if ((((Integer) consensus[j].get("maxCount")).intValue() != -1) && - consensus[j].contains(s)) + if ('a' <= c && c <= 'z') + { + // TO UPPERCASE !!! + //Faster than toUpperCase + c -= ('a' - 'A'); + } + + if (consensus == null || consensus[j] == null) + return false; + + 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; @@ -177,18 +180,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