X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FResidueColourScheme.java;h=3c8e69044e73252b2c5380556570d894eebc0611;hb=e78af69b55f5b95978094c6643ce884ba78efad2;hp=785d22d36323b4766837f048420f26a65a5ae4d7;hpb=e8bf50102d1e937c715bf15046ae5076343313c0;p=jalview.git diff --git a/src/jalview/schemes/ResidueColourScheme.java b/src/jalview/schemes/ResidueColourScheme.java index 785d22d..3c8e690 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,56 +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; } @@ -153,4 +155,131 @@ 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) + { + if(vconsensus==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) + { + 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); + } + + }