JAL-2228 removed ColumnCounterI, finessed recalc of annotation height
[jalview.git] / src / jalview / workers / AlignmentAnnotationFactory.java
index 520b232..68c2295 100644 (file)
@@ -1,5 +1,6 @@
 package jalview.workers;
 
+import jalview.api.AlignmentViewPanel;
 import jalview.bin.Jalview;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.Annotation;
@@ -12,9 +13,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>
  */
@@ -26,30 +27,17 @@ public class AlignmentAnnotationFactory
    * @param counter
    *          provider of feature counts per alignment position
    */
-  public static void newCalculator(FeatureCounterI counter)
+  public static void newCalculator(FeatureSetCounterI counter)
   {
-    if (Jalview.getCurrentAlignFrame() != null)
-    {
-      newCalculator(Jalview.getCurrentAlignFrame(), counter);
-    }
-    else
+    AlignmentViewPanel currentAlignFrame = Jalview.getCurrentAlignFrame().alignPanel;
+    if (currentAlignFrame == null)
     {
       System.err
               .println("Can't register calculator as no alignment window has focus");
+      return;
     }
-  }
-
-  /**
-   * Constructs and registers a new alignment annotation worker
-   * 
-   * @param af
-   *          the AlignFrame for which the annotation is to be calculated
-   * @param counter
-   *          provider of feature counts per alignment position
-   */
-  public static void newCalculator(AlignFrame af, FeatureCounterI counter)
-  {
-    new ColumnCounterWorker(af, counter);
+    new ColumnCounterSetWorker(currentAlignFrame.getAlignViewport(),
+            currentAlignFrame, counter);
   }
 
   /**
@@ -60,9 +48,11 @@ public class AlignmentAnnotationFactory
    */
   public static void newCalculator(AnnotationProviderI calculator)
   {
-    if (Jalview.getCurrentAlignFrame() != null)
+    AlignFrame currentAlignFrame = Jalview.getCurrentAlignFrame();
+    if (currentAlignFrame != null)
     {
-      newCalculator(Jalview.getCurrentAlignFrame(), calculator);
+      new AnnotationWorker(currentAlignFrame.getViewport(),
+              currentAlignFrame.getAlignPanels().get(0), calculator);
     }
     else
     {
@@ -72,20 +62,6 @@ public class AlignmentAnnotationFactory
   }
 
   /**
-   * Constructs and registers a new alignment annotation worker
-   * 
-   * @param af
-   *          the AlignFrame for which the annotation is to be calculated
-   * @param calculator
-   *          provider of AlignmentAnnotation for the alignment
-   */
-  public static void newCalculator(AlignFrame af,
-          AnnotationProviderI calculator)
-  {
-    new AnnotationWorker(af, calculator);
-  }
-
-  /**
    * Factory method to construct an Annotation object
    * 
    * @param displayChar