JAL-1492 JAL-1397 make AnnotatedCollectionI context aware so groups can be coloured...
[jalview.git] / src / jalview / schemes / AnnotationColourGradient.java
index f619d07..3606db9 100755 (executable)
@@ -19,6 +19,7 @@
 package jalview.schemes;
 
 import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AnnotatedCollectionI;
 import jalview.datamodel.GraphLine;
 import jalview.datamodel.SequenceCollectionI;
@@ -138,7 +139,9 @@ public class AnnotationColourGradient extends FollowerColourScheme
       {
         seqannot = new IdentityHashMap<SequenceI, AlignmentAnnotation>();
       }
-      for (AlignmentAnnotation alan : alignment.findAnnotation(annotation
+      // resolve the context containing all the annotation for the sequence
+      AnnotatedCollectionI alcontext = alignment instanceof AlignmentI ? alignment : alignment.getContext();
+      for (AlignmentAnnotation alan : alcontext.findAnnotation(annotation
               .getCalcId()))
       {
         if (alan.sequenceRef != null