1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.gui; |
22 |
|
|
23 |
|
import java.awt.Color; |
24 |
|
import java.awt.Dimension; |
25 |
|
import java.awt.Graphics; |
26 |
|
import java.awt.image.BufferedImage; |
27 |
|
import java.awt.image.RasterFormatException; |
28 |
|
|
29 |
|
import javax.swing.JPanel; |
30 |
|
|
31 |
|
import jalview.api.AlignViewportI; |
32 |
|
import jalview.bin.Cache; |
33 |
|
import jalview.bin.Console; |
34 |
|
import jalview.renderer.OverviewRenderer; |
35 |
|
import jalview.renderer.OverviewResColourFinder; |
36 |
|
import jalview.viewmodel.OverviewDimensions; |
37 |
|
import jalview.viewmodel.seqfeatures.FeatureRendererModel; |
38 |
|
|
|
|
| 91.4% |
Uncovered Elements: 10 (116) |
Complexity: 28 |
Complexity Density: 0.35 |
|
39 |
|
public class OverviewCanvas extends JPanel |
40 |
|
{ |
41 |
|
public static final Color OVERVIEW_DEFAULT_GAP = Color.lightGray; |
42 |
|
|
43 |
|
public static final Color OVERVIEW_DEFAULT_LEGACY_GAP = Color.white; |
44 |
|
|
45 |
|
public static final Color OVERVIEW_DEFAULT_RESIDUE = Color.white; |
46 |
|
|
47 |
|
public static final Color OVERVIEW_DEFAULT_LEGACY_RESIDUE = Color.lightGray; |
48 |
|
|
49 |
|
public static final Color OVERVIEW_DEFAULT_HIDDEN = Color.darkGray |
50 |
|
.darker(); |
51 |
|
|
52 |
|
private static final Color TRANS_GREY = new Color(100, 100, 100, 25); |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
private volatile boolean restart = false; |
57 |
|
|
58 |
|
private volatile boolean updaterunning = false; |
59 |
|
|
60 |
|
private boolean dispose = false; |
61 |
|
|
62 |
|
private BufferedImage miniMe; |
63 |
|
|
64 |
|
private BufferedImage lastMiniMe = null; |
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
private SequenceRenderer sr; |
69 |
|
|
70 |
|
private jalview.renderer.seqfeatures.FeatureRenderer fr; |
71 |
|
|
72 |
|
private OverviewDimensions od; |
73 |
|
|
74 |
|
private OverviewRenderer or = null; |
75 |
|
|
76 |
|
private AlignViewportI av; |
77 |
|
|
78 |
|
private OverviewResColourFinder cf; |
79 |
|
|
80 |
|
private ProgressPanel progressPanel; |
81 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 2 |
Complexity Density: 0.17 |
|
82 |
43 |
public OverviewCanvas(OverviewDimensions overviewDims,... |
83 |
|
AlignViewportI alignvp, ProgressPanel pp) |
84 |
|
{ |
85 |
43 |
od = overviewDims; |
86 |
43 |
av = alignvp; |
87 |
43 |
progressPanel = pp; |
88 |
|
|
89 |
43 |
sr = new SequenceRenderer(av); |
90 |
43 |
sr.renderGaps = false; |
91 |
43 |
fr = new jalview.renderer.seqfeatures.FeatureRenderer(av); |
92 |
|
|
93 |
43 |
boolean useLegacy = Cache.getDefault(Preferences.USE_LEGACY_GAP, false); |
94 |
43 |
Color gapCol = Cache.getDefaultColour(Preferences.GAP_COLOUR, |
95 |
|
OVERVIEW_DEFAULT_GAP); |
96 |
43 |
Color hiddenCol = Cache.getDefaultColour(Preferences.HIDDEN_COLOUR, |
97 |
|
OVERVIEW_DEFAULT_HIDDEN); |
98 |
43 |
Color residueCol = useLegacy ? OVERVIEW_DEFAULT_LEGACY_RESIDUE |
99 |
|
: OVERVIEW_DEFAULT_RESIDUE; |
100 |
|
|
101 |
43 |
cf = new OverviewResColourFinder(gapCol, residueCol, hiddenCol); |
102 |
|
|
103 |
43 |
setSize(od.getWidth(), od.getHeight()); |
104 |
|
} |
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
@param |
111 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
112 |
0 |
public void resetOviewDims(OverviewDimensions overviewDims)... |
113 |
|
{ |
114 |
0 |
od = overviewDims; |
115 |
|
} |
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
121 |
412 |
public boolean restartDraw()... |
122 |
|
{ |
123 |
412 |
synchronized (this) |
124 |
|
{ |
125 |
412 |
if (updaterunning) |
126 |
|
{ |
127 |
309 |
restart = true; |
128 |
309 |
if (or != null) |
129 |
|
{ |
130 |
137 |
or.setRedraw(true); |
131 |
|
} |
132 |
|
} |
133 |
|
else |
134 |
|
{ |
135 |
103 |
updaterunning = true; |
136 |
|
} |
137 |
412 |
return restart; |
138 |
|
} |
139 |
|
} |
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
@param |
145 |
|
|
146 |
|
@param |
147 |
|
|
148 |
|
@param |
149 |
|
|
150 |
|
|
|
|
| 92.9% |
Uncovered Elements: 2 (28) |
Complexity: 5 |
Complexity Density: 0.25 |
|
151 |
231 |
public void draw(boolean showSequenceFeatures, boolean showAnnotation,... |
152 |
|
FeatureRendererModel transferRenderer) |
153 |
|
{ |
154 |
231 |
miniMe = null; |
155 |
|
|
156 |
231 |
if (showSequenceFeatures) |
157 |
|
{ |
158 |
41 |
fr.transferSettings(transferRenderer); |
159 |
|
} |
160 |
|
|
161 |
231 |
setPreferredSize(new Dimension(od.getWidth(), od.getHeight())); |
162 |
|
|
163 |
231 |
or = new OverviewRenderer(fr, od, av.getAlignment(), |
164 |
|
av.getResidueShading(), cf); |
165 |
|
|
166 |
231 |
or.addPropertyChangeListener(progressPanel); |
167 |
|
|
168 |
231 |
miniMe = or.draw(od.getRows(av.getAlignment()), |
169 |
|
od.getColumns(av.getAlignment())); |
170 |
|
|
171 |
231 |
Graphics mg = miniMe.getGraphics(); |
172 |
|
|
173 |
231 |
if (showAnnotation) |
174 |
|
{ |
175 |
231 |
mg.translate(0, od.getSequencesHeight()); |
176 |
226 |
or.drawGraph(mg, av.getAlignmentConservationAnnotation(), |
177 |
|
od.getGraphHeight(), od.getColumns(av.getAlignment())); |
178 |
223 |
mg.translate(0, -od.getSequencesHeight()); |
179 |
|
} |
180 |
|
|
181 |
223 |
or.removePropertyChangeListener(progressPanel); |
182 |
223 |
or = null; |
183 |
223 |
if (restart) |
184 |
|
{ |
185 |
127 |
restart = false; |
186 |
127 |
if (!dispose) |
187 |
|
{ |
188 |
127 |
draw(showSequenceFeatures, showAnnotation, transferRenderer); |
189 |
|
} |
190 |
|
} |
191 |
|
else |
192 |
|
{ |
193 |
96 |
updaterunning = false; |
194 |
96 |
lastMiniMe = miniMe; |
195 |
|
} |
196 |
|
} |
197 |
|
|
|
|
| 85% |
Uncovered Elements: 6 (40) |
Complexity: 11 |
Complexity Density: 0.37 |
|
198 |
19 |
@Override... |
199 |
|
public void paintComponent(Graphics g) |
200 |
|
{ |
201 |
|
|
202 |
|
|
203 |
19 |
if (restart) |
204 |
|
{ |
205 |
4 |
if (lastMiniMe == null) |
206 |
|
{ |
207 |
3 |
g.setColor(Color.white); |
208 |
3 |
g.fillRect(0, 0, getWidth(), getHeight()); |
209 |
|
} |
210 |
|
else |
211 |
|
{ |
212 |
1 |
g.drawImage(lastMiniMe, 0, 0, getWidth(), getHeight(), this); |
213 |
|
} |
214 |
4 |
g.setColor(TRANS_GREY); |
215 |
4 |
g.fillRect(0, 0, getWidth(), getHeight()); |
216 |
|
} |
217 |
15 |
else if (lastMiniMe != null) |
218 |
|
{ |
219 |
|
|
220 |
10 |
if ((getWidth() > 0) && (getHeight() > 0) |
221 |
|
&& ((getWidth() != od.getWidth()) |
222 |
|
|| (getHeight() != od.getHeight()))) |
223 |
|
{ |
224 |
|
|
225 |
|
|
226 |
1 |
if (od.getGraphHeight() > 0 && od.getSequencesHeight() > 0 |
227 |
|
) |
228 |
|
{ |
229 |
1 |
try |
230 |
|
{ |
231 |
1 |
BufferedImage topImage = lastMiniMe.getSubimage(0, 0, |
232 |
|
od.getWidth(), od.getSequencesHeight()); |
233 |
1 |
BufferedImage bottomImage = lastMiniMe.getSubimage(0, |
234 |
|
od.getSequencesHeight(), od.getWidth(), |
235 |
|
od.getGraphHeight()); |
236 |
|
|
237 |
|
|
238 |
|
|
239 |
1 |
od.setWidth(getWidth()); |
240 |
1 |
od.setHeight(getHeight()); |
241 |
|
|
242 |
|
|
243 |
|
|
244 |
1 |
lastMiniMe = new BufferedImage(od.getWidth(), od.getHeight(), |
245 |
|
BufferedImage.TYPE_INT_RGB); |
246 |
1 |
Graphics lg = lastMiniMe.getGraphics(); |
247 |
1 |
lg.drawImage(topImage, 0, 0, od.getWidth(), |
248 |
|
od.getSequencesHeight(), null); |
249 |
1 |
lg.drawImage(bottomImage, 0, od.getSequencesHeight(), |
250 |
|
od.getWidth(), od.getGraphHeight(), this); |
251 |
1 |
lg.dispose(); |
252 |
|
} catch (RasterFormatException e) |
253 |
|
{ |
254 |
0 |
Console.debug( |
255 |
|
"Scaling miscalculation resizing Overview window"); |
256 |
0 |
od.setWidth(getWidth()); |
257 |
0 |
od.setHeight(getHeight()); |
258 |
|
} |
259 |
|
} |
260 |
|
else |
261 |
|
{ |
262 |
0 |
od.setWidth(getWidth()); |
263 |
0 |
od.setHeight(getHeight()); |
264 |
|
} |
265 |
|
|
266 |
|
|
267 |
1 |
od.setBoxPosition(av.getAlignment().getHiddenSequences(), |
268 |
|
av.getAlignment().getHiddenColumns()); |
269 |
|
} |
270 |
|
|
271 |
10 |
g.drawImage(lastMiniMe, 0, 0, getWidth(), getHeight(), this); |
272 |
|
} |
273 |
|
else |
274 |
|
{ |
275 |
5 |
g.drawImage(lastMiniMe, 0, 0, getWidth(), getHeight(), this); |
276 |
|
} |
277 |
|
|
278 |
|
|
279 |
19 |
g.setColor(Color.red); |
280 |
19 |
od.drawBox(g); |
281 |
|
} |
282 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
283 |
40 |
public void dispose()... |
284 |
|
{ |
285 |
40 |
dispose = true; |
286 |
40 |
od = null; |
287 |
40 |
synchronized (this) |
288 |
|
{ |
289 |
40 |
restart = true; |
290 |
40 |
if (or != null) |
291 |
|
{ |
292 |
4 |
or.setRedraw(true); |
293 |
|
} |
294 |
|
} |
295 |
|
} |
296 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
297 |
16 |
public Color getGapColour()... |
298 |
|
{ |
299 |
16 |
return cf.getGapColour(); |
300 |
|
} |
301 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
302 |
16 |
public Color getHiddenColour()... |
303 |
|
{ |
304 |
16 |
return cf.getHiddenColour(); |
305 |
|
} |
306 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
307 |
16 |
public Color getResidueColour()... |
308 |
|
{ |
309 |
16 |
return cf.getResidueColour(); |
310 |
|
} |
311 |
|
|
312 |
|
|
313 |
|
|
314 |
|
|
315 |
|
@param |
316 |
|
@param |
317 |
|
@param |
318 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
319 |
11 |
public void setColours(Color gaps, Color residues, Color hidden)... |
320 |
|
{ |
321 |
11 |
cf = new OverviewResColourFinder(gaps, residues, hidden); |
322 |
|
} |
323 |
|
} |