1 package jalview.workers;
3 import jalview.api.AlignmentViewPanel;
4 import jalview.bin.Jalview;
5 import jalview.datamodel.AlignmentAnnotation;
6 import jalview.datamodel.Annotation;
7 import jalview.gui.AlignFrame;
12 * Factory class with methods which allow clients (including external scripts
13 * such as Groovy) to 'register and forget' an alignment annotation calculator. <br>
14 * Currently supports two flavours of calculator:
16 * <li>a simple 'feature counter' which counts any desired score derivable from
17 * residue value and any sequence features at each position of the alignment</li>
18 * <li>a 'general purpose' calculator which computes one or more complete
19 * AlignmentAnnotation objects</li>
22 public class AlignmentAnnotationFactory
25 * Constructs and registers a new alignment annotation worker
28 * provider of feature counts per alignment position
30 public static void newCalculator(FeatureSetCounterI counter)
32 AlignmentViewPanel currentAlignFrame = Jalview.getCurrentAlignFrame().alignPanel;
33 if (currentAlignFrame == null)
36 .println("Can't register calculator as no alignment window has focus");
39 new ColumnCounterSetWorker(currentAlignFrame.getAlignViewport(),
40 currentAlignFrame, counter);
44 * Constructs and registers a new alignment annotation worker
47 * provider of AlignmentAnnotation for the alignment
49 public static void newCalculator(AnnotationProviderI calculator)
51 AlignFrame currentAlignFrame = Jalview.getCurrentAlignFrame();
52 if (currentAlignFrame != null)
54 new AnnotationWorker(currentAlignFrame.getViewport(),
55 currentAlignFrame.getAlignPanels().get(0), calculator);
60 .println("Can't register calculator as no alignment window has focus");
65 * Factory method to construct an Annotation object
69 * @param secondaryStructure
74 public static Annotation newAnnotation(String displayChar, String desc,
75 char secondaryStructure, float val, Color color)
77 return new Annotation(displayChar, desc, secondaryStructure, val, color);
81 * Factory method to construct an AlignmentAnnotation object
88 public static AlignmentAnnotation newAlignmentAnnotation(String name,
89 String desc, Annotation[] anns)
91 return new AlignmentAnnotation(name, desc, anns);