1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.datamodel; |
22 |
|
|
23 |
|
import java.util.ArrayList; |
24 |
|
import java.util.Arrays; |
25 |
|
import java.util.BitSet; |
26 |
|
import java.util.Iterator; |
27 |
|
import java.util.List; |
28 |
|
import java.util.concurrent.locks.ReentrantReadWriteLock; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
@author |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
|
|
| 0% |
Uncovered Elements: 424 (424) |
Complexity: 98 |
Complexity Density: 0.34 |
|
65 |
|
public class HiddenColumns |
66 |
|
{ |
67 |
|
private static final int HASH_MULTIPLIER = 31; |
68 |
|
|
69 |
|
private static final ReentrantReadWriteLock LOCK = new ReentrantReadWriteLock(); |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
private HiddenColumnsCursor cursor = new HiddenColumnsCursor(); |
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
private int numColumns = 0; |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
private List<int[]> hiddenColumns = new ArrayList<>(); |
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
92 |
0 |
public HiddenColumns()... |
93 |
|
{ |
94 |
|
} |
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
@param |
100 |
|
|
101 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
102 |
0 |
public HiddenColumns(HiddenColumns copy)... |
103 |
|
{ |
104 |
0 |
this(copy, Integer.MIN_VALUE, Integer.MAX_VALUE, 0); |
105 |
|
} |
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
@param |
113 |
|
|
114 |
|
@param |
115 |
|
|
116 |
|
@param |
117 |
|
|
118 |
|
@param |
119 |
|
|
120 |
|
|
121 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 5 |
Complexity Density: 0.42 |
|
122 |
0 |
public HiddenColumns(HiddenColumns copy, int start, int end, int offset)... |
123 |
|
{ |
124 |
0 |
try |
125 |
|
{ |
126 |
0 |
LOCK.writeLock().lock(); |
127 |
0 |
if (copy != null) |
128 |
|
{ |
129 |
0 |
numColumns = 0; |
130 |
0 |
Iterator<int[]> it = copy.getBoundedIterator(start, end); |
131 |
0 |
while (it.hasNext()) |
132 |
|
{ |
133 |
0 |
int[] region = it.next(); |
134 |
|
|
135 |
|
|
136 |
0 |
if (region[0] >= start && region[1] <= end) |
137 |
|
{ |
138 |
0 |
hiddenColumns |
139 |
|
.add(new int[] |
140 |
|
{ region[0] - offset, region[1] - offset }); |
141 |
0 |
numColumns += region[1] - region[0] + 1; |
142 |
|
} |
143 |
|
} |
144 |
0 |
cursor = new HiddenColumnsCursor(hiddenColumns); |
145 |
|
} |
146 |
|
} finally |
147 |
|
{ |
148 |
0 |
LOCK.writeLock().unlock(); |
149 |
|
} |
150 |
|
} |
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
@param |
156 |
|
|
157 |
|
@param |
158 |
|
|
159 |
|
|
|
|
| 0% |
Uncovered Elements: 32 (32) |
Complexity: 8 |
Complexity Density: 0.36 |
|
160 |
0 |
public void hideColumns(int start, int end)... |
161 |
|
{ |
162 |
0 |
try |
163 |
|
{ |
164 |
0 |
LOCK.writeLock().lock(); |
165 |
|
|
166 |
0 |
int previndex = 0; |
167 |
0 |
int prevHiddenCount = 0; |
168 |
0 |
int regionindex = 0; |
169 |
0 |
if (!hiddenColumns.isEmpty()) |
170 |
|
{ |
171 |
|
|
172 |
0 |
HiddenCursorPosition cursorPos = cursor.findRegionForColumn(start, |
173 |
|
false); |
174 |
0 |
regionindex = cursorPos.getRegionIndex(); |
175 |
|
|
176 |
0 |
if (regionindex > 0) |
177 |
|
{ |
178 |
|
|
179 |
0 |
previndex = regionindex - 1; |
180 |
0 |
int[] prevRegion = hiddenColumns.get(previndex); |
181 |
0 |
prevHiddenCount = cursorPos.getHiddenSoFar() |
182 |
|
- (prevRegion[1] - prevRegion[0] + 1); |
183 |
|
} |
184 |
|
} |
185 |
|
|
186 |
|
|
187 |
|
|
188 |
0 |
if (hiddenColumns.isEmpty() |
189 |
|
|| start > hiddenColumns.get(hiddenColumns.size() - 1)[1]) |
190 |
|
{ |
191 |
0 |
hiddenColumns.add(new int[] { start, end }); |
192 |
0 |
numColumns += end - start + 1; |
193 |
|
} |
194 |
|
else |
195 |
|
{ |
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
|
200 |
0 |
boolean added = false; |
201 |
0 |
if (regionindex > 0) |
202 |
|
{ |
203 |
0 |
added = insertRangeAtRegion(regionindex - 1, start, end); |
204 |
|
} |
205 |
0 |
if (!added && regionindex < hiddenColumns.size()) |
206 |
|
{ |
207 |
0 |
insertRangeAtRegion(regionindex, start, end); |
208 |
|
} |
209 |
|
} |
210 |
|
|
211 |
|
|
212 |
|
|
213 |
0 |
cursor = new HiddenColumnsCursor(hiddenColumns, previndex, |
214 |
|
prevHiddenCount); |
215 |
|
} finally |
216 |
|
{ |
217 |
0 |
LOCK.writeLock().unlock(); |
218 |
|
} |
219 |
|
} |
220 |
|
|
221 |
|
|
222 |
|
|
223 |
|
|
224 |
|
|
225 |
|
@param |
226 |
|
|
227 |
|
@param |
228 |
|
|
229 |
|
@param |
230 |
|
|
231 |
|
@return |
232 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 4 |
Complexity Density: 0.27 |
|
233 |
0 |
private boolean insertRangeAtRegion(int i, int start, int end)... |
234 |
|
{ |
235 |
0 |
boolean added = false; |
236 |
|
|
237 |
0 |
int[] region = hiddenColumns.get(i); |
238 |
0 |
if (end < region[0] - 1) |
239 |
|
{ |
240 |
|
|
241 |
|
|
242 |
|
|
243 |
0 |
hiddenColumns.add(i, new int[] { start, end }); |
244 |
0 |
numColumns += end - start + 1; |
245 |
0 |
added = true; |
246 |
|
} |
247 |
0 |
else if (end <= region[1]) |
248 |
|
{ |
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
|
253 |
0 |
int oldstart = region[0]; |
254 |
0 |
region[0] = Math.min(region[0], start); |
255 |
0 |
numColumns += oldstart - region[0]; |
256 |
|
|
257 |
0 |
added = true; |
258 |
|
} |
259 |
0 |
else if (start <= region[1] + 1) |
260 |
|
{ |
261 |
|
|
262 |
|
|
263 |
|
|
264 |
|
|
265 |
0 |
insertRangeAtOverlap(i, start, end, region); |
266 |
0 |
added = true; |
267 |
|
} |
268 |
0 |
return added; |
269 |
|
} |
270 |
|
|
271 |
|
|
272 |
|
|
273 |
|
|
274 |
|
|
275 |
|
@param |
276 |
|
|
277 |
|
@param |
278 |
|
|
279 |
|
@param |
280 |
|
|
281 |
|
@param |
282 |
|
|
283 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 3 |
Complexity Density: 0.2 |
|
284 |
0 |
private void insertRangeAtOverlap(int i, int start, int end, int[] region)... |
285 |
|
{ |
286 |
0 |
int oldstart = region[0]; |
287 |
0 |
int oldend = region[1]; |
288 |
0 |
region[0] = Math.min(region[0], start); |
289 |
0 |
region[1] = Math.max(region[1], end); |
290 |
|
|
291 |
0 |
numColumns += oldstart - region[0]; |
292 |
|
|
293 |
|
|
294 |
|
|
295 |
|
|
296 |
|
|
297 |
0 |
int endi = i; |
298 |
0 |
while (endi < hiddenColumns.size() - 1) |
299 |
|
{ |
300 |
0 |
int[] nextRegion = hiddenColumns.get(endi + 1); |
301 |
0 |
if (nextRegion[0] > end + 1) |
302 |
|
{ |
303 |
|
|
304 |
|
|
305 |
|
|
306 |
0 |
break; |
307 |
|
} |
308 |
0 |
numColumns -= nextRegion[1] - nextRegion[0] + 1; |
309 |
0 |
region[1] = Math.max(nextRegion[1], end); |
310 |
0 |
endi++; |
311 |
|
} |
312 |
0 |
numColumns += region[1] - oldend; |
313 |
0 |
hiddenColumns.subList(i + 1, endi + 1).clear(); |
314 |
|
} |
315 |
|
|
316 |
|
|
317 |
|
|
318 |
|
|
319 |
|
@param |
320 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
321 |
0 |
public void hideList(List<int[]> ranges)... |
322 |
|
{ |
323 |
0 |
try |
324 |
|
{ |
325 |
0 |
LOCK.writeLock().lock(); |
326 |
0 |
for (int[] r : ranges) |
327 |
|
{ |
328 |
0 |
hideColumns(r[0], r[1]); |
329 |
|
} |
330 |
0 |
cursor = new HiddenColumnsCursor(hiddenColumns); |
331 |
|
|
332 |
|
} finally |
333 |
|
{ |
334 |
0 |
LOCK.writeLock().unlock(); |
335 |
|
} |
336 |
|
} |
337 |
|
|
338 |
|
|
339 |
|
|
340 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
341 |
0 |
public void revealAllHiddenColumns(ColumnSelection sel)... |
342 |
|
{ |
343 |
0 |
try |
344 |
|
{ |
345 |
0 |
LOCK.writeLock().lock(); |
346 |
|
|
347 |
0 |
for (int[] region : hiddenColumns) |
348 |
|
{ |
349 |
0 |
for (int j = region[0]; j < region[1] + 1; j++) |
350 |
|
{ |
351 |
0 |
sel.addElement(j); |
352 |
|
} |
353 |
|
} |
354 |
0 |
hiddenColumns.clear(); |
355 |
0 |
cursor = new HiddenColumnsCursor(hiddenColumns); |
356 |
0 |
numColumns = 0; |
357 |
|
|
358 |
|
} finally |
359 |
|
{ |
360 |
0 |
LOCK.writeLock().unlock(); |
361 |
|
} |
362 |
|
} |
363 |
|
|
364 |
|
|
365 |
|
|
366 |
|
|
367 |
|
|
368 |
|
@param |
369 |
|
|
370 |
|
@param |
371 |
|
|
372 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 6 |
Complexity Density: 0.46 |
|
373 |
0 |
public void revealHiddenColumns(int start, ColumnSelection sel)... |
374 |
|
{ |
375 |
0 |
try |
376 |
|
{ |
377 |
0 |
LOCK.writeLock().lock(); |
378 |
|
|
379 |
0 |
if (!hiddenColumns.isEmpty()) |
380 |
|
{ |
381 |
0 |
int regionIndex = cursor.findRegionForColumn(start, false) |
382 |
|
.getRegionIndex(); |
383 |
|
|
384 |
0 |
if (regionIndex != -1 && regionIndex != hiddenColumns.size()) |
385 |
|
{ |
386 |
|
|
387 |
|
|
388 |
0 |
int[] region = hiddenColumns.get(regionIndex); |
389 |
0 |
if (start == region[0]) |
390 |
|
{ |
391 |
0 |
for (int j = region[0]; j < region[1] + 1; j++) |
392 |
|
{ |
393 |
0 |
sel.addElement(j); |
394 |
|
} |
395 |
0 |
int colsToRemove = region[1] - region[0] + 1; |
396 |
0 |
hiddenColumns.remove(regionIndex); |
397 |
0 |
numColumns -= colsToRemove; |
398 |
|
} |
399 |
|
} |
400 |
|
} |
401 |
|
} finally |
402 |
|
{ |
403 |
0 |
LOCK.writeLock().unlock(); |
404 |
|
} |
405 |
|
} |
406 |
|
|
407 |
|
|
408 |
|
|
409 |
|
|
410 |
|
|
411 |
|
@param |
412 |
|
|
413 |
|
@param |
414 |
|
|
415 |
|
@return |
416 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 2 |
Complexity Density: 0.18 |
|
417 |
0 |
public String regionsToString(String delimiter, String between)... |
418 |
|
{ |
419 |
0 |
try |
420 |
|
{ |
421 |
0 |
LOCK.readLock().lock(); |
422 |
0 |
StringBuilder regionBuilder = new StringBuilder(); |
423 |
|
|
424 |
0 |
boolean first = true; |
425 |
0 |
for (int[] range : hiddenColumns) |
426 |
|
{ |
427 |
0 |
if (!first) |
428 |
|
{ |
429 |
0 |
regionBuilder.append(delimiter); |
430 |
|
} |
431 |
|
else |
432 |
|
{ |
433 |
0 |
first = false; |
434 |
|
} |
435 |
0 |
regionBuilder.append(range[0]).append(between).append(range[1]); |
436 |
|
|
437 |
|
} |
438 |
|
|
439 |
0 |
return regionBuilder.toString(); |
440 |
|
} finally |
441 |
|
{ |
442 |
0 |
LOCK.readLock().unlock(); |
443 |
|
} |
444 |
|
} |
445 |
|
|
446 |
|
|
447 |
|
|
448 |
|
|
449 |
|
@return |
450 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
451 |
0 |
public int getSize()... |
452 |
|
{ |
453 |
0 |
return numColumns; |
454 |
|
} |
455 |
|
|
456 |
|
|
457 |
|
|
458 |
|
|
459 |
|
@return |
460 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
461 |
0 |
public int getNumberOfRegions()... |
462 |
|
{ |
463 |
0 |
try |
464 |
|
{ |
465 |
0 |
LOCK.readLock().lock(); |
466 |
0 |
return hiddenColumns.size(); |
467 |
|
} finally |
468 |
|
{ |
469 |
0 |
LOCK.readLock().unlock(); |
470 |
|
} |
471 |
|
} |
472 |
|
|
473 |
|
|
474 |
|
|
475 |
|
|
476 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 5 |
Complexity Density: 0.36 |
|
477 |
0 |
@Override... |
478 |
|
public boolean equals(Object obj) |
479 |
|
{ |
480 |
0 |
try |
481 |
|
{ |
482 |
0 |
LOCK.readLock().lock(); |
483 |
|
|
484 |
0 |
if (!(obj instanceof HiddenColumns)) |
485 |
|
{ |
486 |
0 |
return false; |
487 |
|
} |
488 |
0 |
HiddenColumns that = (HiddenColumns) obj; |
489 |
|
|
490 |
|
|
491 |
|
|
492 |
|
|
493 |
|
|
494 |
0 |
if (that.hiddenColumns.size() != this.hiddenColumns.size()) |
495 |
|
{ |
496 |
0 |
return false; |
497 |
|
} |
498 |
|
|
499 |
0 |
Iterator<int[]> it = this.iterator(); |
500 |
0 |
Iterator<int[]> thatit = that.iterator(); |
501 |
0 |
while (it.hasNext()) |
502 |
|
{ |
503 |
0 |
if (!(Arrays.equals(it.next(), thatit.next()))) |
504 |
|
{ |
505 |
0 |
return false; |
506 |
|
} |
507 |
|
} |
508 |
0 |
return true; |
509 |
|
|
510 |
|
} finally |
511 |
|
{ |
512 |
0 |
LOCK.readLock().unlock(); |
513 |
|
} |
514 |
|
} |
515 |
|
|
516 |
|
|
517 |
|
|
518 |
|
|
519 |
|
@param |
520 |
|
|
521 |
|
@return |
522 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
523 |
0 |
public int visibleToAbsoluteColumn(int column)... |
524 |
|
{ |
525 |
0 |
try |
526 |
|
{ |
527 |
0 |
LOCK.readLock().lock(); |
528 |
0 |
int result = column; |
529 |
|
|
530 |
0 |
if (!hiddenColumns.isEmpty()) |
531 |
|
{ |
532 |
0 |
result += cursor.findRegionForColumn(column, true).getHiddenSoFar(); |
533 |
|
} |
534 |
|
|
535 |
0 |
return result; |
536 |
|
} finally |
537 |
|
{ |
538 |
0 |
LOCK.readLock().unlock(); |
539 |
|
} |
540 |
|
} |
541 |
|
|
542 |
|
|
543 |
|
|
544 |
|
|
545 |
|
|
546 |
|
|
547 |
|
|
548 |
|
@param |
549 |
|
|
550 |
|
@return |
551 |
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 6 |
Complexity Density: 0.38 |
|
552 |
0 |
public int absoluteToVisibleColumn(int hiddenColumn)... |
553 |
|
{ |
554 |
0 |
try |
555 |
|
{ |
556 |
0 |
LOCK.readLock().lock(); |
557 |
0 |
int result = hiddenColumn; |
558 |
|
|
559 |
0 |
if (!hiddenColumns.isEmpty()) |
560 |
|
{ |
561 |
0 |
HiddenCursorPosition cursorPos = cursor |
562 |
|
.findRegionForColumn(hiddenColumn, false); |
563 |
0 |
int index = cursorPos.getRegionIndex(); |
564 |
0 |
int hiddenBeforeCol = cursorPos.getHiddenSoFar(); |
565 |
|
|
566 |
|
|
567 |
|
|
568 |
0 |
result = hiddenColumn - hiddenBeforeCol; |
569 |
|
|
570 |
|
|
571 |
|
|
572 |
0 |
if (index < hiddenColumns.size()) |
573 |
|
{ |
574 |
0 |
int[] region = hiddenColumns.get(index); |
575 |
0 |
if (hiddenColumn >= region[0] && hiddenColumn <= region[1]) |
576 |
|
{ |
577 |
|
|
578 |
|
|
579 |
0 |
if (region[0] == 0) |
580 |
|
{ |
581 |
0 |
result = 0; |
582 |
|
} |
583 |
|
else |
584 |
|
{ |
585 |
0 |
result = region[0] - 1 - hiddenBeforeCol; |
586 |
|
} |
587 |
|
} |
588 |
|
} |
589 |
|
} |
590 |
|
|
591 |
0 |
return result; |
592 |
|
|
593 |
|
} finally |
594 |
|
{ |
595 |
0 |
LOCK.readLock().unlock(); |
596 |
|
} |
597 |
|
} |
598 |
|
|
599 |
|
|
600 |
|
|
601 |
|
|
602 |
|
|
603 |
|
|
604 |
|
|
605 |
|
@param |
606 |
|
|
607 |
|
|
608 |
|
@param |
609 |
|
|
610 |
|
@return |
611 |
|
|
612 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
613 |
0 |
public int offsetByVisibleColumns(int visibleDistance, int startColumn)... |
614 |
|
{ |
615 |
0 |
try |
616 |
|
{ |
617 |
0 |
LOCK.readLock().lock(); |
618 |
0 |
int start = absoluteToVisibleColumn(startColumn); |
619 |
0 |
return visibleToAbsoluteColumn(start + visibleDistance); |
620 |
|
|
621 |
|
} finally |
622 |
|
{ |
623 |
0 |
LOCK.readLock().unlock(); |
624 |
|
} |
625 |
|
} |
626 |
|
|
627 |
|
|
628 |
|
|
629 |
|
|
630 |
|
|
631 |
|
@param |
632 |
|
|
633 |
|
|
634 |
|
@return |
635 |
|
|
636 |
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 9 |
Complexity Density: 0.56 |
|
637 |
0 |
public int getNextHiddenBoundary(boolean left, int alPos)... |
638 |
|
{ |
639 |
0 |
try |
640 |
|
{ |
641 |
0 |
LOCK.readLock().lock(); |
642 |
0 |
if (!hiddenColumns.isEmpty()) |
643 |
|
{ |
644 |
0 |
int index = cursor.findRegionForColumn(alPos, false) |
645 |
|
.getRegionIndex(); |
646 |
|
|
647 |
0 |
if (left && index > 0) |
648 |
|
{ |
649 |
0 |
int[] region = hiddenColumns.get(index - 1); |
650 |
0 |
return region[1]; |
651 |
|
} |
652 |
0 |
else if (!left && index < hiddenColumns.size()) |
653 |
|
{ |
654 |
0 |
int[] region = hiddenColumns.get(index); |
655 |
0 |
if (alPos < region[0]) |
656 |
|
{ |
657 |
0 |
return region[0]; |
658 |
|
} |
659 |
0 |
else if ((alPos <= region[1]) |
660 |
|
&& (index + 1 < hiddenColumns.size())) |
661 |
|
{ |
662 |
|
|
663 |
|
|
664 |
0 |
region = hiddenColumns.get(index + 1); |
665 |
0 |
return region[0]; |
666 |
|
} |
667 |
|
} |
668 |
|
} |
669 |
0 |
return alPos; |
670 |
|
} finally |
671 |
|
{ |
672 |
0 |
LOCK.readLock().unlock(); |
673 |
|
} |
674 |
|
} |
675 |
|
|
676 |
|
|
677 |
|
|
678 |
|
|
679 |
|
@param |
680 |
|
|
681 |
|
@return |
682 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 5 |
Complexity Density: 0.5 |
|
683 |
0 |
public boolean isVisible(int column)... |
684 |
|
{ |
685 |
0 |
try |
686 |
|
{ |
687 |
0 |
LOCK.readLock().lock(); |
688 |
|
|
689 |
0 |
if (!hiddenColumns.isEmpty()) |
690 |
|
{ |
691 |
0 |
int regionindex = cursor.findRegionForColumn(column, false) |
692 |
|
.getRegionIndex(); |
693 |
0 |
if (regionindex > -1 && regionindex < hiddenColumns.size()) |
694 |
|
{ |
695 |
0 |
int[] region = hiddenColumns.get(regionindex); |
696 |
|
|
697 |
|
|
698 |
0 |
if (column >= region[0]) |
699 |
|
{ |
700 |
0 |
return false; |
701 |
|
} |
702 |
|
} |
703 |
|
} |
704 |
0 |
return true; |
705 |
|
|
706 |
|
} finally |
707 |
|
{ |
708 |
0 |
LOCK.readLock().unlock(); |
709 |
|
} |
710 |
|
} |
711 |
|
|
712 |
|
|
713 |
|
|
714 |
|
@return |
715 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
716 |
0 |
public boolean hasHiddenColumns()... |
717 |
|
{ |
718 |
0 |
try |
719 |
|
{ |
720 |
0 |
LOCK.readLock().lock(); |
721 |
|
|
722 |
|
|
723 |
|
|
724 |
0 |
return (!hiddenColumns.isEmpty()); |
725 |
|
} finally |
726 |
|
{ |
727 |
0 |
LOCK.readLock().unlock(); |
728 |
|
} |
729 |
|
} |
730 |
|
|
731 |
|
|
732 |
|
|
733 |
|
@return |
734 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
735 |
0 |
public boolean hasMultiHiddenColumnRegions()... |
736 |
|
{ |
737 |
0 |
try |
738 |
|
{ |
739 |
0 |
LOCK.readLock().lock(); |
740 |
0 |
return !hiddenColumns.isEmpty() && hiddenColumns.size() > 1; |
741 |
|
} finally |
742 |
|
{ |
743 |
0 |
LOCK.readLock().unlock(); |
744 |
|
} |
745 |
|
} |
746 |
|
|
747 |
|
|
748 |
|
|
749 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
750 |
0 |
@Override... |
751 |
|
public int hashCode() |
752 |
|
{ |
753 |
0 |
try |
754 |
|
{ |
755 |
0 |
LOCK.readLock().lock(); |
756 |
0 |
int hashCode = 1; |
757 |
|
|
758 |
0 |
for (int[] hidden : hiddenColumns) |
759 |
|
{ |
760 |
0 |
hashCode = HASH_MULTIPLIER * hashCode + hidden[0]; |
761 |
0 |
hashCode = HASH_MULTIPLIER * hashCode + hidden[1]; |
762 |
|
} |
763 |
0 |
return hashCode; |
764 |
|
} finally |
765 |
|
{ |
766 |
0 |
LOCK.readLock().unlock(); |
767 |
|
} |
768 |
|
} |
769 |
|
|
770 |
|
|
771 |
|
|
772 |
|
|
773 |
|
@param |
774 |
|
|
775 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
776 |
0 |
public void hideColumns(BitSet inserts)... |
777 |
|
{ |
778 |
0 |
hideColumns(inserts, 0, inserts.length() - 1); |
779 |
|
} |
780 |
|
|
781 |
|
|
782 |
|
|
783 |
|
|
784 |
|
|
785 |
|
@param |
786 |
|
|
787 |
|
@param |
788 |
|
|
789 |
|
@param |
790 |
|
|
791 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 5 |
Complexity Density: 0.5 |
|
792 |
0 |
private void hideColumns(BitSet tohide, int start, int end)... |
793 |
|
{ |
794 |
0 |
try |
795 |
|
{ |
796 |
0 |
LOCK.writeLock().lock(); |
797 |
0 |
for (int firstSet = tohide |
798 |
0 |
.nextSetBit(start), lastSet = start; firstSet >= start |
799 |
|
&& lastSet <= end; firstSet = tohide |
800 |
|
.nextSetBit(lastSet)) |
801 |
|
{ |
802 |
0 |
lastSet = tohide.nextClearBit(firstSet); |
803 |
0 |
if (lastSet <= end) |
804 |
|
{ |
805 |
0 |
hideColumns(firstSet, lastSet - 1); |
806 |
|
} |
807 |
0 |
else if (firstSet <= end) |
808 |
|
{ |
809 |
0 |
hideColumns(firstSet, end); |
810 |
|
} |
811 |
|
} |
812 |
0 |
cursor = new HiddenColumnsCursor(hiddenColumns); |
813 |
|
} finally |
814 |
|
{ |
815 |
0 |
LOCK.writeLock().unlock(); |
816 |
|
} |
817 |
|
} |
818 |
|
|
819 |
|
|
820 |
|
|
821 |
|
|
822 |
|
|
823 |
|
|
824 |
|
@param |
825 |
|
|
826 |
|
@param |
827 |
|
|
828 |
|
@param |
829 |
|
|
830 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
831 |
0 |
public void clearAndHideColumns(BitSet tohide, int start, int end)... |
832 |
|
{ |
833 |
0 |
clearHiddenColumnsInRange(start, end); |
834 |
0 |
hideColumns(tohide, start, end); |
835 |
|
} |
836 |
|
|
837 |
|
|
838 |
|
|
839 |
|
|
840 |
|
@param |
841 |
|
|
842 |
|
@param |
843 |
|
|
844 |
|
|
|
|
| 0% |
Uncovered Elements: 36 (36) |
Complexity: 9 |
Complexity Density: 0.38 |
|
845 |
0 |
private void clearHiddenColumnsInRange(int start, int end)... |
846 |
|
{ |
847 |
0 |
try |
848 |
|
{ |
849 |
0 |
LOCK.writeLock().lock(); |
850 |
|
|
851 |
0 |
if (!hiddenColumns.isEmpty()) |
852 |
|
{ |
853 |
0 |
HiddenCursorPosition pos = cursor.findRegionForColumn(start, false); |
854 |
0 |
int index = pos.getRegionIndex(); |
855 |
|
|
856 |
0 |
if (index != -1 && index != hiddenColumns.size()) |
857 |
|
{ |
858 |
|
|
859 |
|
|
860 |
0 |
int[] region = hiddenColumns.get(index); |
861 |
0 |
if (region[0] < start && region[1] >= start) |
862 |
|
{ |
863 |
|
|
864 |
0 |
numColumns -= region[1] - start + 1; |
865 |
0 |
region[1] = start - 1; |
866 |
0 |
index++; |
867 |
|
} |
868 |
|
|
869 |
0 |
int endi = index; |
870 |
0 |
while (endi < hiddenColumns.size()) |
871 |
|
{ |
872 |
0 |
region = hiddenColumns.get(endi); |
873 |
|
|
874 |
0 |
if (region[1] > end) |
875 |
|
{ |
876 |
0 |
if (region[0] <= end) |
877 |
|
{ |
878 |
|
|
879 |
0 |
numColumns -= end - region[0] + 1; |
880 |
0 |
region[0] = end + 1; |
881 |
|
} |
882 |
0 |
break; |
883 |
|
} |
884 |
|
|
885 |
0 |
numColumns -= region[1] - region[0] + 1; |
886 |
0 |
endi++; |
887 |
|
} |
888 |
0 |
hiddenColumns.subList(index, endi).clear(); |
889 |
|
|
890 |
|
} |
891 |
|
|
892 |
0 |
cursor = new HiddenColumnsCursor(hiddenColumns); |
893 |
|
} |
894 |
|
} finally |
895 |
|
{ |
896 |
0 |
LOCK.writeLock().unlock(); |
897 |
|
} |
898 |
|
} |
899 |
|
|
900 |
|
|
901 |
|
|
902 |
|
@param |
903 |
|
|
904 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
|
905 |
0 |
protected void andNot(BitSet updates)... |
906 |
|
{ |
907 |
0 |
try |
908 |
|
{ |
909 |
0 |
LOCK.writeLock().lock(); |
910 |
|
|
911 |
0 |
BitSet hiddenBitSet = new BitSet(); |
912 |
0 |
for (int[] range : hiddenColumns) |
913 |
|
{ |
914 |
0 |
hiddenBitSet.set(range[0], range[1] + 1); |
915 |
|
} |
916 |
0 |
hiddenBitSet.andNot(updates); |
917 |
0 |
hiddenColumns.clear(); |
918 |
0 |
hideColumns(hiddenBitSet); |
919 |
|
} finally |
920 |
|
{ |
921 |
0 |
LOCK.writeLock().unlock(); |
922 |
|
} |
923 |
|
} |
924 |
|
|
925 |
|
|
926 |
|
|
927 |
|
|
928 |
|
@param |
929 |
|
|
930 |
|
@return |
931 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 3 |
Complexity Density: 0.27 |
|
932 |
0 |
public int[] getVisibleStartAndEndIndex(int width)... |
933 |
|
{ |
934 |
0 |
try |
935 |
|
{ |
936 |
0 |
LOCK.readLock().lock(); |
937 |
|
|
938 |
0 |
int firstVisible = 0; |
939 |
0 |
int lastVisible = width - 1; |
940 |
|
|
941 |
0 |
if (!hiddenColumns.isEmpty()) |
942 |
|
{ |
943 |
|
|
944 |
0 |
firstVisible = visibleToAbsoluteColumn(0); |
945 |
|
|
946 |
|
|
947 |
|
|
948 |
0 |
int[] lastregion = hiddenColumns.get(hiddenColumns.size() - 1); |
949 |
0 |
if (lastregion[1] == width - 1) |
950 |
|
{ |
951 |
|
|
952 |
|
|
953 |
0 |
lastVisible = lastregion[0] - 1; |
954 |
|
} |
955 |
|
} |
956 |
0 |
return new int[] { firstVisible, lastVisible }; |
957 |
|
|
958 |
|
} finally |
959 |
|
{ |
960 |
0 |
LOCK.readLock().unlock(); |
961 |
|
} |
962 |
|
} |
963 |
|
|
964 |
|
|
965 |
|
|
966 |
|
|
967 |
|
@param |
968 |
|
|
969 |
|
@return |
970 |
|
|
971 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 6 |
Complexity Density: 0.5 |
|
972 |
0 |
public int[] getRegionWithEdgeAtRes(int res)... |
973 |
|
{ |
974 |
0 |
try |
975 |
|
{ |
976 |
0 |
LOCK.readLock().lock(); |
977 |
0 |
int adjres = visibleToAbsoluteColumn(res); |
978 |
|
|
979 |
0 |
int[] reveal = null; |
980 |
|
|
981 |
0 |
if (!hiddenColumns.isEmpty()) |
982 |
|
{ |
983 |
|
|
984 |
0 |
int regionindex = cursor.findRegionForColumn(adjres - 1, false) |
985 |
|
.getRegionIndex(); |
986 |
0 |
if (regionindex < hiddenColumns.size() |
987 |
|
&& hiddenColumns.get(regionindex)[1] == adjres - 1) |
988 |
|
{ |
989 |
0 |
reveal = hiddenColumns.get(regionindex); |
990 |
|
} |
991 |
|
|
992 |
0 |
else if (regionindex < hiddenColumns.size() |
993 |
|
&& hiddenColumns.get(regionindex)[0] == adjres + 1) |
994 |
|
{ |
995 |
0 |
reveal = hiddenColumns.get(regionindex); |
996 |
|
} |
997 |
|
} |
998 |
0 |
return reveal; |
999 |
|
|
1000 |
|
} finally |
1001 |
|
{ |
1002 |
0 |
LOCK.readLock().unlock(); |
1003 |
|
} |
1004 |
|
} |
1005 |
|
|
1006 |
|
|
1007 |
|
|
1008 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
1009 |
0 |
public Iterator<int[]> iterator()... |
1010 |
|
{ |
1011 |
0 |
try |
1012 |
|
{ |
1013 |
0 |
LOCK.readLock().lock(); |
1014 |
0 |
return new RangeIterator(hiddenColumns); |
1015 |
|
} finally |
1016 |
|
{ |
1017 |
0 |
LOCK.readLock().unlock(); |
1018 |
|
} |
1019 |
|
} |
1020 |
|
|
1021 |
|
|
1022 |
|
|
1023 |
|
|
1024 |
|
@param |
1025 |
|
|
1026 |
|
@param |
1027 |
|
|
1028 |
|
@return |
1029 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
1030 |
0 |
public Iterator<int[]> getBoundedIterator(int start, int end)... |
1031 |
|
{ |
1032 |
0 |
try |
1033 |
|
{ |
1034 |
0 |
LOCK.readLock().lock(); |
1035 |
0 |
return new RangeIterator(start, end, hiddenColumns); |
1036 |
|
} finally |
1037 |
|
{ |
1038 |
0 |
LOCK.readLock().unlock(); |
1039 |
|
} |
1040 |
|
} |
1041 |
|
|
1042 |
|
|
1043 |
|
|
1044 |
|
|
1045 |
|
|
1046 |
|
@param |
1047 |
|
|
1048 |
|
@param |
1049 |
|
|
1050 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
1051 |
0 |
public Iterator<Integer> getStartRegionIterator(int start, int end)... |
1052 |
|
{ |
1053 |
0 |
try |
1054 |
|
{ |
1055 |
0 |
LOCK.readLock().lock(); |
1056 |
|
|
1057 |
|
|
1058 |
0 |
int absoluteStart = visibleToAbsoluteColumn(start); |
1059 |
|
|
1060 |
|
|
1061 |
|
|
1062 |
|
|
1063 |
|
|
1064 |
|
|
1065 |
0 |
HiddenCursorPosition pos = cursor |
1066 |
|
.findRegionForColumn(absoluteStart - 1, false); |
1067 |
|
|
1068 |
0 |
return new StartRegionIterator(pos, start, end, hiddenColumns); |
1069 |
|
} finally |
1070 |
|
{ |
1071 |
0 |
LOCK.readLock().unlock(); |
1072 |
|
} |
1073 |
|
} |
1074 |
|
|
1075 |
|
|
1076 |
|
|
1077 |
|
|
1078 |
|
|
1079 |
|
@param |
1080 |
|
|
1081 |
|
@param |
1082 |
|
|
1083 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
1084 |
0 |
public Iterator<Integer> getVisibleColsIterator(int start, int end)... |
1085 |
|
{ |
1086 |
0 |
try |
1087 |
|
{ |
1088 |
0 |
LOCK.readLock().lock(); |
1089 |
0 |
return new RangeElementsIterator( |
1090 |
|
new VisibleContigsIterator(start, end + 1, hiddenColumns)); |
1091 |
|
} finally |
1092 |
|
{ |
1093 |
0 |
LOCK.readLock().unlock(); |
1094 |
|
} |
1095 |
|
} |
1096 |
|
|
1097 |
|
|
1098 |
|
|
1099 |
|
|
1100 |
|
|
1101 |
|
@param |
1102 |
|
|
1103 |
|
@param |
1104 |
|
|
1105 |
|
@param |
1106 |
|
|
1107 |
|
|
1108 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
1109 |
0 |
public VisibleContigsIterator getVisContigsIterator(int start, int end,... |
1110 |
|
boolean useVisibleCoords) |
1111 |
|
{ |
1112 |
0 |
int adjstart = start; |
1113 |
0 |
int adjend = end; |
1114 |
0 |
if (useVisibleCoords) |
1115 |
|
{ |
1116 |
0 |
adjstart = visibleToAbsoluteColumn(start); |
1117 |
0 |
adjend = visibleToAbsoluteColumn(end); |
1118 |
|
} |
1119 |
|
|
1120 |
0 |
try |
1121 |
|
{ |
1122 |
0 |
LOCK.readLock().lock(); |
1123 |
0 |
return new VisibleContigsIterator(adjstart, adjend, hiddenColumns); |
1124 |
|
} finally |
1125 |
|
{ |
1126 |
0 |
LOCK.readLock().unlock(); |
1127 |
|
} |
1128 |
|
} |
1129 |
|
} |