1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.viewmodel; |
22 |
|
|
23 |
|
import jalview.datamodel.AlignmentI; |
24 |
|
import jalview.datamodel.HiddenColumns; |
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
|
|
| 98.7% |
Uncovered Elements: 4 (303) |
Complexity: 86 |
Complexity Density: 0.48 |
|
32 |
|
public class ViewportRanges extends ViewportProperties |
33 |
|
{ |
34 |
|
public static final String STARTRES = "startres"; |
35 |
|
|
36 |
|
public static final String ENDRES = "endres"; |
37 |
|
|
38 |
|
public static final String STARTSEQ = "startseq"; |
39 |
|
|
40 |
|
public static final String ENDSEQ = "endseq"; |
41 |
|
|
42 |
|
public static final String STARTRESANDSEQ = "startresandseq"; |
43 |
|
|
44 |
|
public static final String MOVE_VIEWPORT = "move_viewport"; |
45 |
|
|
46 |
|
private boolean wrappedMode = false; |
47 |
|
|
48 |
|
|
49 |
|
private int startRes; |
50 |
|
|
51 |
|
|
52 |
|
private int endRes; |
53 |
|
|
54 |
|
|
55 |
|
private int startSeq; |
56 |
|
|
57 |
|
|
58 |
|
private int endSeq; |
59 |
|
|
60 |
|
|
61 |
|
private AlignmentI al; |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
@param |
67 |
|
|
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
69 |
322 |
public ViewportRanges(AlignmentI alignment)... |
70 |
|
{ |
71 |
|
|
72 |
322 |
this.startRes = 0; |
73 |
322 |
this.endRes = alignment.getWidth() - 1; |
74 |
322 |
this.startSeq = 0; |
75 |
322 |
this.endSeq = alignment.getHeight() - 1; |
76 |
322 |
this.al = alignment; |
77 |
|
} |
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
82 |
301 |
public int getAbsoluteAlignmentWidth()... |
83 |
|
{ |
84 |
301 |
return al.getWidth(); |
85 |
|
} |
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
90 |
302 |
public int getAbsoluteAlignmentHeight()... |
91 |
|
{ |
92 |
302 |
return al.getHeight() + al.getHiddenSequences().getSize(); |
93 |
|
} |
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
98 |
2463 |
public int getVisibleAlignmentWidth()... |
99 |
|
{ |
100 |
2463 |
return al.getWidth() - al.getHiddenColumns().getSize(); |
101 |
|
} |
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
106 |
2364 |
public int getVisibleAlignmentHeight()... |
107 |
|
{ |
108 |
2364 |
return al.getHeight(); |
109 |
|
} |
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
@param |
116 |
|
|
117 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
118 |
120 |
public void setStartRes(int res)... |
119 |
|
{ |
120 |
120 |
int width = getViewportWidth(); |
121 |
120 |
setStartEndRes(res, res + width - 1); |
122 |
|
} |
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
@param |
130 |
|
|
131 |
|
@param |
132 |
|
|
133 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
134 |
708 |
public void setStartEndRes(int start, int end)... |
135 |
|
{ |
136 |
708 |
int[] oldvalues = updateStartEndRes(start, end); |
137 |
708 |
int oldstartres = oldvalues[0]; |
138 |
708 |
int oldendres = oldvalues[1]; |
139 |
|
|
140 |
708 |
changeSupport.firePropertyChange(STARTRES, oldstartres, startRes); |
141 |
708 |
if (oldstartres == startRes) |
142 |
|
{ |
143 |
|
|
144 |
|
|
145 |
575 |
changeSupport.firePropertyChange(ENDRES, oldendres, endRes); |
146 |
|
} |
147 |
|
} |
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
@param |
154 |
|
|
155 |
|
@param |
156 |
|
|
157 |
|
@return |
158 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 7 |
Complexity Density: 0.5 |
|
159 |
831 |
private int[] updateStartEndRes(int start, int end)... |
160 |
|
{ |
161 |
831 |
int oldstartres = this.startRes; |
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
831 |
int lastColumn = getVisibleAlignmentWidth() - 1; |
167 |
831 |
if (!wrappedMode && (start > lastColumn)) |
168 |
|
{ |
169 |
4 |
startRes = Math.max(lastColumn, 0); |
170 |
|
} |
171 |
827 |
else if (start < 0) |
172 |
|
{ |
173 |
4 |
startRes = 0; |
174 |
|
} |
175 |
|
else |
176 |
|
{ |
177 |
823 |
startRes = start; |
178 |
|
} |
179 |
|
|
180 |
831 |
int oldendres = this.endRes; |
181 |
831 |
if (end < 0) |
182 |
|
{ |
183 |
3 |
endRes = 0; |
184 |
|
} |
185 |
828 |
else if (!wrappedMode && (end > lastColumn)) |
186 |
|
{ |
187 |
75 |
endRes = Math.max(lastColumn, 0); |
188 |
|
} |
189 |
|
else |
190 |
|
{ |
191 |
753 |
endRes = end; |
192 |
|
} |
193 |
831 |
return new int[] { oldstartres, oldendres }; |
194 |
|
} |
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
|
200 |
|
|
201 |
|
@param |
202 |
|
|
203 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
204 |
386 |
public void setStartSeq(int seq)... |
205 |
|
{ |
206 |
386 |
int startseq = seq; |
207 |
386 |
int height = getViewportHeight(); |
208 |
386 |
if (startseq + height - 1 > getVisibleAlignmentHeight() - 1) |
209 |
|
{ |
210 |
69 |
startseq = getVisibleAlignmentHeight() - height; |
211 |
|
} |
212 |
386 |
setStartEndSeq(startseq, startseq + height - 1); |
213 |
|
} |
214 |
|
|
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
@param |
221 |
|
|
222 |
|
@param |
223 |
|
|
224 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
225 |
864 |
public void setStartEndSeq(int start, int end)... |
226 |
|
{ |
227 |
864 |
int[] oldvalues = updateStartEndSeq(start, end); |
228 |
864 |
int oldstartseq = oldvalues[0]; |
229 |
864 |
int oldendseq = oldvalues[1]; |
230 |
|
|
231 |
864 |
changeSupport.firePropertyChange(STARTSEQ, oldstartseq, startSeq); |
232 |
864 |
if (oldstartseq == startSeq) |
233 |
|
{ |
234 |
|
|
235 |
|
|
236 |
802 |
changeSupport.firePropertyChange(ENDSEQ, oldendseq, endSeq); |
237 |
|
} |
238 |
|
} |
239 |
|
|
240 |
|
|
241 |
|
|
242 |
|
|
243 |
|
|
244 |
|
@param |
245 |
|
|
246 |
|
@param |
247 |
|
|
248 |
|
@return |
249 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 5 |
Complexity Density: 0.36 |
|
250 |
987 |
private int[] updateStartEndSeq(int start, int end)... |
251 |
|
{ |
252 |
987 |
int oldstartseq = this.startSeq; |
253 |
987 |
int visibleHeight = getVisibleAlignmentHeight(); |
254 |
987 |
if (start > visibleHeight - 1) |
255 |
|
{ |
256 |
3 |
startSeq = Math.max(visibleHeight - 1, 0); |
257 |
|
} |
258 |
984 |
else if (start < 0) |
259 |
|
{ |
260 |
72 |
startSeq = 0; |
261 |
|
} |
262 |
|
else |
263 |
|
{ |
264 |
912 |
startSeq = start; |
265 |
|
} |
266 |
|
|
267 |
987 |
int oldendseq = this.endSeq; |
268 |
987 |
if (end >= visibleHeight) |
269 |
|
{ |
270 |
55 |
endSeq = Math.max(visibleHeight - 1, 0); |
271 |
|
} |
272 |
932 |
else if (end < 0) |
273 |
|
{ |
274 |
65 |
endSeq = 0; |
275 |
|
} |
276 |
|
else |
277 |
|
{ |
278 |
867 |
endSeq = end; |
279 |
|
} |
280 |
987 |
return new int[] { oldstartseq, oldendseq }; |
281 |
|
} |
282 |
|
|
283 |
|
|
284 |
|
|
285 |
|
|
286 |
|
|
287 |
|
@param |
288 |
|
|
289 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
290 |
6 |
public void setEndSeq(int seq)... |
291 |
|
{ |
292 |
6 |
int height = getViewportHeight(); |
293 |
6 |
setStartEndSeq(seq - height + 1, seq); |
294 |
|
} |
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
|
299 |
|
|
300 |
|
|
301 |
|
@param |
302 |
|
|
303 |
|
@param |
304 |
|
|
305 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 2 |
Complexity Density: 0.2 |
|
306 |
119 |
public void setStartResAndSeq(int res, int seq)... |
307 |
|
{ |
308 |
119 |
int width = getViewportWidth(); |
309 |
119 |
int[] oldresvalues = updateStartEndRes(res, res + width - 1); |
310 |
|
|
311 |
119 |
int startseq = seq; |
312 |
119 |
int height = getViewportHeight(); |
313 |
119 |
if (startseq + height - 1 > getVisibleAlignmentHeight() - 1) |
314 |
|
{ |
315 |
1 |
startseq = getVisibleAlignmentHeight() - height; |
316 |
|
} |
317 |
119 |
int[] oldseqvalues = updateStartEndSeq(startseq, startseq + height - 1); |
318 |
|
|
319 |
119 |
int[] old = new int[] { oldresvalues[0], oldseqvalues[0] }; |
320 |
119 |
int[] newresseq = new int[] { startRes, startSeq }; |
321 |
119 |
changeSupport.firePropertyChange(STARTRESANDSEQ, old, newresseq); |
322 |
|
} |
323 |
|
|
324 |
|
|
325 |
|
|
326 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
327 |
6755 |
public int getStartRes()... |
328 |
|
{ |
329 |
6755 |
return startRes; |
330 |
|
} |
331 |
|
|
332 |
|
|
333 |
|
|
334 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
335 |
4969 |
public int getEndRes()... |
336 |
|
{ |
337 |
4969 |
return endRes; |
338 |
|
} |
339 |
|
|
340 |
|
|
341 |
|
|
342 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
343 |
4853 |
public int getStartSeq()... |
344 |
|
{ |
345 |
4853 |
return startSeq; |
346 |
|
} |
347 |
|
|
348 |
|
|
349 |
|
|
350 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
351 |
2999 |
public int getEndSeq()... |
352 |
|
{ |
353 |
2999 |
return endSeq; |
354 |
|
} |
355 |
|
|
356 |
|
|
357 |
|
|
358 |
|
|
359 |
|
|
360 |
|
|
361 |
|
@param |
362 |
|
|
363 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
364 |
186 |
public void setViewportWidth(int w)... |
365 |
|
{ |
366 |
186 |
setStartEndRes(startRes, startRes + w - 1); |
367 |
|
} |
368 |
|
|
369 |
|
|
370 |
|
|
371 |
|
|
372 |
|
|
373 |
|
|
374 |
|
@param |
375 |
|
|
376 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
377 |
160 |
public void setViewportHeight(int h)... |
378 |
|
{ |
379 |
160 |
setStartEndSeq(startSeq, startSeq + h - 1); |
380 |
|
} |
381 |
|
|
382 |
|
|
383 |
|
|
384 |
|
|
385 |
|
|
386 |
|
|
387 |
|
@param |
388 |
|
|
389 |
|
@param |
390 |
|
|
391 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 5 |
Complexity Density: 0.71 |
|
392 |
383 |
public void setViewportStartAndWidth(int start, int w)... |
393 |
|
{ |
394 |
383 |
int vpstart = start; |
395 |
383 |
if (vpstart < 0) |
396 |
|
{ |
397 |
2 |
vpstart = 0; |
398 |
|
} |
399 |
|
|
400 |
|
|
401 |
|
|
402 |
|
|
403 |
383 |
if (!wrappedMode) |
404 |
|
{ |
405 |
228 |
if ((w <= getVisibleAlignmentWidth()) |
406 |
|
&& (vpstart + w - 1 > getVisibleAlignmentWidth() - 1)) |
407 |
|
{ |
408 |
1 |
vpstart = getVisibleAlignmentWidth() - w; |
409 |
|
} |
410 |
|
|
411 |
|
} |
412 |
383 |
setStartEndRes(vpstart, vpstart + w - 1); |
413 |
|
} |
414 |
|
|
415 |
|
|
416 |
|
|
417 |
|
|
418 |
|
|
419 |
|
|
420 |
|
@param |
421 |
|
|
422 |
|
@param |
423 |
|
|
424 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 4 |
Complexity Density: 0.67 |
|
425 |
297 |
public void setViewportStartAndHeight(int start, int h)... |
426 |
|
{ |
427 |
297 |
int vpstart = start; |
428 |
297 |
if (vpstart < 0) |
429 |
|
{ |
430 |
3 |
vpstart = 0; |
431 |
|
} |
432 |
294 |
else if ((h <= getVisibleAlignmentHeight()) |
433 |
|
&& (vpstart + h - 1 > getVisibleAlignmentHeight() - 1)) |
434 |
|
|
435 |
|
|
436 |
|
{ |
437 |
5 |
vpstart = getVisibleAlignmentHeight() - h; |
438 |
|
} |
439 |
297 |
setStartEndSeq(vpstart, vpstart + h - 1); |
440 |
|
} |
441 |
|
|
442 |
|
|
443 |
|
|
444 |
|
|
445 |
|
@return |
446 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
447 |
2308 |
public int getViewportWidth()... |
448 |
|
{ |
449 |
2308 |
return (endRes - startRes + 1); |
450 |
|
} |
451 |
|
|
452 |
|
|
453 |
|
|
454 |
|
|
455 |
|
@return |
456 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
457 |
1098 |
public int getViewportHeight()... |
458 |
|
{ |
459 |
1098 |
return (endSeq - startSeq + 1); |
460 |
|
} |
461 |
|
|
462 |
|
|
463 |
|
|
464 |
|
|
465 |
|
@param |
466 |
|
|
467 |
|
|
468 |
|
@return |
469 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 6 |
Complexity Density: 0.5 |
|
470 |
28 |
public boolean scrollUp(boolean up)... |
471 |
|
{ |
472 |
|
|
473 |
|
|
474 |
|
|
475 |
|
|
476 |
28 |
if (up) |
477 |
|
{ |
478 |
18 |
if (wrappedMode) |
479 |
|
{ |
480 |
2 |
pageUp(); |
481 |
|
} |
482 |
|
else |
483 |
|
{ |
484 |
16 |
if (startSeq < 1) |
485 |
|
{ |
486 |
2 |
return false; |
487 |
|
} |
488 |
14 |
setStartSeq(startSeq - 1); |
489 |
|
} |
490 |
|
} |
491 |
|
else |
492 |
|
{ |
493 |
10 |
if (wrappedMode) |
494 |
|
{ |
495 |
4 |
pageDown(); |
496 |
|
} |
497 |
|
else |
498 |
|
{ |
499 |
6 |
if (endSeq >= getVisibleAlignmentHeight() - 1) |
500 |
|
{ |
501 |
2 |
return false; |
502 |
|
} |
503 |
4 |
setStartSeq(startSeq + 1); |
504 |
|
} |
505 |
|
} |
506 |
24 |
return true; |
507 |
|
} |
508 |
|
|
509 |
|
|
510 |
|
|
511 |
|
|
512 |
|
@param |
513 |
|
|
514 |
|
|
515 |
|
@return |
516 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
517 |
24 |
public boolean scrollRight(boolean right)... |
518 |
|
{ |
519 |
24 |
if (!right) |
520 |
|
{ |
521 |
18 |
if (startRes < 1) |
522 |
|
{ |
523 |
2 |
return false; |
524 |
|
} |
525 |
|
|
526 |
16 |
setStartRes(startRes - 1); |
527 |
|
} |
528 |
|
else |
529 |
|
{ |
530 |
6 |
if (endRes >= getVisibleAlignmentWidth() - 1) |
531 |
|
{ |
532 |
2 |
return false; |
533 |
|
} |
534 |
|
|
535 |
4 |
setStartRes(startRes + 1); |
536 |
|
} |
537 |
|
|
538 |
20 |
return true; |
539 |
|
} |
540 |
|
|
541 |
|
|
542 |
|
|
543 |
|
|
544 |
|
|
545 |
|
|
546 |
|
@param |
547 |
|
|
548 |
|
|
549 |
|
@return |
550 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
551 |
7 |
public boolean scrollToWrappedVisible(int res)... |
552 |
|
{ |
553 |
7 |
int newStartRes = calcWrappedStartResidue(res); |
554 |
7 |
if (newStartRes == startRes) |
555 |
|
{ |
556 |
3 |
return false; |
557 |
|
} |
558 |
4 |
setStartRes(newStartRes); |
559 |
|
|
560 |
4 |
return true; |
561 |
|
} |
562 |
|
|
563 |
|
|
564 |
|
|
565 |
|
|
566 |
|
@param |
567 |
|
|
568 |
|
@return |
569 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 4 |
Complexity Density: 0.36 |
|
570 |
9 |
private int calcWrappedStartResidue(int res)... |
571 |
|
{ |
572 |
9 |
int oldStartRes = startRes; |
573 |
9 |
int width = getViewportWidth(); |
574 |
|
|
575 |
9 |
boolean up = res < oldStartRes; |
576 |
9 |
int widthsToScroll = Math.abs((res - oldStartRes) / width); |
577 |
9 |
if (up) |
578 |
|
{ |
579 |
2 |
widthsToScroll++; |
580 |
|
} |
581 |
|
|
582 |
9 |
int residuesToScroll = width * widthsToScroll; |
583 |
9 |
int newStartRes = up ? oldStartRes - residuesToScroll : oldStartRes |
584 |
|
+ residuesToScroll; |
585 |
9 |
if (newStartRes < 0) |
586 |
|
{ |
587 |
2 |
newStartRes = 0; |
588 |
|
} |
589 |
9 |
return newStartRes; |
590 |
|
} |
591 |
|
|
592 |
|
|
593 |
|
|
594 |
|
|
595 |
|
@param |
596 |
|
|
597 |
|
@param |
598 |
|
|
599 |
|
|
|
|
| 82.6% |
Uncovered Elements: 4 (23) |
Complexity: 7 |
Complexity Density: 0.64 |
|
600 |
5 |
public void scrollToVisible(int x, int y)... |
601 |
|
{ |
602 |
16 |
while (y < startSeq) |
603 |
|
{ |
604 |
11 |
scrollUp(true); |
605 |
|
} |
606 |
6 |
while (y > endSeq) |
607 |
|
{ |
608 |
1 |
scrollUp(false); |
609 |
|
} |
610 |
|
|
611 |
5 |
HiddenColumns hidden = al.getHiddenColumns(); |
612 |
18 |
while (x < hidden.visibleToAbsoluteColumn(startRes)) |
613 |
|
{ |
614 |
13 |
if (!scrollRight(false)) |
615 |
|
{ |
616 |
0 |
break; |
617 |
|
} |
618 |
|
} |
619 |
6 |
while (x > hidden.visibleToAbsoluteColumn(endRes)) |
620 |
|
{ |
621 |
1 |
if (!scrollRight(true)) |
622 |
|
{ |
623 |
0 |
break; |
624 |
|
} |
625 |
|
} |
626 |
|
} |
627 |
|
|
628 |
|
|
629 |
|
|
630 |
|
|
631 |
|
@param |
632 |
|
|
633 |
|
@param |
634 |
|
|
635 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (32) |
Complexity: 8 |
Complexity Density: 0.33 |
|
636 |
7 |
public boolean setViewportLocation(int x, int y)... |
637 |
|
{ |
638 |
7 |
boolean changedLocation = false; |
639 |
|
|
640 |
|
|
641 |
7 |
int visX = al.getHiddenColumns().absoluteToVisibleColumn(x); |
642 |
7 |
int visY = al.getHiddenSequences().findIndexWithoutHiddenSeqs(y); |
643 |
|
|
644 |
|
|
645 |
7 |
if (startRes > visX || visX > endRes |
646 |
|
|| startSeq > visY && visY > endSeq) |
647 |
|
{ |
648 |
6 |
int[] old = new int[] { startRes, startSeq }; |
649 |
6 |
int[] newresseq; |
650 |
6 |
if (wrappedMode) |
651 |
|
{ |
652 |
2 |
int newstartres = calcWrappedStartResidue(visX); |
653 |
2 |
setStartRes(newstartres); |
654 |
2 |
newresseq = new int[] { startRes, startSeq }; |
655 |
|
} |
656 |
|
else |
657 |
|
{ |
658 |
|
|
659 |
4 |
int newstartres = visX; |
660 |
4 |
int width = getViewportWidth(); |
661 |
4 |
if (newstartres + width - 1 > getVisibleAlignmentWidth() - 1) |
662 |
|
{ |
663 |
2 |
newstartres = getVisibleAlignmentWidth() - width; |
664 |
|
} |
665 |
4 |
updateStartEndRes(newstartres, newstartres + width - 1); |
666 |
|
|
667 |
|
|
668 |
4 |
int newstartseq = visY; |
669 |
4 |
int height = getViewportHeight(); |
670 |
4 |
if (newstartseq + height - 1 > getVisibleAlignmentHeight() - 1) |
671 |
|
{ |
672 |
1 |
newstartseq = getVisibleAlignmentHeight() - height; |
673 |
|
} |
674 |
4 |
updateStartEndSeq(newstartseq, newstartseq + height - 1); |
675 |
|
|
676 |
4 |
newresseq = new int[] { startRes, startSeq }; |
677 |
|
} |
678 |
6 |
changedLocation = true; |
679 |
6 |
changeSupport.firePropertyChange(MOVE_VIEWPORT, old, newresseq); |
680 |
|
} |
681 |
7 |
return changedLocation; |
682 |
|
} |
683 |
|
|
684 |
|
|
685 |
|
|
686 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
687 |
12 |
public void pageUp()... |
688 |
|
{ |
689 |
12 |
if (wrappedMode) |
690 |
|
{ |
691 |
8 |
setStartRes(Math.max(0, getStartRes() - getViewportWidth())); |
692 |
|
} |
693 |
|
else |
694 |
|
{ |
695 |
4 |
setViewportStartAndHeight(startSeq - (endSeq - startSeq), |
696 |
|
getViewportHeight()); |
697 |
|
} |
698 |
|
} |
699 |
|
|
700 |
|
|
701 |
|
|
702 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
703 |
17 |
public void pageDown()... |
704 |
|
{ |
705 |
17 |
if (wrappedMode) |
706 |
|
{ |
707 |
|
|
708 |
|
|
709 |
|
|
710 |
|
|
711 |
10 |
int newStart = getStartRes() |
712 |
|
+ Math.max(getViewportHeight(), getViewportWidth()); |
713 |
|
|
714 |
|
|
715 |
|
|
716 |
|
|
717 |
|
|
718 |
10 |
if (newStart < getVisibleAlignmentWidth()) |
719 |
|
{ |
720 |
7 |
setStartRes(newStart); |
721 |
|
} |
722 |
|
} |
723 |
|
else |
724 |
|
{ |
725 |
7 |
setViewportStartAndHeight(endSeq, getViewportHeight()); |
726 |
|
} |
727 |
|
} |
728 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
729 |
85 |
public void setWrappedMode(boolean wrapped)... |
730 |
|
{ |
731 |
85 |
wrappedMode = wrapped; |
732 |
|
} |
733 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
734 |
116 |
public boolean isWrappedMode()... |
735 |
|
{ |
736 |
116 |
return wrappedMode; |
737 |
|
} |
738 |
|
|
739 |
|
|
740 |
|
|
741 |
|
|
742 |
|
|
743 |
|
|
744 |
|
|
745 |
|
|
746 |
|
|
747 |
|
|
748 |
|
|
749 |
|
|
750 |
|
|
751 |
|
|
752 |
|
@param |
753 |
|
|
754 |
|
@return |
755 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
756 |
603 |
public int getWrappedScrollPosition(final int topLeftColumn)... |
757 |
|
{ |
758 |
603 |
int w = getViewportWidth(); |
759 |
|
|
760 |
|
|
761 |
|
|
762 |
|
|
763 |
603 |
int scroll = topLeftColumn / w; |
764 |
|
|
765 |
|
|
766 |
|
|
767 |
|
|
768 |
603 |
scroll += topLeftColumn % w > 0 ? 1 : 0; |
769 |
|
|
770 |
603 |
return scroll; |
771 |
|
} |
772 |
|
|
773 |
|
|
774 |
|
|
775 |
|
|
776 |
|
|
777 |
|
@param |
778 |
|
@return |
779 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
780 |
318 |
public int getWrappedMaxScroll(int topLeftColumn)... |
781 |
|
{ |
782 |
318 |
int scrollPosition = getWrappedScrollPosition(topLeftColumn); |
783 |
|
|
784 |
|
|
785 |
|
|
786 |
|
|
787 |
318 |
int columnsRemaining = getVisibleAlignmentWidth() - topLeftColumn; |
788 |
318 |
int width = getViewportWidth(); |
789 |
318 |
int widthsRemaining = columnsRemaining / width |
790 |
318 |
+ (columnsRemaining % width > 0 ? 1 : 0) - 1; |
791 |
318 |
int maxScroll = scrollPosition + widthsRemaining; |
792 |
|
|
793 |
318 |
return maxScroll; |
794 |
|
} |
795 |
|
} |