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(FeatureCounterI counter)
+ public static void newCalculator(ColumnCounterI counter)
{
// TODO need an interface for AlignFrame by which to access
// its AlignViewportI and AlignmentViewPanel
AlignmentViewPanel currentAlignFrame = Jalview.getCurrentAlignFrame().alignPanel;
if (currentAlignFrame != null)
{
- newCalculator(currentAlignFrame.getAlignViewport(),
- currentAlignFrame, counter);
+ Method newCalcMethod = null;
+ try
+ {
+ for (Method m : AlignmentAnnotationFactory.class.getMethods())
+ {
+ if (m.getName().equals("newCalculator"))
+ {
+ if (m.getParameterCount() == 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
{
}
/**
+ * 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);
+ }
+
+ /**
* Constructs and registers a new alignment annotation worker
*
* @param calculator
{
// TODO need an interface for AlignFrame by which to access
// its AlignViewportI and AlignmentViewPanel
- AlignFrame currentAlignFrame = Jalview.getCurrentAlignFrame() ;
+ AlignFrame currentAlignFrame = Jalview.getCurrentAlignFrame();
if (currentAlignFrame != null)
{
newCalculator(currentAlignFrame.getViewport(), currentAlignFrame
* provider of AlignmentAnnotation for the alignment
*/
public static void newCalculator(AlignViewportI viewport,
- AlignmentViewPanel panel,
- AnnotationProviderI calculator)
+ AlignmentViewPanel panel, AnnotationProviderI calculator)
{
new AnnotationWorker(viewport, panel, calculator);
}