2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.workers;
23 import jalview.api.AlignViewportI;
24 import jalview.api.AlignmentViewPanel;
25 import jalview.bin.Jalview;
26 import jalview.datamodel.AlignmentAnnotation;
27 import jalview.datamodel.Annotation;
28 import jalview.gui.AlignFrame;
30 import java.awt.Color;
33 * Factory class with methods which allow clients (including external scripts
34 * such as Groovy) to 'register and forget' an alignment annotation calculator. <br>
35 * Currently supports two flavours of calculator:
37 * <li>a simple 'feature counter' which counts any desired score derivable from
38 * residue value and any sequence features at each position of the alignment</li>
39 * <li>a 'general purpose' calculator which computes one or more complete
40 * AlignmentAnnotation objects</li>
43 public class AlignmentAnnotationFactory
46 * Constructs and registers a new alignment annotation worker
49 * provider of feature counts per alignment position
51 public static void newCalculator(FeatureSetCounterI counter)
53 AlignmentViewPanel currentAlignFrame = Jalview.getCurrentAlignFrame().alignPanel;
54 if (currentAlignFrame == null)
57 .println("Can't register calculator as no alignment window has focus");
60 new ColumnCounterSetWorker(currentAlignFrame.getAlignViewport(),
61 currentAlignFrame, counter);
65 * Constructs and registers a new alignment annotation worker
68 * provider of AlignmentAnnotation for the alignment
70 public static void newCalculator(AnnotationProviderI calculator)
72 // TODO need an interface for AlignFrame by which to access
73 // its AlignViewportI and AlignmentViewPanel
74 AlignFrame currentAlignFrame = Jalview.getCurrentAlignFrame();
75 if (currentAlignFrame != null)
77 new AnnotationWorker(currentAlignFrame.getViewport(),
78 currentAlignFrame.getAlignPanels().get(0), calculator);
83 .println("Can't register calculator as no alignment window has focus");
88 * Constructs and registers a new alignment annotation worker
93 * provider of AlignmentAnnotation for the alignment
95 public static void newCalculator(AlignViewportI viewport,
96 AlignmentViewPanel panel, AnnotationProviderI calculator)
98 new AnnotationWorker(viewport, panel, calculator);
102 * Factory method to construct an Annotation object
106 * @param secondaryStructure
111 public static Annotation newAnnotation(String displayChar, String desc,
112 char secondaryStructure, float val, Color color)
114 return new Annotation(displayChar, desc, secondaryStructure, val, color);
118 * Factory method to construct an AlignmentAnnotation object
125 public static AlignmentAnnotation newAlignmentAnnotation(String name,
126 String desc, Annotation[] anns)
128 return new AlignmentAnnotation(name, desc, anns);