X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fschemes%2FConservationColourScheme.java;h=af52bda7994d29be7e77a855f65f0d2a680589c9;hb=09b64bea954c283bde1d21c0a230f51f1ae89373;hp=1cbc0d4ea6ee37faba342ea7c06df0f864a03afc;hpb=4960c54cb378f2fb063cc36336ab3ac22eda660b;p=jalview.git diff --git a/src/jalview/schemes/ConservationColourScheme.java b/src/jalview/schemes/ConservationColourScheme.java index 1cbc0d4..af52bda 100755 --- a/src/jalview/schemes/ConservationColourScheme.java +++ b/src/jalview/schemes/ConservationColourScheme.java @@ -29,99 +29,64 @@ public class ConservationColourScheme extends ResidueColourScheme { 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 Color findColour(SequenceI seq, String s, int i, java.util.Vector whatever) + public Color findColour(String s, int i, java.util.Vector whatever) { Color c = null; if (colourThreshold > 0 && conserve.getConsSequence() != null) { - if (fullConservation(i)) { - if (byResidue) { - c = findColour(null,s,i); - } else { - c = Color.red; - } - } else { - if (byResidue) { + if (conserve.getConsSequence().getSequence().charAt(i)=='*') + { + if (byResidue) + c = findColour(s, i); + else + c = Color.red; + } + else + { + if (byResidue) + { 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); - - while (tmp >= t) { + if (!jalview.util.Comparison.isGap(conserve.getConsSequence(). + getSequence().charAt(i))) + t = Integer.parseInt(conserve.getConsSequence().getSequence(). + substring(i, i + 1)); + + c = findColour(s, i); + + while (tmp >= t) + { // c = c.darker(); - c = lighter(c,inc); - tmp--; - } - } else { - c = Color.yellow; + c = lighter(c, inc); + tmp--; + } } + else + c = Color.yellow; } } 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); - - if (Integer.parseInt(tmp) >= threshold || tmp.equals("*")) { - return true; - } else { - return false; - } + public Color findColour(String s, int j) { + if(cs!=null) + return cs.findColour( s, j, null); + else + return Color.white; } + + public Color lighter(Color c, int inc) { int red = c.getRed(); int blue = c.getBlue();