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