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") |
|
|
| 0% |
Uncovered Elements: 170 (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 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 3 |
Complexity Density: 0.16 |
|
89 |
0 |
public OverviewPanel(AlignmentPanel alPanel, JInternalFrame frame,... |
90 |
|
boolean isShowHidden) |
91 |
|
{ |
92 |
0 |
this.av = alPanel.av; |
93 |
0 |
this.ap = alPanel; |
94 |
0 |
this.internalFrame = frame; |
95 |
|
|
96 |
0 |
showHidden = isShowHidden; |
97 |
0 |
if (showHidden) |
98 |
|
{ |
99 |
0 |
od = new OverviewDimensionsShowHidden(av.getRanges(), |
100 |
|
(av.isShowAnnotation() |
101 |
|
&& av.getAlignmentConservationAnnotation() != null)); |
102 |
|
} |
103 |
|
else |
104 |
|
{ |
105 |
0 |
od = new OverviewDimensionsHideHidden(av.getRanges(), |
106 |
|
(av.isShowAnnotation() |
107 |
|
&& av.getAlignmentConservationAnnotation() != null)); |
108 |
|
} |
109 |
|
|
110 |
0 |
setLayout(new BorderLayout()); |
111 |
0 |
progressPanel = new ProgressPanel(OverviewRenderer.UPDATE, |
112 |
|
MessageManager.getString("label.oview_calc"), getWidth()); |
113 |
0 |
this.add(progressPanel, BorderLayout.SOUTH); |
114 |
0 |
oviewCanvas = new OverviewCanvas(od, av, progressPanel); |
115 |
|
|
116 |
0 |
add(oviewCanvas, BorderLayout.CENTER); |
117 |
|
|
118 |
0 |
av.getRanges().addPropertyChangeListener(this); |
119 |
|
|
120 |
|
|
121 |
0 |
setPreferredSize(new Dimension(od.getWidth(), od.getHeight())); |
122 |
|
|
123 |
0 |
addComponentListener(new ComponentAdapter() |
124 |
|
{ |
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 5 |
Complexity Density: 0.83 |
|
125 |
0 |
@Override... |
126 |
|
public void componentResized(ComponentEvent evt) |
127 |
|
{ |
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
0 |
if (getWidth() == od.getWidth() && getHeight() == od.getHeight() |
134 |
|
+ progressPanel.getHeight()) |
135 |
|
{ |
136 |
0 |
updateOverviewImage(); |
137 |
|
} |
138 |
|
else |
139 |
|
{ |
140 |
0 |
if ((getWidth() > 0) && (getHeight() > 0)) |
141 |
|
{ |
142 |
0 |
od.setWidth(getWidth()); |
143 |
0 |
od.setHeight(getHeight() - progressPanel.getHeight()); |
144 |
|
} |
145 |
|
|
146 |
0 |
setPreferredSize(new Dimension(od.getWidth(), |
147 |
|
od.getHeight() + progressPanel.getHeight())); |
148 |
|
} |
149 |
|
} |
150 |
|
|
151 |
|
}); |
152 |
|
|
153 |
0 |
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 |
0 |
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 |
0 |
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 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 5 |
Complexity Density: 0.45 |
|
318 |
0 |
public void updateOverviewImage()... |
319 |
|
{ |
320 |
0 |
if (oviewCanvas == null) |
321 |
|
{ |
322 |
|
|
323 |
|
|
324 |
|
|
325 |
0 |
return; |
326 |
|
} |
327 |
|
|
328 |
0 |
if ((getWidth() > 0) && (getHeight() > 0)) |
329 |
|
{ |
330 |
0 |
od.setWidth(getWidth()); |
331 |
0 |
od.setHeight(getHeight() - progressPanel.getHeight()); |
332 |
|
} |
333 |
|
|
334 |
0 |
setPreferredSize(new Dimension(od.getWidth(), |
335 |
|
od.getHeight() + progressPanel.getHeight())); |
336 |
|
|
337 |
0 |
if (oviewCanvas.restartDraw()) |
338 |
|
{ |
339 |
0 |
return; |
340 |
|
} |
341 |
|
|
342 |
0 |
Thread thread = new Thread(this); |
343 |
0 |
thread.start(); |
344 |
0 |
repaint(); |
345 |
|
|
346 |
|
} |
347 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
348 |
0 |
@Override... |
349 |
|
public void run() |
350 |
|
{ |
351 |
0 |
if (oviewCanvas != null) |
352 |
|
{ |
353 |
0 |
oviewCanvas.draw(av.isShowSequenceFeatures(), |
354 |
|
(av.isShowAnnotation() |
355 |
|
&& av.getAlignmentConservationAnnotation() != null), |
356 |
|
ap.getSeqPanel().seqCanvas.getFeatureRenderer()); |
357 |
0 |
setBoxPosition(); |
358 |
|
} |
359 |
|
} |
360 |
|
|
361 |
|
|
362 |
|
|
363 |
|
|
364 |
|
|
365 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
366 |
0 |
private void setBoxPositionOnly()... |
367 |
|
{ |
368 |
0 |
if (od != null) |
369 |
|
{ |
370 |
0 |
int oldX = od.getBoxX(); |
371 |
0 |
int oldY = od.getBoxY(); |
372 |
0 |
int oldWidth = od.getBoxWidth(); |
373 |
0 |
int oldHeight = od.getBoxHeight(); |
374 |
0 |
od.setBoxPosition(av.getAlignment().getHiddenSequences(), |
375 |
|
av.getAlignment().getHiddenColumns()); |
376 |
0 |
repaint(oldX - 1, oldY - 1, oldWidth + 2, oldHeight + 2); |
377 |
0 |
repaint(od.getBoxX(), od.getBoxY(), od.getBoxWidth(), |
378 |
|
od.getBoxHeight()); |
379 |
|
} |
380 |
|
} |
381 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
382 |
0 |
private void setBoxPosition()... |
383 |
|
{ |
384 |
0 |
if (od != null) |
385 |
|
{ |
386 |
0 |
od.setBoxPosition(av.getAlignment().getHiddenSequences(), |
387 |
|
av.getAlignment().getHiddenColumns()); |
388 |
0 |
repaint(); |
389 |
|
} |
390 |
|
} |
391 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
392 |
0 |
@Override... |
393 |
|
public void propertyChange(PropertyChangeEvent evt) |
394 |
|
{ |
395 |
0 |
setBoxPositionOnly(); |
396 |
|
} |
397 |
|
|
398 |
|
|
399 |
|
|
400 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 3 |
Complexity Density: 0.27 |
|
401 |
0 |
protected void dispose()... |
402 |
|
{ |
403 |
0 |
try |
404 |
|
{ |
405 |
0 |
if (av != null) |
406 |
|
{ |
407 |
0 |
av.getRanges().removePropertyChangeListener(this); |
408 |
|
} |
409 |
|
|
410 |
0 |
oviewCanvas.dispose(); |
411 |
|
|
412 |
|
|
413 |
|
|
414 |
|
|
415 |
|
|
416 |
0 |
((JInternalFrame) SwingUtilities |
417 |
|
.getAncestorOfClass(JInternalFrame.class, (this))) |
418 |
|
.setClosed(true); |
419 |
|
} catch (PropertyVetoException e) |
420 |
|
{ |
421 |
|
|
422 |
|
} finally |
423 |
|
{ |
424 |
0 |
progressPanel = null; |
425 |
0 |
av = null; |
426 |
0 |
oviewCanvas = null; |
427 |
0 |
ap = null; |
428 |
0 |
od = null; |
429 |
0 |
internalFrame = null; |
430 |
|
} |
431 |
|
} |
432 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
433 |
0 |
public boolean isShowHiddenRegions()... |
434 |
|
{ |
435 |
0 |
return showHidden; |
436 |
|
} |
437 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
438 |
0 |
public OverviewCanvas getCanvas()... |
439 |
|
{ |
440 |
0 |
return oviewCanvas; |
441 |
|
} |
442 |
|
|
443 |
|
|
444 |
|
|
445 |
|
|
446 |
|
@param |
447 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
448 |
0 |
public void setTitle(String title)... |
449 |
|
{ |
450 |
0 |
internalFrame.setTitle(title); |
451 |
|
} |
452 |
|
|
453 |
|
|
454 |
|
|
455 |
|
|
456 |
|
@return |
457 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
458 |
0 |
public String getTitle()... |
459 |
|
{ |
460 |
0 |
return internalFrame.getTitle(); |
461 |
|
} |
462 |
|
|
463 |
|
|
464 |
|
|
465 |
|
|
466 |
|
@param |
467 |
|
@param |
468 |
|
@param |
469 |
|
@param |
470 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
471 |
0 |
public void setFrameBounds(int xpos, int ypos, int width, int height)... |
472 |
|
{ |
473 |
0 |
internalFrame.setBounds(xpos, ypos, width, height); |
474 |
|
} |
475 |
|
|
476 |
|
|
477 |
|
|
478 |
|
|
479 |
|
@return |
480 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
481 |
0 |
public Rectangle getFrameBounds()... |
482 |
|
{ |
483 |
0 |
return internalFrame.getBounds(); |
484 |
|
} |
485 |
|
|
486 |
|
|
487 |
|
|
488 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
489 |
0 |
public void close()... |
490 |
|
{ |
491 |
0 |
internalFrame.dispose(); |
492 |
|
} |
493 |
|
} |