Colour above or below threshold
[jalview.git] / src / jalview / schemes / AnnotationColourGradient.java
index bc44559..5825612 100755 (executable)
@@ -24,8 +24,14 @@ import jalview.datamodel.*;
 \r
 public class AnnotationColourGradient extends ResidueColourScheme\r
 {\r
+    public static int NO_THRESHOLD = -1;\r
+    public static int BELOW_THRESHOLD = 0;\r
+    public static int ABOVE_THRESHOLD = 1;\r
+\r
     AlignmentAnnotation annotation;\r
-    boolean aboveAnnotationThreshold = false;\r
+    int aboveAnnotationThreshold = -1;\r
+\r
+    GraphLine annotationThreshold;\r
 \r
     float r1, g1, b1, rr, gg, bb, dr, dg, db;\r
     float range;\r
@@ -34,12 +40,15 @@ public class AnnotationColourGradient extends ResidueColourScheme
      * Creates a new AnnotationColourGradient object.\r
      */\r
     public AnnotationColourGradient(AlignmentAnnotation annotation,\r
-        Color minColour, Color maxColour, boolean aboveThreshold)\r
+        Color minColour, Color maxColour, int aboveThreshold)\r
     {\r
       this.annotation = annotation;\r
 \r
       aboveAnnotationThreshold = aboveThreshold;\r
 \r
+      if(aboveThreshold!=NO_THRESHOLD && annotation.graphLines!=null)\r
+        annotationThreshold = annotation.getGraphLine(0);\r
+\r
       r1 = minColour.getRed();\r
       g1 = minColour.getGreen();\r
       b1 = minColour.getBlue();\r
@@ -91,8 +100,9 @@ public class AnnotationColourGradient extends ResidueColourScheme
             currentColour = Color.white;\r
           else\r
           {\r
-            if(!aboveAnnotationThreshold || (annotation.graphLines!=null\r
-               && annotation.annotations[j].value>=annotation.getGraphLine(0).value))\r
+            if(  aboveAnnotationThreshold==NO_THRESHOLD\r
+               || (annotationThreshold!=null && aboveAnnotationThreshold==ABOVE_THRESHOLD && annotation.annotations[j].value>=annotationThreshold.value)\r
+               || (annotationThreshold!=null && aboveAnnotationThreshold==BELOW_THRESHOLD && annotation.annotations[j].value<=annotationThreshold.value))\r
             {\r
                 dr = rr *\r
                      ((annotation.annotations[j].value-annotation.graphMin) / range )\r