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 |
566 |
StartRegionIterator(HiddenCursorPosition pos, int lowerBound,... |
75 |
|
int upperBound, List<int[]> hiddenColumns) |
76 |
|
{ |
77 |
566 |
start = lowerBound; |
78 |
566 |
end = upperBound; |
79 |
|
|
80 |
566 |
if (hiddenColumns != null) |
81 |
|
{ |
82 |
564 |
positions = new ArrayList<>(hiddenColumns.size()); |
83 |
|
|
84 |
|
|
85 |
564 |
int i = 0; |
86 |
564 |
int hiddenSoFar = 0; |
87 |
|
|
88 |
564 |
if (pos != null) |
89 |
|
{ |
90 |
|
|
91 |
551 |
i = pos.getRegionIndex(); |
92 |
551 |
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 |
1123 |
while (i < hiddenColumns.size() |
109 |
|
&& (hiddenColumns.get(i)[0] <= end + hiddenSoFar)) |
110 |
|
{ |
111 |
559 |
int[] region = hiddenColumns.get(i); |
112 |
559 |
positions.add(region[0] - hiddenSoFar); |
113 |
559 |
hiddenSoFar += region[1] - region[0] + 1; |
114 |
559 |
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 |
1123 |
@Override... |
125 |
|
public boolean hasNext() |
126 |
|
{ |
127 |
1123 |
return (currentPosition < positions.size()); |
128 |
|
} |
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
@return |
134 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
135 |
559 |
@Override... |
136 |
|
public Integer next() |
137 |
|
{ |
138 |
559 |
int result = positions.get(currentPosition); |
139 |
559 |
currentPosition++; |
140 |
559 |
return result; |
141 |
|
} |
142 |
|
} |