X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FResidueColourScheme.java;h=c435f7dc264687811c7001b68c8d62b6800d1c23;hb=95a46891288f4fc63d690cab4f56879678f54fb6;hp=71f12c13ab9170442021fdeefc2bfc5a3cf6278b;hpb=89805aa27a9d87b25010f9fbc0e0e4c853c3a1e1;p=jalview.git diff --git a/src/jalview/schemes/ResidueColourScheme.java b/src/jalview/schemes/ResidueColourScheme.java index 71f12c1..c435f7d 100755 --- a/src/jalview/schemes/ResidueColourScheme.java +++ b/src/jalview/schemes/ResidueColourScheme.java @@ -18,6 +18,8 @@ */ package jalview.schemes; +import jalview.analysis.*; + import java.awt.*; import java.util.*; @@ -31,14 +33,31 @@ import java.util.*; */ public class ResidueColourScheme implements ColourSchemeI { + + boolean conservationColouring = false; + boolean consensusColouring = false; + Color[] colors; int threshold = 0; /* Set when threshold colouring to either pid_gaps or pid_nogaps*/ protected String ignoreGaps = "pid_gaps"; - /** DOCUMENT ME!! */ - public Hashtable [] consensus; + /** Consenus as a hashtable array */ + Hashtable [] consensus; + + /** Conservation string as a char array */ + char [] conservation; + + /** DOCUMENT ME!! */ + int inc = 30; + + /** + * The colour to be calculated, manipulated and returned + */ + Color currentColour = null; + + /** * Creates a new ResidueColourScheme object. @@ -46,9 +65,9 @@ public class ResidueColourScheme implements ColourSchemeI * @param colors DOCUMENT ME! * @param threshold DOCUMENT ME! */ - public ResidueColourScheme(Color[] colors, int threshold) + public ResidueColourScheme(Color[] colours, int threshold) { - this.colors = colors; + this.colors = colours; this.threshold = threshold; } @@ -60,54 +79,41 @@ public class ResidueColourScheme implements ColourSchemeI } /** - * DOCUMENT ME! - * - * @param consensus DOCUMENT ME! - */ - public void setConsensus(Vector vconsensus) - { - int i, iSize=vconsensus.size(); - consensus = new Hashtable[iSize]; - for(i=0; i= threshold) + if (((Float)consensus[j].get(ignoreGaps)).floatValue() >= threshold) { return true; } @@ -151,4 +155,128 @@ public class ResidueColourScheme implements ColourSchemeI return false; } + + + public boolean conservationApplied() + { + return conservationColouring; + } + + public void setConservationInc(int i) + { + inc = i; + } + + public int getConservationInc() + { + return inc; + } + + /** + * DOCUMENT ME! + * + * @param consensus DOCUMENT ME! + */ + public void setConsensus(Vector vconsensus) + { + 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) + { + int red = currentColour.getRed(); + int blue = currentColour.getBlue(); + int green = currentColour.getGreen(); + + if (red < (255 - inc)) + { + red = red + inc; + } + else + { + red = 255; + } + + if (blue < (255 - inc)) + { + blue = blue + inc; + } + else + { + blue = 255; + } + + if (green < (255 - inc)) + { + green = green + inc; + } + else + { + green = 255; + } + + currentColour = new Color(red, green, blue); + } + + }