X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FResidueColourScheme.java;h=64fd62e1cb2c921ddaaf9de7519c94fd0ec31d01;hb=bc39ee8df9694f820a8a8bd2430f527b87c07f31;hp=3c8e69044e73252b2c5380556570d894eebc0611;hpb=064f2fdaa463367f8bf7e6aea5e7fc6a32170138;p=jalview.git diff --git a/src/jalview/schemes/ResidueColourScheme.java b/src/jalview/schemes/ResidueColourScheme.java index 3c8e690..64fd62e 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; @@ -83,7 +83,7 @@ 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)]]; } @@ -91,7 +91,7 @@ public class ResidueColourScheme implements ColourSchemeI public Color findColour(String s, int j) { - int index = ((Integer) (ResidueProperties.aaHash.get(s))).intValue(); + int index = ResidueProperties.aaIndex[s.charAt(0)]; if ((threshold == 0) || aboveThreshold(ResidueProperties.aa[index], j)) { @@ -129,9 +129,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 +144,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 +189,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= t) - { - lighter(inc); - tmp--; - } - } - } - - /** - * DOCUMENT ME! - * - * @param c DOCUMENT ME! - * @param inc DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - void lighter(int inc) + void applyConservation(int i) { - int red = currentColour.getRed(); - int blue = currentColour.getBlue(); - int green = currentColour.getGreen(); - if (red < (255 - inc)) + if ((conservation[i] != '*') && (conservation[i] != '+')) + { + if(jalview.util.Comparison.isGap(conservation[i])) { - red = red + inc; + currentColour = Color.white; } else { - red = 255; - } + float t = 11 - (conservation[i] - '0'); + if(t==0) + { + currentColour = Color.white; + return; + } - if (blue < (255 - inc)) - { - blue = blue + inc; - } - else - { - blue = 255; - } + int red = currentColour.getRed(); + int green = currentColour.getGreen(); + int blue = currentColour.getBlue(); - if (green < (255 - inc)) - { - green = green + inc; + int dr = 255 - red; + int dg = 255 - green; + int db = 255 - blue; + + dr *= t / 10f; + dg *= t / 10f; + db *= t / 10f; + + red += (inc / 20f) * dr; + green += (inc / 20f) * dg; + blue += (inc / 20f) * db; + + if (red > 255 || green > 255 || blue > 255) + currentColour = Color.white; + else + currentColour = new Color(red, green, blue); } - else - { - green = 255; } - - currentColour = new Color(red, green, blue); }