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.BorderLayout; |
24 |
|
import java.awt.Cursor; |
25 |
|
import java.awt.Dimension; |
26 |
|
import java.awt.Rectangle; |
27 |
|
import java.awt.event.ActionEvent; |
28 |
|
import java.awt.event.ActionListener; |
29 |
|
import java.awt.event.ComponentAdapter; |
30 |
|
import java.awt.event.ComponentEvent; |
31 |
|
import java.awt.event.MouseAdapter; |
32 |
|
import java.awt.event.MouseEvent; |
33 |
|
import java.awt.event.MouseMotionAdapter; |
34 |
|
import java.beans.PropertyChangeEvent; |
35 |
|
import java.beans.PropertyVetoException; |
36 |
|
|
37 |
|
import javax.swing.JCheckBoxMenuItem; |
38 |
|
import javax.swing.JInternalFrame; |
39 |
|
import javax.swing.JPanel; |
40 |
|
import javax.swing.JPopupMenu; |
41 |
|
import javax.swing.SwingUtilities; |
42 |
|
|
43 |
|
import jalview.renderer.OverviewRenderer; |
44 |
|
import jalview.util.MessageManager; |
45 |
|
import jalview.util.Platform; |
46 |
|
import jalview.viewmodel.OverviewDimensions; |
47 |
|
import jalview.viewmodel.OverviewDimensionsHideHidden; |
48 |
|
import jalview.viewmodel.OverviewDimensionsShowHidden; |
49 |
|
import jalview.viewmodel.ViewportListenerI; |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
@author |
56 |
|
@version |
57 |
|
|
58 |
|
@SuppressWarnings("serial") |
|
|
| 59.4% |
Uncovered Elements: 69 (170) |
Complexity: 46 |
Complexity Density: 0.42 |
|
59 |
|
public class OverviewPanel extends JPanel |
60 |
|
implements Runnable, ViewportListenerI |
61 |
|
{ |
62 |
|
protected OverviewDimensions od; |
63 |
|
|
64 |
|
private OverviewCanvas oviewCanvas; |
65 |
|
|
66 |
|
protected AlignViewport av; |
67 |
|
|
68 |
|
private AlignmentPanel ap; |
69 |
|
|
70 |
|
private JInternalFrame internalFrame; |
71 |
|
|
72 |
|
protected JCheckBoxMenuItem displayToggle; |
73 |
|
|
74 |
|
protected boolean showHidden = true; |
75 |
|
|
76 |
|
protected boolean draggingBox = false; |
77 |
|
|
78 |
|
protected ProgressPanel progressPanel; |
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
@param |
84 |
|
|
85 |
|
@param |
86 |
|
@param |
87 |
|
|
88 |
|
|
|
|
| 91.3% |
Uncovered Elements: 2 (23) |
Complexity: 3 |
Complexity Density: 0.16 |
|
89 |
43 |
public OverviewPanel(AlignmentPanel alPanel, JInternalFrame frame,... |
90 |
|
boolean isShowHidden) |
91 |
|
{ |
92 |
43 |
this.av = alPanel.av; |
93 |
43 |
this.ap = alPanel; |
94 |
43 |
this.internalFrame = frame; |
95 |
|
|
96 |
43 |
showHidden = isShowHidden; |
97 |
43 |
if (showHidden) |
98 |
|
{ |
99 |
6 |
od = new OverviewDimensionsShowHidden(av.getRanges(), |
100 |
|
(av.isShowAnnotation() |
101 |
|
&& av.getAlignmentConservationAnnotation() != null)); |
102 |
|
} |
103 |
|
else |
104 |
|
{ |
105 |
37 |
od = new OverviewDimensionsHideHidden(av.getRanges(), |
106 |
|
(av.isShowAnnotation() |
107 |
|
&& av.getAlignmentConservationAnnotation() != null)); |
108 |
|
} |
109 |
|
|
110 |
43 |
setLayout(new BorderLayout()); |
111 |
43 |
progressPanel = new ProgressPanel(OverviewRenderer.UPDATE, |
112 |
|
MessageManager.getString("label.oview_calc"), getWidth()); |
113 |
43 |
this.add(progressPanel, BorderLayout.SOUTH); |
114 |
43 |
oviewCanvas = new OverviewCanvas(od, av, progressPanel); |
115 |
|
|
116 |
43 |
add(oviewCanvas, BorderLayout.CENTER); |
117 |
|
|
118 |
43 |
av.getRanges().addPropertyChangeListener(this); |
119 |
|
|
120 |
|
|
121 |
43 |
setPreferredSize(new Dimension(od.getWidth(), od.getHeight())); |
122 |
|
|
123 |
43 |
addComponentListener(new ComponentAdapter() |
124 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 5 |
Complexity Density: 0.83 |
|
125 |
97 |
@Override... |
126 |
|
public void componentResized(ComponentEvent evt) |
127 |
|
{ |
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
97 |
if (getWidth() == od.getWidth() && getHeight() == od.getHeight() |
134 |
|
+ progressPanel.getHeight()) |
135 |
|
{ |
136 |
66 |
updateOverviewImage(); |
137 |
|
} |
138 |
|
else |
139 |
|
{ |
140 |
31 |
if ((getWidth() > 0) && (getHeight() > 0)) |
141 |
|
{ |
142 |
19 |
od.setWidth(getWidth()); |
143 |
19 |
od.setHeight(getHeight() - progressPanel.getHeight()); |
144 |
|
} |
145 |
|
|
146 |
31 |
setPreferredSize(new Dimension(od.getWidth(), |
147 |
|
od.getHeight() + progressPanel.getHeight())); |
148 |
|
} |
149 |
|
} |
150 |
|
|
151 |
|
}); |
152 |
|
|
153 |
43 |
addMouseMotionListener(new MouseMotionAdapter() |
154 |
|
{ |
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
155 |
0 |
@Override... |
156 |
|
public void mouseDragged(MouseEvent evt) |
157 |
|
{ |
158 |
0 |
if (!SwingUtilities.isRightMouseButton(evt)) |
159 |
|
{ |
160 |
0 |
if (draggingBox) |
161 |
|
{ |
162 |
|
|
163 |
|
|
164 |
0 |
od.adjustViewportFromMouse(evt.getX(), evt.getY(), |
165 |
|
av.getAlignment().getHiddenSequences(), |
166 |
|
av.getAlignment().getHiddenColumns()); |
167 |
|
} |
168 |
|
else |
169 |
|
{ |
170 |
0 |
od.updateViewportFromMouse(evt.getX(), evt.getY(), |
171 |
|
av.getAlignment().getHiddenSequences(), |
172 |
|
av.getAlignment().getHiddenColumns()); |
173 |
|
} |
174 |
|
} |
175 |
|
} |
176 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
177 |
0 |
@Override... |
178 |
|
public void mouseMoved(MouseEvent evt) |
179 |
|
{ |
180 |
0 |
if (od.isPositionInBox(evt.getX(), evt.getY())) |
181 |
|
{ |
182 |
|
|
183 |
|
|
184 |
|
|
185 |
|
|
186 |
0 |
getParent().setCursor( |
187 |
|
Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
188 |
|
} |
189 |
|
else |
190 |
|
{ |
191 |
|
|
192 |
0 |
getParent().setCursor( |
193 |
|
Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); |
194 |
|
} |
195 |
|
} |
196 |
|
|
197 |
|
}); |
198 |
|
|
199 |
43 |
addMouseListener(new MouseAdapter() |
200 |
|
{ |
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 4 |
Complexity Density: 0.33 |
|
201 |
0 |
@Override... |
202 |
|
public void mousePressed(MouseEvent evt) |
203 |
|
{ |
204 |
|
|
205 |
0 |
if (Platform.isWinRightButton(evt)) |
206 |
|
{ |
207 |
0 |
showPopupMenu(evt); |
208 |
0 |
return; |
209 |
|
} |
210 |
0 |
if (SwingUtilities.isRightMouseButton(evt)) |
211 |
|
{ |
212 |
0 |
return; |
213 |
|
} |
214 |
|
|
215 |
|
|
216 |
|
|
217 |
0 |
if (!od.isPositionInBox(evt.getX(), evt.getY())) |
218 |
|
{ |
219 |
0 |
draggingBox = false; |
220 |
|
|
221 |
|
|
222 |
0 |
setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); |
223 |
|
|
224 |
0 |
od.updateViewportFromMouse(evt.getX(), evt.getY(), |
225 |
|
av.getAlignment().getHiddenSequences(), |
226 |
|
av.getAlignment().getHiddenColumns()); |
227 |
0 |
getParent().setCursor( |
228 |
|
Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
229 |
|
} |
230 |
|
else |
231 |
|
{ |
232 |
0 |
draggingBox = true; |
233 |
0 |
od.setDragPoint(evt.getX(), evt.getY(), |
234 |
|
av.getAlignment().getHiddenSequences(), |
235 |
|
av.getAlignment().getHiddenColumns()); |
236 |
|
} |
237 |
|
} |
238 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
239 |
0 |
@Override... |
240 |
|
public void mouseClicked(MouseEvent evt) |
241 |
|
{ |
242 |
0 |
if (SwingUtilities.isRightMouseButton(evt)) |
243 |
|
{ |
244 |
0 |
showPopupMenu(evt); |
245 |
|
} |
246 |
|
} |
247 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
248 |
0 |
@Override... |
249 |
|
public void mouseReleased(MouseEvent evt) |
250 |
|
{ |
251 |
0 |
draggingBox = false; |
252 |
|
} |
253 |
|
|
254 |
|
}); |
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
43 |
if (Platform.isJS()) |
261 |
|
{ |
262 |
0 |
updateOverviewImage(); |
263 |
|
} |
264 |
|
} |
265 |
|
|
266 |
|
|
267 |
|
|
268 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
269 |
0 |
protected void showPopupMenu(MouseEvent e)... |
270 |
|
{ |
271 |
0 |
JPopupMenu popup = new JPopupMenu(); |
272 |
0 |
ActionListener menuListener = new ActionListener() |
273 |
|
{ |
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
274 |
0 |
@Override... |
275 |
|
public void actionPerformed(ActionEvent event) |
276 |
|
{ |
277 |
|
|
278 |
0 |
toggleHiddenColumns(); |
279 |
0 |
displayToggle.setSelected(showHidden); |
280 |
|
} |
281 |
|
}; |
282 |
0 |
displayToggle = new JCheckBoxMenuItem( |
283 |
|
MessageManager.getString("label.togglehidden")); |
284 |
0 |
displayToggle.setEnabled(true); |
285 |
0 |
displayToggle.setSelected(showHidden); |
286 |
0 |
popup.add(displayToggle); |
287 |
0 |
displayToggle.addActionListener(menuListener); |
288 |
0 |
popup.show(this, e.getX(), e.getY()); |
289 |
|
} |
290 |
|
|
291 |
|
|
292 |
|
|
293 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
294 |
0 |
protected void toggleHiddenColumns()... |
295 |
|
{ |
296 |
0 |
if (showHidden) |
297 |
|
{ |
298 |
0 |
showHidden = false; |
299 |
0 |
od = new OverviewDimensionsHideHidden(av.getRanges(), |
300 |
|
(av.isShowAnnotation() |
301 |
|
&& av.getAlignmentConservationAnnotation() != null)); |
302 |
|
} |
303 |
|
else |
304 |
|
{ |
305 |
0 |
showHidden = true; |
306 |
0 |
od = new OverviewDimensionsShowHidden(av.getRanges(), |
307 |
|
(av.isShowAnnotation() |
308 |
|
&& av.getAlignmentConservationAnnotation() != null)); |
309 |
|
} |
310 |
0 |
oviewCanvas.resetOviewDims(od); |
311 |
0 |
updateOverviewImage(); |
312 |
0 |
setBoxPosition(); |
313 |
|
} |
314 |
|
|
315 |
|
|
316 |
|
|
317 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 5 |
Complexity Density: 0.45 |
|
318 |
428 |
public void updateOverviewImage()... |
319 |
|
{ |
320 |
428 |
if (oviewCanvas == null) |
321 |
|
{ |
322 |
|
|
323 |
|
|
324 |
|
|
325 |
1 |
return; |
326 |
|
} |
327 |
|
|
328 |
427 |
if ((getWidth() > 0) && (getHeight() > 0)) |
329 |
|
{ |
330 |
417 |
od.setWidth(getWidth()); |
331 |
417 |
od.setHeight(getHeight() - progressPanel.getHeight()); |
332 |
|
} |
333 |
|
|
334 |
427 |
setPreferredSize(new Dimension(od.getWidth(), |
335 |
|
od.getHeight() + progressPanel.getHeight())); |
336 |
|
|
337 |
427 |
if (oviewCanvas.restartDraw()) |
338 |
|
{ |
339 |
313 |
return; |
340 |
|
} |
341 |
|
|
342 |
114 |
Thread thread = new Thread(this); |
343 |
114 |
thread.start(); |
344 |
114 |
repaint(); |
345 |
|
|
346 |
|
} |
347 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
348 |
114 |
@Override... |
349 |
|
public void run() |
350 |
|
{ |
351 |
114 |
if (oviewCanvas != null) |
352 |
|
{ |
353 |
111 |
oviewCanvas.draw(av.isShowSequenceFeatures(), |
354 |
|
(av.isShowAnnotation() |
355 |
|
&& av.getAlignmentConservationAnnotation() != null), |
356 |
|
ap.getSeqPanel().seqCanvas.getFeatureRenderer()); |
357 |
102 |
setBoxPosition(); |
358 |
|
} |
359 |
|
} |
360 |
|
|
361 |
|
|
362 |
|
|
363 |
|
|
364 |
|
|
365 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
366 |
114 |
private void setBoxPositionOnly()... |
367 |
|
{ |
368 |
114 |
if (od != null) |
369 |
|
{ |
370 |
114 |
int oldX = od.getBoxX(); |
371 |
114 |
int oldY = od.getBoxY(); |
372 |
114 |
int oldWidth = od.getBoxWidth(); |
373 |
114 |
int oldHeight = od.getBoxHeight(); |
374 |
114 |
od.setBoxPosition(av.getAlignment().getHiddenSequences(), |
375 |
|
av.getAlignment().getHiddenColumns()); |
376 |
114 |
repaint(oldX - 1, oldY - 1, oldWidth + 2, oldHeight + 2); |
377 |
114 |
repaint(od.getBoxX(), od.getBoxY(), od.getBoxWidth(), |
378 |
|
od.getBoxHeight()); |
379 |
|
} |
380 |
|
} |
381 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
382 |
102 |
private void setBoxPosition()... |
383 |
|
{ |
384 |
102 |
if (od != null) |
385 |
|
{ |
386 |
102 |
od.setBoxPosition(av.getAlignment().getHiddenSequences(), |
387 |
|
av.getAlignment().getHiddenColumns()); |
388 |
102 |
repaint(); |
389 |
|
} |
390 |
|
} |
391 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
392 |
114 |
@Override... |
393 |
|
public void propertyChange(PropertyChangeEvent evt) |
394 |
|
{ |
395 |
114 |
setBoxPositionOnly(); |
396 |
|
} |
397 |
|
|
398 |
|
|
399 |
|
|
400 |
|
|
|
|
| 92.3% |
Uncovered Elements: 1 (13) |
Complexity: 3 |
Complexity Density: 0.27 |
|
401 |
40 |
protected void dispose()... |
402 |
|
{ |
403 |
40 |
try |
404 |
|
{ |
405 |
40 |
if (av != null) |
406 |
|
{ |
407 |
40 |
av.getRanges().removePropertyChangeListener(this); |
408 |
|
} |
409 |
|
|
410 |
40 |
oviewCanvas.dispose(); |
411 |
|
|
412 |
|
|
413 |
|
|
414 |
|
|
415 |
|
|
416 |
40 |
((JInternalFrame) SwingUtilities |
417 |
|
.getAncestorOfClass(JInternalFrame.class, (this))) |
418 |
|
.setClosed(true); |
419 |
|
} catch (PropertyVetoException e) |
420 |
|
{ |
421 |
|
|
422 |
|
} finally |
423 |
|
{ |
424 |
40 |
progressPanel = null; |
425 |
40 |
av = null; |
426 |
40 |
oviewCanvas = null; |
427 |
40 |
ap = null; |
428 |
40 |
od = null; |
429 |
40 |
internalFrame = null; |
430 |
|
} |
431 |
|
} |
432 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
433 |
17 |
public boolean isShowHiddenRegions()... |
434 |
|
{ |
435 |
17 |
return showHidden; |
436 |
|
} |
437 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
438 |
59 |
public OverviewCanvas getCanvas()... |
439 |
|
{ |
440 |
59 |
return oviewCanvas; |
441 |
|
} |
442 |
|
|
443 |
|
|
444 |
|
|
445 |
|
|
446 |
|
@param |
447 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
448 |
113 |
public void setTitle(String title)... |
449 |
|
{ |
450 |
113 |
internalFrame.setTitle(title); |
451 |
|
} |
452 |
|
|
453 |
|
|
454 |
|
|
455 |
|
|
456 |
|
@return |
457 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
458 |
68 |
public String getTitle()... |
459 |
|
{ |
460 |
68 |
return internalFrame.getTitle(); |
461 |
|
} |
462 |
|
|
463 |
|
|
464 |
|
|
465 |
|
|
466 |
|
@param |
467 |
|
@param |
468 |
|
@param |
469 |
|
@param |
470 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
471 |
13 |
public void setFrameBounds(int xpos, int ypos, int width, int height)... |
472 |
|
{ |
473 |
13 |
internalFrame.setBounds(xpos, ypos, width, height); |
474 |
|
} |
475 |
|
|
476 |
|
|
477 |
|
|
478 |
|
|
479 |
|
@return |
480 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
481 |
16 |
public Rectangle getFrameBounds()... |
482 |
|
{ |
483 |
16 |
return internalFrame.getBounds(); |
484 |
|
} |
485 |
|
|
486 |
|
|
487 |
|
|
488 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
489 |
12 |
public void close()... |
490 |
|
{ |
491 |
12 |
internalFrame.dispose(); |
492 |
|
} |
493 |
|
} |