X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FConservationColourScheme.java;h=6394124a422e7f0c7cef214ed53e174c48e430ae;hb=e542a2b9968ee6a7def19e79e84c27684ee686e3;hp=1cbc0d4ea6ee37faba342ea7c06df0f864a03afc;hpb=4960c54cb378f2fb063cc36336ab3ac22eda660b;p=jalview.git diff --git a/src/jalview/schemes/ConservationColourScheme.java b/src/jalview/schemes/ConservationColourScheme.java index 1cbc0d4..6394124 100755 --- a/src/jalview/schemes/ConservationColourScheme.java +++ b/src/jalview/schemes/ConservationColourScheme.java @@ -18,109 +18,59 @@ package jalview.schemes; import java.awt.*; -import jalview.gui.*; -import jalview.datamodel.*; import jalview.analysis.*; +import java.util.Vector; public class ConservationColourScheme extends ResidueColourScheme { public Conservation conserve; - boolean byResidue = true; public ColourSchemeI cs; public int inc = 30; - int colourThreshold = 7; - public ConservationColourScheme(SequenceGroup sg) + public ConservationColourScheme(Conservation cons, ColourSchemeI oldcs) { super(); - this.conserve = sg.getConservation(); - colourThreshold = 7; - this.cs = sg.cs; + conserve = cons; + cs = oldcs; } - public void setColours(DrawableSequence seq, int j) { - Color c = Color.white; - String s = seq.getSequence().substring(j,j+1); - - if (colourThreshold > 0 && conserve.getConsSequence() != null) { - if (fullConservation(j)) { - if (byResidue) { - c = findColour(seq,s,j); - } else { - c = Color.red; - } - } else { - if (byResidue) { - - int tmp = 10; - int t = Integer.parseInt(conserve.getConsSequence().getSequence().substring(j,j+1)); - c = findColour(seq,s,j); - - while (tmp >= t) { - // c = c.darker(); - c = lighter(c,inc); - tmp--; - } - } else { - c = Color.yellow; - } - } - } - - seq.setColor(c); + public void setConsensus(Vector consensus) + { + this.consensus = consensus; + if(cs!=null) + cs.setConsensus(consensus); } - public Color findColour(SequenceI seq, String s, int i, java.util.Vector whatever) + + public Color findColour(String s, int i) { - Color c = null; - if (colourThreshold > 0 && conserve.getConsSequence() != null) + Color c = Color.white; + if (cs == null) + return c; + + char ch = conserve.getConsSequence().getSequence().charAt(i); + if (ch == '*' || ch == '+') { - if (fullConservation(i)) { - if (byResidue) { - c = findColour(null,s,i); - } else { - c = Color.red; - } - } else { - if (byResidue) { + c = cs.findColour(s, i); + } + else + { + int tmp = 10; + int t = 0; + if (!jalview.util.Comparison.isGap(ch)) + t = Integer.parseInt(ch + ""); - int tmp = 10; - int t = 0; - try - {t=Integer.parseInt(conserve.getConsSequence().getSequence().substring(i,i+1));} - catch(NumberFormatException ex){ - System.out.println("fix this bug, conserveColourScheme"); - t=0; - } - c = findColour(null,s,i); + c = cs.findColour(s, i); - while (tmp >= t) { - // c = c.darker(); - c = lighter(c,inc); - tmp--; - } - } else { - c = Color.yellow; - } + while (tmp >= t) + { + c = lighter(c, inc); + tmp--; } + } - return c; - } - public Color findColour(DrawableSequence seq, String s, int j) { - return cs.findColour(null, s, -1, null); - } - public boolean fullConservation(int j) { - String tmp = conserve.getConsSequence().getSequence().substring(j,j+1); - if (tmp.equals("*")) return true; else return false; - } - public boolean aboveThreshold(DrawableSequence seq, int j, int threshold) { - String tmp = conserve.getConsSequence().getSequence().substring(j,j+1); + return c; + } - if (Integer.parseInt(tmp) >= threshold || tmp.equals("*")) { - return true; - } else { - return false; - } - } public Color lighter(Color c, int inc) { int red = c.getRed();