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 jalview.api.RotatableCanvasI; |
24 |
|
import jalview.datamodel.Point; |
25 |
|
import jalview.datamodel.SequenceGroup; |
26 |
|
import jalview.datamodel.SequenceI; |
27 |
|
import jalview.datamodel.SequencePoint; |
28 |
|
import jalview.math.RotatableMatrix; |
29 |
|
import jalview.math.RotatableMatrix.Axis; |
30 |
|
import jalview.util.ColorUtils; |
31 |
|
import jalview.util.MessageManager; |
32 |
|
import jalview.viewmodel.AlignmentViewport; |
33 |
|
|
34 |
|
import java.awt.Color; |
35 |
|
import java.awt.Dimension; |
36 |
|
import java.awt.Font; |
37 |
|
import java.awt.Graphics; |
38 |
|
import java.awt.Graphics2D; |
39 |
|
import java.awt.Image; |
40 |
|
import java.awt.RenderingHints; |
41 |
|
import java.awt.event.InputEvent; |
42 |
|
import java.awt.event.KeyEvent; |
43 |
|
import java.awt.event.KeyListener; |
44 |
|
import java.awt.event.MouseEvent; |
45 |
|
import java.awt.event.MouseListener; |
46 |
|
import java.awt.event.MouseMotionListener; |
47 |
|
import java.awt.event.MouseWheelEvent; |
48 |
|
import java.awt.event.MouseWheelListener; |
49 |
|
import java.util.Arrays; |
50 |
|
import java.util.Iterator; |
51 |
|
import java.util.List; |
52 |
|
|
53 |
|
import javax.swing.JPanel; |
54 |
|
import javax.swing.ToolTipManager; |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
|
|
| 41% |
Uncovered Elements: 217 (368) |
Complexity: 95 |
Complexity Density: 0.4 |
|
60 |
|
public class RotatableCanvas extends JPanel implements MouseListener, |
61 |
|
MouseMotionListener, KeyListener, RotatableCanvasI, |
62 |
|
MouseWheelListener |
63 |
|
{ |
64 |
|
private static final float ZOOM_OUT = 0.9f; |
65 |
|
|
66 |
|
private static final float ZOOM_IN = 1.1f; |
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
private static final int NEARBY = 3; |
72 |
|
|
73 |
|
private static final List<String> AXES = Arrays.asList("x", "y", "z"); |
74 |
|
|
75 |
|
private static final Color AXIS_COLOUR = Color.yellow; |
76 |
|
|
77 |
|
private static final int DIMS = 3; |
78 |
|
|
79 |
|
boolean drawAxes = true; |
80 |
|
|
81 |
|
int mouseX; |
82 |
|
|
83 |
|
int mouseY; |
84 |
|
|
85 |
|
Image img; |
86 |
|
|
87 |
|
Graphics ig; |
88 |
|
|
89 |
|
Dimension prefSize; |
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
float[] seqMin; |
99 |
|
|
100 |
|
float[] seqMax; |
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
private float scaleFactor; |
108 |
|
|
109 |
|
int npoint; |
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
List<SequencePoint> sequencePoints; |
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
private Point[] axisEndPoints; |
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
AlignmentViewport av; |
128 |
|
|
129 |
|
AlignmentPanel ap; |
130 |
|
|
131 |
|
private boolean showLabels; |
132 |
|
|
133 |
|
private Color bgColour; |
134 |
|
|
135 |
|
private boolean applyToAllViews; |
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
@param |
141 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
|
142 |
2 |
public RotatableCanvas(AlignmentPanel panel)... |
143 |
|
{ |
144 |
2 |
this.av = panel.av; |
145 |
2 |
this.ap = panel; |
146 |
2 |
setAxisEndPoints(new Point[DIMS]); |
147 |
2 |
setShowLabels(false); |
148 |
2 |
setApplyToAllViews(false); |
149 |
2 |
setBgColour(Color.BLACK); |
150 |
2 |
resetAxes(); |
151 |
|
|
152 |
2 |
ToolTipManager.sharedInstance().registerComponent(this); |
153 |
|
|
154 |
2 |
addMouseListener(this); |
155 |
2 |
addMouseMotionListener(this); |
156 |
2 |
addMouseWheelListener(this); |
157 |
|
} |
158 |
|
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
@param |
163 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
164 |
0 |
public void showLabels(boolean show)... |
165 |
|
{ |
166 |
0 |
setShowLabels(show); |
167 |
0 |
repaint(); |
168 |
|
} |
169 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
170 |
2 |
@Override... |
171 |
|
public void setPoints(List<SequencePoint> points, int np) |
172 |
|
{ |
173 |
2 |
this.sequencePoints = points; |
174 |
2 |
this.npoint = np; |
175 |
2 |
prefSize = getPreferredSize(); |
176 |
|
|
177 |
2 |
findWidths(); |
178 |
|
|
179 |
2 |
setScaleFactor(1f); |
180 |
|
} |
181 |
|
|
182 |
|
|
183 |
|
|
184 |
|
|
185 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
186 |
2 |
protected void resetAxes()... |
187 |
|
{ |
188 |
2 |
getAxisEndPoints()[0] = new Point(1f, 0f, 0f); |
189 |
2 |
getAxisEndPoints()[1] = new Point(0f, 1f, 0f); |
190 |
2 |
getAxisEndPoints()[2] = new Point(0f, 0f, 1f); |
191 |
|
} |
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0.06 |
|
197 |
2 |
protected void findWidths()... |
198 |
|
{ |
199 |
2 |
float[] max = new float[DIMS]; |
200 |
2 |
float[] min = new float[DIMS]; |
201 |
|
|
202 |
2 |
max[0] = -Float.MAX_VALUE; |
203 |
2 |
max[1] = -Float.MAX_VALUE; |
204 |
2 |
max[2] = -Float.MAX_VALUE; |
205 |
|
|
206 |
2 |
min[0] = Float.MAX_VALUE; |
207 |
2 |
min[1] = Float.MAX_VALUE; |
208 |
2 |
min[2] = Float.MAX_VALUE; |
209 |
|
|
210 |
2 |
for (SequencePoint sp : sequencePoints) |
211 |
|
{ |
212 |
30 |
max[0] = Math.max(max[0], sp.coord.x); |
213 |
30 |
max[1] = Math.max(max[1], sp.coord.y); |
214 |
30 |
max[2] = Math.max(max[2], sp.coord.z); |
215 |
30 |
min[0] = Math.min(min[0], sp.coord.x); |
216 |
30 |
min[1] = Math.min(min[1], sp.coord.y); |
217 |
30 |
min[2] = Math.min(min[2], sp.coord.z); |
218 |
|
} |
219 |
|
|
220 |
2 |
seqMin = min; |
221 |
2 |
seqMax = max; |
222 |
|
} |
223 |
|
|
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
@return |
228 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
229 |
2 |
@Override... |
230 |
|
public Dimension getPreferredSize() |
231 |
|
{ |
232 |
2 |
if (prefSize != null) |
233 |
|
{ |
234 |
0 |
return prefSize; |
235 |
|
} |
236 |
|
else |
237 |
|
{ |
238 |
2 |
return new Dimension(400, 400); |
239 |
|
} |
240 |
|
} |
241 |
|
|
242 |
|
|
243 |
|
|
244 |
|
|
245 |
|
@return |
246 |
|
@see |
247 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
248 |
0 |
@Override... |
249 |
|
public Dimension getMinimumSize() |
250 |
|
{ |
251 |
0 |
return getPreferredSize(); |
252 |
|
} |
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
|
@param |
258 |
|
|
|
|
| 81.8% |
Uncovered Elements: 4 (22) |
Complexity: 5 |
Complexity Density: 0.31 |
|
259 |
27 |
@Override... |
260 |
|
public void paintComponent(Graphics g1) |
261 |
|
{ |
262 |
|
|
263 |
27 |
Graphics2D g = (Graphics2D) g1; |
264 |
|
|
265 |
27 |
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
266 |
|
RenderingHints.VALUE_ANTIALIAS_ON); |
267 |
27 |
if (sequencePoints == null) |
268 |
|
{ |
269 |
0 |
g.setFont(new Font("Verdana", Font.PLAIN, 18)); |
270 |
0 |
g.drawString( |
271 |
|
MessageManager.getString("label.calculating_pca") + "....", |
272 |
|
20, getHeight() / 2); |
273 |
|
} |
274 |
|
else |
275 |
|
{ |
276 |
|
|
277 |
|
|
278 |
|
|
279 |
27 |
boolean resized = prefSize.width != getWidth() |
280 |
|
|| prefSize.height != getHeight(); |
281 |
27 |
if (img == null || resized) |
282 |
|
{ |
283 |
2 |
prefSize.width = getWidth(); |
284 |
2 |
prefSize.height = getHeight(); |
285 |
|
|
286 |
2 |
img = createImage(getWidth(), getHeight()); |
287 |
2 |
ig = img.getGraphics(); |
288 |
|
} |
289 |
|
|
290 |
27 |
drawBackground(ig); |
291 |
27 |
drawScene(ig); |
292 |
|
|
293 |
27 |
if (drawAxes) |
294 |
|
{ |
295 |
27 |
drawAxes(ig); |
296 |
|
} |
297 |
|
|
298 |
27 |
g.drawImage(img, 0, 0, this); |
299 |
|
} |
300 |
|
} |
301 |
|
|
302 |
|
|
303 |
|
|
304 |
|
|
305 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
306 |
0 |
public void resetView()... |
307 |
|
{ |
308 |
0 |
img = null; |
309 |
0 |
findWidths(); |
310 |
0 |
resetAxes(); |
311 |
0 |
repaint(); |
312 |
|
} |
313 |
|
|
314 |
|
|
315 |
|
|
316 |
|
|
317 |
|
@param |
318 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
319 |
27 |
public void drawAxes(Graphics g)... |
320 |
|
{ |
321 |
27 |
g.setColor(AXIS_COLOUR); |
322 |
|
|
323 |
27 |
int midX = getWidth() / 2; |
324 |
27 |
int midY = getHeight() / 2; |
325 |
27 |
float maxWidth = Math.max(Math.abs(seqMax[0] - seqMin[0]), |
326 |
|
Math.abs(seqMax[1] - seqMin[1])); |
327 |
27 |
int pix = Math.min(getWidth(), getHeight()); |
328 |
27 |
float scaleBy = pix * getScaleFactor() / (2f * maxWidth); |
329 |
|
|
330 |
108 |
for (int i = 0; i < DIMS; i++) |
331 |
|
{ |
332 |
81 |
g.drawLine(midX, midY, |
333 |
|
midX + (int) (getAxisEndPoints()[i].x * scaleBy * seqMax[0]), |
334 |
|
midY + (int) (getAxisEndPoints()[i].y * scaleBy * seqMax[1])); |
335 |
|
} |
336 |
|
} |
337 |
|
|
338 |
|
|
339 |
|
|
340 |
|
|
341 |
|
@param |
342 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
343 |
27 |
public void drawBackground(Graphics g)... |
344 |
|
{ |
345 |
27 |
g.setColor(getBgColour()); |
346 |
27 |
g.fillRect(0, 0, prefSize.width, prefSize.height); |
347 |
|
} |
348 |
|
|
349 |
|
|
350 |
|
|
351 |
|
|
352 |
|
|
353 |
|
|
354 |
|
|
355 |
|
|
356 |
|
@param |
357 |
|
|
|
|
| 65.7% |
Uncovered Elements: 12 (35) |
Complexity: 4 |
Complexity Density: 0.14 |
|
358 |
27 |
public void drawScene(Graphics g1)... |
359 |
|
{ |
360 |
27 |
Graphics2D g = (Graphics2D) g1; |
361 |
|
|
362 |
27 |
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
363 |
|
RenderingHints.VALUE_ANTIALIAS_ON); |
364 |
27 |
int pix = Math.min(getWidth(), getHeight()); |
365 |
27 |
float xWidth = Math.abs(seqMax[0] - seqMin[0]); |
366 |
27 |
float yWidth = Math.abs(seqMax[1] - seqMin[1]); |
367 |
27 |
float maxWidth = Math.max(xWidth, yWidth); |
368 |
27 |
float scaleBy = pix * getScaleFactor() / (2f * maxWidth); |
369 |
|
|
370 |
27 |
float[] centre = getCentre(); |
371 |
|
|
372 |
432 |
for (int i = 0; i < npoint; i++) |
373 |
|
{ |
374 |
|
|
375 |
|
|
376 |
|
|
377 |
|
|
378 |
405 |
SequencePoint sp = sequencePoints.get(i); |
379 |
405 |
Color sequenceColour = getSequencePointColour(sp); |
380 |
405 |
g.setColor(sequenceColour); |
381 |
|
|
382 |
405 |
int halfwidth = getWidth() / 2; |
383 |
405 |
int halfheight = getHeight() / 2; |
384 |
405 |
int x = (int) ((sp.coord.x - centre[0]) * scaleBy) + halfwidth; |
385 |
405 |
int y = (int) ((sp.coord.y - centre[1]) * scaleBy) + halfheight; |
386 |
405 |
g.fillRect(x - 3, y - 3, 6, 6); |
387 |
|
|
388 |
405 |
if (isShowLabels()) |
389 |
|
{ |
390 |
0 |
g.setColor(Color.red); |
391 |
0 |
g.drawString(sp.getSequence().getName(), x - 3, y - 4); |
392 |
|
} |
393 |
|
} |
394 |
27 |
if (isShowLabels()) |
395 |
|
{ |
396 |
0 |
g.setColor(AXIS_COLOUR); |
397 |
0 |
int midX = getWidth() / 2; |
398 |
0 |
int midY = getHeight() / 2; |
399 |
0 |
Iterator<String> axes = AXES.iterator(); |
400 |
0 |
for (Point p : getAxisEndPoints()) |
401 |
|
{ |
402 |
0 |
int x = midX + (int) (p.x * scaleBy * seqMax[0]); |
403 |
0 |
int y = midY + (int) (p.y * scaleBy * seqMax[1]); |
404 |
0 |
g.drawString(axes.next(), x - 3, y - 4); |
405 |
|
} |
406 |
|
} |
407 |
|
|
408 |
|
|
409 |
|
|
410 |
|
|
411 |
|
|
412 |
|
|
413 |
|
} |
414 |
|
|
415 |
|
|
416 |
|
|
417 |
|
|
418 |
|
|
419 |
|
|
420 |
|
|
421 |
|
@param |
422 |
|
@return |
423 |
|
|
|
|
| 65.2% |
Uncovered Elements: 8 (23) |
Complexity: 6 |
Complexity Density: 0.46 |
|
424 |
405 |
protected Color getSequencePointColour(SequencePoint sp)... |
425 |
|
{ |
426 |
405 |
SequenceI sequence = sp.getSequence(); |
427 |
405 |
Color sequenceColour = av.getSequenceColour(sequence); |
428 |
405 |
if (sequenceColour == Color.black) |
429 |
|
{ |
430 |
0 |
sequenceColour = Color.white; |
431 |
|
} |
432 |
405 |
if (av.getSelectionGroup() != null) |
433 |
|
{ |
434 |
0 |
if (av.getSelectionGroup().getSequences(null).contains(sequence)) |
435 |
|
{ |
436 |
0 |
sequenceColour = Color.gray; |
437 |
|
} |
438 |
|
} |
439 |
|
|
440 |
|
|
441 |
|
|
442 |
|
|
443 |
405 |
float zCentre = (seqMin[2] + seqMax[2]) / 2f; |
444 |
405 |
if (sp.coord.z > zCentre) |
445 |
|
{ |
446 |
162 |
sequenceColour = ColorUtils.getGraduatedColour(sp.coord.z, 0, |
447 |
|
sequenceColour, seqMax[2], sequenceColour.brighter()); |
448 |
|
} |
449 |
243 |
else if (sp.coord.z < zCentre) |
450 |
|
{ |
451 |
243 |
sequenceColour = ColorUtils.getGraduatedColour(sp.coord.z, seqMin[2], |
452 |
|
sequenceColour.darker(), 0, sequenceColour); |
453 |
|
} |
454 |
|
|
455 |
405 |
return sequenceColour; |
456 |
|
} |
457 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
458 |
0 |
@Override... |
459 |
|
public void keyTyped(KeyEvent evt) |
460 |
|
{ |
461 |
|
} |
462 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
463 |
0 |
@Override... |
464 |
|
public void keyReleased(KeyEvent evt) |
465 |
|
{ |
466 |
|
} |
467 |
|
|
468 |
|
|
469 |
|
|
470 |
|
|
471 |
|
@param |
472 |
|
|
|
|
| 0% |
Uncovered Elements: 30 (30) |
Complexity: 10 |
Complexity Density: 0.62 |
|
473 |
0 |
@Override... |
474 |
|
public void keyPressed(KeyEvent evt) |
475 |
|
{ |
476 |
0 |
int keyCode = evt.getKeyCode(); |
477 |
0 |
boolean shiftDown = evt.isShiftDown(); |
478 |
|
|
479 |
0 |
if (keyCode == KeyEvent.VK_UP) |
480 |
|
{ |
481 |
0 |
if (shiftDown) |
482 |
|
{ |
483 |
0 |
rotate(0f, -1f); |
484 |
|
} |
485 |
|
else |
486 |
|
{ |
487 |
0 |
zoom(ZOOM_IN); |
488 |
|
} |
489 |
|
} |
490 |
0 |
else if (keyCode == KeyEvent.VK_DOWN) |
491 |
|
{ |
492 |
0 |
if (shiftDown) |
493 |
|
{ |
494 |
0 |
rotate(0f, 1f); |
495 |
|
} |
496 |
|
else |
497 |
|
{ |
498 |
0 |
zoom(ZOOM_OUT); |
499 |
|
} |
500 |
|
} |
501 |
0 |
else if (shiftDown && keyCode == KeyEvent.VK_LEFT) |
502 |
|
{ |
503 |
0 |
rotate(1f, 0f); |
504 |
|
} |
505 |
0 |
else if (shiftDown && keyCode == KeyEvent.VK_RIGHT) |
506 |
|
{ |
507 |
0 |
rotate(-1f, 0f); |
508 |
|
} |
509 |
0 |
else if (evt.getKeyChar() == 's') |
510 |
|
{ |
511 |
|
|
512 |
|
|
513 |
|
|
514 |
|
|
515 |
|
|
516 |
|
|
517 |
|
|
518 |
|
} |
519 |
|
|
520 |
0 |
repaint(); |
521 |
|
} |
522 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
523 |
0 |
@Override... |
524 |
|
public void zoom(float factor) |
525 |
|
{ |
526 |
0 |
if (factor > 0f) |
527 |
|
{ |
528 |
0 |
setScaleFactor(getScaleFactor() * factor); |
529 |
|
} |
530 |
|
} |
531 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
532 |
0 |
@Override... |
533 |
|
public void mouseClicked(MouseEvent evt) |
534 |
|
{ |
535 |
|
} |
536 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
537 |
0 |
@Override... |
538 |
|
public void mouseEntered(MouseEvent evt) |
539 |
|
{ |
540 |
|
} |
541 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
542 |
0 |
@Override... |
543 |
|
public void mouseExited(MouseEvent evt) |
544 |
|
{ |
545 |
|
} |
546 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
547 |
0 |
@Override... |
548 |
|
public void mouseReleased(MouseEvent evt) |
549 |
|
{ |
550 |
|
} |
551 |
|
|
552 |
|
|
553 |
|
|
554 |
|
|
555 |
|
|
556 |
|
|
557 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 4 |
Complexity Density: 0.25 |
|
558 |
0 |
@Override... |
559 |
|
public void mousePressed(MouseEvent evt) |
560 |
|
{ |
561 |
0 |
int x = evt.getX(); |
562 |
0 |
int y = evt.getY(); |
563 |
|
|
564 |
0 |
mouseX = x; |
565 |
0 |
mouseY = y; |
566 |
|
|
567 |
|
|
568 |
|
|
569 |
|
|
570 |
|
|
571 |
|
|
572 |
0 |
SequenceI found = findSequenceAtPoint(x, y); |
573 |
|
|
574 |
0 |
if (found != null) |
575 |
|
{ |
576 |
0 |
AlignmentPanel[] aps = getAssociatedPanels(); |
577 |
|
|
578 |
0 |
for (int a = 0; a < aps.length; a++) |
579 |
|
{ |
580 |
0 |
if (aps[a].av.getSelectionGroup() != null) |
581 |
|
{ |
582 |
0 |
aps[a].av.getSelectionGroup().addOrRemove(found, true); |
583 |
|
} |
584 |
|
else |
585 |
|
{ |
586 |
0 |
aps[a].av.setSelectionGroup(new SequenceGroup()); |
587 |
0 |
aps[a].av.getSelectionGroup().addOrRemove(found, true); |
588 |
0 |
aps[a].av.getSelectionGroup() |
589 |
|
.setEndRes(aps[a].av.getAlignment().getWidth() - 1); |
590 |
|
} |
591 |
|
} |
592 |
0 |
PaintRefresher.Refresh(this, av.getSequenceSetId()); |
593 |
|
|
594 |
0 |
av.sendSelection(); |
595 |
|
} |
596 |
|
|
597 |
0 |
repaint(); |
598 |
|
} |
599 |
|
|
600 |
|
|
601 |
|
|
602 |
|
|
603 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
604 |
0 |
@Override... |
605 |
|
public void mouseMoved(MouseEvent evt) |
606 |
|
{ |
607 |
0 |
SequenceI found = findSequenceAtPoint(evt.getX(), evt.getY()); |
608 |
|
|
609 |
0 |
this.setToolTipText(found == null ? null : found.getName()); |
610 |
|
} |
611 |
|
|
612 |
|
|
613 |
|
|
614 |
|
|
615 |
|
|
616 |
|
@param |
617 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 4 |
Complexity Density: 0.36 |
|
618 |
0 |
@Override... |
619 |
|
public void mouseDragged(MouseEvent evt) |
620 |
|
{ |
621 |
0 |
int xPos = evt.getX(); |
622 |
0 |
int yPos = evt.getY(); |
623 |
|
|
624 |
0 |
if (xPos == mouseX && yPos == mouseY) |
625 |
|
{ |
626 |
0 |
return; |
627 |
|
} |
628 |
|
|
629 |
0 |
int xDelta = xPos - mouseX; |
630 |
0 |
int yDelta = yPos - mouseY; |
631 |
|
|
632 |
|
|
633 |
0 |
if ((evt.getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK) != 0) |
634 |
|
{ |
635 |
|
|
636 |
|
|
637 |
|
} |
638 |
|
else |
639 |
|
{ |
640 |
0 |
rotate(xDelta, yDelta); |
641 |
|
|
642 |
0 |
mouseX = xPos; |
643 |
0 |
mouseY = yPos; |
644 |
|
|
645 |
|
|
646 |
|
|
647 |
0 |
repaint(); |
648 |
|
} |
649 |
|
} |
650 |
|
|
|
|
| 0% |
Uncovered Elements: 31 (31) |
Complexity: 7 |
Complexity Density: 0.33 |
|
651 |
0 |
@Override... |
652 |
|
public void rotate(float x, float y) |
653 |
|
{ |
654 |
0 |
if (x == 0f && y == 0f) |
655 |
|
{ |
656 |
0 |
return; |
657 |
|
} |
658 |
|
|
659 |
|
|
660 |
|
|
661 |
|
|
662 |
0 |
RotatableMatrix rotmat = new RotatableMatrix(); |
663 |
|
|
664 |
|
|
665 |
|
|
666 |
|
|
667 |
|
|
668 |
|
|
669 |
0 |
if (y != 0) |
670 |
|
{ |
671 |
0 |
rotmat.rotate(y, Axis.X); |
672 |
|
} |
673 |
|
|
674 |
|
|
675 |
|
|
676 |
|
|
677 |
|
|
678 |
0 |
if (x != 0) |
679 |
|
{ |
680 |
0 |
rotmat.rotate(x, Axis.Y); |
681 |
|
} |
682 |
|
|
683 |
|
|
684 |
|
|
685 |
|
|
686 |
|
|
687 |
|
|
688 |
0 |
float[] centre = getCentre(); |
689 |
0 |
float zMin = Float.MAX_VALUE; |
690 |
0 |
float zMax = -Float.MAX_VALUE; |
691 |
|
|
692 |
0 |
for (int i = 0; i < npoint; i++) |
693 |
|
{ |
694 |
0 |
SequencePoint sp = sequencePoints.get(i); |
695 |
0 |
sp.translate(-centre[0], -centre[1], -centre[2]); |
696 |
|
|
697 |
|
|
698 |
0 |
sp.coord = rotmat.vectorMultiply(sp.coord); |
699 |
|
|
700 |
|
|
701 |
0 |
sp.translate(centre[0], centre[1], centre[2]); |
702 |
|
|
703 |
0 |
zMin = Math.min(zMin, sp.coord.z); |
704 |
0 |
zMax = Math.max(zMax, sp.coord.z); |
705 |
|
} |
706 |
|
|
707 |
0 |
seqMin[2] = zMin; |
708 |
0 |
seqMax[2] = zMax; |
709 |
|
|
710 |
|
|
711 |
|
|
712 |
|
|
713 |
0 |
for (int i = 0; i < DIMS; i++) |
714 |
|
{ |
715 |
0 |
getAxisEndPoints()[i] = rotmat.vectorMultiply(getAxisEndPoints()[i]); |
716 |
|
} |
717 |
|
} |
718 |
|
|
719 |
|
|
720 |
|
|
721 |
|
|
722 |
|
|
723 |
|
@return |
724 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
725 |
27 |
private float[] getCentre()... |
726 |
|
{ |
727 |
27 |
float xCentre = (seqMin[0] + seqMax[0]) / 2f; |
728 |
27 |
float yCentre = (seqMin[1] + seqMax[1]) / 2f; |
729 |
27 |
float zCentre = (seqMin[2] + seqMax[2]) / 2f; |
730 |
|
|
731 |
27 |
return new float[] { xCentre, yCentre, zCentre }; |
732 |
|
} |
733 |
|
|
734 |
|
|
735 |
|
|
736 |
|
|
737 |
|
|
738 |
|
|
739 |
|
@param |
740 |
|
@param |
741 |
|
@param |
742 |
|
@param |
743 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 8 |
Complexity Density: 0.8 |
|
744 |
0 |
protected void rectSelect(int x1, int y1, int x2, int y2)... |
745 |
|
{ |
746 |
0 |
float[] centre = getCentre(); |
747 |
|
|
748 |
0 |
for (int i = 0; i < npoint; i++) |
749 |
|
{ |
750 |
0 |
SequencePoint sp = sequencePoints.get(i); |
751 |
0 |
int tmp1 = (int) (((sp.coord.x - centre[0]) * getScaleFactor()) |
752 |
|
+ (getWidth() / 2.0)); |
753 |
0 |
int tmp2 = (int) (((sp.coord.y - centre[1]) * getScaleFactor()) |
754 |
|
+ (getHeight() / 2.0)); |
755 |
|
|
756 |
0 |
if ((tmp1 > x1) && (tmp1 < x2) && (tmp2 > y1) && (tmp2 < y2)) |
757 |
|
{ |
758 |
0 |
if (av != null) |
759 |
|
{ |
760 |
0 |
SequenceI sequence = sp.getSequence(); |
761 |
0 |
if (!av.getSelectionGroup().getSequences(null) |
762 |
|
.contains(sequence)) |
763 |
|
{ |
764 |
0 |
av.getSelectionGroup().addSequence(sequence, true); |
765 |
|
} |
766 |
|
} |
767 |
|
} |
768 |
|
} |
769 |
|
} |
770 |
|
|
771 |
|
|
772 |
|
|
773 |
|
|
774 |
|
|
775 |
|
@param |
776 |
|
@param |
777 |
|
|
778 |
|
@return |
779 |
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 5 |
Complexity Density: 0.26 |
|
780 |
0 |
protected SequenceI findSequenceAtPoint(int x, int y)... |
781 |
|
{ |
782 |
0 |
int halfwidth = getWidth() / 2; |
783 |
0 |
int halfheight = getHeight() / 2; |
784 |
|
|
785 |
0 |
int found = -1; |
786 |
0 |
int pix = Math.min(getWidth(), getHeight()); |
787 |
0 |
float xWidth = Math.abs(seqMax[0] - seqMin[0]); |
788 |
0 |
float yWidth = Math.abs(seqMax[1] - seqMin[1]); |
789 |
0 |
float maxWidth = Math.max(xWidth, yWidth); |
790 |
0 |
float scaleBy = pix * getScaleFactor() / (2f * maxWidth); |
791 |
|
|
792 |
0 |
float[] centre = getCentre(); |
793 |
|
|
794 |
0 |
for (int i = 0; i < npoint; i++) |
795 |
|
{ |
796 |
0 |
SequencePoint sp = sequencePoints.get(i); |
797 |
0 |
int px = (int) ((sp.coord.x - centre[0]) * scaleBy) |
798 |
|
+ halfwidth; |
799 |
0 |
int py = (int) ((sp.coord.y - centre[1]) * scaleBy) |
800 |
|
+ halfheight; |
801 |
|
|
802 |
0 |
if ((Math.abs(px - x) < NEARBY) && (Math.abs(py - y) < NEARBY)) |
803 |
|
{ |
804 |
0 |
found = i; |
805 |
0 |
break; |
806 |
|
} |
807 |
|
} |
808 |
|
|
809 |
0 |
if (found != -1) |
810 |
|
{ |
811 |
0 |
return sequencePoints.get(found).getSequence(); |
812 |
|
} |
813 |
|
else |
814 |
|
{ |
815 |
0 |
return null; |
816 |
|
} |
817 |
|
} |
818 |
|
|
819 |
|
|
820 |
|
|
821 |
|
|
822 |
|
|
823 |
|
@return |
824 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
825 |
0 |
AlignmentPanel[] getAssociatedPanels()... |
826 |
|
{ |
827 |
0 |
if (isApplyToAllViews()) |
828 |
|
{ |
829 |
0 |
return PaintRefresher.getAssociatedPanels(av.getSequenceSetId()); |
830 |
|
} |
831 |
|
else |
832 |
|
{ |
833 |
0 |
return new AlignmentPanel[] { ap }; |
834 |
|
} |
835 |
|
} |
836 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
837 |
1 |
public Color getBackgroundColour()... |
838 |
|
{ |
839 |
1 |
return getBgColour(); |
840 |
|
} |
841 |
|
|
842 |
|
|
843 |
|
|
844 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
845 |
0 |
@Override... |
846 |
|
public void mouseWheelMoved(MouseWheelEvent e) |
847 |
|
{ |
848 |
0 |
double wheelRotation = e.getPreciseWheelRotation(); |
849 |
0 |
if (wheelRotation > 0) |
850 |
|
{ |
851 |
0 |
zoom(ZOOM_IN); |
852 |
0 |
repaint(); |
853 |
|
} |
854 |
0 |
else if (wheelRotation < 0) |
855 |
|
{ |
856 |
0 |
zoom(ZOOM_OUT); |
857 |
0 |
repaint(); |
858 |
|
} |
859 |
|
} |
860 |
|
|
861 |
|
|
862 |
|
|
863 |
|
|
864 |
|
|
865 |
|
|
866 |
|
@return |
867 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
868 |
1 |
public float[] getSeqMin()... |
869 |
|
{ |
870 |
1 |
return seqMin; |
871 |
|
} |
872 |
|
|
873 |
|
|
874 |
|
|
875 |
|
|
876 |
|
|
877 |
|
|
878 |
|
@return |
879 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
880 |
1 |
public float[] getSeqMax()... |
881 |
|
{ |
882 |
1 |
return seqMax; |
883 |
|
} |
884 |
|
|
885 |
|
|
886 |
|
|
887 |
|
|
888 |
|
|
889 |
|
@param |
890 |
|
@param |
891 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
892 |
1 |
public void setSeqMinMax(float[] min, float[] max)... |
893 |
|
{ |
894 |
1 |
seqMin = min; |
895 |
1 |
seqMax = max; |
896 |
|
} |
897 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
898 |
55 |
public float getScaleFactor()... |
899 |
|
{ |
900 |
55 |
return scaleFactor; |
901 |
|
} |
902 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
903 |
3 |
public void setScaleFactor(float scaleFactor)... |
904 |
|
{ |
905 |
3 |
this.scaleFactor = scaleFactor; |
906 |
|
} |
907 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
908 |
433 |
public boolean isShowLabels()... |
909 |
|
{ |
910 |
433 |
return showLabels; |
911 |
|
} |
912 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
913 |
3 |
public void setShowLabels(boolean showLabels)... |
914 |
|
{ |
915 |
3 |
this.showLabels = showLabels; |
916 |
|
} |
917 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
918 |
1 |
public boolean isApplyToAllViews()... |
919 |
|
{ |
920 |
1 |
return applyToAllViews; |
921 |
|
} |
922 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
923 |
4 |
public void setApplyToAllViews(boolean applyToAllViews)... |
924 |
|
{ |
925 |
4 |
this.applyToAllViews = applyToAllViews; |
926 |
|
} |
927 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
928 |
172 |
public Point[] getAxisEndPoints()... |
929 |
|
{ |
930 |
172 |
return axisEndPoints; |
931 |
|
} |
932 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
933 |
2 |
public void setAxisEndPoints(Point[] axisEndPoints)... |
934 |
|
{ |
935 |
2 |
this.axisEndPoints = axisEndPoints; |
936 |
|
} |
937 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
938 |
28 |
public Color getBgColour()... |
939 |
|
{ |
940 |
28 |
return bgColour; |
941 |
|
} |
942 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
943 |
3 |
public void setBgColour(Color bgColour)... |
944 |
|
{ |
945 |
3 |
this.bgColour = bgColour; |
946 |
|
} |
947 |
|
} |