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.Font; |
26 |
|
import java.awt.FontMetrics; |
27 |
|
import java.awt.Graphics; |
28 |
|
import java.awt.Graphics2D; |
29 |
|
import java.awt.Point; |
30 |
|
import java.awt.Rectangle; |
31 |
|
import java.awt.RenderingHints; |
32 |
|
import java.awt.event.MouseEvent; |
33 |
|
import java.awt.event.MouseListener; |
34 |
|
import java.awt.event.MouseMotionListener; |
35 |
|
import java.awt.print.PageFormat; |
36 |
|
import java.awt.print.Printable; |
37 |
|
import java.awt.print.PrinterException; |
38 |
|
import java.awt.print.PrinterJob; |
39 |
|
import java.util.ArrayList; |
40 |
|
import java.util.BitSet; |
41 |
|
import java.util.HashMap; |
42 |
|
import java.util.Hashtable; |
43 |
|
import java.util.List; |
44 |
|
import java.util.Map; |
45 |
|
import java.util.Map.Entry; |
46 |
|
import java.util.Vector; |
47 |
|
|
48 |
|
import javax.swing.JPanel; |
49 |
|
import javax.swing.JScrollPane; |
50 |
|
import javax.swing.SwingUtilities; |
51 |
|
import javax.swing.ToolTipManager; |
52 |
|
|
53 |
|
import jalview.analysis.Conservation; |
54 |
|
import jalview.analysis.TreeModel; |
55 |
|
import jalview.api.AlignViewportI; |
56 |
|
import jalview.bin.Console; |
57 |
|
import jalview.datamodel.AlignmentAnnotation; |
58 |
|
import jalview.datamodel.Annotation; |
59 |
|
import jalview.datamodel.BinaryNode; |
60 |
|
import jalview.datamodel.ColumnSelection; |
61 |
|
import jalview.datamodel.ContactMatrixI; |
62 |
|
import jalview.datamodel.HiddenColumns; |
63 |
|
import jalview.datamodel.Sequence; |
64 |
|
import jalview.datamodel.SequenceGroup; |
65 |
|
import jalview.datamodel.SequenceI; |
66 |
|
import jalview.datamodel.SequenceNode; |
67 |
|
import jalview.gui.JalviewColourChooser.ColourChooserListener; |
68 |
|
import jalview.schemes.ColourSchemeI; |
69 |
|
import jalview.structure.SelectionSource; |
70 |
|
import jalview.util.ColorUtils; |
71 |
|
import jalview.util.Format; |
72 |
|
import jalview.util.MessageManager; |
73 |
|
import jalview.ws.datamodel.MappableContactMatrixI; |
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
@author |
79 |
|
@version |
80 |
|
|
|
|
| 0% |
Uncovered Elements: 675 (675) |
Complexity: 173 |
Complexity Density: 0.4 |
|
81 |
|
public class TreeCanvas extends JPanel implements MouseListener, Runnable, |
82 |
|
Printable, MouseMotionListener, SelectionSource |
83 |
|
{ |
84 |
|
|
85 |
|
public static final String PLACEHOLDER = " * "; |
86 |
|
|
87 |
|
TreeModel tree; |
88 |
|
|
89 |
|
JScrollPane scrollPane; |
90 |
|
|
91 |
|
TreePanel tp; |
92 |
|
|
93 |
|
private AlignViewport av; |
94 |
|
|
95 |
|
private AlignmentPanel ap; |
96 |
|
|
97 |
|
Font font; |
98 |
|
|
99 |
|
FontMetrics fm; |
100 |
|
|
101 |
|
boolean fitToWindow = true; |
102 |
|
|
103 |
|
boolean showDistances = false; |
104 |
|
|
105 |
|
boolean showBootstrap = false; |
106 |
|
|
107 |
|
boolean markPlaceholders = false; |
108 |
|
|
109 |
|
int offx = 20; |
110 |
|
|
111 |
|
int offy; |
112 |
|
|
113 |
|
private float threshold; |
114 |
|
|
115 |
|
String longestName; |
116 |
|
|
117 |
|
int labelLength = -1; |
118 |
|
|
119 |
|
Map<Object, Rectangle> nameHash = new Hashtable<>(); |
120 |
|
|
121 |
|
Map<BinaryNode, Rectangle> nodeHash = new Hashtable<>(); |
122 |
|
|
123 |
|
BinaryNode highlightNode; |
124 |
|
|
125 |
|
boolean applyToAllViews = false; |
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
@param |
131 |
|
|
132 |
|
@param |
133 |
|
|
134 |
|
@param |
135 |
|
|
136 |
|
@param |
137 |
|
|
138 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
139 |
0 |
public TreeCanvas(TreePanel tp, AlignmentPanel ap, JScrollPane scroller)... |
140 |
|
{ |
141 |
0 |
this.tp = tp; |
142 |
0 |
this.av = ap.av; |
143 |
0 |
this.setAssociatedPanel(ap); |
144 |
0 |
font = av.getFont(); |
145 |
0 |
scrollPane = scroller; |
146 |
0 |
addMouseListener(this); |
147 |
0 |
addMouseMotionListener(this); |
148 |
|
|
149 |
0 |
ToolTipManager.sharedInstance().registerComponent(this); |
150 |
|
} |
151 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 5 |
Complexity Density: 0.36 |
|
152 |
0 |
public void clearSelectedLeaves()... |
153 |
|
{ |
154 |
0 |
Vector<BinaryNode> leaves = tp.getTree() |
155 |
|
.findLeaves(tp.getTree().getTopNode()); |
156 |
0 |
if (tp.isColumnWise()) |
157 |
|
{ |
158 |
0 |
markColumnsFor(getAssociatedPanels(), leaves, Color.white, true); |
159 |
|
} |
160 |
|
else |
161 |
|
{ |
162 |
0 |
for (AlignmentPanel ap : getAssociatedPanels()) |
163 |
|
{ |
164 |
0 |
SequenceGroup selected = ap.av.getSelectionGroup(); |
165 |
0 |
if (selected != null) |
166 |
|
{ |
167 |
|
{ |
168 |
0 |
for (int i = 0; i < leaves.size(); i++) |
169 |
|
{ |
170 |
0 |
SequenceI seq = (SequenceI) leaves.elementAt(i).element(); |
171 |
0 |
if (selected.contains(seq)) |
172 |
|
{ |
173 |
0 |
selected.addOrRemove(seq, false); |
174 |
|
} |
175 |
|
} |
176 |
0 |
selected.recalcConservation(); |
177 |
|
} |
178 |
|
} |
179 |
0 |
ap.av.sendSelection(); |
180 |
|
} |
181 |
|
} |
182 |
0 |
PaintRefresher.Refresh(tp, av.getSequenceSetId()); |
183 |
0 |
repaint(); |
184 |
|
} |
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
189 |
|
@param |
190 |
|
|
191 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
192 |
0 |
public void treeSelectionChanged(SequenceI sequence)... |
193 |
|
{ |
194 |
0 |
AlignmentPanel[] aps = getAssociatedPanels(); |
195 |
|
|
196 |
0 |
for (int a = 0; a < aps.length; a++) |
197 |
|
{ |
198 |
0 |
SequenceGroup selected = aps[a].av.getSelectionGroup(); |
199 |
|
|
200 |
0 |
if (selected == null) |
201 |
|
{ |
202 |
0 |
selected = new SequenceGroup(); |
203 |
0 |
aps[a].av.setSelectionGroup(selected); |
204 |
|
} |
205 |
|
|
206 |
0 |
selected.setEndRes(aps[a].av.getAlignment().getWidth() - 1); |
207 |
0 |
selected.addOrRemove(sequence, true); |
208 |
|
} |
209 |
|
} |
210 |
|
|
211 |
|
|
212 |
|
|
213 |
|
|
214 |
|
@param |
215 |
|
|
216 |
|
|
|
|
| 0% |
Uncovered Elements: 33 (33) |
Complexity: 11 |
Complexity Density: 0.52 |
|
217 |
0 |
public void setTree(TreeModel tree)... |
218 |
|
{ |
219 |
0 |
this.tree = tree; |
220 |
0 |
tree.findHeight(tree.getTopNode()); |
221 |
|
|
222 |
|
|
223 |
0 |
Vector<BinaryNode> leaves = tree.findLeaves(tree.getTopNode()); |
224 |
0 |
boolean has_placeholders = false; |
225 |
0 |
longestName = ""; |
226 |
|
|
227 |
0 |
AlignmentAnnotation aa = tp.getAssocAnnotation(); |
228 |
0 |
ContactMatrixI cm = (aa != null) ? av.getContactMatrix(aa) : null; |
229 |
0 |
if (cm != null && cm.hasCutHeight()) |
230 |
|
{ |
231 |
0 |
threshold = (float) cm.getCutHeight(); |
232 |
|
} |
233 |
|
|
234 |
0 |
for (int i = 0; i < leaves.size(); i++) |
235 |
|
{ |
236 |
0 |
BinaryNode lf = leaves.elementAt(i); |
237 |
|
|
238 |
0 |
if (lf instanceof SequenceNode && ((SequenceNode) lf).isPlaceholder()) |
239 |
|
{ |
240 |
0 |
has_placeholders = true; |
241 |
|
} |
242 |
|
|
243 |
0 |
if (longestName.length() < ((Sequence) lf.element()).getName() |
244 |
|
.length()) |
245 |
|
{ |
246 |
0 |
longestName = TreeCanvas.PLACEHOLDER |
247 |
|
+ ((Sequence) lf.element()).getName(); |
248 |
|
} |
249 |
0 |
if (tp.isColumnWise() && cm != null) |
250 |
|
{ |
251 |
|
|
252 |
0 |
try |
253 |
|
{ |
254 |
0 |
Color col = cm.getGroupColorForPosition(parseColumnNode(lf)); |
255 |
0 |
setColor(lf, col.brighter()); |
256 |
|
} catch (NumberFormatException ex) |
257 |
|
{ |
258 |
|
} |
259 |
0 |
; |
260 |
|
} |
261 |
|
} |
262 |
|
|
263 |
0 |
setMarkPlaceholders(has_placeholders); |
264 |
|
} |
265 |
|
|
266 |
|
|
267 |
|
|
268 |
|
|
269 |
|
@param |
270 |
|
|
271 |
|
@param |
272 |
|
|
273 |
|
@param |
274 |
|
|
275 |
|
@param |
276 |
|
|
277 |
|
@param |
278 |
|
|
279 |
|
@param |
280 |
|
|
281 |
|
@param |
282 |
|
|
283 |
|
|
|
|
| 0% |
Uncovered Elements: 105 (105) |
Complexity: 28 |
Complexity Density: 0.42 |
|
284 |
0 |
public void drawNode(Graphics g, BinaryNode node, double chunk,... |
285 |
|
double wscale, int width, int offx, int offy) |
286 |
|
{ |
287 |
0 |
if (node == null) |
288 |
|
{ |
289 |
0 |
return; |
290 |
|
} |
291 |
|
|
292 |
0 |
if ((node.left() == null) && (node.right() == null)) |
293 |
|
{ |
294 |
|
|
295 |
0 |
double height = node.height; |
296 |
0 |
double dist = node.dist; |
297 |
|
|
298 |
0 |
int xstart = (int) ((height - dist) * wscale) + offx; |
299 |
0 |
int xend = (int) (height * wscale) + offx; |
300 |
|
|
301 |
0 |
int ypos = (int) (node.ycount * chunk) + offy; |
302 |
|
|
303 |
0 |
if (node.element() instanceof SequenceI) |
304 |
|
{ |
305 |
0 |
SequenceI seq = (SequenceI) node.element(); |
306 |
|
|
307 |
0 |
if (av.getSequenceColour(seq) == Color.white) |
308 |
|
{ |
309 |
0 |
g.setColor(Color.black); |
310 |
|
} |
311 |
|
else |
312 |
|
{ |
313 |
0 |
g.setColor(av.getSequenceColour(seq).darker()); |
314 |
|
} |
315 |
|
} |
316 |
|
else |
317 |
|
{ |
318 |
0 |
g.setColor(Color.black); |
319 |
|
} |
320 |
|
|
321 |
|
|
322 |
0 |
g.drawLine(xstart, ypos, xend, ypos); |
323 |
|
|
324 |
0 |
String nodeLabel = ""; |
325 |
|
|
326 |
0 |
if (showDistances && (node.dist > 0)) |
327 |
|
{ |
328 |
0 |
nodeLabel = new Format("%g").form(node.dist); |
329 |
|
} |
330 |
|
|
331 |
0 |
if (showBootstrap && node.bootstrap > -1) |
332 |
|
{ |
333 |
0 |
if (showDistances) |
334 |
|
{ |
335 |
0 |
nodeLabel = nodeLabel + " : "; |
336 |
|
} |
337 |
|
|
338 |
0 |
nodeLabel = nodeLabel + String.valueOf(node.bootstrap); |
339 |
|
} |
340 |
|
|
341 |
0 |
if (!nodeLabel.equals("")) |
342 |
|
{ |
343 |
0 |
g.drawString(nodeLabel, xstart + 2, ypos - 2); |
344 |
|
} |
345 |
|
|
346 |
0 |
String name = (markPlaceholders && ((node instanceof SequenceNode |
347 |
|
&& ((SequenceNode) node).isPlaceholder()))) |
348 |
|
? (PLACEHOLDER + node.getName()) |
349 |
|
: node.getName(); |
350 |
|
|
351 |
0 |
int charWidth = fm.stringWidth(name) + 3; |
352 |
0 |
int charHeight = font.getSize(); |
353 |
|
|
354 |
0 |
Rectangle rect = new Rectangle(xend + 10, ypos - charHeight / 2, |
355 |
|
charWidth, charHeight); |
356 |
|
|
357 |
0 |
nameHash.put(node.element(), rect); |
358 |
|
|
359 |
|
|
360 |
0 |
boolean isSelected = false; |
361 |
0 |
if (tp.isColumnWise()) |
362 |
|
{ |
363 |
0 |
isSelected = isColumnForNodeSelected(node); |
364 |
|
} |
365 |
|
else |
366 |
|
{ |
367 |
0 |
SequenceGroup selected = av.getSelectionGroup(); |
368 |
|
|
369 |
0 |
if ((selected != null) |
370 |
|
&& selected.getSequences(null).contains(node.element())) |
371 |
|
{ |
372 |
0 |
isSelected = true; |
373 |
|
} |
374 |
|
} |
375 |
0 |
if (isSelected) |
376 |
|
{ |
377 |
0 |
g.setColor(Color.gray); |
378 |
|
|
379 |
0 |
g.fillRect(xend + 10, ypos - charHeight / 2, charWidth, charHeight); |
380 |
0 |
g.setColor(Color.white); |
381 |
|
} |
382 |
|
|
383 |
0 |
g.drawString(name, xend + 10, ypos + fm.getDescent()); |
384 |
0 |
g.setColor(Color.black); |
385 |
|
} |
386 |
|
else |
387 |
|
{ |
388 |
0 |
drawNode(g, (BinaryNode) node.left(), chunk, wscale, width, offx, |
389 |
|
offy); |
390 |
0 |
drawNode(g, (BinaryNode) node.right(), chunk, wscale, width, offx, |
391 |
|
offy); |
392 |
|
|
393 |
0 |
double height = node.height; |
394 |
0 |
double dist = node.dist; |
395 |
|
|
396 |
0 |
int xstart = (int) ((height - dist) * wscale) + offx; |
397 |
0 |
int xend = (int) (height * wscale) + offx; |
398 |
0 |
int ypos = (int) (node.ycount * chunk) + offy; |
399 |
|
|
400 |
0 |
g.setColor(node.color.darker()); |
401 |
|
|
402 |
|
|
403 |
0 |
g.drawLine(xstart, ypos, xend, ypos); |
404 |
0 |
if (node == highlightNode) |
405 |
|
{ |
406 |
0 |
g.fillRect(xend - 3, ypos - 3, 6, 6); |
407 |
|
} |
408 |
|
else |
409 |
|
{ |
410 |
0 |
g.fillRect(xend - 2, ypos - 2, 4, 4); |
411 |
|
} |
412 |
|
|
413 |
0 |
int ystart = (node.left() == null ? 0 |
414 |
|
: (int) (node.left().ycount * chunk)) + offy; |
415 |
0 |
int yend = (node.right() == null ? 0 |
416 |
|
: (int) (node.right().ycount * chunk)) + offy; |
417 |
|
|
418 |
0 |
Rectangle pos = new Rectangle(xend - 2, ypos - 2, 5, 5); |
419 |
0 |
nodeHash.put(node, pos); |
420 |
|
|
421 |
0 |
g.drawLine((int) (height * wscale) + offx, ystart, |
422 |
|
(int) (height * wscale) + offx, yend); |
423 |
|
|
424 |
0 |
String nodeLabel = ""; |
425 |
|
|
426 |
0 |
if (showDistances && (node.dist > 0)) |
427 |
|
{ |
428 |
0 |
nodeLabel = new Format("%g").form(node.dist); |
429 |
|
} |
430 |
|
|
431 |
0 |
if (showBootstrap && node.bootstrap > -1) |
432 |
|
{ |
433 |
0 |
if (showDistances) |
434 |
|
{ |
435 |
0 |
nodeLabel = nodeLabel + " : "; |
436 |
|
} |
437 |
|
|
438 |
0 |
nodeLabel = nodeLabel + String.valueOf(node.bootstrap); |
439 |
|
} |
440 |
|
|
441 |
0 |
if (!nodeLabel.equals("")) |
442 |
|
{ |
443 |
0 |
g.drawString(nodeLabel, xstart + 2, ypos - 2); |
444 |
|
} |
445 |
|
} |
446 |
|
} |
447 |
|
|
448 |
|
|
449 |
|
|
450 |
|
|
451 |
|
@param |
452 |
|
|
453 |
|
@param |
454 |
|
|
455 |
|
|
456 |
|
@return |
457 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 9 |
Complexity Density: 1 |
|
458 |
0 |
public Object findElement(int x, int y)... |
459 |
|
{ |
460 |
0 |
for (Entry<Object, Rectangle> entry : nameHash.entrySet()) |
461 |
|
{ |
462 |
0 |
Rectangle rect = entry.getValue(); |
463 |
|
|
464 |
0 |
if ((x >= rect.x) && (x <= (rect.x + rect.width)) && (y >= rect.y) |
465 |
|
&& (y <= (rect.y + rect.height))) |
466 |
|
{ |
467 |
0 |
return entry.getKey(); |
468 |
|
} |
469 |
|
} |
470 |
|
|
471 |
0 |
for (Entry<BinaryNode, Rectangle> entry : nodeHash.entrySet()) |
472 |
|
{ |
473 |
0 |
Rectangle rect = entry.getValue(); |
474 |
|
|
475 |
0 |
if ((x >= rect.x) && (x <= (rect.x + rect.width)) && (y >= rect.y) |
476 |
|
&& (y <= (rect.y + rect.height))) |
477 |
|
{ |
478 |
0 |
return entry.getKey(); |
479 |
|
} |
480 |
|
} |
481 |
|
|
482 |
0 |
return null; |
483 |
|
} |
484 |
|
|
485 |
|
|
486 |
|
|
487 |
|
|
488 |
|
@param |
489 |
|
|
490 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
491 |
0 |
public void pickNodes(Rectangle pickBox)... |
492 |
|
{ |
493 |
0 |
int width = getWidth(); |
494 |
0 |
int height = getHeight(); |
495 |
|
|
496 |
0 |
BinaryNode top = tree.getTopNode(); |
497 |
|
|
498 |
0 |
double wscale = ((width * .8) - (offx * 2)) / tree.getMaxHeight(); |
499 |
|
|
500 |
0 |
if (top.count == 0) |
501 |
|
{ |
502 |
0 |
top.count = ((BinaryNode) top.left()).count |
503 |
|
+ ((BinaryNode) top.right()).count; |
504 |
|
} |
505 |
|
|
506 |
0 |
float chunk = (float) (height - (offy)) / top.count; |
507 |
|
|
508 |
0 |
pickNode(pickBox, top, chunk, wscale, width, offx, offy); |
509 |
|
} |
510 |
|
|
511 |
|
|
512 |
|
|
513 |
|
|
514 |
|
@param |
515 |
|
|
516 |
|
@param |
517 |
|
|
518 |
|
@param |
519 |
|
|
520 |
|
@param |
521 |
|
|
522 |
|
@param |
523 |
|
|
524 |
|
@param |
525 |
|
|
526 |
|
@param |
527 |
|
|
528 |
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 7 |
Complexity Density: 0.5 |
|
529 |
0 |
public void pickNode(Rectangle pickBox, BinaryNode node, float chunk,... |
530 |
|
double wscale, int width, int offx, int offy) |
531 |
|
{ |
532 |
0 |
if (node == null) |
533 |
|
{ |
534 |
0 |
return; |
535 |
|
} |
536 |
|
|
537 |
0 |
if ((node.left() == null) && (node.right() == null)) |
538 |
|
{ |
539 |
0 |
double height = node.height; |
540 |
|
|
541 |
|
|
542 |
0 |
int xend = (int) (height * wscale) + offx; |
543 |
|
|
544 |
0 |
int ypos = (int) (node.ycount * chunk) + offy; |
545 |
|
|
546 |
0 |
if (pickBox.contains(new Point(xend, ypos))) |
547 |
|
{ |
548 |
0 |
if (node.element() instanceof SequenceI) |
549 |
|
{ |
550 |
0 |
SequenceI seq = (SequenceI) node.element(); |
551 |
0 |
SequenceGroup sg = av.getSelectionGroup(); |
552 |
|
|
553 |
0 |
if (sg != null) |
554 |
|
{ |
555 |
0 |
sg.addOrRemove(seq, true); |
556 |
|
} |
557 |
|
} |
558 |
|
} |
559 |
|
} |
560 |
|
else |
561 |
|
{ |
562 |
0 |
pickNode(pickBox, (BinaryNode) node.left(), chunk, wscale, width, |
563 |
|
offx, offy); |
564 |
0 |
pickNode(pickBox, (BinaryNode) node.right(), chunk, wscale, width, |
565 |
|
offx, offy); |
566 |
|
} |
567 |
|
} |
568 |
|
|
569 |
|
|
570 |
|
|
571 |
|
|
572 |
|
@param |
573 |
|
|
574 |
|
@param |
575 |
|
|
576 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 5 |
Complexity Density: 0.45 |
|
577 |
0 |
public void setColor(BinaryNode node, Color c)... |
578 |
|
{ |
579 |
0 |
if (node == null) |
580 |
|
{ |
581 |
0 |
return; |
582 |
|
} |
583 |
|
|
584 |
0 |
node.color = c; |
585 |
0 |
if (node.element() instanceof SequenceI) |
586 |
|
{ |
587 |
0 |
final SequenceI seq = (SequenceI) node.element(); |
588 |
0 |
AlignmentPanel[] aps = getAssociatedPanels(); |
589 |
0 |
if (aps != null) |
590 |
|
{ |
591 |
0 |
for (int a = 0; a < aps.length; a++) |
592 |
|
{ |
593 |
0 |
aps[a].av.setSequenceColour(seq, c); |
594 |
|
} |
595 |
|
} |
596 |
|
} |
597 |
0 |
setColor((BinaryNode) node.left(), c); |
598 |
0 |
setColor((BinaryNode) node.right(), c); |
599 |
|
} |
600 |
|
|
601 |
|
|
602 |
|
|
603 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
604 |
0 |
void startPrinting()... |
605 |
|
{ |
606 |
0 |
Thread thread = new Thread(this); |
607 |
0 |
thread.start(); |
608 |
|
} |
609 |
|
|
610 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 4 |
Complexity Density: 0.4 |
|
611 |
0 |
@Override... |
612 |
|
public void run() |
613 |
|
{ |
614 |
0 |
PrinterJob printJob = PrinterJob.getPrinterJob(); |
615 |
0 |
PageFormat defaultPage = printJob.defaultPage(); |
616 |
0 |
PageFormat pf = printJob.pageDialog(defaultPage); |
617 |
|
|
618 |
0 |
if (defaultPage == pf) |
619 |
|
{ |
620 |
|
|
621 |
|
|
622 |
|
|
623 |
0 |
return; |
624 |
|
} |
625 |
|
|
626 |
0 |
printJob.setPrintable(this, pf); |
627 |
|
|
628 |
0 |
if (printJob.printDialog()) |
629 |
|
{ |
630 |
0 |
try |
631 |
|
{ |
632 |
0 |
printJob.print(); |
633 |
|
} catch (Exception PrintException) |
634 |
|
{ |
635 |
0 |
PrintException.printStackTrace(); |
636 |
|
} |
637 |
|
} |
638 |
|
} |
639 |
|
|
640 |
|
|
641 |
|
|
642 |
|
|
643 |
|
@param |
644 |
|
|
645 |
|
@param |
646 |
|
|
647 |
|
@param |
648 |
|
|
649 |
|
|
650 |
|
@return |
651 |
|
|
652 |
|
@throws |
653 |
|
|
654 |
|
|
|
|
| 0% |
Uncovered Elements: 28 (28) |
Complexity: 5 |
Complexity Density: 0.25 |
|
655 |
0 |
@Override... |
656 |
|
public int print(Graphics pg, PageFormat pf, int pi) |
657 |
|
throws PrinterException |
658 |
|
{ |
659 |
0 |
pg.setFont(font); |
660 |
0 |
pg.translate((int) pf.getImageableX(), (int) pf.getImageableY()); |
661 |
|
|
662 |
0 |
int pwidth = (int) pf.getImageableWidth(); |
663 |
0 |
int pheight = (int) pf.getImageableHeight(); |
664 |
|
|
665 |
0 |
int noPages = getHeight() / pheight; |
666 |
|
|
667 |
0 |
if (pi > noPages) |
668 |
|
{ |
669 |
0 |
return Printable.NO_SUCH_PAGE; |
670 |
|
} |
671 |
|
|
672 |
0 |
if (pwidth > getWidth()) |
673 |
|
{ |
674 |
0 |
pwidth = getWidth(); |
675 |
|
} |
676 |
|
|
677 |
0 |
if (fitToWindow) |
678 |
|
{ |
679 |
0 |
if (pheight > getHeight()) |
680 |
|
{ |
681 |
0 |
pheight = getHeight(); |
682 |
|
} |
683 |
|
|
684 |
0 |
noPages = 0; |
685 |
|
} |
686 |
|
else |
687 |
|
{ |
688 |
0 |
FontMetrics fm = pg.getFontMetrics(font); |
689 |
0 |
int height = fm.getHeight() * nameHash.size(); |
690 |
0 |
pg.translate(0, -pi * pheight); |
691 |
0 |
pg.setClip(0, pi * pheight, pwidth, (pi * pheight) + pheight); |
692 |
|
|
693 |
|
|
694 |
|
|
695 |
|
|
696 |
0 |
pheight = height; |
697 |
|
} |
698 |
|
|
699 |
0 |
draw(pg, pwidth, pheight); |
700 |
|
|
701 |
0 |
return Printable.PAGE_EXISTS; |
702 |
|
} |
703 |
|
|
704 |
|
|
705 |
|
|
706 |
|
|
707 |
|
@param |
708 |
|
|
709 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 6 |
Complexity Density: 0.43 |
|
710 |
0 |
@Override... |
711 |
|
public void paintComponent(Graphics g) |
712 |
|
{ |
713 |
0 |
super.paintComponent(g); |
714 |
0 |
g.setFont(font); |
715 |
|
|
716 |
0 |
if (tree == null) |
717 |
|
{ |
718 |
0 |
g.drawString( |
719 |
|
MessageManager.getString("label.calculating_tree") + "....", |
720 |
|
20, getHeight() / 2); |
721 |
|
} |
722 |
|
else |
723 |
|
{ |
724 |
0 |
fm = g.getFontMetrics(font); |
725 |
|
|
726 |
0 |
int nameCount = nameHash.size(); |
727 |
0 |
if (nameCount == 0) |
728 |
|
{ |
729 |
0 |
repaint(); |
730 |
|
} |
731 |
|
|
732 |
0 |
if (fitToWindow || (!fitToWindow && (scrollPane |
733 |
|
.getHeight() > ((fm.getHeight() * nameCount) + offy)))) |
734 |
|
{ |
735 |
0 |
draw(g, scrollPane.getWidth(), scrollPane.getHeight()); |
736 |
0 |
setPreferredSize(null); |
737 |
|
} |
738 |
|
else |
739 |
|
{ |
740 |
0 |
setPreferredSize(new Dimension(scrollPane.getWidth(), |
741 |
|
fm.getHeight() * nameCount)); |
742 |
0 |
draw(g, scrollPane.getWidth(), fm.getHeight() * nameCount); |
743 |
|
} |
744 |
|
|
745 |
0 |
scrollPane.revalidate(); |
746 |
|
} |
747 |
|
} |
748 |
|
|
749 |
|
|
750 |
|
|
751 |
|
|
752 |
|
@param |
753 |
|
|
754 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
755 |
0 |
@Override... |
756 |
|
public void setFont(Font font) |
757 |
|
{ |
758 |
0 |
this.font = font; |
759 |
0 |
repaint(); |
760 |
|
} |
761 |
|
|
762 |
|
|
763 |
|
|
764 |
|
|
765 |
|
@param |
766 |
|
|
767 |
|
@param |
768 |
|
|
769 |
|
@param |
770 |
|
|
771 |
|
|
|
|
| 0% |
Uncovered Elements: 31 (31) |
Complexity: 6 |
Complexity Density: 0.26 |
|
772 |
0 |
public void draw(Graphics g1, int width, int height)... |
773 |
|
{ |
774 |
0 |
Graphics2D g2 = (Graphics2D) g1; |
775 |
0 |
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
776 |
|
RenderingHints.VALUE_ANTIALIAS_ON); |
777 |
0 |
g2.setColor(Color.white); |
778 |
0 |
g2.fillRect(0, 0, width, height); |
779 |
0 |
g2.setFont(font); |
780 |
|
|
781 |
0 |
if (longestName == null || tree == null) |
782 |
|
{ |
783 |
0 |
g2.drawString("Calculating tree.", 20, 20); |
784 |
0 |
return; |
785 |
|
} |
786 |
0 |
offy = font.getSize() + 10; |
787 |
|
|
788 |
0 |
fm = g2.getFontMetrics(font); |
789 |
|
|
790 |
0 |
labelLength = fm.stringWidth(longestName) + 20; |
791 |
|
|
792 |
0 |
double wscale = (width - labelLength - (offx * 2)) |
793 |
|
/ tree.getMaxHeight(); |
794 |
|
|
795 |
0 |
BinaryNode top = tree.getTopNode(); |
796 |
|
|
797 |
0 |
if (top.count == 0) |
798 |
|
{ |
799 |
0 |
top.count = top.left().count + top.right().count; |
800 |
|
} |
801 |
|
|
802 |
0 |
float chunk = (float) (height - (offy)) / top.count; |
803 |
|
|
804 |
0 |
drawNode(g2, tree.getTopNode(), chunk, wscale, width, offx, offy); |
805 |
|
|
806 |
0 |
if (threshold != 0) |
807 |
|
{ |
808 |
0 |
if (av.getCurrentTree() == tree) |
809 |
|
{ |
810 |
0 |
g2.setColor(Color.red); |
811 |
|
} |
812 |
|
else |
813 |
|
{ |
814 |
0 |
g2.setColor(Color.gray); |
815 |
|
} |
816 |
|
|
817 |
0 |
int x = (int) ((threshold * (getWidth() - labelLength - (2 * offx))) |
818 |
|
+ offx); |
819 |
|
|
820 |
0 |
g2.drawLine(x, 0, x, getHeight()); |
821 |
|
} |
822 |
|
} |
823 |
|
|
824 |
|
|
825 |
|
|
826 |
|
|
827 |
|
@param |
828 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
829 |
0 |
@Override... |
830 |
|
public void mouseReleased(MouseEvent e) |
831 |
|
{ |
832 |
|
|
833 |
|
|
834 |
|
|
835 |
0 |
if (e.isPopupTrigger()) |
836 |
|
{ |
837 |
0 |
chooseSubtreeColour(); |
838 |
0 |
e.consume(); |
839 |
|
} |
840 |
|
} |
841 |
|
|
842 |
|
|
843 |
|
|
844 |
|
|
845 |
|
@param |
846 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
847 |
0 |
@Override... |
848 |
|
public void mouseEntered(MouseEvent e) |
849 |
|
{ |
850 |
|
} |
851 |
|
|
852 |
|
|
853 |
|
|
854 |
|
|
855 |
|
@param |
856 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
857 |
0 |
@Override... |
858 |
|
public void mouseExited(MouseEvent e) |
859 |
|
{ |
860 |
|
} |
861 |
|
|
862 |
|
|
863 |
|
|
864 |
|
|
865 |
|
|
866 |
|
|
867 |
|
@param |
868 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 5 |
Complexity Density: 0.33 |
|
869 |
0 |
@Override... |
870 |
|
public void mouseClicked(MouseEvent evt) |
871 |
|
{ |
872 |
0 |
if (highlightNode == null) |
873 |
|
{ |
874 |
0 |
return; |
875 |
|
} |
876 |
|
|
877 |
0 |
if (evt.getClickCount() > 1) |
878 |
|
{ |
879 |
0 |
tree.swapNodes(highlightNode); |
880 |
0 |
tree.reCount(tree.getTopNode()); |
881 |
0 |
tree.findHeight(tree.getTopNode()); |
882 |
|
} |
883 |
|
else |
884 |
|
{ |
885 |
0 |
Vector<BinaryNode> leaves = tree.findLeaves(highlightNode); |
886 |
0 |
if (tp.isColumnWise()) |
887 |
|
{ |
888 |
0 |
markColumnsFor(getAssociatedPanels(), leaves, Color.red, false); |
889 |
|
} |
890 |
|
else |
891 |
|
{ |
892 |
0 |
for (int i = 0; i < leaves.size(); i++) |
893 |
|
{ |
894 |
0 |
SequenceI seq = (SequenceI) leaves.elementAt(i).element(); |
895 |
0 |
treeSelectionChanged(seq); |
896 |
|
} |
897 |
|
} |
898 |
0 |
av.sendSelection(); |
899 |
|
} |
900 |
|
|
901 |
0 |
PaintRefresher.Refresh(tp, av.getSequenceSetId()); |
902 |
0 |
repaint(); |
903 |
|
} |
904 |
|
|
905 |
|
|
906 |
|
|
907 |
|
|
908 |
|
|
909 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
910 |
0 |
void chooseSubtreeColour()... |
911 |
|
{ |
912 |
0 |
String ttl = MessageManager.getString("label.select_subtree_colour"); |
913 |
0 |
ColourChooserListener listener = new ColourChooserListener() |
914 |
|
{ |
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
915 |
0 |
@Override... |
916 |
|
public void colourSelected(Color c) |
917 |
|
{ |
918 |
0 |
setColor(highlightNode, c); |
919 |
0 |
PaintRefresher.Refresh(tp, ap.av.getSequenceSetId()); |
920 |
0 |
repaint(); |
921 |
|
} |
922 |
|
}; |
923 |
0 |
JalviewColourChooser.showColourChooser(this, ttl, highlightNode.color, |
924 |
|
listener); |
925 |
|
} |
926 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
927 |
0 |
@Override... |
928 |
|
public void mouseMoved(MouseEvent evt) |
929 |
|
{ |
930 |
0 |
av.setCurrentTree(tree); |
931 |
|
|
932 |
0 |
Object ob = findElement(evt.getX(), evt.getY()); |
933 |
|
|
934 |
0 |
if (ob instanceof BinaryNode) |
935 |
|
{ |
936 |
0 |
highlightNode = (BinaryNode) ob; |
937 |
0 |
this.setToolTipText( |
938 |
|
"<html>" + MessageManager.getString("label.highlightnode")); |
939 |
0 |
repaint(); |
940 |
|
|
941 |
|
} |
942 |
|
else |
943 |
|
{ |
944 |
0 |
if (highlightNode != null) |
945 |
|
{ |
946 |
0 |
highlightNode = null; |
947 |
0 |
setToolTipText(null); |
948 |
0 |
repaint(); |
949 |
|
} |
950 |
|
} |
951 |
|
} |
952 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
953 |
0 |
@Override... |
954 |
|
public void mouseDragged(MouseEvent ect) |
955 |
|
{ |
956 |
|
} |
957 |
|
|
958 |
|
|
959 |
|
|
960 |
|
|
961 |
|
|
962 |
|
|
963 |
|
|
964 |
|
@param |
965 |
|
|
|
|
| 0% |
Uncovered Elements: 55 (55) |
Complexity: 10 |
Complexity Density: 0.27 |
|
966 |
0 |
@Override... |
967 |
|
public void mousePressed(MouseEvent e) |
968 |
|
{ |
969 |
0 |
av.setCurrentTree(tree); |
970 |
|
|
971 |
|
|
972 |
|
|
973 |
|
|
974 |
|
|
975 |
0 |
if (e.isPopupTrigger()) |
976 |
|
{ |
977 |
0 |
if (highlightNode != null) |
978 |
|
{ |
979 |
0 |
chooseSubtreeColour(); |
980 |
|
} |
981 |
0 |
return; |
982 |
|
} |
983 |
|
|
984 |
|
|
985 |
|
|
986 |
|
|
987 |
|
|
988 |
|
|
989 |
|
|
990 |
0 |
if (SwingUtilities.isRightMouseButton(e)) |
991 |
|
{ |
992 |
0 |
return; |
993 |
|
} |
994 |
|
|
995 |
0 |
int x = e.getX(); |
996 |
0 |
int y = e.getY(); |
997 |
|
|
998 |
0 |
Object ob = findElement(x, y); |
999 |
|
|
1000 |
0 |
if (ob instanceof SequenceI) |
1001 |
|
{ |
1002 |
0 |
treeSelectionChanged((Sequence) ob); |
1003 |
0 |
PaintRefresher.Refresh(tp, |
1004 |
|
getAssociatedPanel().av.getSequenceSetId()); |
1005 |
0 |
repaint(); |
1006 |
0 |
av.sendSelection(); |
1007 |
0 |
return; |
1008 |
|
} |
1009 |
0 |
else if (!(ob instanceof BinaryNode)) |
1010 |
|
{ |
1011 |
|
|
1012 |
0 |
if (tree.getMaxHeight() != 0) |
1013 |
|
{ |
1014 |
0 |
threshold = (float) (x - offx) |
1015 |
|
/ (float) (getWidth() - labelLength - (2 * offx)); |
1016 |
|
|
1017 |
0 |
List<BinaryNode> groups = tree.groupNodes(threshold); |
1018 |
0 |
setColor(tree.getTopNode(), Color.black); |
1019 |
|
|
1020 |
0 |
AlignmentPanel[] aps = getAssociatedPanels(); |
1021 |
|
|
1022 |
|
|
1023 |
|
|
1024 |
0 |
for (int a = 0; a < aps.length; a++) |
1025 |
|
{ |
1026 |
0 |
aps[a].av.setSelectionGroup(null); |
1027 |
0 |
aps[a].av.getAlignment().deleteAllGroups(); |
1028 |
0 |
aps[a].av.clearSequenceColours(); |
1029 |
0 |
if (aps[a].av.getCodingComplement() != null) |
1030 |
|
{ |
1031 |
0 |
aps[a].av.getCodingComplement().setSelectionGroup(null); |
1032 |
0 |
aps[a].av.getCodingComplement().getAlignment() |
1033 |
|
.deleteAllGroups(); |
1034 |
0 |
aps[a].av.getCodingComplement().clearSequenceColours(); |
1035 |
|
} |
1036 |
0 |
aps[a].av.setUpdateStructures(true); |
1037 |
|
} |
1038 |
0 |
colourGroups(groups); |
1039 |
|
|
1040 |
|
|
1041 |
|
|
1042 |
|
|
1043 |
|
|
1044 |
0 |
if (groups.isEmpty()) |
1045 |
|
{ |
1046 |
0 |
threshold = 0f; |
1047 |
|
} |
1048 |
|
} |
1049 |
0 |
Console.log.debug("Tree cut threshold set at:" + threshold); |
1050 |
0 |
PaintRefresher.Refresh(tp, |
1051 |
|
getAssociatedPanel().av.getSequenceSetId()); |
1052 |
0 |
repaint(); |
1053 |
|
} |
1054 |
|
|
1055 |
|
} |
1056 |
|
|
|
|
| 0% |
Uncovered Elements: 40 (40) |
Complexity: 8 |
Complexity Density: 0.31 |
|
1057 |
0 |
void colourGroups(List<BinaryNode> groups)... |
1058 |
|
{ |
1059 |
0 |
AlignmentPanel[] aps = getAssociatedPanels(); |
1060 |
0 |
List<BitSet> colGroups = new ArrayList<>(); |
1061 |
0 |
Map<BitSet, Color> colors = new HashMap(); |
1062 |
0 |
for (int i = 0; i < groups.size(); i++) |
1063 |
|
{ |
1064 |
0 |
Color col = ColorUtils.getARandomColor(); |
1065 |
|
|
1066 |
0 |
setColor(groups.get(i), col.brighter()); |
1067 |
|
|
1068 |
0 |
Vector<BinaryNode> l = tree.findLeaves(groups.get(i)); |
1069 |
0 |
if (!tp.isColumnWise()) |
1070 |
|
{ |
1071 |
0 |
createSeqGroupFor(aps, l, col); |
1072 |
|
} |
1073 |
|
else |
1074 |
|
{ |
1075 |
0 |
BitSet gp = createColumnGroupFor(l, col); |
1076 |
|
|
1077 |
0 |
colGroups.add(gp); |
1078 |
0 |
colors.put(gp, col); |
1079 |
|
} |
1080 |
|
} |
1081 |
0 |
if (tp.isColumnWise()) |
1082 |
|
{ |
1083 |
0 |
AlignmentAnnotation aa = tp.getAssocAnnotation(); |
1084 |
0 |
if (aa != null) |
1085 |
|
{ |
1086 |
0 |
ContactMatrixI cm = av.getContactMatrix(aa); |
1087 |
0 |
if (cm != null) |
1088 |
|
{ |
1089 |
0 |
cm.updateGroups(colGroups); |
1090 |
0 |
for (BitSet gp : colors.keySet()) |
1091 |
|
{ |
1092 |
0 |
cm.setColorForGroup(gp, colors.get(gp)); |
1093 |
|
} |
1094 |
|
} |
1095 |
0 |
cm.transferGroupColorsTo(aa); |
1096 |
|
} |
1097 |
|
} |
1098 |
|
|
1099 |
|
|
1100 |
|
|
1101 |
0 |
for (int a = 0; a < aps.length; a++) |
1102 |
|
{ |
1103 |
0 |
aps[a].updateAnnotation(); |
1104 |
0 |
final AlignViewportI codingComplement = aps[a].av |
1105 |
|
.getCodingComplement(); |
1106 |
0 |
if (codingComplement != null) |
1107 |
|
{ |
1108 |
0 |
((AlignViewport) codingComplement).getAlignPanel() |
1109 |
|
.updateAnnotation(); |
1110 |
|
} |
1111 |
|
} |
1112 |
|
} |
1113 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1114 |
0 |
private int parseColumnNode(BinaryNode bn) throws NumberFormatException... |
1115 |
|
{ |
1116 |
0 |
return Integer.parseInt( |
1117 |
|
bn.getName().substring(bn.getName().indexOf("c") + 1)); |
1118 |
|
} |
1119 |
|
|
|
|
| 0% |
Uncovered Elements: 42 (42) |
Complexity: 10 |
Complexity Density: 0.36 |
|
1120 |
0 |
private boolean isColumnForNodeSelected(BinaryNode bn)... |
1121 |
|
{ |
1122 |
0 |
SequenceI rseq = tp.assocAnnotation.sequenceRef; |
1123 |
0 |
int colm = -1; |
1124 |
0 |
try |
1125 |
|
{ |
1126 |
0 |
colm = parseColumnNode(bn); |
1127 |
|
} catch (Exception e) |
1128 |
|
{ |
1129 |
0 |
return false; |
1130 |
|
} |
1131 |
0 |
if (av == null || av.getAlignment() == null) |
1132 |
|
{ |
1133 |
|
|
1134 |
0 |
return false; |
1135 |
|
} |
1136 |
0 |
ColumnSelection cs = av.getColumnSelection(); |
1137 |
0 |
HiddenColumns hc = av.getAlignment().getHiddenColumns(); |
1138 |
0 |
AlignmentAnnotation aa = tp.getAssocAnnotation(); |
1139 |
0 |
int offp = -1; |
1140 |
0 |
if (aa != null) |
1141 |
|
{ |
1142 |
0 |
ContactMatrixI cm = av.getContactMatrix(aa); |
1143 |
|
|
1144 |
|
|
1145 |
|
|
1146 |
0 |
if (cm instanceof MappableContactMatrixI) |
1147 |
|
{ |
1148 |
0 |
int[] pos; |
1149 |
|
|
1150 |
|
|
1151 |
0 |
MappableContactMatrixI mcm = (MappableContactMatrixI) cm; |
1152 |
0 |
pos = mcm.getMappedPositionsFor(rseq, colm + 1); |
1153 |
|
|
1154 |
0 |
if (pos != null) |
1155 |
|
{ |
1156 |
0 |
offp = rseq.findIndex(pos[0]); |
1157 |
|
} |
1158 |
|
} |
1159 |
|
else |
1160 |
|
{ |
1161 |
0 |
offp = colm; |
1162 |
|
} |
1163 |
|
} |
1164 |
0 |
if (offp <= 0) |
1165 |
|
{ |
1166 |
0 |
return false; |
1167 |
|
} |
1168 |
|
|
1169 |
0 |
offp -= 2; |
1170 |
0 |
if (!av.hasHiddenColumns()) |
1171 |
|
{ |
1172 |
0 |
return cs.contains(offp); |
1173 |
|
} |
1174 |
0 |
if (hc.isVisible(offp)) |
1175 |
|
{ |
1176 |
0 |
return cs.contains(offp); |
1177 |
|
|
1178 |
|
} |
1179 |
0 |
return false; |
1180 |
|
} |
1181 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 4 |
Complexity Density: 0.4 |
|
1182 |
0 |
private BitSet createColumnGroupFor(Vector<BinaryNode> l, Color col)... |
1183 |
|
{ |
1184 |
0 |
BitSet gp = new BitSet(); |
1185 |
0 |
for (BinaryNode bn : l) |
1186 |
|
{ |
1187 |
0 |
int colm = -1; |
1188 |
0 |
if (bn.element() != null && bn.element() instanceof Integer) |
1189 |
|
{ |
1190 |
0 |
colm = (Integer) bn.element(); |
1191 |
|
} |
1192 |
|
else |
1193 |
|
{ |
1194 |
|
|
1195 |
0 |
try |
1196 |
|
{ |
1197 |
0 |
colm = parseColumnNode(bn); |
1198 |
|
} catch (Exception e) |
1199 |
|
{ |
1200 |
0 |
continue; |
1201 |
|
} |
1202 |
|
} |
1203 |
0 |
gp.set(colm); |
1204 |
|
} |
1205 |
0 |
return gp; |
1206 |
|
} |
1207 |
|
|
|
|
| 0% |
Uncovered Elements: 40 (40) |
Complexity: 12 |
Complexity Density: 0.46 |
|
1208 |
0 |
private void markColumnsFor(AlignmentPanel[] aps, Vector<BinaryNode> l,... |
1209 |
|
Color col, boolean clearSelected) |
1210 |
|
{ |
1211 |
0 |
SequenceI rseq = tp.assocAnnotation.sequenceRef; |
1212 |
0 |
if (av == null || av.getAlignment() == null) |
1213 |
|
{ |
1214 |
|
|
1215 |
0 |
return; |
1216 |
|
} |
1217 |
|
|
1218 |
|
|
1219 |
0 |
ColumnSelection cs = av.getColumnSelection(); |
1220 |
0 |
HiddenColumns hc = av.getAlignment().getHiddenColumns(); |
1221 |
0 |
ContactMatrixI cm = av.getContactMatrix(tp.assocAnnotation); |
1222 |
0 |
MappableContactMatrixI mcm = null; |
1223 |
0 |
int offp; |
1224 |
0 |
if (cm instanceof MappableContactMatrixI) |
1225 |
|
{ |
1226 |
0 |
mcm = (MappableContactMatrixI) cm; |
1227 |
|
} |
1228 |
0 |
for (BinaryNode bn : l) |
1229 |
|
{ |
1230 |
0 |
int colm = -1; |
1231 |
0 |
try |
1232 |
|
{ |
1233 |
0 |
colm = Integer.parseInt( |
1234 |
|
bn.getName().substring(bn.getName().indexOf("c") + 1)); |
1235 |
|
} catch (Exception e) |
1236 |
|
{ |
1237 |
0 |
continue; |
1238 |
|
} |
1239 |
0 |
if (mcm != null) |
1240 |
|
{ |
1241 |
0 |
int[] seqpos = mcm.getMappedPositionsFor(rseq, colm); |
1242 |
0 |
if (seqpos == null) |
1243 |
|
{ |
1244 |
|
|
1245 |
0 |
continue; |
1246 |
|
} |
1247 |
|
|
1248 |
0 |
offp = rseq.findIndex(seqpos[0]) - 1; |
1249 |
|
} |
1250 |
|
else |
1251 |
|
{ |
1252 |
0 |
offp = (rseq != null) ? rseq.findIndex(rseq.getStart() + colm) |
1253 |
|
: colm; |
1254 |
|
} |
1255 |
0 |
if (!av.hasHiddenColumns() || hc.isVisible(offp)) |
1256 |
|
{ |
1257 |
0 |
if (clearSelected || cs.contains(offp)) |
1258 |
|
{ |
1259 |
0 |
cs.removeElement(offp); |
1260 |
|
} |
1261 |
|
else |
1262 |
|
{ |
1263 |
0 |
cs.addElement(offp); |
1264 |
|
} |
1265 |
|
} |
1266 |
|
} |
1267 |
0 |
PaintRefresher.Refresh(tp, av.getSequenceSetId()); |
1268 |
|
} |
1269 |
|
|
|
|
| 0% |
Uncovered Elements: 33 (33) |
Complexity: 6 |
Complexity Density: 0.26 |
|
1270 |
0 |
public void createSeqGroupFor(AlignmentPanel[] aps, Vector<BinaryNode> l,... |
1271 |
|
Color col) |
1272 |
|
{ |
1273 |
|
|
1274 |
0 |
Vector<SequenceI> sequences = new Vector<>(); |
1275 |
|
|
1276 |
0 |
for (int j = 0; j < l.size(); j++) |
1277 |
|
{ |
1278 |
0 |
SequenceI s1 = (SequenceI) l.elementAt(j).element(); |
1279 |
|
|
1280 |
0 |
if (!sequences.contains(s1)) |
1281 |
|
{ |
1282 |
0 |
sequences.addElement(s1); |
1283 |
|
} |
1284 |
|
} |
1285 |
|
|
1286 |
0 |
ColourSchemeI cs = null; |
1287 |
0 |
SequenceGroup _sg = new SequenceGroup(sequences, null, cs, true, true, |
1288 |
|
false, 0, av.getAlignment().getWidth() - 1); |
1289 |
|
|
1290 |
0 |
_sg.setName("JTreeGroup:" + _sg.hashCode()); |
1291 |
0 |
_sg.setIdColour(col); |
1292 |
|
|
1293 |
0 |
for (int a = 0; a < aps.length; a++) |
1294 |
|
{ |
1295 |
0 |
SequenceGroup sg = new SequenceGroup(_sg); |
1296 |
0 |
AlignViewport viewport = aps[a].av; |
1297 |
|
|
1298 |
|
|
1299 |
0 |
if (viewport.getGlobalColourScheme() != null) |
1300 |
|
{ |
1301 |
0 |
cs = viewport.getGlobalColourScheme().getInstance(viewport, sg); |
1302 |
0 |
sg.setColourScheme(cs); |
1303 |
0 |
sg.getGroupColourScheme().setThreshold( |
1304 |
|
viewport.getResidueShading().getThreshold(), |
1305 |
|
viewport.isIgnoreGapsConsensus()); |
1306 |
|
|
1307 |
0 |
if (viewport.getResidueShading().conservationApplied()) |
1308 |
|
{ |
1309 |
0 |
Conservation c = new Conservation("Group", sg.getSequences(null), |
1310 |
|
sg.getStartRes(), sg.getEndRes()); |
1311 |
0 |
c.calculate(); |
1312 |
0 |
c.verdict(false, viewport.getConsPercGaps()); |
1313 |
0 |
sg.cs.setConservation(c); |
1314 |
|
} |
1315 |
|
} |
1316 |
|
|
1317 |
0 |
viewport.setUpdateStructures(true); |
1318 |
|
|
1319 |
0 |
viewport.addSequenceGroup(sg); |
1320 |
|
} |
1321 |
|
} |
1322 |
|
|
1323 |
|
|
1324 |
|
|
1325 |
|
|
1326 |
|
@param |
1327 |
|
|
1328 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1329 |
0 |
public void setShowDistances(boolean state)... |
1330 |
|
{ |
1331 |
0 |
this.showDistances = state; |
1332 |
0 |
repaint(); |
1333 |
|
} |
1334 |
|
|
1335 |
|
|
1336 |
|
|
1337 |
|
|
1338 |
|
@param |
1339 |
|
|
1340 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1341 |
0 |
public void setShowBootstrap(boolean state)... |
1342 |
|
{ |
1343 |
0 |
this.showBootstrap = state; |
1344 |
0 |
repaint(); |
1345 |
|
} |
1346 |
|
|
1347 |
|
|
1348 |
|
|
1349 |
|
|
1350 |
|
@param |
1351 |
|
|
1352 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1353 |
0 |
public void setMarkPlaceholders(boolean state)... |
1354 |
|
{ |
1355 |
0 |
this.markPlaceholders = state; |
1356 |
0 |
repaint(); |
1357 |
|
} |
1358 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
1359 |
0 |
AlignmentPanel[] getAssociatedPanels()... |
1360 |
|
{ |
1361 |
0 |
if (applyToAllViews) |
1362 |
|
{ |
1363 |
0 |
return PaintRefresher.getAssociatedPanels(av.getSequenceSetId()); |
1364 |
|
} |
1365 |
|
else |
1366 |
|
{ |
1367 |
0 |
return new AlignmentPanel[] { getAssociatedPanel() }; |
1368 |
|
} |
1369 |
|
} |
1370 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1371 |
0 |
public AlignmentPanel getAssociatedPanel()... |
1372 |
|
{ |
1373 |
0 |
return ap; |
1374 |
|
} |
1375 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1376 |
0 |
public void setAssociatedPanel(AlignmentPanel ap)... |
1377 |
|
{ |
1378 |
0 |
this.ap = ap; |
1379 |
|
} |
1380 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1381 |
0 |
public AlignViewport getViewport()... |
1382 |
|
{ |
1383 |
0 |
return av; |
1384 |
|
} |
1385 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1386 |
0 |
public void setViewport(AlignViewport av)... |
1387 |
|
{ |
1388 |
0 |
this.av = av; |
1389 |
|
} |
1390 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1391 |
0 |
public float getThreshold()... |
1392 |
|
{ |
1393 |
0 |
return threshold; |
1394 |
|
} |
1395 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1396 |
0 |
public void setThreshold(float threshold)... |
1397 |
|
{ |
1398 |
0 |
this.threshold = threshold; |
1399 |
|
} |
1400 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1401 |
0 |
public boolean isApplyToAllViews()... |
1402 |
|
{ |
1403 |
0 |
return this.applyToAllViews; |
1404 |
|
} |
1405 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1406 |
0 |
public void setApplyToAllViews(boolean applyToAllViews)... |
1407 |
|
{ |
1408 |
0 |
this.applyToAllViews = applyToAllViews; |
1409 |
|
} |
1410 |
|
} |