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