JAL-2228 removed FeatureCounterI in favour of FeatureSetCounterI with
[jalview.git] / src / jalview / workers / AlignmentAnnotationFactory.java
index 4e11c70..68c2295 100644 (file)
@@ -1,6 +1,5 @@
 package jalview.workers;
 
-import jalview.api.AlignViewportI;
 import jalview.api.AlignmentViewPanel;
 import jalview.bin.Jalview;
 import jalview.datamodel.AlignmentAnnotation;
@@ -8,7 +7,6 @@ import jalview.datamodel.Annotation;
 import jalview.gui.AlignFrame;
 
 import java.awt.Color;
-import java.lang.reflect.Method;
 
 /**
  * Factory class with methods which allow clients (including external scripts
@@ -29,83 +27,17 @@ public class AlignmentAnnotationFactory
    * @param counter
    *          provider of feature counts per alignment position
    */
-  public static void newCalculator(ColumnCounterI counter)
+  public static void newCalculator(FeatureSetCounterI counter)
   {
-    // TODO need an interface for AlignFrame by which to access
-    // its AlignViewportI and AlignmentViewPanel
     AlignmentViewPanel currentAlignFrame = Jalview.getCurrentAlignFrame().alignPanel;
-    if (currentAlignFrame != null)
-    {
-      Method newCalcMethod = null;
-      try
-      {
-        for (Method m : AlignmentAnnotationFactory.class.getMethods())
-        {
-          if (m.getName().equals("newCalculator"))
-          {
-            if (m.getParameterTypes().length == 3
-                    && m.getParameterTypes()[2].isInstance(counter))
-            {
-              newCalcMethod = m;
-              break;
-            }
-          }
-        }
-      } catch (Exception q)
-      {
-      }
-      if (newCalcMethod == null)
-      {
-
-        System.err
-                .println("Couldn't find a newCalculator method for ColumnCounterI type "
-                        + counter.getClass().getName());
-      }
-      try
-      {
-        newCalcMethod.invoke(null, currentAlignFrame.getAlignViewport(),
-                currentAlignFrame, counter);
-      } catch (Exception ie)
-      {
-        System.err
-                .println("Exception when reporting newCalculator method for ColumnCounterI type "
-                        + counter.getClass().getName());
-      }
-    }
-    else
+    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 viewport
-   * @param panel
-   * @param counter
-   *          provider of feature counts per alignment position
-   */
-  public static void newCalculator(AlignViewportI viewport,
-          AlignmentViewPanel panel, FeatureCounterI counter)
-  {
-    new ColumnCounterWorker(viewport, panel, counter);
-  }
-
-  /**
-   * Constructs and registers a new alignment annotation worker for a set of
-   * column counters
-   * 
-   * @param viewport
-   * @param panel
-   * @param counter
-   *          provider of feature counts per alignment position
-   */
-  public static void newCalculator(AlignViewportI viewport,
-          AlignmentViewPanel panel, FeatureSetCounterI counter)
-  {
-    new ColumnCounterSetWorker(viewport, panel, counter);
+    new ColumnCounterSetWorker(currentAlignFrame.getAlignViewport(),
+            currentAlignFrame, counter);
   }
 
   /**
@@ -116,13 +48,11 @@ public class AlignmentAnnotationFactory
    */
   public static void newCalculator(AnnotationProviderI calculator)
   {
-    // TODO need an interface for AlignFrame by which to access
-    // its AlignViewportI and AlignmentViewPanel
     AlignFrame currentAlignFrame = Jalview.getCurrentAlignFrame();
     if (currentAlignFrame != null)
     {
-      newCalculator(currentAlignFrame.getViewport(), currentAlignFrame
-              .getAlignPanels().get(0), calculator);
+      new AnnotationWorker(currentAlignFrame.getViewport(),
+              currentAlignFrame.getAlignPanels().get(0), calculator);
     }
     else
     {
@@ -132,20 +62,6 @@ public class AlignmentAnnotationFactory
   }
 
   /**
-   * Constructs and registers a new alignment annotation worker
-   * 
-   * @param viewport
-   * @param panel
-   * @param calculator
-   *          provider of AlignmentAnnotation for the alignment
-   */
-  public static void newCalculator(AlignViewportI viewport,
-          AlignmentViewPanel panel, AnnotationProviderI calculator)
-  {
-    new AnnotationWorker(viewport, panel, calculator);
-  }
-
-  /**
    * Factory method to construct an Annotation object
    * 
    * @param displayChar