From 8bde1dc9a0a4538ee0a0d2a320a10540e55da61b Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Fri, 27 Apr 2007 08:21:09 +0000 Subject: [PATCH] Allow threshold to be min/max --- src/jalview/schemes/AnnotationColourGradient.java | 61 +++++++++++++++------ 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/src/jalview/schemes/AnnotationColourGradient.java b/src/jalview/schemes/AnnotationColourGradient.java index 06085da..ff6673a 100755 --- a/src/jalview/schemes/AnnotationColourGradient.java +++ b/src/jalview/schemes/AnnotationColourGradient.java @@ -29,16 +29,18 @@ public class AnnotationColourGradient public static int BELOW_THRESHOLD = 0; public static int ABOVE_THRESHOLD = 1; - AlignmentAnnotation annotation; + public AlignmentAnnotation annotation; int aboveAnnotationThreshold = -1; + public boolean thresholdIsMinMax = false; GraphLine annotationThreshold; float r1, g1, b1, rr, gg, bb, dr, dg, db; - float range = 0; ColourSchemeI colourScheme; + public boolean predefinedColours = false; + /** * Creates a new AnnotationColourGradient object. */ @@ -88,9 +90,6 @@ public class AnnotationColourGradient rr = maxColour.getRed() - r1; gg = maxColour.getGreen() - g1; bb = maxColour.getBlue() - b1; - - range = annotation.graphMax - annotation.graphMin; - } public String getAnnotation() @@ -160,6 +159,15 @@ public class AnnotationColourGradient && annotation.annotations[j] != null && !jalview.util.Comparison.isGap(c)) { + + if (predefinedColours) + { + if(annotation.annotations[j].colour != null) + return annotation.annotations[j].colour; + else + return currentColour; + } + if (aboveAnnotationThreshold == NO_THRESHOLD || (annotationThreshold != null && aboveAnnotationThreshold == ABOVE_THRESHOLD && @@ -168,24 +176,43 @@ public class AnnotationColourGradient (annotationThreshold != null && aboveAnnotationThreshold == BELOW_THRESHOLD && annotation.annotations[j].value <= annotationThreshold.value)) { + + float range=1f; + if (thresholdIsMinMax + && annotation.threshold != null + && aboveAnnotationThreshold == ABOVE_THRESHOLD + && annotation.annotations[j].value>annotation.threshold.value) + { + range = + (annotation.annotations[j].value - annotation.threshold.value) / + (annotation.graphMax - annotation.threshold.value); + } + else if (thresholdIsMinMax + && annotation.threshold != null + && aboveAnnotationThreshold == BELOW_THRESHOLD + && annotation.annotations[j].value > annotation.graphMin) + { + range = + ( annotation.annotations[j].value - annotation.graphMin ) / + (annotation.threshold.value - annotation.graphMin ); + } + else + { + range = (annotation.annotations[j].value - + annotation.graphMin) / + (annotation.graphMax - annotation.graphMin); + } + + if (colourScheme != null) { currentColour = colourScheme.findColour(c, j); } else if (range != 0) { - dr = rr * - ( (annotation.annotations[j].value - annotation.graphMin) / - range) - + r1; - dg = gg * - ( (annotation.annotations[j].value - annotation.graphMin) / - range) - + g1; - db = bb * - ( (annotation.annotations[j].value - annotation.graphMin) / - range) - + b1; + dr = rr * range + r1; + dg = gg * range + g1; + db = bb * range + b1; currentColour = new Color( (int) dr, (int) dg, (int) db); } -- 1.7.10.2