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 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (36) |
Complexity: 10 |
Complexity Density: 0.42 |
|
31 |
|
public class StartRegionIterator implements Iterator<Integer> |
32 |
|
{ |
33 |
|
|
34 |
|
private int start; |
35 |
|
|
36 |
|
|
37 |
|
private int end; |
38 |
|
|
39 |
|
|
40 |
|
private int currentPosition = 0; |
41 |
|
|
42 |
|
|
43 |
|
private List<Integer> positions = null; |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
@param |
49 |
|
|
50 |
|
@param |
51 |
|
|
52 |
|
@param |
53 |
|
|
54 |
|
|
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
56 |
7 |
StartRegionIterator(int lowerBound, int upperBound,... |
57 |
|
List<int[]> hiddenColumns) |
58 |
|
{ |
59 |
7 |
this(null, lowerBound, upperBound, hiddenColumns); |
60 |
|
} |
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
@param |
66 |
|
|
67 |
|
@param |
68 |
|
|
69 |
|
@param |
70 |
|
|
71 |
|
@param |
72 |
|
|
73 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (27) |
Complexity: 7 |
Complexity Density: 0.37 |
|
74 |
418 |
StartRegionIterator(HiddenCursorPosition pos, int lowerBound,... |
75 |
|
int upperBound, List<int[]> hiddenColumns) |
76 |
|
{ |
77 |
418 |
start = lowerBound; |
78 |
418 |
end = upperBound; |
79 |
|
|
80 |
418 |
if (hiddenColumns != null) |
81 |
|
{ |
82 |
416 |
positions = new ArrayList<>(hiddenColumns.size()); |
83 |
|
|
84 |
|
|
85 |
416 |
int i = 0; |
86 |
416 |
int hiddenSoFar = 0; |
87 |
|
|
88 |
416 |
if (pos != null) |
89 |
|
{ |
90 |
|
|
91 |
403 |
i = pos.getRegionIndex(); |
92 |
403 |
hiddenSoFar = pos.getHiddenSoFar(); |
93 |
|
} |
94 |
|
else |
95 |
|
{ |
96 |
|
|
97 |
15 |
while ((i < hiddenColumns.size()) |
98 |
|
&& (hiddenColumns.get(i)[0] < start + hiddenSoFar)) |
99 |
|
{ |
100 |
2 |
int[] region = hiddenColumns.get(i); |
101 |
2 |
hiddenSoFar += region[1] - region[0] + 1; |
102 |
2 |
i++; |
103 |
|
} |
104 |
|
} |
105 |
|
|
106 |
|
|
107 |
|
|
108 |
829 |
while (i < hiddenColumns.size() |
109 |
|
&& (hiddenColumns.get(i)[0] <= end + hiddenSoFar)) |
110 |
|
{ |
111 |
413 |
int[] region = hiddenColumns.get(i); |
112 |
413 |
positions.add(region[0] - hiddenSoFar); |
113 |
413 |
hiddenSoFar += region[1] - region[0] + 1; |
114 |
413 |
i++; |
115 |
|
} |
116 |
|
} |
117 |
|
else |
118 |
|
{ |
119 |
2 |
positions = new ArrayList<>(); |
120 |
|
} |
121 |
|
|
122 |
|
} |
123 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
124 |
829 |
@Override... |
125 |
|
public boolean hasNext() |
126 |
|
{ |
127 |
829 |
return (currentPosition < positions.size()); |
128 |
|
} |
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
@return |
134 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
135 |
413 |
@Override... |
136 |
|
public Integer next() |
137 |
|
{ |
138 |
413 |
int result = positions.get(currentPosition); |
139 |
413 |
currentPosition++; |
140 |
413 |
return result; |
141 |
|
} |
142 |
|
} |