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.Iterator; |
25 |
|
import java.util.List; |
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
|
|
| 0% |
Uncovered Elements: 47 (47) |
Complexity: 11 |
Complexity Density: 0.35 |
|
32 |
|
public class VisibleContigsIterator implements Iterator<int[]> |
33 |
|
{ |
34 |
|
private List<int[]> vcontigs = new ArrayList<>(); |
35 |
|
|
36 |
|
private int currentPosition = 0; |
37 |
|
|
38 |
|
private boolean endsAtHidden = false; |
39 |
|
|
|
|
| 0% |
Uncovered Elements: 38 (38) |
Complexity: 8 |
Complexity Density: 0.31 |
|
40 |
0 |
VisibleContigsIterator(int start, int end, List<int[]> hiddenColumns)... |
41 |
|
{ |
42 |
0 |
if (hiddenColumns != null && hiddenColumns.size() > 0) |
43 |
|
{ |
44 |
0 |
int vstart = start; |
45 |
0 |
int hideStart; |
46 |
0 |
int hideEnd; |
47 |
|
|
48 |
0 |
for (int[] region : hiddenColumns) |
49 |
|
{ |
50 |
0 |
endsAtHidden = false; |
51 |
0 |
hideStart = region[0]; |
52 |
0 |
hideEnd = region[1]; |
53 |
|
|
54 |
|
|
55 |
0 |
if (hideEnd < vstart) |
56 |
|
{ |
57 |
0 |
continue; |
58 |
|
} |
59 |
0 |
if (hideStart > vstart) |
60 |
|
{ |
61 |
0 |
if (end - 1 > hideStart - 1) |
62 |
|
{ |
63 |
0 |
int[] contig = new int[] { vstart, hideStart - 1 }; |
64 |
0 |
vcontigs.add(contig); |
65 |
0 |
endsAtHidden = true; |
66 |
|
} |
67 |
|
else |
68 |
|
{ |
69 |
0 |
int[] contig = new int[] { vstart, end - 1 }; |
70 |
0 |
vcontigs.add(contig); |
71 |
|
} |
72 |
|
} |
73 |
0 |
vstart = hideEnd + 1; |
74 |
|
|
75 |
|
|
76 |
0 |
if (vstart >= end) |
77 |
|
{ |
78 |
0 |
break; |
79 |
|
} |
80 |
|
} |
81 |
|
|
82 |
0 |
if (vstart < end) |
83 |
|
{ |
84 |
0 |
int[] contig = new int[] { vstart, end - 1 }; |
85 |
0 |
vcontigs.add(contig); |
86 |
0 |
endsAtHidden = false; |
87 |
|
} |
88 |
|
} |
89 |
|
else |
90 |
|
{ |
91 |
0 |
int[] contig = new int[] { start, end - 1 }; |
92 |
0 |
vcontigs.add(contig); |
93 |
|
} |
94 |
|
} |
95 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
96 |
0 |
@Override... |
97 |
|
public boolean hasNext() |
98 |
|
{ |
99 |
0 |
return (currentPosition < vcontigs.size()); |
100 |
|
} |
101 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
102 |
0 |
@Override... |
103 |
|
public int[] next() |
104 |
|
{ |
105 |
0 |
int[] result = vcontigs.get(currentPosition); |
106 |
0 |
currentPosition++; |
107 |
0 |
return result; |
108 |
|
} |
109 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
110 |
0 |
public boolean endsAtHidden()... |
111 |
|
{ |
112 |
0 |
return endsAtHidden; |
113 |
|
} |
114 |
|
} |