X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FConservationColourScheme.java;h=bbc0edd139adac4ea3605edd14789ce2c2bd5661;hb=588042b69abf8e60bcc950b24c283933c7dd422f;hp=8c3f694de5f3661289f1b900c1d124c42ccd7163;hpb=5cd8e373c75fb348ecda4d94d8a46468fb92756d;p=jalview.git diff --git a/src/jalview/schemes/ConservationColourScheme.java b/src/jalview/schemes/ConservationColourScheme.java index 8c3f694..bbc0edd 100755 --- a/src/jalview/schemes/ConservationColourScheme.java +++ b/src/jalview/schemes/ConservationColourScheme.java @@ -16,73 +16,87 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.schemes; -import java.awt.*; + import jalview.analysis.*; + +import java.awt.*; + import java.util.Vector; + public class ConservationColourScheme extends ResidueColourScheme { - public Conservation conserve; - public ColourSchemeI cs; - public int inc = 30; - - public ConservationColourScheme(Conservation cons, ColourSchemeI oldcs) - { - super(); - conserve = cons; - cs = oldcs; - } - - public void setConsensus(Vector consensus) - { - this.consensus = consensus; - if(cs!=null) - cs.setConsensus(consensus); - } - - public Color findColour(String s, int i) - { - Color c = Color.white; - if (cs == null) - return c; - - char ch = conserve.getConsSequence().getSequence().charAt(i); - if (ch == '*' || ch == '+') - { - c = cs.findColour(s, i); - } - else - { - int tmp = 10; - int t = 0; - if (!jalview.util.Comparison.isGap(ch)) - t = Integer.parseInt(ch + ""); - - c = cs.findColour(s, i); - - while (tmp >= t) - { - c = lighter(c, inc); - tmp--; - } - - } - - return c; - } - - - public Color lighter(Color c, int inc) { - int red = c.getRed(); - int blue = c.getBlue(); - int green = c.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;} - - return new Color(red,green,blue); - } + public Conservation conserve; + public ColourSchemeI cs; + public int inc = 30; + + public ConservationColourScheme(Conservation cons, ColourSchemeI oldcs) { + super(); + conserve = cons; + cs = oldcs; + } + + public void setConsensus(Vector consensus) { + this.consensus = consensus; + + if (cs != null) { + cs.setConsensus(consensus); + } + } + + public Color findColour(String s, int i) { + Color c = Color.white; + + if (cs == null) { + return c; + } + + char ch = conserve.getConsSequence().getSequence().charAt(i); + + if ((ch == '*') || (ch == '+')) { + c = cs.findColour(s, i); + } else { + int tmp = 10; + int t = 0; + + if (!jalview.util.Comparison.isGap(ch)) { + t = Integer.parseInt(ch + ""); + } + + c = cs.findColour(s, i); + + while (tmp >= t) { + c = lighter(c, inc); + tmp--; + } + } + + return c; + } + + public Color lighter(Color c, int inc) { + int red = c.getRed(); + int blue = c.getBlue(); + int green = c.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; + } + return new Color(red, green, blue); + } }