Use original colour scheme as base for annotation colouring
authoramwaterhouse <Andrew Waterhouse>
Thu, 16 Feb 2006 15:45:06 +0000 (15:45 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 16 Feb 2006 15:45:06 +0000 (15:45 +0000)
src/jalview/schemes/AnnotationColourGradient.java

index 433af79..3cb7e17 100755 (executable)
@@ -34,7 +34,31 @@ public class AnnotationColourGradient extends ResidueColourScheme
     GraphLine annotationThreshold;\r
 \r
     float r1, g1, b1, rr, gg, bb, dr, dg, db;\r
-    float range;\r
+    float range = 0;\r
+\r
+    ColourSchemeI colourScheme;\r
+\r
+    /**\r
+     * Creates a new AnnotationColourGradient object.\r
+     */\r
+    public AnnotationColourGradient(AlignmentAnnotation annotation,\r
+                                    ColourSchemeI originalColour,\r
+                                    int aboveThreshold)\r
+    {\r
+      if(originalColour instanceof AnnotationColourGradient)\r
+      {\r
+        colourScheme = ((AnnotationColourGradient)originalColour).colourScheme;\r
+      }\r
+      else\r
+        colourScheme = originalColour;\r
+\r
+      this.annotation = annotation;\r
+\r
+      aboveAnnotationThreshold = aboveThreshold;\r
+\r
+      if(aboveThreshold!=NO_THRESHOLD && annotation.threshold!=null)\r
+        annotationThreshold = annotation.threshold;\r
+    }\r
 \r
     /**\r
      * Creates a new AnnotationColourGradient object.\r
@@ -80,7 +104,6 @@ public class AnnotationColourGradient extends ResidueColourScheme
      */\r
     public Color findColour(String n)\r
     {\r
-      System.out.println("AnnotationColourGradient findColour(string)");\r
         return Color.red;\r
     }\r
 \r
@@ -104,17 +127,29 @@ public class AnnotationColourGradient extends ResidueColourScheme
                || (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
+              if(colourScheme!=null)\r
+              {\r
+                currentColour = colourScheme.findColour(n, j);\r
+              }\r
+              else if(range!=0)\r
+              {\r
                 dr = rr *\r
-                     ((annotation.annotations[j].value-annotation.graphMin) / range )\r
-                     +r1;\r
+                    ( (annotation.annotations[j].value - annotation.graphMin) /\r
+                     range)\r
+                    + r1;\r
                 dg = gg *\r
-                     ((annotation.annotations[j].value-annotation.graphMin)  / range )\r
-                     +g1;\r
+                    ( (annotation.annotations[j].value - annotation.graphMin) /\r
+                     range)\r
+                    + g1;\r
                 db = bb *\r
-                     ((annotation.annotations[j].value-annotation.graphMin) / range )\r
-                     +b1;\r
-\r
-                 currentColour = new Color( (int) dr, (int) dg, (int) db);\r
+                    ( (annotation.annotations[j].value - annotation.graphMin) /\r
+                     range)\r
+                    + b1;\r
+\r
+                currentColour = new Color( (int) dr, (int) dg, (int) db);\r
+              }\r
+              else\r
+                currentColour = Color.white;\r
             }\r
             else\r
               currentColour = Color.white;\r