1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.appletgui; |
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.viewmodel.AlignmentViewport; |
32 |
|
import jalview.viewmodel.ViewportListenerI; |
33 |
|
import jalview.viewmodel.ViewportRanges; |
34 |
|
|
35 |
|
import java.awt.Color; |
36 |
|
import java.awt.FontMetrics; |
37 |
|
import java.awt.Graphics; |
38 |
|
import java.awt.Image; |
39 |
|
import java.awt.Panel; |
40 |
|
import java.beans.PropertyChangeEvent; |
41 |
|
import java.util.Iterator; |
42 |
|
|
43 |
|
@SuppressWarnings("serial") |
|
|
| 0% |
Uncovered Elements: 543 (543) |
Complexity: 140 |
Complexity Density: 0.42 |
|
44 |
|
public class SeqCanvas extends Panel implements ViewportListenerI |
45 |
|
{ |
46 |
|
FeatureRenderer fr; |
47 |
|
|
48 |
|
SequenceRenderer sr; |
49 |
|
|
50 |
|
Image img; |
51 |
|
|
52 |
|
Graphics gg; |
53 |
|
|
54 |
|
int imgWidth; |
55 |
|
|
56 |
|
int imgHeight; |
57 |
|
|
58 |
|
AlignViewport av; |
59 |
|
|
60 |
|
boolean fastPaint = false; |
61 |
|
|
62 |
|
int cursorX = 0; |
63 |
|
|
64 |
|
int cursorY = 0; |
65 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
66 |
0 |
public SeqCanvas(AlignViewport av)... |
67 |
|
{ |
68 |
0 |
this.av = av; |
69 |
0 |
fr = new FeatureRenderer(av); |
70 |
0 |
sr = new SequenceRenderer(av); |
71 |
0 |
PaintRefresher.Register(this, av.getSequenceSetId()); |
72 |
0 |
updateViewport(); |
73 |
|
|
74 |
0 |
av.getRanges().addPropertyChangeListener(this); |
75 |
|
} |
76 |
|
|
77 |
|
int avcharHeight = 0, avcharWidth = 0; |
78 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
79 |
0 |
private void updateViewport()... |
80 |
|
{ |
81 |
0 |
avcharHeight = av.getCharHeight(); |
82 |
0 |
avcharWidth = av.getCharWidth(); |
83 |
|
} |
84 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
85 |
0 |
public AlignmentViewport getViewport()... |
86 |
|
{ |
87 |
0 |
return av; |
88 |
|
} |
89 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
90 |
0 |
public FeatureRenderer getFeatureRenderer()... |
91 |
|
{ |
92 |
0 |
return fr; |
93 |
|
} |
94 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
95 |
0 |
public SequenceRenderer getSequenceRenderer()... |
96 |
|
{ |
97 |
0 |
return sr; |
98 |
|
} |
99 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 4 |
Complexity Density: 0.36 |
|
100 |
0 |
private void drawNorthScale(Graphics g, int startx, int endx, int ypos)... |
101 |
|
{ |
102 |
0 |
updateViewport(); |
103 |
0 |
g.setColor(Color.black); |
104 |
0 |
for (ScaleMark mark : new ScaleRenderer().calculateMarks(av, startx, |
105 |
|
endx)) |
106 |
|
{ |
107 |
0 |
int mpos = mark.column; |
108 |
0 |
if (mpos < 0) |
109 |
|
{ |
110 |
0 |
continue; |
111 |
|
} |
112 |
0 |
String mstring = mark.text; |
113 |
|
|
114 |
0 |
if (mark.major) |
115 |
|
{ |
116 |
0 |
if (mstring != null) |
117 |
|
{ |
118 |
0 |
g.drawString(mstring, mpos * avcharWidth, |
119 |
|
ypos - (avcharHeight / 2)); |
120 |
|
} |
121 |
0 |
g.drawLine((mpos * avcharWidth) + (avcharWidth / 2), |
122 |
|
(ypos + 2) - (avcharHeight / 2), |
123 |
|
(mpos * avcharWidth) + (avcharWidth / 2), ypos - 2); |
124 |
|
} |
125 |
|
} |
126 |
|
} |
127 |
|
|
|
|
| 0% |
Uncovered Elements: 28 (28) |
Complexity: 6 |
Complexity Density: 0.33 |
|
128 |
0 |
private void drawWestScale(Graphics g, int startx, int endx, int ypos)... |
129 |
|
{ |
130 |
0 |
FontMetrics fm = getFontMetrics(av.getFont()); |
131 |
0 |
ypos += avcharHeight; |
132 |
0 |
if (av.hasHiddenColumns()) |
133 |
|
{ |
134 |
0 |
startx = av.getAlignment().getHiddenColumns() |
135 |
|
.visibleToAbsoluteColumn(startx); |
136 |
0 |
endx = av.getAlignment().getHiddenColumns() |
137 |
|
.visibleToAbsoluteColumn(endx); |
138 |
|
} |
139 |
|
|
140 |
|
|
141 |
0 |
for (int i = 0; i < av.getAlignment().getHeight(); i++) |
142 |
|
{ |
143 |
0 |
SequenceI seq = av.getAlignment().getSequenceAt(i); |
144 |
0 |
int index = startx; |
145 |
0 |
int value = -1; |
146 |
|
|
147 |
0 |
while (index < endx) |
148 |
|
{ |
149 |
0 |
if (jalview.util.Comparison.isGap(seq.getCharAt(index))) |
150 |
|
{ |
151 |
0 |
index++; |
152 |
|
|
153 |
0 |
continue; |
154 |
|
} |
155 |
|
|
156 |
0 |
value = av.getAlignment().getSequenceAt(i).findPosition(index); |
157 |
|
|
158 |
0 |
break; |
159 |
|
} |
160 |
|
|
161 |
0 |
if (value != -1) |
162 |
|
{ |
163 |
0 |
int x = LABEL_WEST - fm.stringWidth(String.valueOf(value)) |
164 |
|
- avcharWidth / 2; |
165 |
0 |
g.drawString(value + "", x, |
166 |
|
(ypos + (i * avcharHeight)) - (avcharHeight / 5)); |
167 |
|
} |
168 |
|
} |
169 |
|
} |
170 |
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 6 |
Complexity Density: 0.38 |
|
171 |
0 |
private void drawEastScale(Graphics g, int startx, int endx, int ypos)... |
172 |
|
{ |
173 |
0 |
ypos += avcharHeight; |
174 |
|
|
175 |
0 |
if (av.hasHiddenColumns()) |
176 |
|
{ |
177 |
0 |
endx = av.getAlignment().getHiddenColumns() |
178 |
|
.visibleToAbsoluteColumn(endx); |
179 |
|
} |
180 |
|
|
181 |
0 |
SequenceI seq; |
182 |
|
|
183 |
0 |
for (int i = 0; i < av.getAlignment().getHeight(); i++) |
184 |
|
{ |
185 |
0 |
seq = av.getAlignment().getSequenceAt(i); |
186 |
0 |
int index = endx; |
187 |
0 |
int value = -1; |
188 |
|
|
189 |
0 |
while (index > startx) |
190 |
|
{ |
191 |
0 |
if (jalview.util.Comparison.isGap(seq.getCharAt(index))) |
192 |
|
{ |
193 |
0 |
index--; |
194 |
|
|
195 |
0 |
continue; |
196 |
|
} |
197 |
|
|
198 |
0 |
value = seq.findPosition(index); |
199 |
|
|
200 |
0 |
break; |
201 |
|
} |
202 |
|
|
203 |
0 |
if (value != -1) |
204 |
|
{ |
205 |
0 |
g.drawString(String.valueOf(value), 0, |
206 |
|
(ypos + (i * avcharHeight)) - (avcharHeight / 5)); |
207 |
|
} |
208 |
|
} |
209 |
|
} |
210 |
|
|
211 |
|
int lastsr = 0; |
212 |
|
|
|
|
| 0% |
Uncovered Elements: 44 (44) |
Complexity: 10 |
Complexity Density: 0.36 |
|
213 |
0 |
void fastPaint(int horizontal, int vertical)... |
214 |
|
{ |
215 |
0 |
if (fastPaint || gg == null) |
216 |
|
{ |
217 |
0 |
return; |
218 |
|
} |
219 |
|
|
220 |
0 |
ViewportRanges ranges = av.getRanges(); |
221 |
|
|
222 |
0 |
updateViewport(); |
223 |
|
|
224 |
|
|
225 |
|
|
226 |
|
|
227 |
0 |
if (lastsr + horizontal != ranges.getStartRes()) |
228 |
|
{ |
229 |
0 |
horizontal = ranges.getStartRes() - lastsr; |
230 |
|
} |
231 |
|
|
232 |
0 |
lastsr = ranges.getStartRes(); |
233 |
|
|
234 |
0 |
fastPaint = true; |
235 |
0 |
gg.copyArea(horizontal * avcharWidth, vertical * avcharHeight, |
236 |
|
imgWidth - horizontal * avcharWidth, |
237 |
|
imgHeight - vertical * avcharHeight, -horizontal * avcharWidth, |
238 |
|
-vertical * avcharHeight); |
239 |
|
|
240 |
0 |
int sr = ranges.getStartRes(), er = ranges.getEndRes(), |
241 |
|
ss = ranges.getStartSeq(), es = ranges.getEndSeq(), transX = 0, |
242 |
|
transY = 0; |
243 |
|
|
244 |
0 |
if (horizontal > 0) |
245 |
|
{ |
246 |
0 |
transX = (er - sr - horizontal) * avcharWidth; |
247 |
0 |
sr = er - horizontal; |
248 |
|
} |
249 |
0 |
else if (horizontal < 0) |
250 |
|
{ |
251 |
0 |
er = sr - horizontal; |
252 |
|
} |
253 |
|
|
254 |
0 |
else if (vertical > 0) |
255 |
|
{ |
256 |
0 |
ss = es - vertical; |
257 |
0 |
if (ss < ranges.getStartSeq()) |
258 |
|
|
259 |
|
|
260 |
|
{ |
261 |
0 |
ss = ranges.getStartSeq(); |
262 |
|
} |
263 |
|
else |
264 |
|
{ |
265 |
0 |
transY = imgHeight - ((vertical + 1) * avcharHeight); |
266 |
|
} |
267 |
|
} |
268 |
0 |
else if (vertical < 0) |
269 |
|
{ |
270 |
0 |
es = ss - vertical; |
271 |
0 |
if (es > ranges.getEndSeq()) |
272 |
|
{ |
273 |
0 |
es = ranges.getEndSeq(); |
274 |
|
} |
275 |
|
} |
276 |
|
|
277 |
0 |
gg.translate(transX, transY); |
278 |
|
|
279 |
0 |
drawPanel(gg, sr, er, ss, es, 0); |
280 |
0 |
gg.translate(-transX, -transY); |
281 |
|
|
282 |
0 |
repaint(); |
283 |
|
|
284 |
|
} |
285 |
|
|
286 |
|
|
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
|
291 |
|
|
292 |
|
|
293 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
294 |
0 |
@Override... |
295 |
|
public void update(Graphics g) |
296 |
|
{ |
297 |
0 |
paint(g); |
298 |
|
} |
299 |
|
|
|
|
| 0% |
Uncovered Elements: 36 (36) |
Complexity: 12 |
Complexity Density: 0.46 |
|
300 |
0 |
@Override... |
301 |
|
public void paint(Graphics g) |
302 |
|
{ |
303 |
|
|
304 |
0 |
if (img != null |
305 |
|
&& (fastPaint || (getSize().width != g.getClipBounds().width) |
306 |
|
|| (getSize().height != g.getClipBounds().height))) |
307 |
|
{ |
308 |
0 |
g.drawImage(img, 0, 0, this); |
309 |
0 |
fastPaint = false; |
310 |
0 |
return; |
311 |
|
} |
312 |
|
|
313 |
0 |
if (fastPaint) |
314 |
|
{ |
315 |
0 |
g.drawImage(img, 0, 0, this); |
316 |
0 |
fastPaint = false; |
317 |
0 |
return; |
318 |
|
} |
319 |
|
|
320 |
0 |
updateViewport(); |
321 |
|
|
322 |
0 |
imgWidth = this.getSize().width; |
323 |
0 |
imgHeight = this.getSize().height; |
324 |
|
|
325 |
0 |
imgWidth -= imgWidth % avcharWidth; |
326 |
0 |
imgHeight -= imgHeight % avcharHeight; |
327 |
|
|
328 |
0 |
if (imgWidth < 1 || imgHeight < 1) |
329 |
|
{ |
330 |
0 |
return; |
331 |
|
} |
332 |
|
|
333 |
0 |
if (img == null || imgWidth != img.getWidth(this) |
334 |
|
|| imgHeight != img.getHeight(this)) |
335 |
|
{ |
336 |
0 |
img = createImage(imgWidth, imgHeight); |
337 |
0 |
gg = img.getGraphics(); |
338 |
0 |
gg.setFont(av.getFont()); |
339 |
|
} |
340 |
|
|
341 |
0 |
gg.setColor(Color.white); |
342 |
0 |
gg.fillRect(0, 0, imgWidth, imgHeight); |
343 |
|
|
344 |
0 |
ViewportRanges ranges = av.getRanges(); |
345 |
|
|
346 |
0 |
if (av.getWrapAlignment()) |
347 |
|
{ |
348 |
0 |
drawWrappedPanel(gg, imgWidth, imgHeight, ranges.getStartRes()); |
349 |
|
} |
350 |
|
else |
351 |
|
{ |
352 |
0 |
drawPanel(gg, ranges.getStartRes(), ranges.getEndRes(), |
353 |
|
ranges.getStartSeq(), ranges.getEndSeq(), 0); |
354 |
|
} |
355 |
|
|
356 |
0 |
g.drawImage(img, 0, 0, this); |
357 |
|
|
358 |
|
} |
359 |
|
|
360 |
|
int LABEL_WEST, LABEL_EAST; |
361 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
362 |
0 |
public int getWrappedCanvasWidth(int cwidth)... |
363 |
|
{ |
364 |
0 |
cwidth -= cwidth % av.getCharWidth(); |
365 |
|
|
366 |
0 |
FontMetrics fm = getFontMetrics(av.getFont()); |
367 |
|
|
368 |
0 |
LABEL_EAST = 0; |
369 |
0 |
LABEL_WEST = 0; |
370 |
|
|
371 |
0 |
if (av.getScaleRightWrapped()) |
372 |
|
{ |
373 |
0 |
LABEL_EAST = fm.stringWidth(getMask()); |
374 |
|
} |
375 |
|
|
376 |
0 |
if (av.getScaleLeftWrapped()) |
377 |
|
{ |
378 |
0 |
LABEL_WEST = fm.stringWidth(getMask()); |
379 |
|
} |
380 |
|
|
381 |
0 |
return (cwidth - LABEL_EAST - LABEL_WEST) / av.getCharWidth(); |
382 |
|
} |
383 |
|
|
384 |
|
|
385 |
|
|
386 |
|
|
387 |
|
@return |
388 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 4 |
Complexity Density: 0.36 |
|
389 |
0 |
String getMask()... |
390 |
|
{ |
391 |
0 |
String mask = "0"; |
392 |
0 |
int maxWidth = 0; |
393 |
0 |
int tmp; |
394 |
0 |
AlignmentI alignment = av.getAlignment(); |
395 |
0 |
for (int i = 0; i < alignment.getHeight(); i++) |
396 |
|
{ |
397 |
0 |
tmp = alignment.getSequenceAt(i).getEnd(); |
398 |
0 |
if (tmp > maxWidth) |
399 |
|
{ |
400 |
0 |
maxWidth = tmp; |
401 |
|
} |
402 |
|
} |
403 |
|
|
404 |
0 |
for (int i = maxWidth; i > 0; i /= 10) |
405 |
|
{ |
406 |
0 |
mask += "0"; |
407 |
|
} |
408 |
0 |
return mask; |
409 |
|
} |
410 |
|
|
|
|
| 0% |
Uncovered Elements: 79 (79) |
Complexity: 16 |
Complexity Density: 0.3 |
|
411 |
0 |
private void drawWrappedPanel(Graphics g, int canvasWidth,... |
412 |
|
int canvasHeight, int startRes) |
413 |
|
{ |
414 |
0 |
AlignmentI al = av.getAlignment(); |
415 |
|
|
416 |
0 |
FontMetrics fm = getFontMetrics(av.getFont()); |
417 |
|
|
418 |
0 |
LABEL_EAST = 0; |
419 |
0 |
LABEL_WEST = 0; |
420 |
|
|
421 |
0 |
if (av.getScaleRightWrapped()) |
422 |
|
{ |
423 |
0 |
LABEL_EAST = fm.stringWidth(getMask()); |
424 |
|
} |
425 |
|
|
426 |
0 |
if (av.getScaleLeftWrapped()) |
427 |
|
{ |
428 |
0 |
LABEL_WEST = fm.stringWidth(getMask()); |
429 |
|
} |
430 |
|
|
431 |
0 |
int hgap = avcharHeight; |
432 |
0 |
if (av.getScaleAboveWrapped()) |
433 |
|
{ |
434 |
0 |
hgap += avcharHeight; |
435 |
|
} |
436 |
|
|
437 |
0 |
int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / avcharWidth; |
438 |
0 |
int cHeight = av.getAlignment().getHeight() * avcharHeight; |
439 |
|
|
440 |
0 |
av.setWrappedWidth(cWidth); |
441 |
|
|
442 |
0 |
av.getRanges().setViewportStartAndWidth(startRes, cWidth); |
443 |
|
|
444 |
0 |
int endx; |
445 |
0 |
int ypos = hgap; |
446 |
|
|
447 |
0 |
int maxwidth = av.getAlignment().getVisibleWidth(); |
448 |
|
|
449 |
0 |
while ((ypos <= canvasHeight) && (startRes < maxwidth)) |
450 |
|
{ |
451 |
0 |
endx = startRes + cWidth - 1; |
452 |
|
|
453 |
0 |
if (endx > maxwidth) |
454 |
|
{ |
455 |
0 |
endx = maxwidth; |
456 |
|
} |
457 |
|
|
458 |
0 |
g.setColor(Color.black); |
459 |
|
|
460 |
0 |
if (av.getScaleLeftWrapped()) |
461 |
|
{ |
462 |
0 |
drawWestScale(g, startRes, endx, ypos); |
463 |
|
} |
464 |
|
|
465 |
0 |
if (av.getScaleRightWrapped()) |
466 |
|
{ |
467 |
0 |
g.translate(canvasWidth - LABEL_EAST, 0); |
468 |
0 |
drawEastScale(g, startRes, endx, ypos); |
469 |
0 |
g.translate(-(canvasWidth - LABEL_EAST), 0); |
470 |
|
} |
471 |
|
|
472 |
0 |
g.translate(LABEL_WEST, 0); |
473 |
|
|
474 |
0 |
if (av.getScaleAboveWrapped()) |
475 |
|
{ |
476 |
0 |
drawNorthScale(g, startRes, endx, ypos); |
477 |
|
} |
478 |
0 |
if (av.hasHiddenColumns() && av.getShowHiddenMarkers()) |
479 |
|
{ |
480 |
0 |
HiddenColumns hidden = av.getAlignment().getHiddenColumns(); |
481 |
0 |
g.setColor(Color.blue); |
482 |
0 |
int res; |
483 |
0 |
Iterator<Integer> it = hidden.getStartRegionIterator(startRes, |
484 |
|
endx + 1); |
485 |
0 |
while (it.hasNext()) |
486 |
|
{ |
487 |
0 |
res = it.next() - startRes; |
488 |
0 |
gg.fillPolygon( |
489 |
|
new int[] |
490 |
|
{ res * avcharWidth - avcharHeight / 4, |
491 |
|
res * avcharWidth + avcharHeight / 4, |
492 |
|
res * avcharWidth }, |
493 |
|
new int[] |
494 |
|
{ ypos - (avcharHeight / 2), ypos - (avcharHeight / 2), |
495 |
|
ypos - (avcharHeight / 2) + 8 }, |
496 |
|
3); |
497 |
|
} |
498 |
|
} |
499 |
|
|
500 |
0 |
if (g.getClip() == null) |
501 |
|
{ |
502 |
0 |
g.setClip(0, 0, cWidth * avcharWidth, canvasHeight); |
503 |
|
} |
504 |
|
|
505 |
0 |
drawPanel(g, startRes, endx, 0, al.getHeight() - 1, ypos); |
506 |
0 |
g.setClip(null); |
507 |
|
|
508 |
0 |
if (av.isShowAnnotation()) |
509 |
|
{ |
510 |
0 |
g.translate(0, cHeight + ypos + 4); |
511 |
0 |
if (annotations == null) |
512 |
|
{ |
513 |
0 |
annotations = new AnnotationPanel(av); |
514 |
|
} |
515 |
|
|
516 |
0 |
annotations.drawComponent(g, startRes, endx + 1); |
517 |
0 |
g.translate(0, -cHeight - ypos - 4); |
518 |
|
} |
519 |
0 |
g.translate(-LABEL_WEST, 0); |
520 |
|
|
521 |
0 |
ypos += cHeight + getAnnotationHeight() + hgap; |
522 |
|
|
523 |
0 |
startRes += cWidth; |
524 |
|
} |
525 |
|
|
526 |
|
} |
527 |
|
|
528 |
|
AnnotationPanel annotations; |
529 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
530 |
0 |
int getAnnotationHeight()... |
531 |
|
{ |
532 |
0 |
if (!av.isShowAnnotation()) |
533 |
|
{ |
534 |
0 |
return 0; |
535 |
|
} |
536 |
|
|
537 |
0 |
if (annotations == null) |
538 |
|
{ |
539 |
0 |
annotations = new AnnotationPanel(av); |
540 |
|
} |
541 |
|
|
542 |
0 |
return annotations.adjustPanelHeight(); |
543 |
|
} |
544 |
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 6 |
Complexity Density: 0.33 |
|
545 |
0 |
private void drawPanel(Graphics g1, final int startRes, final int endRes,... |
546 |
|
final int startSeq, final int endSeq, final int offset) |
547 |
|
{ |
548 |
|
|
549 |
0 |
if (!av.hasHiddenColumns()) |
550 |
|
{ |
551 |
0 |
draw(g1, startRes, endRes, startSeq, endSeq, offset); |
552 |
|
} |
553 |
|
else |
554 |
|
{ |
555 |
0 |
int screenY = 0; |
556 |
0 |
int blockStart; |
557 |
0 |
int blockEnd; |
558 |
|
|
559 |
0 |
HiddenColumns hidden = av.getAlignment().getHiddenColumns(); |
560 |
0 |
VisibleContigsIterator regions = hidden |
561 |
|
.getVisContigsIterator(startRes, endRes + 1, true); |
562 |
|
|
563 |
0 |
while (regions.hasNext()) |
564 |
|
{ |
565 |
0 |
int[] region = regions.next(); |
566 |
0 |
blockEnd = region[1]; |
567 |
0 |
blockStart = region[0]; |
568 |
|
|
569 |
|
|
570 |
|
|
571 |
|
|
572 |
|
|
573 |
0 |
g1.translate(screenY * avcharWidth, 0); |
574 |
|
|
575 |
0 |
draw(g1, blockStart, blockEnd, startSeq, endSeq, offset); |
576 |
|
|
577 |
|
|
578 |
|
|
579 |
|
|
580 |
|
|
581 |
0 |
if (av.getShowHiddenMarkers() |
582 |
|
&& (regions.hasNext() || regions.endsAtHidden())) |
583 |
|
{ |
584 |
0 |
g1.setColor(Color.blue); |
585 |
0 |
g1.drawLine((blockEnd - blockStart + 1) * avcharWidth - 1, |
586 |
|
0 + offset, (blockEnd - blockStart + 1) * avcharWidth - 1, |
587 |
|
(endSeq - startSeq + 1) * avcharHeight + offset); |
588 |
|
} |
589 |
|
|
590 |
0 |
g1.translate(-screenY * avcharWidth, 0); |
591 |
0 |
screenY += blockEnd - blockStart + 1; |
592 |
|
} |
593 |
|
} |
594 |
|
} |
595 |
|
|
596 |
|
|
597 |
|
|
|
|
| 0% |
Uncovered Elements: 37 (37) |
Complexity: 13 |
Complexity Density: 0.62 |
|
598 |
0 |
void draw(Graphics g, int startRes, int endRes, int startSeq, int endSeq,... |
599 |
|
int offset) |
600 |
|
{ |
601 |
0 |
g.setFont(av.getFont()); |
602 |
0 |
sr.prepare(g, av.isRenderGaps()); |
603 |
0 |
updateViewport(); |
604 |
0 |
SequenceI nextSeq; |
605 |
|
|
606 |
|
|
607 |
|
|
608 |
0 |
for (int i = startSeq; i <= endSeq; i++) |
609 |
|
{ |
610 |
0 |
nextSeq = av.getAlignment().getSequenceAt(i); |
611 |
|
|
612 |
0 |
if (nextSeq == null) |
613 |
|
{ |
614 |
0 |
continue; |
615 |
|
} |
616 |
|
|
617 |
0 |
sr.drawSequence(nextSeq, av.getAlignment().findAllGroups(nextSeq), |
618 |
|
startRes, endRes, offset + ((i - startSeq) * avcharHeight)); |
619 |
|
|
620 |
0 |
if (av.isShowSequenceFeatures()) |
621 |
|
{ |
622 |
0 |
fr.drawSequence(g, nextSeq, startRes, endRes, |
623 |
|
offset + ((i - startSeq) * avcharHeight), false); |
624 |
|
} |
625 |
|
|
626 |
|
|
627 |
|
|
628 |
0 |
if (av.hasSearchResults()) |
629 |
|
{ |
630 |
0 |
int[] visibleResults = av.getSearchResults().getResults(nextSeq, |
631 |
|
startRes, endRes); |
632 |
0 |
if (visibleResults != null) |
633 |
|
{ |
634 |
0 |
for (int r = 0; r < visibleResults.length; r += 2) |
635 |
|
{ |
636 |
0 |
sr.drawHighlightedText(nextSeq, visibleResults[r], |
637 |
|
visibleResults[r + 1], |
638 |
|
(visibleResults[r] - startRes) * avcharWidth, |
639 |
|
offset + ((i - startSeq) * avcharHeight)); |
640 |
|
} |
641 |
|
} |
642 |
|
} |
643 |
|
|
644 |
0 |
if (av.cursorMode && cursorY == i && cursorX >= startRes |
645 |
|
&& cursorX <= endRes) |
646 |
|
{ |
647 |
0 |
char s = nextSeq.getCharAt(cursorX); |
648 |
|
|
649 |
0 |
sr.drawCursor(g, s, (cursorX - startRes) * avcharWidth, |
650 |
|
offset + ((i - startSeq) * avcharHeight)); |
651 |
|
} |
652 |
|
} |
653 |
|
|
654 |
0 |
if (av.getSelectionGroup() != null |
655 |
|
|| av.getAlignment().getGroups().size() > 0) |
656 |
|
{ |
657 |
0 |
drawGroupsBoundaries(g, startRes, endRes, startSeq, endSeq, offset); |
658 |
|
} |
659 |
|
|
660 |
|
} |
661 |
|
|
|
|
| 0% |
Uncovered Elements: 130 (130) |
Complexity: 37 |
Complexity Density: 0.49 |
|
662 |
0 |
private void drawGroupsBoundaries(Graphics g, int startRes, int endRes,... |
663 |
|
int startSeq, int endSeq, int offset) |
664 |
|
{ |
665 |
|
|
666 |
|
|
667 |
|
|
668 |
|
|
669 |
0 |
SequenceGroup group = av.getSelectionGroup(); |
670 |
|
|
671 |
0 |
int sx = -1; |
672 |
0 |
int sy = -1; |
673 |
0 |
int ex = -1; |
674 |
0 |
int groupIndex = -1; |
675 |
|
|
676 |
0 |
if ((group == null) && (av.getAlignment().getGroups().size() > 0)) |
677 |
|
{ |
678 |
0 |
group = av.getAlignment().getGroups().get(0); |
679 |
0 |
groupIndex = 0; |
680 |
|
} |
681 |
|
|
682 |
0 |
if (group != null) |
683 |
|
{ |
684 |
0 |
do |
685 |
|
{ |
686 |
0 |
int oldY = -1; |
687 |
0 |
int i = 0; |
688 |
0 |
boolean inGroup = false; |
689 |
0 |
int top = -1; |
690 |
0 |
int bottom = -1; |
691 |
0 |
int alHeight = av.getAlignment().getHeight() - 1; |
692 |
|
|
693 |
0 |
for (i = startSeq; i <= endSeq; i++) |
694 |
|
{ |
695 |
0 |
sx = (group.getStartRes() - startRes) * avcharWidth; |
696 |
0 |
sy = offset + ((i - startSeq) * avcharHeight); |
697 |
0 |
ex = (((group.getEndRes() + 1) - group.getStartRes()) |
698 |
|
* avcharWidth) - 1; |
699 |
|
|
700 |
0 |
if (sx + ex < 0 || sx > imgWidth) |
701 |
|
{ |
702 |
0 |
continue; |
703 |
|
} |
704 |
|
|
705 |
0 |
if ((sx <= (endRes - startRes) * avcharWidth) |
706 |
|
&& group.getSequences(null) |
707 |
|
.contains(av.getAlignment().getSequenceAt(i))) |
708 |
|
{ |
709 |
0 |
if ((bottom == -1) |
710 |
|
&& (i >= alHeight || !group.getSequences(null).contains( |
711 |
|
av.getAlignment().getSequenceAt(i + 1)))) |
712 |
|
{ |
713 |
0 |
bottom = sy + avcharHeight; |
714 |
|
} |
715 |
|
|
716 |
0 |
if (!inGroup) |
717 |
|
{ |
718 |
0 |
if (((top == -1) && (i == 0)) || !group.getSequences(null) |
719 |
|
.contains(av.getAlignment().getSequenceAt(i - 1))) |
720 |
|
{ |
721 |
0 |
top = sy; |
722 |
|
} |
723 |
|
|
724 |
0 |
oldY = sy; |
725 |
0 |
inGroup = true; |
726 |
|
|
727 |
0 |
if (group == av.getSelectionGroup()) |
728 |
|
{ |
729 |
0 |
g.setColor(Color.red); |
730 |
|
} |
731 |
|
else |
732 |
|
{ |
733 |
0 |
g.setColor(group.getOutlineColour()); |
734 |
|
} |
735 |
|
} |
736 |
|
} |
737 |
|
else |
738 |
|
{ |
739 |
0 |
if (inGroup) |
740 |
|
{ |
741 |
0 |
if (sx >= 0 && sx < imgWidth) |
742 |
|
{ |
743 |
0 |
g.drawLine(sx, oldY, sx, sy); |
744 |
|
} |
745 |
|
|
746 |
0 |
if (sx + ex < imgWidth) |
747 |
|
{ |
748 |
0 |
g.drawLine(sx + ex, oldY, sx + ex, sy); |
749 |
|
} |
750 |
|
|
751 |
0 |
if (sx < 0) |
752 |
|
{ |
753 |
0 |
ex += sx; |
754 |
0 |
sx = 0; |
755 |
|
} |
756 |
|
|
757 |
0 |
if (sx + ex > imgWidth) |
758 |
|
{ |
759 |
0 |
ex = imgWidth; |
760 |
|
} |
761 |
|
|
762 |
0 |
else if (sx + ex >= (endRes - startRes + 1) * avcharWidth) |
763 |
|
{ |
764 |
0 |
ex = (endRes - startRes + 1) * avcharWidth; |
765 |
|
} |
766 |
|
|
767 |
0 |
if (top != -1) |
768 |
|
{ |
769 |
0 |
g.drawLine(sx, top, sx + ex, top); |
770 |
0 |
top = -1; |
771 |
|
} |
772 |
|
|
773 |
0 |
if (bottom != -1) |
774 |
|
{ |
775 |
0 |
g.drawLine(sx, bottom, sx + ex, bottom); |
776 |
0 |
bottom = -1; |
777 |
|
} |
778 |
|
|
779 |
0 |
inGroup = false; |
780 |
|
} |
781 |
|
} |
782 |
|
} |
783 |
|
|
784 |
0 |
if (inGroup) |
785 |
|
{ |
786 |
0 |
sy = offset + ((i - startSeq) * avcharHeight); |
787 |
0 |
if (sx >= 0 && sx < imgWidth) |
788 |
|
{ |
789 |
0 |
g.drawLine(sx, oldY, sx, sy); |
790 |
|
} |
791 |
|
|
792 |
0 |
if (sx + ex < imgWidth) |
793 |
|
{ |
794 |
0 |
g.drawLine(sx + ex, oldY, sx + ex, sy); |
795 |
|
} |
796 |
|
|
797 |
0 |
if (sx < 0) |
798 |
|
{ |
799 |
0 |
ex += sx; |
800 |
0 |
sx = 0; |
801 |
|
} |
802 |
|
|
803 |
0 |
if (sx + ex > imgWidth) |
804 |
|
{ |
805 |
0 |
ex = imgWidth; |
806 |
|
} |
807 |
0 |
else if (sx + ex >= (endRes - startRes + 1) * avcharWidth) |
808 |
|
{ |
809 |
0 |
ex = (endRes - startRes + 1) * avcharWidth; |
810 |
|
} |
811 |
|
|
812 |
0 |
if (top != -1) |
813 |
|
{ |
814 |
0 |
g.drawLine(sx, top, sx + ex, top); |
815 |
0 |
top = -1; |
816 |
|
} |
817 |
|
|
818 |
0 |
if (bottom != -1) |
819 |
|
{ |
820 |
0 |
g.drawLine(sx, bottom - 1, sx + ex, bottom - 1); |
821 |
0 |
bottom = -1; |
822 |
|
} |
823 |
|
|
824 |
0 |
inGroup = false; |
825 |
|
} |
826 |
|
|
827 |
0 |
groupIndex++; |
828 |
|
|
829 |
0 |
if (groupIndex >= av.getAlignment().getGroups().size()) |
830 |
|
{ |
831 |
0 |
break; |
832 |
|
} |
833 |
|
|
834 |
0 |
group = av.getAlignment().getGroups().get(groupIndex); |
835 |
0 |
} while (groupIndex < av.getAlignment().getGroups().size()); |
836 |
|
|
837 |
|
} |
838 |
|
} |
839 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
840 |
0 |
public void highlightSearchResults(SearchResultsI results)... |
841 |
|
{ |
842 |
0 |
av.setSearchResults(results); |
843 |
0 |
repaint(); |
844 |
|
} |
845 |
|
|
|
|
| 0% |
Uncovered Elements: 47 (47) |
Complexity: 12 |
Complexity Density: 0.44 |
|
846 |
0 |
@Override... |
847 |
|
public void propertyChange(PropertyChangeEvent evt) |
848 |
|
{ |
849 |
0 |
String eventName = evt.getPropertyName(); |
850 |
|
|
851 |
0 |
if (eventName.equals(SequenceGroup.SEQ_GROUP_CHANGED)) |
852 |
|
{ |
853 |
0 |
fastPaint = true; |
854 |
0 |
repaint(); |
855 |
0 |
return; |
856 |
|
} |
857 |
0 |
else if (eventName.equals(ViewportRanges.MOVE_VIEWPORT)) |
858 |
|
{ |
859 |
0 |
fastPaint = false; |
860 |
0 |
repaint(); |
861 |
0 |
return; |
862 |
|
} |
863 |
|
|
864 |
0 |
if (!av.getWrapAlignment()) |
865 |
|
{ |
866 |
0 |
int scrollX = 0; |
867 |
0 |
if (eventName.equals(ViewportRanges.STARTRES) |
868 |
|
|| eventName.equals(ViewportRanges.STARTRESANDSEQ)) |
869 |
|
{ |
870 |
|
|
871 |
|
|
872 |
0 |
if (eventName.equals(ViewportRanges.STARTRES)) |
873 |
|
{ |
874 |
0 |
scrollX = (int) evt.getNewValue() - (int) evt.getOldValue(); |
875 |
|
} |
876 |
|
else |
877 |
|
{ |
878 |
0 |
scrollX = ((int[]) evt.getNewValue())[0] |
879 |
|
- ((int[]) evt.getOldValue())[0]; |
880 |
|
} |
881 |
0 |
ViewportRanges vpRanges = av.getRanges(); |
882 |
0 |
int range = vpRanges.getEndRes() - vpRanges.getStartRes(); |
883 |
0 |
if (scrollX > range) |
884 |
|
{ |
885 |
0 |
scrollX = range; |
886 |
|
} |
887 |
0 |
else if (scrollX < -range) |
888 |
|
{ |
889 |
0 |
scrollX = -range; |
890 |
|
} |
891 |
|
} |
892 |
|
|
893 |
|
|
894 |
|
|
895 |
|
|
896 |
|
|
897 |
|
|
898 |
0 |
if (eventName.equals(ViewportRanges.STARTRES)) |
899 |
|
{ |
900 |
|
|
901 |
0 |
fastPaint(scrollX, 0); |
902 |
|
} |
903 |
0 |
else if (eventName.equals(ViewportRanges.STARTSEQ)) |
904 |
|
{ |
905 |
|
|
906 |
0 |
fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue()); |
907 |
|
} |
908 |
0 |
else if (eventName.equals(ViewportRanges.STARTRESANDSEQ)) |
909 |
|
{ |
910 |
0 |
fastPaint(scrollX, 0); |
911 |
|
} |
912 |
|
} |
913 |
|
} |
914 |
|
|
915 |
|
|
916 |
|
|
917 |
|
|
918 |
|
|
919 |
|
|
920 |
|
|
921 |
|
|
922 |
|
|
923 |
|
@author |
924 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
925 |
0 |
public void clearFastPaint()... |
926 |
|
{ |
927 |
0 |
fastPaint = false; |
928 |
|
} |
929 |
|
|
930 |
|
} |