1 package jalview.workers;
3 import jalview.datamodel.AlignmentAnnotation;
4 import jalview.datamodel.Annotation;
5 import jalview.gui.AlignFrame;
6 import jalview.gui.Desktop;
11 * Factory class with methods which allow clients (including external scripts
12 * such as Groovy) to 'register and forget' an alignment annotation calculator. <br>
13 * Currently supports two flavours of calculator:
15 * <li>a 'feature counter' which can count any desired property derivable from
16 * residue value and any sequence features at each position of the alignment</li>
17 * <li>a 'general purpose' calculator which computes one more complete
18 * AlignmentAnnotation objects</li>
21 public class AlignmentAnnotationFactory
24 * Constructs and registers a new alignment annotation worker
27 * provider of feature counts per alignment position
29 public static void newCalculator(FeatureCounterI counter)
31 if (Desktop.getCurrentAlignFrame() != null)
33 newCalculator(Desktop.getCurrentAlignFrame(), counter);
38 .println("Can't register calculator as no alignment window has focus");
43 * Constructs and registers a new alignment annotation worker
46 * the AlignFrame for which the annotation is to be calculated
48 * provider of feature counts per alignment position
50 public static void newCalculator(AlignFrame af, FeatureCounterI counter)
52 new ColumnCounterWorker(af, counter);
56 * Constructs and registers a new alignment annotation worker
59 * provider of AlignmentAnnotation for the alignment
61 public static void newCalculator(AnnotationProviderI calculator)
63 if (Desktop.getCurrentAlignFrame() != null)
65 newCalculator(Desktop.getCurrentAlignFrame(), calculator);
70 .println("Can't register calculator as no alignment window has focus");
75 * Constructs and registers a new alignment annotation worker
78 * the AlignFrame for which the annotation is to be calculated
80 * provider of AlignmentAnnotation for the alignment
82 public static void newCalculator(AlignFrame af,
83 AnnotationProviderI calculator)
85 new AnnotationWorker(af, calculator);
89 * Factory method to construct an Annotation object
93 * @param secondaryStructure
98 public static Annotation newAnnotation(String displayChar, String desc,
99 char secondaryStructure, float val, Color color)
101 return new Annotation(displayChar, desc, secondaryStructure, val, color);
105 * Factory method to construct an AlignmentAnnotation object
112 public static AlignmentAnnotation newAlignmentAnnotation(String name,
113 String desc, Annotation[] anns)
115 return new AlignmentAnnotation(name, desc, anns);