From 5963dedafa1af673a588f0d30710f7391eb822c4 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Thu, 16 Feb 2006 15:45:06 +0000 Subject: [PATCH] Use original colour scheme as base for annotation colouring --- src/jalview/schemes/AnnotationColourGradient.java | 55 +++++++++++++++++---- 1 file changed, 45 insertions(+), 10 deletions(-) diff --git a/src/jalview/schemes/AnnotationColourGradient.java b/src/jalview/schemes/AnnotationColourGradient.java index 433af79..3cb7e17 100755 --- a/src/jalview/schemes/AnnotationColourGradient.java +++ b/src/jalview/schemes/AnnotationColourGradient.java @@ -34,7 +34,31 @@ public class AnnotationColourGradient extends ResidueColourScheme GraphLine annotationThreshold; float r1, g1, b1, rr, gg, bb, dr, dg, db; - float range; + float range = 0; + + ColourSchemeI colourScheme; + + /** + * Creates a new AnnotationColourGradient object. + */ + public AnnotationColourGradient(AlignmentAnnotation annotation, + ColourSchemeI originalColour, + int aboveThreshold) + { + if(originalColour instanceof AnnotationColourGradient) + { + colourScheme = ((AnnotationColourGradient)originalColour).colourScheme; + } + else + colourScheme = originalColour; + + this.annotation = annotation; + + aboveAnnotationThreshold = aboveThreshold; + + if(aboveThreshold!=NO_THRESHOLD && annotation.threshold!=null) + annotationThreshold = annotation.threshold; + } /** * Creates a new AnnotationColourGradient object. @@ -80,7 +104,6 @@ public class AnnotationColourGradient extends ResidueColourScheme */ public Color findColour(String n) { - System.out.println("AnnotationColourGradient findColour(string)"); return Color.red; } @@ -104,17 +127,29 @@ public class AnnotationColourGradient extends ResidueColourScheme || (annotationThreshold!=null && aboveAnnotationThreshold==ABOVE_THRESHOLD && annotation.annotations[j].value>=annotationThreshold.value) || (annotationThreshold!=null && aboveAnnotationThreshold==BELOW_THRESHOLD && annotation.annotations[j].value<=annotationThreshold.value)) { + if(colourScheme!=null) + { + currentColour = colourScheme.findColour(n, j); + } + else if(range!=0) + { dr = rr * - ((annotation.annotations[j].value-annotation.graphMin) / range ) - +r1; + ( (annotation.annotations[j].value - annotation.graphMin) / + range) + + r1; dg = gg * - ((annotation.annotations[j].value-annotation.graphMin) / range ) - +g1; + ( (annotation.annotations[j].value - annotation.graphMin) / + range) + + g1; db = bb * - ((annotation.annotations[j].value-annotation.graphMin) / range ) - +b1; - - currentColour = new Color( (int) dr, (int) dg, (int) db); + ( (annotation.annotations[j].value - annotation.graphMin) / + range) + + b1; + + currentColour = new Color( (int) dr, (int) dg, (int) db); + } + else + currentColour = Color.white; } else currentColour = Color.white; -- 1.7.10.2