From 95ebd2cf76003f52476a7802c99831dfa98945f7 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Fri, 3 Feb 2006 17:48:22 +0000 Subject: [PATCH] Conservation colouring does what it should always have done --- src/jalview/schemes/ResidueColourScheme.java | 77 +++++++++----------------- 1 file changed, 25 insertions(+), 52 deletions(-) diff --git a/src/jalview/schemes/ResidueColourScheme.java b/src/jalview/schemes/ResidueColourScheme.java index 3c8e690..78ebab0 100755 --- a/src/jalview/schemes/ResidueColourScheme.java +++ b/src/jalview/schemes/ResidueColourScheme.java @@ -216,69 +216,42 @@ public class ResidueColourScheme implements ColourSchemeI * * @return DOCUMENT ME! */ - void applyConservation(int i) - { - if ((conservation[i] != '*') && (conservation[i] != '+')) - { - int tmp = 10; - int t = 0; - - if (!jalview.util.Comparison.isGap(conservation[i])) - { - t = conservation[i]-'0'; - } - - while (tmp >= t) - { - lighter(inc); - tmp--; - } - } - } - - /** - * DOCUMENT ME! - * - * @param c DOCUMENT ME! - * @param inc DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - void lighter(int inc) + void applyConservation(int i) { - int red = currentColour.getRed(); - int blue = currentColour.getBlue(); - int green = currentColour.getGreen(); - if (red < (255 - inc)) + if ((conservation[i] != '*') && (conservation[i] != '+')) + { + if(jalview.util.Comparison.isGap(conservation[i])) { - red = red + inc; + currentColour = Color.white; } else { - red = 255; - } + float t = 11 - (conservation[i] - '0'); - if (blue < (255 - inc)) - { - blue = blue + inc; - } - else - { - blue = 255; - } + int red = currentColour.getRed(); + int green = currentColour.getGreen(); + int blue = currentColour.getBlue(); - if (green < (255 - inc)) - { - green = green + inc; + int dr = 255 - red; + int dg = 255 - green; + int db = 255 - blue; + + dr *= t / 10f; + dg *= t / 10f; + db *= t / 10f; + + red += (inc / 20f) * dr; + green += (inc / 20f) * dg; + blue += (inc / 20f) * db; + + if (red > 255 || green > 255 || blue > 255) + currentColour = Color.white; + else + currentColour = new Color(red, green, blue); } - else - { - green = 255; } - - currentColour = new Color(red, green, blue); } -- 1.7.10.2