JAL-2371 CollectionColourScheme wraps ColourSchemeI
[jalview.git] / src / jalview / schemes / AnnotationColourGradient.java
index fb1443d..1a3e9ef 100755 (executable)
@@ -68,7 +68,7 @@ public class AnnotationColourGradient extends FollowerColourScheme
           Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
   {
     AnnotationColourGradient acg = new AnnotationColourGradient(annotation,
-            colourScheme, aboveAnnotationThreshold);
+            getColourScheme(), aboveAnnotationThreshold);
     acg.thresholdIsMinMax = thresholdIsMinMax;
     acg.annotationThreshold = (annotationThreshold == null) ? null
             : new GraphLine(annotationThreshold);
@@ -92,11 +92,12 @@ public class AnnotationColourGradient extends FollowerColourScheme
   {
     if (originalColour instanceof AnnotationColourGradient)
     {
-      colourScheme = ((AnnotationColourGradient) originalColour).colourScheme;
+      setColourScheme(((AnnotationColourGradient) originalColour)
+              .getColourScheme());
     }
     else
     {
-      colourScheme = originalColour;
+      setColourScheme(originalColour);
     }
 
     this.annotation = annotation;
@@ -276,88 +277,89 @@ public class AnnotationColourGradient extends FollowerColourScheme
     {
       return currentColour;
     }
-    if ((threshold == 0) || aboveThreshold(c, j))
+    // if ((threshold == 0) || aboveThreshold(c, j))
+    // {
+    if (annotation.annotations != null && j < annotation.annotations.length
+            && annotation.annotations[j] != null
+            && !jalview.util.Comparison.isGap(c))
     {
-      if (annotation.annotations != null
-              && j < annotation.annotations.length
-              && annotation.annotations[j] != null
-              && !jalview.util.Comparison.isGap(c))
+      Annotation aj = annotation.annotations[j];
+      // 'use original colours' => colourScheme != null
+      // -> look up colour to be used
+      // predefined colours => preconfigured shading
+      // -> only use original colours reference if thresholding enabled &
+      // minmax exists
+      // annotation.hasIcons => null or black colours replaced with glyph
+      // colours
+      // -> reuse original colours if present
+      // -> if thresholding enabled then return colour on non-whitespace glyph
+
+      if (aboveAnnotationThreshold == NO_THRESHOLD
+              || (annotationThreshold != null && (aboveAnnotationThreshold == ABOVE_THRESHOLD ? aj.value >= annotationThreshold.value
+                      : aj.value <= annotationThreshold.value)))
       {
-        Annotation aj = annotation.annotations[j];
-        // 'use original colours' => colourScheme != null
-        // -> look up colour to be used
-        // predefined colours => preconfigured shading
-        // -> only use original colours reference if thresholding enabled &
-        // minmax exists
-        // annotation.hasIcons => null or black colours replaced with glyph
-        // colours
-        // -> reuse original colours if present
-        // -> if thresholding enabled then return colour on non-whitespace glyph
-
-        if (aboveAnnotationThreshold == NO_THRESHOLD
-                || (annotationThreshold != null && (aboveAnnotationThreshold == ABOVE_THRESHOLD ? aj.value >= annotationThreshold.value
-                        : aj.value <= annotationThreshold.value)))
+        if (predefinedColours && aj.colour != null
+                && !aj.colour.equals(Color.black))
         {
-          if (predefinedColours && aj.colour != null
-                  && !aj.colour.equals(Color.black))
-          {
-            currentColour = aj.colour;
-          }
-          else if (annotation.hasIcons
-                  && annotation.graph == AlignmentAnnotation.NO_GRAPH)
+          currentColour = aj.colour;
+        }
+        else if (annotation.hasIcons
+                && annotation.graph == AlignmentAnnotation.NO_GRAPH)
+        {
+          if (aj.secondaryStructure > ' ' && aj.secondaryStructure != '.'
+                  && aj.secondaryStructure != '-')
           {
-            if (aj.secondaryStructure > ' ' && aj.secondaryStructure != '.'
-                    && aj.secondaryStructure != '-')
+            if (getColourScheme() != null)
+            {
+              currentColour = getColourScheme().findColour(c, j, seq, null,
+                      0f);
+            }
+            else
             {
-              if (colourScheme != null)
+              if (annotation.isRNA())
               {
-                currentColour = colourScheme.findColour(c, j, seq);
+                currentColour = ColourSchemeProperty.rnaHelices[(int) aj.value];
               }
               else
               {
-                if (annotation.isRNA())
-                {
-                  currentColour = ColourSchemeProperty.rnaHelices[(int) aj.value];
-                }
-                else
-                {
-                  currentColour = annotation.annotations[j].secondaryStructure == 'H' ? jalview.renderer.AnnotationRenderer.HELIX_COLOUR
-                          : annotation.annotations[j].secondaryStructure == 'E' ? jalview.renderer.AnnotationRenderer.SHEET_COLOUR
-                                  : jalview.renderer.AnnotationRenderer.STEM_COLOUR;
-                }
+                currentColour = annotation.annotations[j].secondaryStructure == 'H' ? jalview.renderer.AnnotationRenderer.HELIX_COLOUR
+                        : annotation.annotations[j].secondaryStructure == 'E' ? jalview.renderer.AnnotationRenderer.SHEET_COLOUR
+                                : jalview.renderer.AnnotationRenderer.STEM_COLOUR;
               }
             }
-            else
-            {
-              //
-              return Color.white;
-            }
           }
-          else if (noGradient)
+          else
           {
-            if (colourScheme != null)
-            {
-              currentColour = colourScheme.findColour(c, j, seq);
-            }
-            else
-            {
-              if (aj.colour != null)
-              {
-                currentColour = aj.colour;
-              }
-            }
+            //
+            return Color.white;
+          }
+        }
+        else if (noGradient)
+        {
+          if (getColourScheme() != null)
+          {
+            currentColour = getColourScheme().findColour(c, j, seq, null,
+                    0f);
           }
           else
           {
-            currentColour = shadeCalculation(annotation, j);
+            if (aj.colour != null)
+            {
+              currentColour = aj.colour;
+            }
           }
         }
-        if (conservationColouring)
+        else
         {
-          currentColour = applyConservation(currentColour, j);
+          currentColour = shadeCalculation(annotation, j);
         }
       }
+      // if (conservationColouring)
+      // {
+      // currentColour = applyConservation(currentColour, j);
+      // }
     }
+    // }
     return currentColour;
   }