package jalview.workers;
-import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.bin.Jalview;
import jalview.datamodel.AlignmentAnnotation;
import jalview.gui.AlignFrame;
import java.awt.Color;
-import java.lang.reflect.Method;
/**
* Factory class with methods which allow clients (including external scripts
* @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);
}
/**
*/
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
{
}
/**
- * 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