Merge branch 'develop' into features/JAL-2068groovyAnnotationWorker
[jalview.git] / src / jalview / workers / AlignmentAnnotationFactory.java
index 520b232..f804a19 100644 (file)
@@ -1,5 +1,7 @@
 package jalview.workers;
 
+import jalview.api.AlignViewportI;
+import jalview.api.AlignmentViewPanel;
 import jalview.bin.Jalview;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.Annotation;
@@ -12,9 +14,9 @@ import java.awt.Color;
  * such as Groovy) to 'register and forget' an alignment annotation calculator. <br>
  * Currently supports two flavours of calculator:
  * <ul>
- * <li>a 'feature counter' which can count any desired property derivable from
+ * <li>a simple 'feature counter' which counts any desired score derivable from
  * residue value and any sequence features at each position of the alignment</li>
- * <li>a 'general purpose' calculator which computes one more complete
+ * <li>a 'general purpose' calculator which computes one or more complete
  * AlignmentAnnotation objects</li>
  * </ul>
  */
@@ -28,9 +30,13 @@ public class AlignmentAnnotationFactory
    */
   public static void newCalculator(FeatureCounterI counter)
   {
-    if (Jalview.getCurrentAlignFrame() != null)
+    // TODO need an interface for AlignFrame by which to access
+    // its AlignViewportI and AlignmentViewPanel
+    AlignFrame currentAlignFrame = Jalview.getCurrentAlignFrame() ;
+    if (currentAlignFrame != null)
     {
-      newCalculator(Jalview.getCurrentAlignFrame(), counter);
+      newCalculator(currentAlignFrame.getViewport(), currentAlignFrame
+              .getAlignPanels().get(0), counter);
     }
     else
     {
@@ -42,14 +48,15 @@ public class AlignmentAnnotationFactory
   /**
    * Constructs and registers a new alignment annotation worker
    * 
-   * @param af
-   *          the AlignFrame for which the annotation is to be calculated
+   * @param viewport
+   * @param panel
    * @param counter
    *          provider of feature counts per alignment position
    */
-  public static void newCalculator(AlignFrame af, FeatureCounterI counter)
+  public static void newCalculator(AlignViewportI viewport,
+          AlignmentViewPanel panel, FeatureCounterI counter)
   {
-    new ColumnCounterWorker(af, counter);
+    new ColumnCounterWorker(viewport, panel, counter);
   }
 
   /**
@@ -60,9 +67,13 @@ public class AlignmentAnnotationFactory
    */
   public static void newCalculator(AnnotationProviderI calculator)
   {
-    if (Jalview.getCurrentAlignFrame() != null)
+    // TODO need an interface for AlignFrame by which to access
+    // its AlignViewportI and AlignmentViewPanel
+    AlignFrame currentAlignFrame = Jalview.getCurrentAlignFrame() ;
+    if (currentAlignFrame != null)
     {
-      newCalculator(Jalview.getCurrentAlignFrame(), calculator);
+      newCalculator(currentAlignFrame.getViewport(), currentAlignFrame
+              .getAlignPanels().get(0), calculator);
     }
     else
     {
@@ -74,15 +85,16 @@ public class AlignmentAnnotationFactory
   /**
    * Constructs and registers a new alignment annotation worker
    * 
-   * @param af
-   *          the AlignFrame for which the annotation is to be calculated
+   * @param viewport
+   * @param panel
    * @param calculator
    *          provider of AlignmentAnnotation for the alignment
    */
-  public static void newCalculator(AlignFrame af,
+  public static void newCalculator(AlignViewportI viewport,
+          AlignmentViewPanel panel,
           AnnotationProviderI calculator)
   {
-    new AnnotationWorker(af, calculator);
+    new AnnotationWorker(viewport, panel, calculator);
   }
 
   /**