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.BasicStroke; |
24 |
|
import java.awt.BorderLayout; |
25 |
|
import java.awt.Color; |
26 |
|
import java.awt.FontMetrics; |
27 |
|
import java.awt.Graphics; |
28 |
|
import java.awt.Graphics2D; |
29 |
|
import java.awt.Rectangle; |
30 |
|
import java.awt.RenderingHints; |
31 |
|
import java.awt.image.BufferedImage; |
32 |
|
import java.beans.PropertyChangeEvent; |
33 |
|
import java.util.Iterator; |
34 |
|
import java.util.List; |
35 |
|
|
36 |
|
import javax.swing.JPanel; |
37 |
|
|
38 |
|
import jalview.api.SequenceRenderer; |
39 |
|
import jalview.datamodel.AlignmentI; |
40 |
|
import jalview.datamodel.HiddenColumns; |
41 |
|
import jalview.datamodel.SearchResultsI; |
42 |
|
import jalview.datamodel.SequenceGroup; |
43 |
|
import jalview.datamodel.SequenceI; |
44 |
|
import jalview.datamodel.VisibleContigsIterator; |
45 |
|
import jalview.renderer.ScaleRenderer; |
46 |
|
import jalview.renderer.ScaleRenderer.ScaleMark; |
47 |
|
import jalview.util.Comparison; |
48 |
|
import jalview.viewmodel.ViewportListenerI; |
49 |
|
import jalview.viewmodel.ViewportRanges; |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
@SuppressWarnings("serial") |
|
|
| 62.7% |
Uncovered Elements: 372 (998) |
Complexity: 211 |
Complexity Density: 0.31 |
|
58 |
|
public class SeqCanvas extends JPanel implements ViewportListenerI |
59 |
|
{ |
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
static final int SEQS_ANNOTATION_GAP = 3; |
65 |
|
|
66 |
|
private static final String ZEROS = "0000000000"; |
67 |
|
|
68 |
|
final FeatureRenderer fr; |
69 |
|
|
70 |
|
BufferedImage img; |
71 |
|
|
72 |
|
AlignViewport av; |
73 |
|
|
74 |
|
int cursorX = 0; |
75 |
|
|
76 |
|
int cursorY = 0; |
77 |
|
|
78 |
|
private final SequenceRenderer seqRdr; |
79 |
|
|
80 |
|
boolean fastPaint = false; |
81 |
|
|
82 |
|
private boolean fastpainting = false; |
83 |
|
|
84 |
|
private AnnotationPanel annotations; |
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
private int labelWidthEast; |
90 |
|
|
91 |
|
private int labelWidthWest; |
92 |
|
|
93 |
|
int wrappedSpaceAboveAlignment; |
94 |
|
|
95 |
|
int wrappedRepeatHeightPx; |
96 |
|
|
97 |
|
private int wrappedVisibleWidths; |
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
@param |
106 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
107 |
478 |
public SeqCanvas(AlignmentPanel ap)... |
108 |
|
{ |
109 |
478 |
this.av = ap.av; |
110 |
478 |
fr = new FeatureRenderer(ap); |
111 |
478 |
seqRdr = new jalview.gui.SequenceRenderer(av); |
112 |
478 |
setLayout(new BorderLayout()); |
113 |
478 |
PaintRefresher.Register(this, av.getSequenceSetId()); |
114 |
478 |
setBackground(Color.white); |
115 |
|
|
116 |
478 |
av.getRanges().addPropertyChangeListener(this); |
117 |
|
} |
118 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
119 |
6 |
public SequenceRenderer getSequenceRenderer()... |
120 |
|
{ |
121 |
6 |
return seqRdr; |
122 |
|
} |
123 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
124 |
623 |
public FeatureRenderer getFeatureRenderer()... |
125 |
|
{ |
126 |
623 |
return fr; |
127 |
|
} |
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
@param |
134 |
|
|
135 |
|
|
136 |
|
@param |
137 |
|
|
138 |
|
@param |
139 |
|
|
140 |
|
@param |
141 |
|
|
142 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 4 |
Complexity Density: 0.25 |
|
143 |
0 |
private void drawNorthScale(Graphics g, int startx, int endx, int ypos)... |
144 |
|
{ |
145 |
0 |
int charHeight = av.getCharHeight(); |
146 |
0 |
int charWidth = av.getCharWidth(); |
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
0 |
g.setColor(Color.white); |
152 |
0 |
g.fillRect(0, ypos - charHeight - charHeight / 2, getWidth(), |
153 |
|
charHeight * 3 / 2 + 2); |
154 |
0 |
g.setColor(Color.black); |
155 |
|
|
156 |
0 |
List<ScaleMark> marks = new ScaleRenderer().calculateMarks(av, startx, |
157 |
|
endx); |
158 |
0 |
for (ScaleMark mark : marks) |
159 |
|
{ |
160 |
0 |
int mpos = mark.column; |
161 |
0 |
if (mpos < 0) |
162 |
|
{ |
163 |
0 |
continue; |
164 |
|
} |
165 |
0 |
String mstring = mark.text; |
166 |
|
|
167 |
0 |
if (mark.major) |
168 |
|
{ |
169 |
0 |
if (mstring != null) |
170 |
|
{ |
171 |
0 |
g.drawString(mstring, mpos * charWidth, ypos - (charHeight / 2)); |
172 |
|
} |
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
|
178 |
0 |
int xpos = (mpos * charWidth) + (charWidth / 2); |
179 |
0 |
g.drawLine(xpos, (ypos + 2) - (charHeight / 2), xpos, ypos - 2); |
180 |
|
} |
181 |
|
} |
182 |
|
} |
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
@param |
188 |
|
|
189 |
|
@param |
190 |
|
|
191 |
|
@param |
192 |
|
|
193 |
|
@param |
194 |
|
|
195 |
|
@param |
196 |
|
|
197 |
|
|
|
|
| 92% |
Uncovered Elements: 4 (50) |
Complexity: 11 |
Complexity Density: 0.34 |
|
198 |
424 |
void drawVerticalScale(Graphics g, final int startx, final int endx,... |
199 |
|
final int ypos, final boolean left) |
200 |
|
{ |
201 |
424 |
int charHeight = av.getCharHeight(); |
202 |
424 |
int charWidth = av.getCharWidth(); |
203 |
|
|
204 |
424 |
int yPos = ypos + charHeight; |
205 |
424 |
int startX = startx; |
206 |
424 |
int endX = endx; |
207 |
|
|
208 |
424 |
if (av.hasHiddenColumns()) |
209 |
|
{ |
210 |
414 |
HiddenColumns hiddenColumns = av.getAlignment().getHiddenColumns(); |
211 |
414 |
startX = hiddenColumns.visibleToAbsoluteColumn(startx); |
212 |
414 |
endX = hiddenColumns.visibleToAbsoluteColumn(endx); |
213 |
|
} |
214 |
424 |
FontMetrics fm = getFontMetrics(av.getFont()); |
215 |
|
|
216 |
1412 |
for (int i = 0; i < av.getAlignment().getHeight(); i++) |
217 |
|
{ |
218 |
988 |
SequenceI seq = av.getAlignment().getSequenceAt(i); |
219 |
|
|
220 |
|
|
221 |
|
|
222 |
|
|
223 |
|
|
224 |
988 |
int index = left ? startX : endX; |
225 |
988 |
int value = -1; |
226 |
1288 |
while (index >= startX && index <= endX) |
227 |
|
{ |
228 |
1288 |
if (!Comparison.isGap(seq.getCharAt(index))) |
229 |
|
{ |
230 |
988 |
value = seq.findPosition(index); |
231 |
988 |
break; |
232 |
|
} |
233 |
300 |
if (left) |
234 |
|
{ |
235 |
0 |
index++; |
236 |
|
} |
237 |
|
else |
238 |
|
{ |
239 |
300 |
index--; |
240 |
|
} |
241 |
|
} |
242 |
|
|
243 |
|
|
244 |
|
|
245 |
|
|
246 |
988 |
g.setColor(Color.white); |
247 |
988 |
int y = (yPos + (i * charHeight)) - (charHeight / 5); |
248 |
|
|
249 |
988 |
g.fillRect(0, y - charHeight, left ? labelWidthWest : labelWidthEast, |
250 |
|
charHeight + 1); |
251 |
|
|
252 |
988 |
if (value != -1) |
253 |
|
{ |
254 |
|
|
255 |
|
|
256 |
|
|
257 |
|
|
258 |
988 |
int labelSpace = left ? labelWidthWest : labelWidthEast; |
259 |
988 |
labelSpace -= charWidth / 2; |
260 |
988 |
String valueAsString = String.valueOf(value); |
261 |
988 |
int labelLength = fm.stringWidth(valueAsString); |
262 |
988 |
int xOffset = labelSpace - labelLength; |
263 |
988 |
g.setColor(Color.black); |
264 |
988 |
g.drawString(valueAsString, xOffset, y); |
265 |
|
} |
266 |
|
} |
267 |
|
|
268 |
|
} |
269 |
|
|
270 |
|
|
271 |
|
|
272 |
|
|
273 |
|
|
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
|
278 |
|
|
279 |
|
|
280 |
|
|
281 |
|
|
282 |
|
|
283 |
|
|
284 |
|
@param |
285 |
|
|
286 |
|
@param |
287 |
|
|
288 |
|
|
|
|
| 92% |
Uncovered Elements: 4 (50) |
Complexity: 9 |
Complexity Density: 0.25 |
|
289 |
76 |
public void fastPaint(int horizontal, int vertical)... |
290 |
|
{ |
291 |
|
|
292 |
|
|
293 |
|
|
294 |
|
|
295 |
76 |
if (fastpainting || img == null) |
296 |
|
{ |
297 |
62 |
return; |
298 |
|
} |
299 |
14 |
fastpainting = true; |
300 |
14 |
fastPaint = true; |
301 |
14 |
try |
302 |
|
{ |
303 |
14 |
int charHeight = av.getCharHeight(); |
304 |
14 |
int charWidth = av.getCharWidth(); |
305 |
|
|
306 |
14 |
ViewportRanges ranges = av.getRanges(); |
307 |
14 |
int startRes = ranges.getStartRes(); |
308 |
14 |
int endRes = ranges.getEndRes(); |
309 |
14 |
int startSeq = ranges.getStartSeq(); |
310 |
14 |
int endSeq = ranges.getEndSeq(); |
311 |
14 |
int transX = 0; |
312 |
14 |
int transY = 0; |
313 |
|
|
314 |
14 |
if (horizontal > 0) |
315 |
|
{ |
316 |
1 |
transX = (endRes - startRes - horizontal) * charWidth; |
317 |
1 |
startRes = endRes - horizontal; |
318 |
|
} |
319 |
13 |
else if (horizontal < 0) |
320 |
|
{ |
321 |
0 |
endRes = startRes - horizontal; |
322 |
|
} |
323 |
|
|
324 |
14 |
if (vertical > 0) |
325 |
|
{ |
326 |
8 |
startSeq = endSeq - vertical + 1; |
327 |
|
|
328 |
8 |
if (startSeq < ranges.getStartSeq()) |
329 |
|
{ |
330 |
2 |
startSeq = ranges.getStartSeq(); |
331 |
|
} |
332 |
|
else |
333 |
|
{ |
334 |
6 |
transY = img.getHeight() - (vertical * charHeight); |
335 |
|
} |
336 |
|
} |
337 |
6 |
else if (vertical < 0) |
338 |
|
{ |
339 |
5 |
endSeq = startSeq - vertical - 1; |
340 |
|
|
341 |
5 |
if (endSeq > ranges.getEndSeq()) |
342 |
|
{ |
343 |
0 |
endSeq = ranges.getEndSeq(); |
344 |
|
} |
345 |
|
} |
346 |
|
|
347 |
|
|
348 |
|
|
349 |
|
|
350 |
|
|
351 |
|
|
352 |
14 |
Graphics gg = img.getGraphics(); |
353 |
14 |
gg.copyArea(horizontal * charWidth, vertical * charHeight, |
354 |
|
img.getWidth(), img.getHeight(), -horizontal * charWidth, |
355 |
|
-vertical * charHeight); |
356 |
|
|
357 |
|
|
358 |
|
|
359 |
14 |
gg.translate(transX, transY); |
360 |
14 |
drawPanel(seqRdr, gg, startRes, endRes, startSeq, endSeq, 0); |
361 |
14 |
gg.translate(-transX, -transY); |
362 |
14 |
gg.dispose(); |
363 |
|
|
364 |
|
|
365 |
|
|
366 |
|
|
367 |
|
|
368 |
|
|
369 |
14 |
av.getAlignPanel().repaint(); |
370 |
|
} finally |
371 |
|
{ |
372 |
14 |
fastpainting = false; |
373 |
|
} |
374 |
|
} |
375 |
|
|
|
|
| 87% |
Uncovered Elements: 6 (46) |
Complexity: 13 |
Complexity Density: 0.38 |
|
376 |
3168 |
@Override... |
377 |
|
public void paintComponent(Graphics g) |
378 |
|
{ |
379 |
|
|
380 |
3168 |
int charHeight = av.getCharHeight(); |
381 |
3168 |
int charWidth = av.getCharWidth(); |
382 |
|
|
383 |
3168 |
int width = getWidth(); |
384 |
3168 |
int height = getHeight(); |
385 |
|
|
386 |
3168 |
width -= (width % charWidth); |
387 |
3168 |
height -= (height % charHeight); |
388 |
|
|
389 |
|
|
390 |
|
|
391 |
3168 |
if (width == 0 || height == 0) |
392 |
|
{ |
393 |
0 |
return; |
394 |
|
} |
395 |
|
|
396 |
3168 |
ViewportRanges ranges = av.getRanges(); |
397 |
3168 |
int startRes = ranges.getStartRes(); |
398 |
3168 |
int startSeq = ranges.getStartSeq(); |
399 |
3168 |
int endRes = ranges.getEndRes(); |
400 |
3168 |
int endSeq = ranges.getEndSeq(); |
401 |
|
|
402 |
|
|
403 |
|
|
404 |
|
|
405 |
|
|
406 |
|
|
407 |
|
|
408 |
|
|
409 |
|
|
410 |
|
|
411 |
|
|
412 |
|
|
413 |
|
|
414 |
|
|
415 |
|
|
416 |
|
|
417 |
|
|
418 |
|
|
419 |
|
|
420 |
|
|
421 |
|
|
422 |
|
|
423 |
|
|
424 |
3168 |
Rectangle vis, clip; |
425 |
? |
if (img != null |
426 |
|
&& (fastPaint |
427 |
|
|| (vis = getVisibleRect()).width != (clip = g |
428 |
|
.getClipBounds()).width |
429 |
|
|| vis.height != clip.height)) |
430 |
|
{ |
431 |
228 |
g.drawImage(img, 0, 0, this); |
432 |
228 |
drawSelectionGroup((Graphics2D) g, startRes, endRes, startSeq, |
433 |
|
endSeq); |
434 |
228 |
fastPaint = false; |
435 |
|
} |
436 |
|
else |
437 |
|
{ |
438 |
|
|
439 |
|
|
440 |
|
|
441 |
2940 |
if (img == null || width != img.getWidth() |
442 |
|
|| height != img.getHeight()) |
443 |
|
{ |
444 |
410 |
img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); |
445 |
|
} |
446 |
|
|
447 |
2940 |
Graphics2D gg = (Graphics2D) img.getGraphics(); |
448 |
2940 |
gg.setFont(av.getFont()); |
449 |
|
|
450 |
2940 |
if (av.antiAlias) |
451 |
|
{ |
452 |
692 |
gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
453 |
|
RenderingHints.VALUE_ANTIALIAS_ON); |
454 |
|
} |
455 |
|
|
456 |
2940 |
gg.setColor(Color.white); |
457 |
2940 |
gg.fillRect(0, 0, img.getWidth(), img.getHeight()); |
458 |
|
|
459 |
2940 |
if (av.getWrapAlignment()) |
460 |
|
{ |
461 |
212 |
drawWrappedPanel(seqRdr, gg, getWidth(), getHeight(), |
462 |
|
ranges.getStartRes()); |
463 |
|
} |
464 |
|
else |
465 |
|
{ |
466 |
2728 |
drawPanel(seqRdr, gg, startRes, endRes, startSeq, endSeq, 0); |
467 |
|
} |
468 |
|
|
469 |
2940 |
drawSelectionGroup(gg, startRes, endRes, startSeq, endSeq); |
470 |
|
|
471 |
2940 |
g.drawImage(img, 0, 0, this); |
472 |
2940 |
gg.dispose(); |
473 |
|
} |
474 |
|
|
475 |
3168 |
if (av.cursorMode) |
476 |
|
{ |
477 |
0 |
drawCursor(g, startRes, endRes, startSeq, endSeq); |
478 |
|
} |
479 |
|
} |
480 |
|
|
481 |
|
|
482 |
|
|
483 |
|
|
484 |
|
@param |
485 |
|
|
486 |
|
@param |
487 |
|
|
488 |
|
@param |
489 |
|
|
490 |
|
@param |
491 |
|
|
492 |
|
@param |
493 |
|
|
494 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
495 |
38 |
public void drawPanelForPrinting(Graphics g1, int startRes, int endRes,... |
496 |
|
int startSeq, int endSeq) |
497 |
|
{ |
498 |
38 |
SequenceRenderer localSeqR = new jalview.gui.SequenceRenderer(av); |
499 |
38 |
drawPanel(localSeqR, g1, startRes, endRes, startSeq, endSeq, 0); |
500 |
|
|
501 |
38 |
drawSelectionGroup((Graphics2D) g1, startRes, endRes, startSeq, endSeq); |
502 |
|
} |
503 |
|
|
504 |
|
|
505 |
|
|
506 |
|
|
507 |
|
@param |
508 |
|
|
509 |
|
@param |
510 |
|
|
511 |
|
@param |
512 |
|
|
513 |
|
@param |
514 |
|
|
515 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
516 |
0 |
public void drawWrappedPanelForPrinting(Graphics g, int canvasWidth,... |
517 |
|
int canvasHeight, int startRes) |
518 |
|
{ |
519 |
0 |
SequenceRenderer localSeqR = new jalview.gui.SequenceRenderer(av); |
520 |
0 |
drawWrappedPanel(localSeqR, g, canvasWidth, canvasHeight, startRes); |
521 |
|
|
522 |
0 |
SequenceGroup group = av.getSelectionGroup(); |
523 |
0 |
if (group != null) |
524 |
|
{ |
525 |
0 |
drawWrappedSelection((Graphics2D) g, group, canvasWidth, canvasHeight, |
526 |
|
startRes); |
527 |
|
} |
528 |
|
} |
529 |
|
|
530 |
|
|
531 |
|
|
532 |
|
|
533 |
|
|
534 |
|
@param |
535 |
|
|
536 |
|
|
537 |
|
@return |
538 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 5 |
Complexity Density: 0.62 |
|
539 |
591 |
public int getWrappedCanvasWidth(int canvasWidth)... |
540 |
|
{ |
541 |
591 |
int charWidth = av.getCharWidth(); |
542 |
|
|
543 |
591 |
FontMetrics fm = getFontMetrics(av.getFont()); |
544 |
|
|
545 |
591 |
int labelWidth = 0; |
546 |
|
|
547 |
591 |
if (av.getScaleRightWrapped() || av.getScaleLeftWrapped()) |
548 |
|
{ |
549 |
481 |
labelWidth = getLabelWidth(fm); |
550 |
|
} |
551 |
|
|
552 |
591 |
labelWidthEast = av.getScaleRightWrapped() ? labelWidth : 0; |
553 |
|
|
554 |
591 |
labelWidthWest = av.getScaleLeftWrapped() ? labelWidth : 0; |
555 |
|
|
556 |
591 |
return (canvasWidth - labelWidthEast - labelWidthWest) / charWidth; |
557 |
|
} |
558 |
|
|
|
|
| 78.6% |
Uncovered Elements: 3 (14) |
Complexity: 5 |
Complexity Density: 0.62 |
|
559 |
218 |
public int getMinimumWrappedCanvasWidth()... |
560 |
|
{ |
561 |
218 |
int charWidth = av.getCharWidth(); |
562 |
218 |
FontMetrics fm = getFontMetrics(av.getFont()); |
563 |
218 |
int labelWidth = 0; |
564 |
218 |
if (av.getScaleRightWrapped() || av.getScaleLeftWrapped()) |
565 |
|
{ |
566 |
218 |
labelWidth = getLabelWidth(fm); |
567 |
|
} |
568 |
218 |
labelWidthEast = av.getScaleRightWrapped() ? labelWidth : 0; |
569 |
218 |
labelWidthWest = av.getScaleLeftWrapped() ? labelWidth : 0; |
570 |
218 |
return labelWidthEast + labelWidthWest + charWidth; |
571 |
|
} |
572 |
|
|
573 |
|
|
574 |
|
|
575 |
|
|
576 |
|
|
577 |
|
|
578 |
|
|
579 |
|
|
580 |
|
@param |
581 |
|
@return |
582 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
583 |
699 |
protected int getLabelWidth(FontMetrics fm)... |
584 |
|
{ |
585 |
|
|
586 |
|
|
587 |
|
|
588 |
|
|
589 |
699 |
int maxWidth = 0; |
590 |
699 |
AlignmentI alignment = av.getAlignment(); |
591 |
2680 |
for (int i = 0; i < alignment.getHeight(); i++) |
592 |
|
{ |
593 |
1981 |
maxWidth = Math.max(maxWidth, alignment.getSequenceAt(i).getEnd()); |
594 |
|
} |
595 |
|
|
596 |
699 |
int length = 0; |
597 |
2816 |
for (int i = maxWidth; i > 0; i /= 10) |
598 |
|
{ |
599 |
2117 |
length++; |
600 |
|
} |
601 |
|
|
602 |
699 |
return fm.stringWidth(ZEROS.substring(0, length)) + av.getCharWidth(); |
603 |
|
} |
604 |
|
|
605 |
|
|
606 |
|
|
607 |
|
|
608 |
|
|
609 |
|
@param |
610 |
|
@param |
611 |
|
|
612 |
|
@param |
613 |
|
|
614 |
|
@param |
615 |
|
|
616 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 3 |
Complexity Density: 0.19 |
|
617 |
212 |
public void drawWrappedPanel(SequenceRenderer seqRdr, Graphics g,... |
618 |
|
int canvasWidth, int canvasHeight, final int startColumn) |
619 |
|
{ |
620 |
212 |
int wrappedWidthInResidues = calculateWrappedGeometry(canvasWidth, |
621 |
|
canvasHeight); |
622 |
|
|
623 |
212 |
av.setWrappedWidth(wrappedWidthInResidues); |
624 |
|
|
625 |
212 |
ViewportRanges ranges = av.getRanges(); |
626 |
212 |
ranges.setViewportStartAndWidth(startColumn, wrappedWidthInResidues); |
627 |
|
|
628 |
|
|
629 |
|
|
630 |
|
|
631 |
212 |
calculateWrappedGeometry(canvasWidth, canvasHeight); |
632 |
|
|
633 |
|
|
634 |
|
|
635 |
|
|
636 |
|
|
637 |
212 |
int ypos = wrappedSpaceAboveAlignment; |
638 |
212 |
int maxWidth = ranges.getVisibleAlignmentWidth(); |
639 |
|
|
640 |
212 |
int start = startColumn; |
641 |
212 |
int currentWidth = 0; |
642 |
424 |
while ((currentWidth < wrappedVisibleWidths) && (start < maxWidth)) |
643 |
|
{ |
644 |
212 |
int endColumn = Math.min(maxWidth, |
645 |
|
start + wrappedWidthInResidues - 1); |
646 |
212 |
drawWrappedWidth(seqRdr, g, ypos, start, endColumn, canvasHeight); |
647 |
212 |
ypos += wrappedRepeatHeightPx; |
648 |
212 |
start += wrappedWidthInResidues; |
649 |
212 |
currentWidth++; |
650 |
|
} |
651 |
|
|
652 |
212 |
drawWrappedDecorators(g, startColumn); |
653 |
|
} |
654 |
|
|
655 |
|
|
656 |
|
|
657 |
|
|
658 |
|
|
659 |
|
|
660 |
|
|
661 |
|
|
662 |
|
|
663 |
|
|
664 |
|
|
665 |
|
@param |
666 |
|
@param |
667 |
|
@return |
668 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (29) |
Complexity: 5 |
Complexity Density: 0.24 |
|
669 |
504 |
protected int calculateWrappedGeometry(int canvasWidth, int canvasHeight)... |
670 |
|
{ |
671 |
504 |
int charHeight = av.getCharHeight(); |
672 |
|
|
673 |
|
|
674 |
|
|
675 |
|
|
676 |
|
|
677 |
504 |
wrappedSpaceAboveAlignment = charHeight |
678 |
504 |
* (av.getScaleAboveWrapped() ? 2 : 1); |
679 |
|
|
680 |
|
|
681 |
|
|
682 |
|
|
683 |
|
|
684 |
504 |
wrappedRepeatHeightPx = wrappedSpaceAboveAlignment; |
685 |
504 |
wrappedRepeatHeightPx += av.getAlignment().getHeight() * charHeight; |
686 |
|
|
687 |
|
|
688 |
|
|
689 |
|
|
690 |
|
|
691 |
504 |
if (av.isShowAnnotation()) |
692 |
|
{ |
693 |
472 |
wrappedRepeatHeightPx += getAnnotationHeight(); |
694 |
472 |
wrappedRepeatHeightPx += SEQS_ANNOTATION_GAP; |
695 |
|
} |
696 |
|
|
697 |
|
|
698 |
|
|
699 |
|
|
700 |
|
|
701 |
504 |
ViewportRanges ranges = av.getRanges(); |
702 |
504 |
wrappedVisibleWidths = canvasHeight / wrappedRepeatHeightPx; |
703 |
504 |
int remainder = canvasHeight % wrappedRepeatHeightPx; |
704 |
504 |
if (remainder >= (wrappedSpaceAboveAlignment + charHeight)) |
705 |
|
{ |
706 |
478 |
wrappedVisibleWidths++; |
707 |
|
} |
708 |
|
|
709 |
|
|
710 |
|
|
711 |
|
|
712 |
504 |
int wrappedWidthInResidues = getWrappedCanvasWidth(canvasWidth); |
713 |
504 |
av.setWrappedWidth(wrappedWidthInResidues); |
714 |
|
|
715 |
|
|
716 |
|
|
717 |
504 |
int xMax = ranges.getVisibleAlignmentWidth(); |
718 |
504 |
int startToEnd = xMax - ranges.getStartRes(); |
719 |
504 |
int maxWidths = startToEnd / wrappedWidthInResidues; |
720 |
504 |
if (startToEnd % wrappedWidthInResidues > 0) |
721 |
|
{ |
722 |
503 |
maxWidths++; |
723 |
|
} |
724 |
504 |
wrappedVisibleWidths = Math.min(wrappedVisibleWidths, maxWidths); |
725 |
|
|
726 |
504 |
return wrappedWidthInResidues; |
727 |
|
} |
728 |
|
|
729 |
|
|
730 |
|
|
731 |
|
|
732 |
|
|
733 |
|
@param |
734 |
|
@param |
735 |
|
@param |
736 |
|
@param |
737 |
|
@param |
738 |
|
|
|
|
| 86.4% |
Uncovered Elements: 3 (22) |
Complexity: 3 |
Complexity Density: 0.17 |
|
739 |
212 |
protected void drawWrappedWidth(SequenceRenderer seqRdr, Graphics g,... |
740 |
|
final int ypos, final int startColumn, final int endColumn, |
741 |
|
final int canvasHeight) |
742 |
|
{ |
743 |
212 |
ViewportRanges ranges = av.getRanges(); |
744 |
212 |
int viewportWidth = ranges.getViewportWidth(); |
745 |
|
|
746 |
212 |
int endx = Math.min(startColumn + viewportWidth - 1, endColumn); |
747 |
|
|
748 |
|
|
749 |
|
|
750 |
|
|
751 |
|
|
752 |
|
|
753 |
212 |
int charWidth = av.getCharWidth(); |
754 |
212 |
int xOffset = labelWidthWest |
755 |
|
+ ((startColumn - ranges.getStartRes()) % viewportWidth) |
756 |
|
* charWidth; |
757 |
|
|
758 |
212 |
g.translate(xOffset, 0); |
759 |
|
|
760 |
|
|
761 |
|
|
762 |
|
|
763 |
|
|
764 |
212 |
g.setColor(Color.white); |
765 |
212 |
g.fillRect(0, ypos, (endx - startColumn + 1) * charWidth, |
766 |
|
wrappedRepeatHeightPx); |
767 |
|
|
768 |
212 |
drawPanel(seqRdr, g, startColumn, endx, 0, |
769 |
|
av.getAlignment().getHeight() - 1, ypos); |
770 |
|
|
771 |
212 |
int cHeight = av.getAlignment().getHeight() * av.getCharHeight(); |
772 |
|
|
773 |
212 |
if (av.isShowAnnotation()) |
774 |
|
{ |
775 |
212 |
final int yShift = cHeight + ypos + SEQS_ANNOTATION_GAP; |
776 |
212 |
g.translate(0, yShift); |
777 |
212 |
if (annotations == null) |
778 |
|
{ |
779 |
0 |
annotations = new AnnotationPanel(av); |
780 |
|
} |
781 |
|
|
782 |
212 |
annotations.renderer.drawComponent(annotations, av, g, -1, |
783 |
|
startColumn, endx + 1); |
784 |
212 |
g.translate(0, -yShift); |
785 |
|
} |
786 |
212 |
g.translate(-xOffset, 0); |
787 |
|
} |
788 |
|
|
789 |
|
|
790 |
|
|
791 |
|
|
792 |
|
|
793 |
|
@param |
794 |
|
@param |
795 |
|
|
|
|
| 90.5% |
Uncovered Elements: 4 (42) |
Complexity: 7 |
Complexity Density: 0.22 |
|
796 |
212 |
protected void drawWrappedDecorators(Graphics g, final int startColumn)... |
797 |
|
{ |
798 |
212 |
int charWidth = av.getCharWidth(); |
799 |
|
|
800 |
212 |
g.setFont(av.getFont()); |
801 |
|
|
802 |
212 |
g.setColor(Color.black); |
803 |
|
|
804 |
212 |
int ypos = wrappedSpaceAboveAlignment; |
805 |
212 |
ViewportRanges ranges = av.getRanges(); |
806 |
212 |
int viewportWidth = ranges.getViewportWidth(); |
807 |
212 |
int maxWidth = ranges.getVisibleAlignmentWidth(); |
808 |
212 |
int widthsDrawn = 0; |
809 |
212 |
int startCol = startColumn; |
810 |
|
|
811 |
424 |
while (widthsDrawn < wrappedVisibleWidths) |
812 |
|
{ |
813 |
212 |
int endColumn = Math.min(maxWidth, startCol + viewportWidth - 1); |
814 |
|
|
815 |
212 |
if (av.getScaleLeftWrapped()) |
816 |
|
{ |
817 |
212 |
drawVerticalScale(g, startCol, endColumn - 1, ypos, true); |
818 |
|
} |
819 |
|
|
820 |
212 |
if (av.getScaleRightWrapped()) |
821 |
|
{ |
822 |
212 |
int x = labelWidthWest + viewportWidth * charWidth; |
823 |
|
|
824 |
212 |
g.translate(x, 0); |
825 |
212 |
drawVerticalScale(g, startCol, endColumn, ypos, false); |
826 |
212 |
g.translate(-x, 0); |
827 |
|
} |
828 |
|
|
829 |
|
|
830 |
|
|
831 |
|
|
832 |
|
|
833 |
212 |
g.translate(labelWidthWest, 0); |
834 |
212 |
g.setColor(Color.white); |
835 |
212 |
g.fillRect(0, ypos - wrappedSpaceAboveAlignment, |
836 |
|
viewportWidth * charWidth + labelWidthWest, |
837 |
|
wrappedSpaceAboveAlignment); |
838 |
212 |
g.setColor(Color.black); |
839 |
212 |
g.translate(-labelWidthWest, 0); |
840 |
|
|
841 |
212 |
g.translate(labelWidthWest, 0); |
842 |
|
|
843 |
212 |
if (av.getScaleAboveWrapped()) |
844 |
|
{ |
845 |
0 |
drawNorthScale(g, startCol, endColumn, ypos); |
846 |
|
} |
847 |
|
|
848 |
212 |
if (av.hasHiddenColumns() && av.getShowHiddenMarkers()) |
849 |
|
{ |
850 |
207 |
drawHiddenColumnMarkers(g, ypos, startCol, endColumn); |
851 |
|
} |
852 |
|
|
853 |
212 |
g.translate(-labelWidthWest, 0); |
854 |
|
|
855 |
212 |
ypos += wrappedRepeatHeightPx; |
856 |
212 |
startCol += viewportWidth; |
857 |
212 |
widthsDrawn++; |
858 |
|
} |
859 |
|
} |
860 |
|
|
861 |
|
|
862 |
|
|
863 |
|
|
864 |
|
|
865 |
|
@param |
866 |
|
@param |
867 |
|
@param |
868 |
|
@param |
869 |
|
|
|
|
| 89.5% |
Uncovered Elements: 2 (19) |
Complexity: 4 |
Complexity Density: 0.27 |
|
870 |
207 |
protected void drawHiddenColumnMarkers(Graphics g, int ypos,... |
871 |
|
int startColumn, int endColumn) |
872 |
|
{ |
873 |
207 |
int charHeight = av.getCharHeight(); |
874 |
207 |
int charWidth = av.getCharWidth(); |
875 |
|
|
876 |
207 |
g.setColor(Color.blue); |
877 |
207 |
int res; |
878 |
207 |
HiddenColumns hidden = av.getAlignment().getHiddenColumns(); |
879 |
|
|
880 |
207 |
Iterator<Integer> it = hidden.getStartRegionIterator(startColumn, |
881 |
|
endColumn); |
882 |
414 |
while (it.hasNext()) |
883 |
|
{ |
884 |
207 |
res = it.next() - startColumn; |
885 |
|
|
886 |
207 |
if (res < 0 || res > endColumn - startColumn + 1) |
887 |
|
{ |
888 |
0 |
continue; |
889 |
|
} |
890 |
|
|
891 |
|
|
892 |
|
|
893 |
|
|
894 |
|
|
895 |
207 |
int xMiddle = res * charWidth; |
896 |
207 |
int[] xPoints = new int[] { xMiddle - charHeight / 4, |
897 |
|
xMiddle + charHeight / 4, xMiddle }; |
898 |
207 |
int yTop = ypos - (charHeight / 2); |
899 |
207 |
int[] yPoints = new int[] { yTop, yTop, yTop + 8 }; |
900 |
207 |
g.fillPolygon(xPoints, yPoints, 3); |
901 |
|
} |
902 |
|
} |
903 |
|
|
904 |
|
|
905 |
|
|
906 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 4 |
Complexity Density: 0.24 |
|
907 |
0 |
private void drawWrappedSelection(Graphics2D g, SequenceGroup group,... |
908 |
|
int canvasWidth, int canvasHeight, int startRes) |
909 |
|
{ |
910 |
|
|
911 |
|
|
912 |
0 |
g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, |
913 |
|
BasicStroke.JOIN_ROUND, 3f, new float[] |
914 |
|
{ 5f, 3f }, 0f)); |
915 |
0 |
g.setColor(Color.RED); |
916 |
|
|
917 |
0 |
int charWidth = av.getCharWidth(); |
918 |
0 |
int cWidth = (canvasWidth - labelWidthEast - labelWidthWest) |
919 |
|
/ charWidth; |
920 |
0 |
int startx = startRes; |
921 |
0 |
int maxwidth = av.getAlignment().getVisibleWidth(); |
922 |
0 |
int ypos = wrappedSpaceAboveAlignment; |
923 |
|
|
924 |
0 |
while ((ypos <= canvasHeight) && (startx < maxwidth)) |
925 |
|
{ |
926 |
|
|
927 |
0 |
int endx = startx + cWidth - 1; |
928 |
|
|
929 |
0 |
if (endx > maxwidth) |
930 |
|
{ |
931 |
0 |
endx = maxwidth; |
932 |
|
} |
933 |
|
|
934 |
0 |
g.translate(labelWidthWest, 0); |
935 |
0 |
drawUnwrappedSelection(g, group, startx, endx, 0, |
936 |
|
av.getAlignment().getHeight() - 1, ypos); |
937 |
0 |
g.translate(-labelWidthWest, 0); |
938 |
|
|
939 |
0 |
ypos += wrappedRepeatHeightPx; |
940 |
|
|
941 |
0 |
startx += cWidth; |
942 |
|
} |
943 |
0 |
g.setStroke(new BasicStroke()); |
944 |
|
} |
945 |
|
|
946 |
|
|
947 |
|
|
948 |
|
|
949 |
|
|
950 |
|
@return |
951 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
952 |
544 |
int getAnnotationHeight()... |
953 |
|
{ |
954 |
544 |
if (!av.isShowAnnotation()) |
955 |
|
{ |
956 |
15 |
return 0; |
957 |
|
} |
958 |
|
|
959 |
529 |
if (annotations == null) |
960 |
|
{ |
961 |
13 |
annotations = new AnnotationPanel(av); |
962 |
|
} |
963 |
|
|
964 |
529 |
return annotations.adjustPanelHeight(); |
965 |
|
} |
966 |
|
|
967 |
|
|
968 |
|
|
969 |
|
|
970 |
|
|
971 |
|
|
972 |
|
|
973 |
|
@param |
974 |
|
|
975 |
|
|
976 |
|
|
977 |
|
@param |
978 |
|
|
979 |
|
@param |
980 |
|
|
981 |
|
@param |
982 |
|
|
983 |
|
@param |
984 |
|
|
985 |
|
@param |
986 |
|
|
987 |
|
@param |
988 |
|
|
989 |
|
|
|
|
| 93.3% |
Uncovered Elements: 2 (30) |
Complexity: 7 |
Complexity Density: 0.32 |
|
990 |
2993 |
public void drawPanel(SequenceRenderer localSeqR, Graphics g1,... |
991 |
|
final int startRes, final int endRes, final int startSeq, |
992 |
|
final int endSeq, final int yOffset) |
993 |
|
{ |
994 |
2993 |
int charHeight = av.getCharHeight(); |
995 |
2993 |
int charWidth = av.getCharWidth(); |
996 |
|
|
997 |
2993 |
if (localSeqR == null) |
998 |
|
{ |
999 |
0 |
localSeqR = seqRdr; |
1000 |
|
} |
1001 |
2993 |
if (!av.hasHiddenColumns()) |
1002 |
|
{ |
1003 |
2555 |
draw(localSeqR, g1, startRes, endRes, startSeq, endSeq, yOffset); |
1004 |
|
} |
1005 |
|
else |
1006 |
|
{ |
1007 |
438 |
int screenY = 0; |
1008 |
438 |
int blockStart; |
1009 |
438 |
int blockEnd; |
1010 |
|
|
1011 |
438 |
HiddenColumns hidden = av.getAlignment().getHiddenColumns(); |
1012 |
438 |
VisibleContigsIterator regions = hidden |
1013 |
|
.getVisContigsIterator(startRes, endRes + 1, true); |
1014 |
|
|
1015 |
927 |
while (regions.hasNext()) |
1016 |
|
{ |
1017 |
489 |
int[] region = regions.next(); |
1018 |
489 |
blockEnd = region[1]; |
1019 |
489 |
blockStart = region[0]; |
1020 |
|
|
1021 |
|
|
1022 |
|
|
1023 |
|
|
1024 |
|
|
1025 |
489 |
g1.translate(screenY * charWidth, 0); |
1026 |
|
|
1027 |
489 |
draw(localSeqR, g1, blockStart, blockEnd, startSeq, endSeq, |
1028 |
|
yOffset); |
1029 |
|
|
1030 |
|
|
1031 |
|
|
1032 |
|
|
1033 |
|
|
1034 |
489 |
if (av.getShowHiddenMarkers() |
1035 |
|
&& (regions.hasNext() || regions.endsAtHidden())) |
1036 |
|
{ |
1037 |
51 |
g1.setColor(Color.blue); |
1038 |
|
|
1039 |
51 |
g1.drawLine((blockEnd - blockStart + 1) * charWidth - 1, |
1040 |
|
0 + yOffset, (blockEnd - blockStart + 1) * charWidth - 1, |
1041 |
|
(endSeq - startSeq + 1) * charHeight + yOffset); |
1042 |
|
} |
1043 |
|
|
1044 |
489 |
g1.translate(-screenY * charWidth, 0); |
1045 |
489 |
screenY += blockEnd - blockStart + 1; |
1046 |
|
} |
1047 |
|
} |
1048 |
|
|
1049 |
|
} |
1050 |
|
|
1051 |
|
|
1052 |
|
|
1053 |
|
|
1054 |
|
@param |
1055 |
|
|
1056 |
|
@param |
1057 |
|
@param |
1058 |
|
|
1059 |
|
@param |
1060 |
|
|
1061 |
|
@param |
1062 |
|
|
1063 |
|
@param |
1064 |
|
|
1065 |
|
@param |
1066 |
|
|
1067 |
|
|
|
|
| 94.1% |
Uncovered Elements: 2 (34) |
Complexity: 9 |
Complexity Density: 0.45 |
|
1068 |
3044 |
private void draw(SequenceRenderer seqRdr, Graphics g, int startRes,... |
1069 |
|
int endRes, int startSeq, int endSeq, int offset) |
1070 |
|
{ |
1071 |
3044 |
int charHeight = av.getCharHeight(); |
1072 |
3044 |
int charWidth = av.getCharWidth(); |
1073 |
|
|
1074 |
3044 |
g.setFont(av.getFont()); |
1075 |
3044 |
seqRdr.prepare(g, av.isRenderGaps()); |
1076 |
|
|
1077 |
3044 |
SequenceI nextSeq; |
1078 |
|
|
1079 |
|
|
1080 |
|
|
1081 |
18576 |
for (int i = startSeq; i <= endSeq; i++) |
1082 |
|
{ |
1083 |
15532 |
nextSeq = av.getAlignment().getSequenceAt(i); |
1084 |
15532 |
if (nextSeq == null) |
1085 |
|
{ |
1086 |
|
|
1087 |
|
|
1088 |
0 |
continue; |
1089 |
|
} |
1090 |
15532 |
seqRdr.drawSequence(nextSeq, av.getAlignment().findAllGroups(nextSeq), |
1091 |
|
startRes, endRes, offset + ((i - startSeq) * charHeight)); |
1092 |
|
|
1093 |
15532 |
if (av.isShowSequenceFeatures()) |
1094 |
|
{ |
1095 |
874 |
fr.drawSequence(g, nextSeq, startRes, endRes, |
1096 |
|
offset + ((i - startSeq) * charHeight), false); |
1097 |
|
} |
1098 |
|
|
1099 |
|
|
1100 |
|
|
1101 |
|
|
1102 |
15532 |
if (av.hasSearchResults()) |
1103 |
|
{ |
1104 |
36 |
SearchResultsI searchResults = av.getSearchResults(); |
1105 |
36 |
int[] visibleResults = searchResults.getResults(nextSeq, startRes, |
1106 |
|
endRes); |
1107 |
36 |
if (visibleResults != null) |
1108 |
|
{ |
1109 |
32 |
for (int r = 0; r < visibleResults.length; r += 2) |
1110 |
|
{ |
1111 |
16 |
seqRdr.drawHighlightedText(nextSeq, visibleResults[r], |
1112 |
|
visibleResults[r + 1], |
1113 |
|
(visibleResults[r] - startRes) * charWidth, |
1114 |
|
offset + ((i - startSeq) * charHeight)); |
1115 |
|
} |
1116 |
|
} |
1117 |
|
} |
1118 |
|
} |
1119 |
|
|
1120 |
3044 |
if (av.getSelectionGroup() != null |
1121 |
|
|| av.getAlignment().getGroups().size() > 0) |
1122 |
|
{ |
1123 |
1574 |
drawGroupsBoundaries(g, startRes, endRes, startSeq, endSeq, offset); |
1124 |
|
} |
1125 |
|
|
1126 |
|
} |
1127 |
|
|
1128 |
|
|
1129 |
|
|
1130 |
|
|
1131 |
|
|
1132 |
|
@param |
1133 |
|
@param |
1134 |
|
@param |
1135 |
|
@param |
1136 |
|
@param |
1137 |
|
@param |
1138 |
|
|
|
|
| 95.5% |
Uncovered Elements: 1 (22) |
Complexity: 5 |
Complexity Density: 0.36 |
|
1139 |
1574 |
void drawGroupsBoundaries(Graphics g1, int startRes, int endRes,... |
1140 |
|
int startSeq, int endSeq, int offset) |
1141 |
|
{ |
1142 |
1574 |
Graphics2D g = (Graphics2D) g1; |
1143 |
|
|
1144 |
1574 |
SequenceGroup group = null; |
1145 |
1574 |
int groupIndex = -1; |
1146 |
|
|
1147 |
1574 |
if (av.getAlignment().getGroups().size() > 0) |
1148 |
|
{ |
1149 |
1563 |
group = av.getAlignment().getGroups().get(0); |
1150 |
1563 |
groupIndex = 0; |
1151 |
|
} |
1152 |
|
|
1153 |
1574 |
if (group != null) |
1154 |
|
{ |
1155 |
1563 |
do |
1156 |
|
{ |
1157 |
1895 |
g.setColor(group.getOutlineColour()); |
1158 |
1895 |
drawPartialGroupOutline(g, group, startRes, endRes, startSeq, |
1159 |
|
endSeq, offset); |
1160 |
|
|
1161 |
1895 |
groupIndex++; |
1162 |
1895 |
if (groupIndex >= av.getAlignment().getGroups().size()) |
1163 |
|
{ |
1164 |
1563 |
break; |
1165 |
|
} |
1166 |
332 |
group = av.getAlignment().getGroups().get(groupIndex); |
1167 |
332 |
} while (groupIndex < av.getAlignment().getGroups().size()); |
1168 |
|
} |
1169 |
|
} |
1170 |
|
|
1171 |
|
|
1172 |
|
|
1173 |
|
|
1174 |
|
@param |
1175 |
|
@param |
1176 |
|
@param |
1177 |
|
@param |
1178 |
|
@param |
1179 |
|
|
|
|
| 84.6% |
Uncovered Elements: 2 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
1180 |
3206 |
private void drawSelectionGroup(Graphics2D g, int startRes, int endRes,... |
1181 |
|
int startSeq, int endSeq) |
1182 |
|
{ |
1183 |
3206 |
SequenceGroup group = av.getSelectionGroup(); |
1184 |
3206 |
if (group == null) |
1185 |
|
{ |
1186 |
3172 |
return; |
1187 |
|
} |
1188 |
|
|
1189 |
34 |
g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, |
1190 |
|
BasicStroke.JOIN_ROUND, 3f, new float[] |
1191 |
|
{ 5f, 3f }, 0f)); |
1192 |
34 |
g.setColor(Color.RED); |
1193 |
34 |
if (!av.getWrapAlignment()) |
1194 |
|
{ |
1195 |
34 |
drawUnwrappedSelection(g, group, startRes, endRes, startSeq, endSeq, |
1196 |
|
0); |
1197 |
|
} |
1198 |
|
else |
1199 |
|
{ |
1200 |
0 |
drawWrappedSelection(g, group, getWidth(), getHeight(), |
1201 |
|
av.getRanges().getStartRes()); |
1202 |
|
} |
1203 |
34 |
g.setStroke(new BasicStroke()); |
1204 |
|
} |
1205 |
|
|
1206 |
|
|
1207 |
|
|
1208 |
|
|
1209 |
|
@param |
1210 |
|
|
1211 |
|
@param |
1212 |
|
|
1213 |
|
@param |
1214 |
|
|
1215 |
|
@param |
1216 |
|
|
1217 |
|
@return |
1218 |
|
|
1219 |
|
|
|
|
| 0% |
Uncovered Elements: 42 (42) |
Complexity: 10 |
Complexity Density: 0.33 |
|
1220 |
0 |
private void drawCursor(Graphics g, int startRes, int endRes,... |
1221 |
|
int startSeq, int endSeq) |
1222 |
|
{ |
1223 |
|
|
1224 |
0 |
int cursor_ypos = cursorY; |
1225 |
|
|
1226 |
|
|
1227 |
0 |
if (cursor_ypos >= startSeq && cursor_ypos <= endSeq) |
1228 |
|
{ |
1229 |
0 |
int yoffset = 0; |
1230 |
0 |
int xoffset = 0; |
1231 |
0 |
int startx = startRes; |
1232 |
0 |
int endx = endRes; |
1233 |
|
|
1234 |
|
|
1235 |
0 |
int cursor_xpos = av.getAlignment().getHiddenColumns() |
1236 |
|
.absoluteToVisibleColumn(cursorX); |
1237 |
|
|
1238 |
0 |
if (av.getAlignment().getHiddenColumns().isVisible(cursorX)) |
1239 |
|
{ |
1240 |
|
|
1241 |
0 |
if (av.getWrapAlignment()) |
1242 |
|
{ |
1243 |
|
|
1244 |
0 |
int charHeight = av.getCharHeight(); |
1245 |
0 |
int charWidth = av.getCharWidth(); |
1246 |
0 |
int canvasWidth = getWidth(); |
1247 |
0 |
int canvasHeight = getHeight(); |
1248 |
|
|
1249 |
|
|
1250 |
0 |
int hgap = charHeight; |
1251 |
0 |
if (av.getScaleAboveWrapped()) |
1252 |
|
{ |
1253 |
0 |
hgap += charHeight; |
1254 |
|
} |
1255 |
|
|
1256 |
0 |
int cWidth = (canvasWidth - labelWidthEast - labelWidthWest) |
1257 |
|
/ charWidth; |
1258 |
0 |
int cHeight = av.getAlignment().getHeight() * charHeight; |
1259 |
|
|
1260 |
0 |
endx = startx + cWidth - 1; |
1261 |
0 |
int ypos = hgap; |
1262 |
|
|
1263 |
|
|
1264 |
0 |
while ((ypos <= canvasHeight) && (endx < cursor_xpos)) |
1265 |
|
{ |
1266 |
|
|
1267 |
0 |
ypos += cHeight + getAnnotationHeight() + hgap; |
1268 |
|
|
1269 |
|
|
1270 |
0 |
startx += cWidth; |
1271 |
0 |
endx = startx + cWidth - 1; |
1272 |
|
} |
1273 |
0 |
yoffset = ypos; |
1274 |
0 |
xoffset = labelWidthWest; |
1275 |
|
} |
1276 |
|
|
1277 |
|
|
1278 |
0 |
if (cursor_xpos >= startx && cursor_xpos <= endx) |
1279 |
|
{ |
1280 |
|
|
1281 |
0 |
SequenceI seq = av.getAlignment().getSequenceAt(cursorY); |
1282 |
0 |
char s = seq.getCharAt(cursorX); |
1283 |
|
|
1284 |
0 |
seqRdr.drawCursor(g, s, |
1285 |
|
xoffset + (cursor_xpos - startx) * av.getCharWidth(), |
1286 |
|
yoffset + (cursor_ypos - startSeq) * av.getCharHeight()); |
1287 |
|
} |
1288 |
|
} |
1289 |
|
} |
1290 |
|
} |
1291 |
|
|
1292 |
|
|
1293 |
|
|
1294 |
|
|
1295 |
|
@param |
1296 |
|
|
1297 |
|
@param |
1298 |
|
|
1299 |
|
@param |
1300 |
|
|
1301 |
|
@param |
1302 |
|
|
1303 |
|
@param |
1304 |
|
|
1305 |
|
@param |
1306 |
|
|
1307 |
|
@param |
1308 |
|
|
1309 |
|
|
|
|
| 20% |
Uncovered Elements: 16 (20) |
Complexity: 3 |
Complexity Density: 0.19 |
|
1310 |
34 |
private void drawUnwrappedSelection(Graphics2D g, SequenceGroup group,... |
1311 |
|
int startRes, int endRes, int startSeq, int endSeq, int offset) |
1312 |
|
{ |
1313 |
34 |
int charWidth = av.getCharWidth(); |
1314 |
|
|
1315 |
34 |
if (!av.hasHiddenColumns()) |
1316 |
|
{ |
1317 |
34 |
drawPartialGroupOutline(g, group, startRes, endRes, startSeq, endSeq, |
1318 |
|
offset); |
1319 |
|
} |
1320 |
|
else |
1321 |
|
{ |
1322 |
|
|
1323 |
0 |
int screenY = 0; |
1324 |
0 |
int blockStart; |
1325 |
0 |
int blockEnd; |
1326 |
|
|
1327 |
0 |
HiddenColumns hidden = av.getAlignment().getHiddenColumns(); |
1328 |
0 |
VisibleContigsIterator regions = hidden |
1329 |
|
.getVisContigsIterator(startRes, endRes + 1, true); |
1330 |
0 |
while (regions.hasNext()) |
1331 |
|
{ |
1332 |
0 |
int[] region = regions.next(); |
1333 |
0 |
blockEnd = region[1]; |
1334 |
0 |
blockStart = region[0]; |
1335 |
|
|
1336 |
0 |
g.translate(screenY * charWidth, 0); |
1337 |
0 |
drawPartialGroupOutline(g, group, blockStart, blockEnd, startSeq, |
1338 |
|
endSeq, offset); |
1339 |
|
|
1340 |
0 |
g.translate(-screenY * charWidth, 0); |
1341 |
0 |
screenY += blockEnd - blockStart + 1; |
1342 |
|
} |
1343 |
|
} |
1344 |
|
} |
1345 |
|
|
1346 |
|
|
1347 |
|
|
1348 |
|
|
1349 |
|
@param |
1350 |
|
@param |
1351 |
|
@param |
1352 |
|
@param |
1353 |
|
@param |
1354 |
|
@param |
1355 |
|
@param |
1356 |
|
|
|
|
| 96.1% |
Uncovered Elements: 2 (51) |
Complexity: 15 |
Complexity Density: 0.45 |
|
1357 |
1929 |
private void drawPartialGroupOutline(Graphics2D g, SequenceGroup group,... |
1358 |
|
int startRes, int endRes, int startSeq, int endSeq, |
1359 |
|
int verticalOffset) |
1360 |
|
{ |
1361 |
1929 |
int charHeight = av.getCharHeight(); |
1362 |
1929 |
int charWidth = av.getCharWidth(); |
1363 |
1929 |
int visWidth = (endRes - startRes + 1) * charWidth; |
1364 |
|
|
1365 |
1929 |
int oldY = -1; |
1366 |
1929 |
int i = 0; |
1367 |
1929 |
boolean inGroup = false; |
1368 |
1929 |
int top = -1; |
1369 |
1929 |
int bottom = -1; |
1370 |
1929 |
int sy = -1; |
1371 |
|
|
1372 |
1929 |
List<SequenceI> seqs = group.getSequences(null); |
1373 |
|
|
1374 |
|
|
1375 |
1929 |
int sx = (group.getStartRes() - startRes) * charWidth; |
1376 |
|
|
1377 |
|
|
1378 |
1929 |
int xwidth = (((group.getEndRes() + 1) - group.getStartRes()) |
1379 |
|
* charWidth) - 1; |
1380 |
|
|
1381 |
1929 |
if (!(sx + xwidth < 0 || sx > visWidth)) |
1382 |
|
{ |
1383 |
11618 |
for (i = startSeq; i <= endSeq; i++) |
1384 |
|
{ |
1385 |
9689 |
sy = verticalOffset + (i - startSeq) * charHeight; |
1386 |
|
|
1387 |
9689 |
if ((sx <= (endRes - startRes) * charWidth) |
1388 |
|
&& seqs.contains(av.getAlignment().getSequenceAt(i))) |
1389 |
|
{ |
1390 |
7909 |
if ((bottom == -1) |
1391 |
|
&& !seqs.contains(av.getAlignment().getSequenceAt(i + 1))) |
1392 |
|
{ |
1393 |
230 |
bottom = sy + charHeight; |
1394 |
|
} |
1395 |
|
|
1396 |
7909 |
if (!inGroup) |
1397 |
|
{ |
1398 |
1602 |
if (((top == -1) && (i == 0)) || !seqs |
1399 |
|
.contains(av.getAlignment().getSequenceAt(i - 1))) |
1400 |
|
{ |
1401 |
1602 |
top = sy; |
1402 |
|
} |
1403 |
|
|
1404 |
1602 |
oldY = sy; |
1405 |
1602 |
inGroup = true; |
1406 |
|
} |
1407 |
|
} |
1408 |
1780 |
else if (inGroup) |
1409 |
|
{ |
1410 |
69 |
drawVerticals(g, sx, xwidth, visWidth, oldY, bottom); |
1411 |
69 |
drawHorizontals(g, sx, xwidth, visWidth, top, bottom); |
1412 |
|
|
1413 |
|
|
1414 |
69 |
top = -1; |
1415 |
69 |
bottom = -1; |
1416 |
69 |
inGroup = false; |
1417 |
|
} |
1418 |
|
} |
1419 |
1929 |
if (inGroup) |
1420 |
|
{ |
1421 |
1533 |
sy = verticalOffset + ((i - startSeq) * charHeight); |
1422 |
1533 |
drawVerticals(g, sx, xwidth, visWidth, oldY, |
1423 |
1533 |
bottom == -1 ? sy : bottom); |
1424 |
1533 |
drawHorizontals(g, sx, xwidth, visWidth, top, bottom); |
1425 |
|
} |
1426 |
|
} |
1427 |
|
} |
1428 |
|
|
1429 |
|
|
1430 |
|
|
1431 |
|
|
1432 |
|
@param |
1433 |
|
|
1434 |
|
@param |
1435 |
|
|
1436 |
|
@param |
1437 |
|
|
1438 |
|
@param |
1439 |
|
|
1440 |
|
@param |
1441 |
|
|
1442 |
|
@param |
1443 |
|
|
1444 |
|
|
|
|
| 94.7% |
Uncovered Elements: 1 (19) |
Complexity: 5 |
Complexity Density: 0.45 |
|
1445 |
1602 |
private void drawHorizontals(Graphics2D g, int sx, int xwidth,... |
1446 |
|
int visWidth, int top, int bottom) |
1447 |
|
{ |
1448 |
1602 |
int width = xwidth; |
1449 |
1602 |
int startx = sx; |
1450 |
1602 |
if (startx < 0) |
1451 |
|
{ |
1452 |
680 |
width += startx; |
1453 |
680 |
startx = 0; |
1454 |
|
} |
1455 |
|
|
1456 |
|
|
1457 |
|
|
1458 |
1602 |
if (startx + width >= visWidth) |
1459 |
|
{ |
1460 |
1538 |
width = visWidth - startx; |
1461 |
|
} |
1462 |
|
|
1463 |
1602 |
if (top != -1) |
1464 |
|
{ |
1465 |
1602 |
g.drawLine(startx, top, startx + width, top); |
1466 |
|
} |
1467 |
|
|
1468 |
1602 |
if (bottom != -1) |
1469 |
|
{ |
1470 |
230 |
g.drawLine(startx, bottom - 1, startx + width, bottom - 1); |
1471 |
|
} |
1472 |
|
} |
1473 |
|
|
1474 |
|
|
1475 |
|
|
1476 |
|
|
1477 |
|
|
1478 |
|
@param |
1479 |
|
|
1480 |
|
@param |
1481 |
|
|
1482 |
|
@param |
1483 |
|
|
1484 |
|
@param |
1485 |
|
|
1486 |
|
@param |
1487 |
|
|
1488 |
|
@param |
1489 |
|
|
1490 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 4 |
Complexity Density: 1 |
|
1491 |
1602 |
private void drawVerticals(Graphics2D g, int sx, int xwidth, int visWidth,... |
1492 |
|
int oldY, int sy) |
1493 |
|
{ |
1494 |
|
|
1495 |
|
|
1496 |
1602 |
if (sx >= 0 && sx < visWidth) |
1497 |
|
{ |
1498 |
922 |
g.drawLine(sx, oldY, sx, sy - 1); |
1499 |
|
} |
1500 |
|
|
1501 |
|
|
1502 |
|
|
1503 |
1602 |
if (sx + xwidth < visWidth) |
1504 |
|
{ |
1505 |
64 |
g.drawLine(sx + xwidth, oldY, sx + xwidth, sy - 1); |
1506 |
|
} |
1507 |
|
} |
1508 |
|
|
1509 |
|
|
1510 |
|
|
1511 |
|
|
1512 |
|
|
1513 |
|
|
1514 |
|
|
1515 |
|
|
1516 |
|
@param |
1517 |
|
@return |
1518 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1519 |
0 |
public boolean highlightSearchResults(SearchResultsI results)... |
1520 |
|
{ |
1521 |
0 |
return highlightSearchResults(results, false); |
1522 |
|
|
1523 |
|
} |
1524 |
|
|
1525 |
|
|
1526 |
|
|
1527 |
|
|
1528 |
|
|
1529 |
|
|
1530 |
|
|
1531 |
|
|
1532 |
|
|
1533 |
|
|
1534 |
|
|
1535 |
|
|
1536 |
|
|
1537 |
|
|
1538 |
|
|
1539 |
|
|
1540 |
|
|
1541 |
|
@param |
1542 |
|
@param |
1543 |
|
|
1544 |
|
|
1545 |
|
@return |
1546 |
|
|
|
|
| 77.8% |
Uncovered Elements: 6 (27) |
Complexity: 4 |
Complexity Density: 0.19 |
|
1547 |
2 |
public boolean highlightSearchResults(SearchResultsI results,... |
1548 |
|
boolean doFastPaint) |
1549 |
|
{ |
1550 |
2 |
if (fastpainting) |
1551 |
|
{ |
1552 |
0 |
return false; |
1553 |
|
} |
1554 |
2 |
boolean wrapped = av.getWrapAlignment(); |
1555 |
2 |
try |
1556 |
|
{ |
1557 |
2 |
fastPaint = doFastPaint; |
1558 |
2 |
fastpainting = fastPaint; |
1559 |
|
|
1560 |
|
|
1561 |
|
|
1562 |
|
|
1563 |
|
|
1564 |
|
|
1565 |
2 |
SearchResultsI previous = av.getSearchResults(); |
1566 |
2 |
av.setSearchResults(results); |
1567 |
2 |
boolean redrawn = false; |
1568 |
2 |
boolean drawn = false; |
1569 |
2 |
if (wrapped) |
1570 |
|
{ |
1571 |
0 |
redrawn = drawMappedPositionsWrapped(previous); |
1572 |
0 |
drawn = drawMappedPositionsWrapped(results); |
1573 |
0 |
redrawn |= drawn; |
1574 |
|
} |
1575 |
|
else |
1576 |
|
{ |
1577 |
2 |
redrawn = drawMappedPositions(previous); |
1578 |
2 |
drawn = drawMappedPositions(results); |
1579 |
2 |
redrawn |= drawn; |
1580 |
|
} |
1581 |
|
|
1582 |
|
|
1583 |
|
|
1584 |
|
|
1585 |
2 |
if (redrawn) |
1586 |
|
{ |
1587 |
1 |
repaint(); |
1588 |
|
} |
1589 |
|
|
1590 |
|
|
1591 |
|
|
1592 |
|
|
1593 |
2 |
return drawn; |
1594 |
|
|
1595 |
|
} finally |
1596 |
|
{ |
1597 |
2 |
fastpainting = false; |
1598 |
|
} |
1599 |
|
} |
1600 |
|
|
1601 |
|
|
1602 |
|
|
1603 |
|
|
1604 |
|
|
1605 |
|
|
1606 |
|
|
1607 |
|
|
1608 |
|
|
1609 |
|
@param |
1610 |
|
@return |
1611 |
|
|
|
|
| 86% |
Uncovered Elements: 8 (57) |
Complexity: 11 |
Complexity Density: 0.27 |
|
1612 |
4 |
protected boolean drawMappedPositions(SearchResultsI results)... |
1613 |
|
{ |
1614 |
4 |
if ((results == null) || (img == null)) |
1615 |
|
{ |
1616 |
3 |
return false; |
1617 |
|
} |
1618 |
|
|
1619 |
|
|
1620 |
|
|
1621 |
|
|
1622 |
|
|
1623 |
1 |
int firstSeq = Integer.MAX_VALUE; |
1624 |
1 |
int lastSeq = -1; |
1625 |
1 |
int firstCol = Integer.MAX_VALUE; |
1626 |
1 |
int lastCol = -1; |
1627 |
1 |
boolean matchFound = false; |
1628 |
|
|
1629 |
1 |
ViewportRanges ranges = av.getRanges(); |
1630 |
1 |
int firstVisibleColumn = ranges.getStartRes(); |
1631 |
1 |
int lastVisibleColumn = ranges.getEndRes(); |
1632 |
1 |
AlignmentI alignment = av.getAlignment(); |
1633 |
1 |
if (av.hasHiddenColumns()) |
1634 |
|
{ |
1635 |
0 |
firstVisibleColumn = alignment.getHiddenColumns() |
1636 |
|
.visibleToAbsoluteColumn(firstVisibleColumn); |
1637 |
0 |
lastVisibleColumn = alignment.getHiddenColumns() |
1638 |
|
.visibleToAbsoluteColumn(lastVisibleColumn); |
1639 |
|
} |
1640 |
|
|
1641 |
6 |
for (int seqNo = ranges.getStartSeq(); seqNo <= ranges |
1642 |
|
.getEndSeq(); seqNo++) |
1643 |
|
{ |
1644 |
5 |
SequenceI seq = alignment.getSequenceAt(seqNo); |
1645 |
|
|
1646 |
5 |
int[] visibleResults = results.getResults(seq, firstVisibleColumn, |
1647 |
|
lastVisibleColumn); |
1648 |
5 |
if (visibleResults != null) |
1649 |
|
{ |
1650 |
2 |
for (int i = 0; i < visibleResults.length - 1; i += 2) |
1651 |
|
{ |
1652 |
1 |
int firstMatchedColumn = visibleResults[i]; |
1653 |
1 |
int lastMatchedColumn = visibleResults[i + 1]; |
1654 |
1 |
if (firstMatchedColumn <= lastVisibleColumn |
1655 |
|
&& lastMatchedColumn >= firstVisibleColumn) |
1656 |
|
{ |
1657 |
|
|
1658 |
|
|
1659 |
|
|
1660 |
|
|
1661 |
|
|
1662 |
1 |
matchFound = true; |
1663 |
1 |
firstSeq = Math.min(firstSeq, seqNo); |
1664 |
1 |
lastSeq = Math.max(lastSeq, seqNo); |
1665 |
1 |
firstMatchedColumn = Math.max(firstMatchedColumn, |
1666 |
|
firstVisibleColumn); |
1667 |
1 |
lastMatchedColumn = Math.min(lastMatchedColumn, |
1668 |
|
lastVisibleColumn); |
1669 |
1 |
firstCol = Math.min(firstCol, firstMatchedColumn); |
1670 |
1 |
lastCol = Math.max(lastCol, lastMatchedColumn); |
1671 |
|
} |
1672 |
|
} |
1673 |
|
} |
1674 |
|
} |
1675 |
|
|
1676 |
1 |
if (matchFound) |
1677 |
|
{ |
1678 |
1 |
if (av.hasHiddenColumns()) |
1679 |
|
{ |
1680 |
0 |
firstCol = alignment.getHiddenColumns() |
1681 |
|
.absoluteToVisibleColumn(firstCol); |
1682 |
0 |
lastCol = alignment.getHiddenColumns() |
1683 |
|
.absoluteToVisibleColumn(lastCol); |
1684 |
|
} |
1685 |
1 |
int transX = (firstCol - ranges.getStartRes()) * av.getCharWidth(); |
1686 |
1 |
int transY = (firstSeq - ranges.getStartSeq()) * av.getCharHeight(); |
1687 |
1 |
Graphics gg = img.getGraphics(); |
1688 |
1 |
gg.translate(transX, transY); |
1689 |
1 |
drawPanel(seqRdr, gg, firstCol, lastCol, firstSeq, lastSeq, 0); |
1690 |
1 |
gg.translate(-transX, -transY); |
1691 |
1 |
gg.dispose(); |
1692 |
|
} |
1693 |
|
|
1694 |
1 |
return matchFound; |
1695 |
|
} |
1696 |
|
|
|
|
| 60.3% |
Uncovered Elements: 25 (63) |
Complexity: 16 |
Complexity Density: 0.46 |
|
1697 |
632 |
@Override... |
1698 |
|
public void propertyChange(PropertyChangeEvent evt) |
1699 |
|
{ |
1700 |
632 |
String eventName = evt.getPropertyName(); |
1701 |
|
|
1702 |
|
|
1703 |
632 |
if (eventName.equals(SequenceGroup.SEQ_GROUP_CHANGED)) |
1704 |
|
{ |
1705 |
0 |
fastPaint = true; |
1706 |
0 |
repaint(); |
1707 |
0 |
return; |
1708 |
|
} |
1709 |
632 |
else if (eventName.equals(ViewportRanges.MOVE_VIEWPORT)) |
1710 |
|
{ |
1711 |
0 |
fastPaint = false; |
1712 |
|
|
1713 |
|
|
1714 |
0 |
repaint(); |
1715 |
0 |
return; |
1716 |
|
} |
1717 |
|
|
1718 |
632 |
int scrollX = 0; |
1719 |
632 |
if (eventName.equals(ViewportRanges.STARTRES) |
1720 |
|
|| eventName.equals(ViewportRanges.STARTRESANDSEQ)) |
1721 |
|
{ |
1722 |
|
|
1723 |
|
|
1724 |
36 |
if (eventName.equals(ViewportRanges.STARTRES)) |
1725 |
|
{ |
1726 |
36 |
scrollX = (int) evt.getNewValue() - (int) evt.getOldValue(); |
1727 |
|
} |
1728 |
|
else |
1729 |
|
{ |
1730 |
0 |
scrollX = ((int[]) evt.getNewValue())[0] |
1731 |
|
- ((int[]) evt.getOldValue())[0]; |
1732 |
|
} |
1733 |
36 |
ViewportRanges vpRanges = av.getRanges(); |
1734 |
|
|
1735 |
36 |
int range = vpRanges.getEndRes() - vpRanges.getStartRes() + 1; |
1736 |
36 |
if (scrollX > range) |
1737 |
|
{ |
1738 |
2 |
scrollX = range; |
1739 |
|
} |
1740 |
34 |
else if (scrollX < -range) |
1741 |
|
{ |
1742 |
0 |
scrollX = -range; |
1743 |
|
} |
1744 |
|
} |
1745 |
|
|
1746 |
|
|
1747 |
|
|
1748 |
|
|
1749 |
|
|
1750 |
632 |
if (eventName.equals(ViewportRanges.STARTRES)) |
1751 |
|
{ |
1752 |
36 |
if (av.getWrapAlignment()) |
1753 |
|
{ |
1754 |
1 |
fastPaintWrapped(scrollX); |
1755 |
|
} |
1756 |
|
else |
1757 |
|
{ |
1758 |
35 |
fastPaint(scrollX, 0); |
1759 |
|
} |
1760 |
|
} |
1761 |
596 |
else if (eventName.equals(ViewportRanges.STARTSEQ)) |
1762 |
|
{ |
1763 |
|
|
1764 |
41 |
fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue()); |
1765 |
|
} |
1766 |
555 |
else if (eventName.equals(ViewportRanges.STARTRESANDSEQ)) |
1767 |
|
{ |
1768 |
0 |
if (av.getWrapAlignment()) |
1769 |
|
{ |
1770 |
0 |
fastPaintWrapped(scrollX); |
1771 |
|
} |
1772 |
|
else |
1773 |
|
{ |
1774 |
0 |
fastPaint(scrollX, 0); |
1775 |
|
} |
1776 |
|
} |
1777 |
555 |
else if (eventName.equals(ViewportRanges.STARTSEQ)) |
1778 |
|
{ |
1779 |
|
|
1780 |
0 |
fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue()); |
1781 |
|
} |
1782 |
555 |
else if (eventName.equals(ViewportRanges.STARTRESANDSEQ)) |
1783 |
|
{ |
1784 |
0 |
if (av.getWrapAlignment()) |
1785 |
|
{ |
1786 |
0 |
fastPaintWrapped(scrollX); |
1787 |
|
} |
1788 |
|
} |
1789 |
|
} |
1790 |
|
|
1791 |
|
|
1792 |
|
|
1793 |
|
|
1794 |
|
|
1795 |
|
|
1796 |
|
|
1797 |
|
@param |
1798 |
|
|
1799 |
|
|
|
|
| 22.2% |
Uncovered Elements: 21 (27) |
Complexity: 5 |
Complexity Density: 0.24 |
|
1800 |
1 |
protected void fastPaintWrapped(int scrollX)... |
1801 |
|
{ |
1802 |
1 |
ViewportRanges ranges = av.getRanges(); |
1803 |
|
|
1804 |
1 |
if (Math.abs(scrollX) >= ranges.getViewportWidth()) |
1805 |
|
{ |
1806 |
|
|
1807 |
|
|
1808 |
|
|
1809 |
|
|
1810 |
1 |
fastPaint = false; |
1811 |
1 |
repaint(); |
1812 |
1 |
return; |
1813 |
|
} |
1814 |
|
|
1815 |
0 |
if (fastpainting || img == null) |
1816 |
|
{ |
1817 |
0 |
return; |
1818 |
|
} |
1819 |
|
|
1820 |
0 |
fastPaint = true; |
1821 |
0 |
fastpainting = true; |
1822 |
|
|
1823 |
0 |
try |
1824 |
|
{ |
1825 |
|
|
1826 |
0 |
Graphics gg = img.getGraphics(); |
1827 |
|
|
1828 |
0 |
calculateWrappedGeometry(getWidth(), getHeight()); |
1829 |
|
|
1830 |
|
|
1831 |
|
|
1832 |
|
|
1833 |
0 |
shiftWrappedAlignment(-scrollX); |
1834 |
|
|
1835 |
|
|
1836 |
|
|
1837 |
|
|
1838 |
|
|
1839 |
|
|
1840 |
0 |
if (scrollX < 0) |
1841 |
|
{ |
1842 |
0 |
int startRes = ranges.getStartRes(); |
1843 |
0 |
drawWrappedWidth(seqRdr, gg, wrappedSpaceAboveAlignment, startRes, |
1844 |
|
startRes - scrollX - 1, getHeight()); |
1845 |
|
} |
1846 |
|
else |
1847 |
|
{ |
1848 |
0 |
fastPaintWrappedAddRight(scrollX); |
1849 |
|
} |
1850 |
|
|
1851 |
|
|
1852 |
|
|
1853 |
|
|
1854 |
0 |
drawWrappedDecorators(gg, ranges.getStartRes()); |
1855 |
|
|
1856 |
0 |
gg.dispose(); |
1857 |
|
|
1858 |
0 |
repaint(); |
1859 |
|
} finally |
1860 |
|
{ |
1861 |
0 |
fastpainting = false; |
1862 |
|
} |
1863 |
|
} |
1864 |
|
|
1865 |
|
|
1866 |
|
|
1867 |
|
|
1868 |
|
|
1869 |
|
|
1870 |
|
|
1871 |
|
|
1872 |
|
@param |
1873 |
|
|
|
|
| 0% |
Uncovered Elements: 49 (49) |
Complexity: 5 |
Complexity Density: 0.12 |
|
1874 |
0 |
protected void fastPaintWrappedAddRight(int columns)... |
1875 |
|
{ |
1876 |
0 |
if (columns == 0) |
1877 |
|
{ |
1878 |
0 |
return; |
1879 |
|
} |
1880 |
|
|
1881 |
0 |
Graphics gg = img.getGraphics(); |
1882 |
|
|
1883 |
0 |
ViewportRanges ranges = av.getRanges(); |
1884 |
0 |
int viewportWidth = ranges.getViewportWidth(); |
1885 |
0 |
int charWidth = av.getCharWidth(); |
1886 |
|
|
1887 |
|
|
1888 |
|
|
1889 |
|
|
1890 |
|
|
1891 |
0 |
int visibleWidths = wrappedVisibleWidths; |
1892 |
0 |
int canvasHeight = getHeight(); |
1893 |
0 |
boolean lastWidthPartHeight = (wrappedVisibleWidths |
1894 |
|
* wrappedRepeatHeightPx) > canvasHeight; |
1895 |
|
|
1896 |
0 |
if (lastWidthPartHeight) |
1897 |
|
{ |
1898 |
0 |
int widthsAbove = Math.max(0, visibleWidths - 2); |
1899 |
0 |
int ypos = wrappedRepeatHeightPx * widthsAbove |
1900 |
|
+ wrappedSpaceAboveAlignment; |
1901 |
0 |
int endRes = ranges.getEndRes(); |
1902 |
0 |
endRes += widthsAbove * viewportWidth; |
1903 |
0 |
int startRes = endRes - columns; |
1904 |
0 |
int xOffset = ((startRes - ranges.getStartRes()) % viewportWidth) |
1905 |
|
* charWidth; |
1906 |
|
|
1907 |
|
|
1908 |
|
|
1909 |
|
|
1910 |
|
|
1911 |
0 |
gg.translate(xOffset, 0); |
1912 |
0 |
gg.setColor(Color.white); |
1913 |
0 |
gg.fillRect(labelWidthWest, ypos, (endRes - startRes + 1) * charWidth, |
1914 |
|
wrappedRepeatHeightPx); |
1915 |
0 |
gg.translate(-xOffset, 0); |
1916 |
|
|
1917 |
0 |
drawWrappedWidth(seqRdr, gg, ypos, startRes, endRes, canvasHeight); |
1918 |
|
|
1919 |
|
} |
1920 |
|
|
1921 |
|
|
1922 |
|
|
1923 |
|
|
1924 |
|
|
1925 |
|
|
1926 |
|
|
1927 |
0 |
int widthsAbove = visibleWidths - 1; |
1928 |
0 |
int ypos = wrappedRepeatHeightPx * widthsAbove |
1929 |
|
+ wrappedSpaceAboveAlignment; |
1930 |
0 |
int endRes = ranges.getEndRes(); |
1931 |
0 |
endRes += widthsAbove * viewportWidth; |
1932 |
0 |
int startRes = endRes - columns + 1; |
1933 |
|
|
1934 |
|
|
1935 |
|
|
1936 |
|
|
1937 |
0 |
int xOffset = ((startRes - ranges.getStartRes()) % viewportWidth) |
1938 |
|
* charWidth; |
1939 |
0 |
gg.translate(xOffset, 0); |
1940 |
0 |
gg.setColor(Color.white); |
1941 |
0 |
int width = viewportWidth * charWidth - xOffset; |
1942 |
0 |
gg.fillRect(labelWidthWest, ypos, width, wrappedRepeatHeightPx); |
1943 |
0 |
gg.translate(-xOffset, 0); |
1944 |
|
|
1945 |
0 |
gg.setFont(av.getFont()); |
1946 |
0 |
gg.setColor(Color.black); |
1947 |
|
|
1948 |
0 |
if (startRes < ranges.getVisibleAlignmentWidth()) |
1949 |
|
{ |
1950 |
0 |
drawWrappedWidth(seqRdr, gg, ypos, startRes, endRes, canvasHeight); |
1951 |
|
} |
1952 |
|
|
1953 |
|
|
1954 |
|
|
1955 |
|
|
1956 |
0 |
int heightBelow = canvasHeight - visibleWidths * wrappedRepeatHeightPx; |
1957 |
0 |
if (heightBelow > 0) |
1958 |
|
{ |
1959 |
0 |
gg.setColor(Color.white); |
1960 |
0 |
gg.fillRect(0, canvasHeight - heightBelow, getWidth(), heightBelow); |
1961 |
|
} |
1962 |
0 |
gg.dispose(); |
1963 |
|
} |
1964 |
|
|
1965 |
|
|
1966 |
|
|
1967 |
|
|
1968 |
|
|
1969 |
|
|
1970 |
|
|
1971 |
|
@param |
1972 |
|
|
|
|
| 0% |
Uncovered Elements: 42 (42) |
Complexity: 8 |
Complexity Density: 0.27 |
|
1973 |
0 |
protected void shiftWrappedAlignment(int positions)... |
1974 |
|
{ |
1975 |
0 |
if (positions == 0) |
1976 |
|
{ |
1977 |
0 |
return; |
1978 |
|
} |
1979 |
|
|
1980 |
0 |
Graphics gg = img.getGraphics(); |
1981 |
|
|
1982 |
0 |
int charWidth = av.getCharWidth(); |
1983 |
|
|
1984 |
0 |
int canvasHeight = getHeight(); |
1985 |
0 |
ViewportRanges ranges = av.getRanges(); |
1986 |
0 |
int viewportWidth = ranges.getViewportWidth(); |
1987 |
0 |
int widthToCopy = (ranges.getViewportWidth() - Math.abs(positions)) |
1988 |
|
* charWidth; |
1989 |
0 |
int heightToCopy = wrappedRepeatHeightPx - wrappedSpaceAboveAlignment; |
1990 |
0 |
int xMax = ranges.getVisibleAlignmentWidth(); |
1991 |
|
|
1992 |
0 |
if (positions > 0) |
1993 |
|
{ |
1994 |
|
|
1995 |
|
|
1996 |
|
|
1997 |
|
|
1998 |
|
|
1999 |
|
|
2000 |
|
|
2001 |
|
|
2002 |
|
|
2003 |
|
|
2004 |
|
|
2005 |
0 |
int y = canvasHeight / wrappedRepeatHeightPx * wrappedRepeatHeightPx; |
2006 |
0 |
y += wrappedSpaceAboveAlignment; |
2007 |
0 |
int copyFromLeftStart = labelWidthWest; |
2008 |
0 |
int copyFromRightStart = copyFromLeftStart + widthToCopy; |
2009 |
|
|
2010 |
0 |
while (y >= 0) |
2011 |
|
{ |
2012 |
|
|
2013 |
|
|
2014 |
|
|
2015 |
0 |
gg.copyArea(copyFromLeftStart, y, widthToCopy, heightToCopy, |
2016 |
|
positions * charWidth, 0); |
2017 |
0 |
if (y > 0) |
2018 |
|
{ |
2019 |
|
|
2020 |
|
|
2021 |
|
|
2022 |
|
|
2023 |
0 |
gg.copyArea(copyFromRightStart, y - wrappedRepeatHeightPx, |
2024 |
|
positions * charWidth, heightToCopy, -widthToCopy, |
2025 |
|
wrappedRepeatHeightPx); |
2026 |
|
} |
2027 |
|
|
2028 |
0 |
y -= wrappedRepeatHeightPx; |
2029 |
|
} |
2030 |
|
} |
2031 |
|
else |
2032 |
|
{ |
2033 |
|
|
2034 |
|
|
2035 |
|
|
2036 |
|
|
2037 |
|
|
2038 |
|
|
2039 |
|
|
2040 |
0 |
int xpos = av.getRanges().getStartRes(); |
2041 |
0 |
int y = wrappedSpaceAboveAlignment; |
2042 |
0 |
int copyFromRightStart = labelWidthWest - positions * charWidth; |
2043 |
|
|
2044 |
0 |
while (y < canvasHeight) |
2045 |
|
{ |
2046 |
0 |
gg.copyArea(copyFromRightStart, y, widthToCopy, heightToCopy, |
2047 |
|
positions * charWidth, 0); |
2048 |
0 |
if (y + wrappedRepeatHeightPx < canvasHeight - wrappedRepeatHeightPx |
2049 |
|
&& (xpos + viewportWidth <= xMax)) |
2050 |
|
{ |
2051 |
0 |
gg.copyArea(labelWidthWest, y + wrappedRepeatHeightPx, |
2052 |
|
-positions * charWidth, heightToCopy, widthToCopy, |
2053 |
|
-wrappedRepeatHeightPx); |
2054 |
|
} |
2055 |
0 |
y += wrappedRepeatHeightPx; |
2056 |
0 |
xpos += viewportWidth; |
2057 |
|
} |
2058 |
|
} |
2059 |
0 |
gg.dispose(); |
2060 |
|
} |
2061 |
|
|
2062 |
|
|
2063 |
|
|
2064 |
|
|
2065 |
|
|
2066 |
|
|
2067 |
|
|
2068 |
|
|
2069 |
|
@param |
2070 |
|
@return |
2071 |
|
|
|
|
| 0% |
Uncovered Elements: 68 (68) |
Complexity: 14 |
Complexity Density: 0.3 |
|
2072 |
0 |
protected boolean drawMappedPositionsWrapped(SearchResultsI results)... |
2073 |
|
{ |
2074 |
0 |
if ((results == null) || (img == null)) |
2075 |
|
{ |
2076 |
0 |
return false; |
2077 |
|
} |
2078 |
0 |
int charHeight = av.getCharHeight(); |
2079 |
|
|
2080 |
0 |
boolean matchFound = false; |
2081 |
|
|
2082 |
0 |
calculateWrappedGeometry(getWidth(), getHeight()); |
2083 |
0 |
int wrappedWidth = av.getWrappedWidth(); |
2084 |
0 |
int wrappedHeight = wrappedRepeatHeightPx; |
2085 |
|
|
2086 |
0 |
ViewportRanges ranges = av.getRanges(); |
2087 |
0 |
int canvasHeight = getHeight(); |
2088 |
0 |
int repeats = canvasHeight / wrappedHeight; |
2089 |
0 |
if (canvasHeight / wrappedHeight > 0) |
2090 |
|
{ |
2091 |
0 |
repeats++; |
2092 |
|
} |
2093 |
|
|
2094 |
0 |
int firstVisibleColumn = ranges.getStartRes(); |
2095 |
0 |
int lastVisibleColumn = ranges.getStartRes() |
2096 |
|
+ repeats * ranges.getViewportWidth() - 1; |
2097 |
|
|
2098 |
0 |
AlignmentI alignment = av.getAlignment(); |
2099 |
0 |
if (av.hasHiddenColumns()) |
2100 |
|
{ |
2101 |
0 |
firstVisibleColumn = alignment.getHiddenColumns() |
2102 |
|
.visibleToAbsoluteColumn(firstVisibleColumn); |
2103 |
0 |
lastVisibleColumn = alignment.getHiddenColumns() |
2104 |
|
.visibleToAbsoluteColumn(lastVisibleColumn); |
2105 |
|
} |
2106 |
|
|
2107 |
0 |
int gapHeight = charHeight * (av.getScaleAboveWrapped() ? 2 : 1); |
2108 |
|
|
2109 |
0 |
Graphics gg = img.getGraphics(); |
2110 |
|
|
2111 |
0 |
for (int seqNo = ranges.getStartSeq(); seqNo <= ranges |
2112 |
|
.getEndSeq(); seqNo++) |
2113 |
|
{ |
2114 |
0 |
SequenceI seq = alignment.getSequenceAt(seqNo); |
2115 |
|
|
2116 |
0 |
int[] visibleResults = results.getResults(seq, firstVisibleColumn, |
2117 |
|
lastVisibleColumn); |
2118 |
0 |
if (visibleResults != null) |
2119 |
|
{ |
2120 |
0 |
for (int i = 0; i < visibleResults.length - 1; i += 2) |
2121 |
|
{ |
2122 |
0 |
int firstMatchedColumn = visibleResults[i]; |
2123 |
0 |
int lastMatchedColumn = visibleResults[i + 1]; |
2124 |
0 |
if (firstMatchedColumn <= lastVisibleColumn |
2125 |
|
&& lastMatchedColumn >= firstVisibleColumn) |
2126 |
|
{ |
2127 |
|
|
2128 |
|
|
2129 |
|
|
2130 |
0 |
firstMatchedColumn = Math.max(firstMatchedColumn, |
2131 |
|
firstVisibleColumn); |
2132 |
0 |
lastMatchedColumn = Math.min(lastMatchedColumn, |
2133 |
|
lastVisibleColumn); |
2134 |
|
|
2135 |
|
|
2136 |
|
|
2137 |
|
|
2138 |
|
|
2139 |
0 |
for (int mappedPos = firstMatchedColumn; mappedPos <= lastMatchedColumn; mappedPos++) |
2140 |
|
{ |
2141 |
0 |
int displayColumn = mappedPos; |
2142 |
0 |
if (av.hasHiddenColumns()) |
2143 |
|
{ |
2144 |
0 |
displayColumn = alignment.getHiddenColumns() |
2145 |
|
.absoluteToVisibleColumn(displayColumn); |
2146 |
|
} |
2147 |
|
|
2148 |
|
|
2149 |
|
|
2150 |
|
|
2151 |
0 |
int transX = labelWidthWest |
2152 |
|
+ ((displayColumn - ranges.getStartRes()) |
2153 |
|
% wrappedWidth) * av.getCharWidth(); |
2154 |
|
|
2155 |
|
|
2156 |
|
|
2157 |
|
|
2158 |
0 |
int transY = gapHeight; |
2159 |
0 |
transY += (displayColumn - ranges.getStartRes()) |
2160 |
|
/ wrappedWidth * wrappedHeight; |
2161 |
0 |
transY += (seqNo - ranges.getStartSeq()) * av.getCharHeight(); |
2162 |
|
|
2163 |
|
|
2164 |
|
|
2165 |
|
|
2166 |
0 |
int yOffset = 0; |
2167 |
0 |
if (transY < getHeight()) |
2168 |
|
{ |
2169 |
0 |
matchFound = true; |
2170 |
0 |
gg.translate(transX, transY); |
2171 |
0 |
drawPanel(seqRdr, gg, displayColumn, displayColumn, seqNo, |
2172 |
|
seqNo, yOffset); |
2173 |
0 |
gg.translate(-transX, -transY); |
2174 |
|
} |
2175 |
|
} |
2176 |
|
} |
2177 |
|
} |
2178 |
|
} |
2179 |
|
} |
2180 |
|
|
2181 |
0 |
gg.dispose(); |
2182 |
|
|
2183 |
0 |
return matchFound; |
2184 |
|
} |
2185 |
|
|
2186 |
|
|
2187 |
|
|
2188 |
|
|
2189 |
|
@return |
2190 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2191 |
72 |
int getLabelWidthWest()... |
2192 |
|
{ |
2193 |
72 |
return labelWidthWest; |
2194 |
|
} |
2195 |
|
|
2196 |
|
} |