Clover icon

Coverage Report

  1. Project Clover database Fri Dec 6 2024 13:47:14 GMT
  2. Package jalview.workers

File AlignmentAnnotationFactory.java

 

Coverage histogram

../../img/srcFileCovDistChart0.png
60% of files have more coverage

Code metrics

4
12
5
1
135
55
7
0.58
2.4
5
1.4

Classes

Class Line # Actions
AlignmentAnnotationFactory 45 12 7
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
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.
11    *
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.
16    *
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.
20    */
21    package jalview.workers;
22   
23    import java.awt.Color;
24   
25    import jalview.api.AlignViewportI;
26    import jalview.api.AlignmentViewPanel;
27    import jalview.bin.Jalview;
28    import jalview.datamodel.AlignmentAnnotation;
29    import jalview.datamodel.Annotation;
30    import jalview.gui.AlignFrame;
31   
32    /**
33    * Factory class with methods which allow clients (including external scripts
34    * such as Groovy) to 'register and forget' an alignment annotation calculator.
35    * <br>
36    * Currently supports two flavours of calculator:
37    * <ul>
38    * <li>a simple 'feature counter' which counts any desired score derivable from
39    * residue value and any sequence features at each position of the
40    * alignment</li>
41    * <li>a 'general purpose' calculator which computes one or more complete
42    * AlignmentAnnotation objects</li>
43    * </ul>
44    */
 
45    public class AlignmentAnnotationFactory
46    {
47    /**
48    * Constructs and registers a new alignment annotation worker
49    *
50    * @param counter
51    * provider of feature counts per alignment position
52    */
 
53  0 toggle public static void newCalculator(FeatureSetCounterI counter)
54    {
55  0 AlignmentViewPanel currentAlignFrame = Jalview.getInstance()
56    .getCurrentAlignFrame().alignPanel;
57  0 if (currentAlignFrame == null)
58    {
59  0 jalview.bin.Console.errPrintln(
60    "Can't register calculator as no alignment window has focus");
61  0 return;
62    }
63  0 new ColumnCounterSetWorker(currentAlignFrame.getAlignViewport(),
64    currentAlignFrame, counter);
65    }
66   
67    /**
68    * Constructs and registers a new alignment annotation worker
69    *
70    * @param calculator
71    * provider of AlignmentAnnotation for the alignment
72    */
 
73  0 toggle public static void newCalculator(AnnotationProviderI calculator)
74    {
75    // TODO need an interface for AlignFrame by which to access
76    // its AlignViewportI and AlignmentViewPanel
77  0 AlignFrame currentAlignFrame = Jalview.getInstance()
78    .getCurrentAlignFrame();
79  0 if (currentAlignFrame != null)
80    {
81  0 new AnnotationWorker(currentAlignFrame.getViewport(),
82    currentAlignFrame.getAlignPanels().get(0), calculator);
83    }
84    else
85    {
86  0 jalview.bin.Console.errPrintln(
87    "Can't register calculator as no alignment window has focus");
88    }
89    }
90   
91    /**
92    * Constructs and registers a new alignment annotation worker
93    *
94    * @param viewport
95    * @param panel
96    * @param calculator
97    * provider of AlignmentAnnotation for the alignment
98    */
 
99  0 toggle public static void newCalculator(AlignViewportI viewport,
100    AlignmentViewPanel panel, AnnotationProviderI calculator)
101    {
102  0 new AnnotationWorker(viewport, panel, calculator);
103    }
104   
105    /**
106    * Factory method to construct an Annotation object
107    *
108    * @param displayChar
109    * @param desc
110    * @param secondaryStructure
111    * @param val
112    * @param color
113    * @return
114    */
 
115  0 toggle public static Annotation newAnnotation(String displayChar, String desc,
116    char secondaryStructure, float val, Color color)
117    {
118  0 return new Annotation(displayChar, desc, secondaryStructure, val,
119    color);
120    }
121   
122    /**
123    * Factory method to construct an AlignmentAnnotation object
124    *
125    * @param name
126    * @param desc
127    * @param anns
128    * @return
129    */
 
130  0 toggle public static AlignmentAnnotation newAlignmentAnnotation(String name,
131    String desc, Annotation[] anns)
132    {
133  0 return new AlignmentAnnotation(name, desc, anns);
134    }
135    }