Merge branch 'documentation/JAL-3111_release_211' into bug/JAL-2830_editManglesDatase...
[jalview.git] / src / jalview / schemes / AnnotationColourGradient.java
index c28ea5f..75a07b9 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,8 +77,8 @@ public class AnnotationColourGradient extends FollowerColourScheme
   private IdentityHashMap<SequenceI, AlignmentAnnotation> seqannot = null;
 
   @Override
-  public ColourSchemeI getInstance(AnnotatedCollectionI sg,
-          Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
+  public ColourSchemeI getInstance(AlignViewportI view,
+          AnnotatedCollectionI sg)
   {
     AnnotationColourGradient acg = new AnnotationColourGradient(annotation,
             getColourScheme(), aboveAnnotationThreshold);
@@ -185,7 +186,7 @@ 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
@@ -319,9 +320,9 @@ public class AnnotationColourGradient extends FollowerColourScheme
     if (annotationThreshold != null)
     {
       if ((aboveAnnotationThreshold == ABOVE_THRESHOLD
-              && aj.value < annotationThreshold.value)
+              && aj.value <= annotationThreshold.value)
               || (aboveAnnotationThreshold == BELOW_THRESHOLD
-                      && aj.value > annotationThreshold.value))
+                      && aj.value >= annotationThreshold.value))
       {
         return Color.white;
       }
@@ -414,14 +415,17 @@ public class AnnotationColourGradient extends FollowerColourScheme
             && aboveAnnotationThreshold == ABOVE_THRESHOLD
             && value >= ann.threshold.value)
     {
-      range = (value - ann.threshold.value)
+      range = ann.graphMax == ann.threshold.value ? 1f
+              : (value - ann.threshold.value)
               / (ann.graphMax - ann.threshold.value);
     }
     else if (thresholdIsMinMax && ann.threshold != null
             && aboveAnnotationThreshold == BELOW_THRESHOLD
             && value <= ann.threshold.value)
     {
-      range = (value - ann.graphMin) / (ann.threshold.value - ann.graphMin);
+      range = ann.graphMin == ann.threshold.value ? 0f
+              : (value - ann.graphMin)
+                      / (ann.threshold.value - ann.graphMin);
     }
     else
     {
@@ -475,7 +479,7 @@ public class AnnotationColourGradient extends FollowerColourScheme
   @Override
   public String getSchemeName()
   {
-    return "Annotation";
+    return ANNOTATION_COLOUR;
   }
 
   @Override