JAL-3127 Colour sequences by ID - need to check that group colours are properly propa...
[jalview.git] / src / jalview / schemes / AnnotationColourGradient.java
index a5d779d..334998f 100755 (executable)
@@ -20,6 +20,7 @@
  */
 package jalview.schemes;
 
+import jalview.api.AlignViewportI;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AnnotatedCollectionI;
@@ -76,7 +77,8 @@ public class AnnotationColourGradient extends FollowerColourScheme
   private IdentityHashMap<SequenceI, AlignmentAnnotation> seqannot = null;
 
   @Override
-  public ColourSchemeI getInstance(AnnotatedCollectionI sg,
+  public ColourSchemeI getInstance(AlignViewportI view,
+          AnnotatedCollectionI sg,
           Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
   {
     AnnotationColourGradient acg = new AnnotationColourGradient(annotation,
@@ -185,18 +187,19 @@ public class AnnotationColourGradient extends FollowerColourScheme
       }
       else
       {
-        seqannot = new IdentityHashMap<SequenceI, AlignmentAnnotation>();
+        seqannot = new IdentityHashMap<>();
       }
       // resolve the context containing all the annotation for the sequence
-      AnnotatedCollectionI alcontext = alignment instanceof AlignmentI ? alignment
+      AnnotatedCollectionI alcontext = alignment instanceof AlignmentI
+              ? alignment
               : alignment.getContext();
       boolean f = true, rna = false;
-      for (AlignmentAnnotation alan : alcontext.findAnnotation(annotation
-              .getCalcId()))
+      for (AlignmentAnnotation alan : alcontext
+              .findAnnotation(annotation.getCalcId()))
       {
         if (alan.sequenceRef != null
-                && (alan.label != null && annotation != null && alan.label
-                        .equals(annotation.label)))
+                && (alan.label != null && annotation != null
+                        && alan.label.equals(annotation.label)))
         {
           if (!rna && alan.isRNA())
           {
@@ -252,8 +255,8 @@ public class AnnotationColourGradient extends FollowerColourScheme
 
   public Color getMaxColour()
   {
-    return new Color(redMin + redRange, greenMin + greenRange, blueMin
-            + blueRange);
+    return new Color(redMin + redRange, greenMin + greenRange,
+            blueMin + blueRange);
   }
 
   /**
@@ -287,8 +290,9 @@ public class AnnotationColourGradient extends FollowerColourScheme
     /*
      * locate the annotation we are configured to colour by
      */
-    AlignmentAnnotation ann = (seqAssociated && seqannot != null ? seqannot
-            .get(seq) : this.annotation);
+    AlignmentAnnotation ann = (seqAssociated && seqannot != null
+            ? seqannot.get(seq)
+            : this.annotation);
 
     /*
      * if gap or no annotation at position, no colour (White)
@@ -316,8 +320,10 @@ public class AnnotationColourGradient extends FollowerColourScheme
      */
     if (annotationThreshold != null)
     {
-      if ((aboveAnnotationThreshold == ABOVE_THRESHOLD && aj.value >= annotationThreshold.value)
-              || (aboveAnnotationThreshold == BELOW_THRESHOLD && aj.value > annotationThreshold.value))
+      if ((aboveAnnotationThreshold == ABOVE_THRESHOLD
+              && aj.value < annotationThreshold.value)
+              || (aboveAnnotationThreshold == BELOW_THRESHOLD
+                      && aj.value > annotationThreshold.value))
       {
         return Color.white;
       }
@@ -354,8 +360,10 @@ public class AnnotationColourGradient extends FollowerColourScheme
           }
           else
           {
-            result = ann.annotations[j].secondaryStructure == 'H' ? AnnotationRenderer.HELIX_COLOUR
-                    : ann.annotations[j].secondaryStructure == 'E' ? AnnotationRenderer.SHEET_COLOUR
+            result = ann.annotations[j].secondaryStructure == 'H'
+                    ? AnnotationRenderer.HELIX_COLOUR
+                    : ann.annotations[j].secondaryStructure == 'E'
+                            ? AnnotationRenderer.SHEET_COLOUR
                             : AnnotationRenderer.STEM_COLOUR;
           }
         }