Clover icon

Coverage Report

  1. Project Clover database Mon Nov 18 2024 09:56:54 GMT
  2. Package jalview.workers

File AlignCalcWorker.java

 

Coverage histogram

../../img/srcFileCovDistChart5.png
43% of files have more coverage

Code metrics

8
28
6
1
139
80
11
0.39
4.67
6
1.83

Classes

Class Line # Actions
AlignCalcWorker 39 28 11
0.550%
 

Contributing tests

This file is covered by 182 tests. .

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 jalview.api.AlignCalcManagerI;
24    import jalview.api.AlignCalcWorkerI;
25    import jalview.api.AlignViewportI;
26    import jalview.api.AlignmentViewPanel;
27    import jalview.datamodel.AlignmentAnnotation;
28    import jalview.datamodel.AlignmentI;
29    import jalview.datamodel.Annotation;
30   
31    import java.util.List;
32   
33    /**
34    * Base class for alignment calculation workers
35    *
36    * @author jimp
37    *
38    */
 
39    public abstract class AlignCalcWorker implements AlignCalcWorkerI
40    {
41    /**
42    * manager and data source for calculations
43    */
44    protected AlignViewportI alignViewport;
45   
46    protected AlignCalcManagerI calcMan;
47   
48    protected AlignmentViewPanel ap;
49   
50    protected List<AlignmentAnnotation> ourAnnots;
51   
 
52  1351 toggle public AlignCalcWorker(AlignViewportI alignViewport,
53    AlignmentViewPanel alignPanel)
54    {
55  1351 this.alignViewport = alignViewport;
56  1351 calcMan = alignViewport.getCalcManager();
57  1351 ap = alignPanel;
58    }
59   
 
60  18 toggle protected void abortAndDestroy()
61    {
62  18 if (calcMan != null)
63    {
64  15 calcMan.workerComplete(this);
65    }
66  18 alignViewport = null;
67  18 calcMan = null;
68  18 ap = null;
69   
70    }
71   
 
72  1243 toggle @Override
73    public boolean involves(AlignmentAnnotation i)
74    {
75  1243 return ourAnnots != null && ourAnnots.contains(i);
76    }
77   
78    /**
79    * Permanently removes from the alignment all annotation rows managed by this
80    * worker
81    */
 
82  0 toggle @Override
83    public void removeAnnotation()
84    {
85  0 if (ourAnnots != null && alignViewport != null)
86    {
87  0 AlignmentI alignment = alignViewport.getAlignment();
88  0 synchronized (ourAnnots)
89    {
90  0 for (AlignmentAnnotation aa : ourAnnots)
91    {
92  0 alignment.deleteAnnotation(aa, true);
93    }
94    }
95  0 ourAnnots.clear();
96    }
97    }
98   
99    // TODO: allow GUI to query workers associated with annotation to add items to
100    // annotation label panel popup menu
101   
 
102  0 toggle @Override
103    public boolean isDeletable()
104    {
105  0 return false;
106    }
107   
108    /**
109    * Calculate min and max values of annotations and set as graphMin, graphMax
110    * on the AlignmentAnnotation. This is needed because otherwise, well, bad
111    * things happen.
112    *
113    * @param ann
114    * @param anns
115    */
 
116  2 toggle protected void setGraphMinMax(AlignmentAnnotation ann, Annotation[] anns)
117    {
118    // TODO feels like this belongs inside AlignmentAnnotation!
119  2 float max = Float.MIN_VALUE;
120  2 float min = Float.MAX_VALUE;
121  2 boolean set = false;
122  2 for (Annotation a : anns)
123    {
124  0 if (a != null)
125    {
126  0 set = true;
127  0 float val = a.value;
128  0 max = Math.max(max, val);
129  0 min = Math.min(min, val);
130    }
131    }
132  2 if (set)
133    {
134  0 ann.graphMin = min;
135  0 ann.graphMax = max;
136    }
137    }
138   
139    }