remove todo
[jalview.git] / src / jalview / schemes / AnnotationColourGradient.java
index c3357ad..8f0626f 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;
@@ -51,7 +52,27 @@ public class AnnotationColourGradient extends FollowerColourScheme
   private boolean seqAssociated = false;
 
   IdentityHashMap<SequenceI, AlignmentAnnotation> seqannot = null;
-
+  @Override
+  public ColourSchemeI applyTo(AnnotatedCollectionI sg,
+          Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
+  {
+    AnnotationColourGradient acg = new AnnotationColourGradient(annotation, colourScheme, aboveAnnotationThreshold);
+    acg.thresholdIsMinMax = thresholdIsMinMax;
+    acg.annotationThreshold = (annotationThreshold==null) ? null : new GraphLine(annotationThreshold);
+    acg.r1 = r1;
+    acg.g1 = g1;
+    acg.b1 = b1;
+    acg.rr = rr;
+    acg.gg = gg;
+    acg.bb = bb;
+    acg.dr = dr;
+    acg.dg = dg;
+    acg.db = db;
+    acg.predefinedColours = predefinedColours;
+    acg.seqAssociated = seqAssociated;
+    
+    return acg;
+  }
   /**
    * Creates a new AnnotationColourGradient object.
    */
@@ -105,7 +126,6 @@ public class AnnotationColourGradient extends FollowerColourScheme
   public void alignmentChanged(AnnotatedCollectionI alignment,
           Map<SequenceI, SequenceCollectionI> hiddenReps)
   {
-    // TODO Auto-generated method stub
     super.alignmentChanged(alignment, hiddenReps);
 
     if (seqAssociated && annotation.getCalcId() != null)
@@ -118,7 +138,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