1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.renderer; |
22 |
|
|
23 |
|
import java.util.Arrays; |
24 |
|
import java.util.Iterator; |
25 |
|
import java.util.List; |
26 |
|
|
27 |
|
import jalview.datamodel.ColumnSelection; |
28 |
|
import jalview.datamodel.ContactListI; |
29 |
|
import jalview.datamodel.HiddenColumns; |
30 |
|
import jalview.renderer.ContactGeometry.contactInterval; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
@author |
37 |
|
|
38 |
|
|
|
|
| 0% |
Uncovered Elements: 88 (88) |
Complexity: 27 |
Complexity Density: 0.53 |
|
39 |
|
public class ContactGeometry |
40 |
|
{ |
41 |
|
|
42 |
|
final ContactListI contacts; |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
final int pixels_step; |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
final double contacts_per_pixel; |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
final int contact_height; |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
final int graphHeight; |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
final double contacts_step; |
68 |
|
|
69 |
|
final int lastStep; |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
@param |
75 |
|
@param |
76 |
|
|
77 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
78 |
0 |
public ContactGeometry(final ContactListI contacts, int graphHeight)... |
79 |
|
{ |
80 |
0 |
this.contacts = contacts; |
81 |
0 |
this.graphHeight = graphHeight; |
82 |
0 |
contact_height = contacts.getContactHeight(); |
83 |
|
|
84 |
0 |
contacts_per_pixel = (graphHeight <= 1) ? contact_height |
85 |
|
: ((double) contact_height) / ((double) graphHeight); |
86 |
|
|
87 |
0 |
if (contacts_per_pixel >= 1) |
88 |
|
{ |
89 |
|
|
90 |
0 |
pixels_step = 1; |
91 |
|
} |
92 |
|
else |
93 |
|
{ |
94 |
|
|
95 |
0 |
pixels_step = (int) Math |
96 |
|
.ceil(((double) graphHeight) / (double) contact_height); |
97 |
|
} |
98 |
0 |
contacts_step = pixels_step * contacts_per_pixel; |
99 |
0 |
lastStep = (int) Math.min((double) graphHeight, |
100 |
|
((double) graphHeight) / ((double) pixels_step)); |
101 |
|
} |
102 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 5 |
Complexity Density: 0.56 |
|
103 |
|
public class contactInterval |
104 |
|
{ |
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
105 |
0 |
public contactInterval(int cStart, int cEnd, int pStart, int pEnd)... |
106 |
|
{ |
107 |
0 |
this.cStart = cStart; |
108 |
0 |
this.cEnd = cEnd; |
109 |
0 |
this.pStart = pStart; |
110 |
0 |
this.pEnd = pEnd; |
111 |
|
} |
112 |
|
|
113 |
|
|
114 |
|
public final int cStart; |
115 |
|
|
116 |
|
public final int cEnd; |
117 |
|
|
118 |
|
|
119 |
|
public final int pStart; |
120 |
|
|
121 |
|
public final int pEnd; |
122 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
123 |
0 |
@Override... |
124 |
|
public boolean equals(Object obj) |
125 |
|
{ |
126 |
0 |
if (obj == null || !(obj instanceof contactInterval)) |
127 |
|
{ |
128 |
0 |
return false; |
129 |
|
} |
130 |
0 |
contactInterval them = (contactInterval) obj; |
131 |
0 |
return cStart == them.cStart && cEnd == them.cEnd && pEnd == them.pEnd |
132 |
|
&& pStart == them.pStart; |
133 |
|
} |
134 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
135 |
0 |
@Override... |
136 |
|
public String toString() |
137 |
|
{ |
138 |
0 |
return "Contacts [" + cStart + "," + cEnd + "] : Pixels [" + pStart |
139 |
|
+ "," + pEnd + "]"; |
140 |
|
} |
141 |
|
} |
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
@param |
146 |
|
@param |
147 |
|
@param |
148 |
|
|
149 |
|
|
150 |
|
@return |
151 |
|
|
152 |
|
|
153 |
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 9 |
Complexity Density: 0.64 |
|
154 |
0 |
boolean intersects(contactInterval ci, ColumnSelection columnSelection,... |
155 |
|
HiddenColumns hiddenColumns, boolean visibleOnly) |
156 |
|
{ |
157 |
0 |
boolean rowsel = false; |
158 |
0 |
final int[] mappedRange = contacts.getMappedPositionsFor(ci.cStart, |
159 |
|
ci.cEnd); |
160 |
0 |
if (mappedRange == null) |
161 |
|
{ |
162 |
0 |
return false; |
163 |
|
} |
164 |
0 |
for (int p = 0; p < mappedRange.length && !rowsel; p += 2) |
165 |
|
{ |
166 |
0 |
boolean containsHidden = false; |
167 |
0 |
if (visibleOnly && hiddenColumns != null |
168 |
|
&& hiddenColumns.hasHiddenColumns()) |
169 |
|
{ |
170 |
|
|
171 |
0 |
Iterator<int[]> viscont = hiddenColumns.getVisContigsIterator( |
172 |
|
-1 + mappedRange[p], -1 + mappedRange[p + 1], false); |
173 |
0 |
containsHidden = !viscont.hasNext(); |
174 |
0 |
if (!containsHidden) |
175 |
|
{ |
176 |
0 |
for (int[] interval = viscont.next(); viscont |
177 |
|
.hasNext(); rowsel |= columnSelection |
178 |
|
.intersects(interval[p], interval[p + 1])) |
179 |
0 |
; |
180 |
|
} |
181 |
|
} |
182 |
|
else |
183 |
|
{ |
184 |
0 |
rowsel = columnSelection.intersects(-1 + mappedRange[p], |
185 |
|
-1 + mappedRange[p + 1]); |
186 |
|
} |
187 |
|
} |
188 |
0 |
return rowsel; |
189 |
|
|
190 |
|
} |
191 |
|
|
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
@param |
199 |
|
|
200 |
|
@param |
201 |
|
@return |
202 |
|
|
203 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 5 |
Complexity Density: 0.5 |
|
204 |
0 |
public contactInterval mapFor(int pStart, int pEnd)... |
205 |
|
{ |
206 |
0 |
if (pStart < 0) |
207 |
|
{ |
208 |
0 |
pStart = 0; |
209 |
|
} |
210 |
0 |
if (pEnd < pStart) |
211 |
|
{ |
212 |
0 |
pEnd = pStart; |
213 |
|
} |
214 |
0 |
if (pEnd >= graphHeight) |
215 |
|
{ |
216 |
0 |
pEnd = graphHeight - 1; |
217 |
|
} |
218 |
0 |
if (pStart >= graphHeight) |
219 |
|
{ |
220 |
0 |
pStart = graphHeight - pixels_step; |
221 |
|
} |
222 |
0 |
int step = Math.floorDiv(pStart, pixels_step); |
223 |
0 |
return findStep(step); |
224 |
|
} |
225 |
|
|
226 |
|
|
227 |
|
|
228 |
|
@param |
229 |
|
|
230 |
|
@return |
231 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
232 |
0 |
contactInterval findStep(int step)... |
233 |
|
{ |
234 |
0 |
if (step < 0 || step > lastStep) |
235 |
|
{ |
236 |
0 |
return null; |
237 |
|
} |
238 |
0 |
return new contactInterval((int) Math.floor(contacts_step * step), |
239 |
|
-1 + (int) Math.min(contact_height, |
240 |
|
Math.floor(contacts_step * (step + 1))), |
241 |
|
pixels_step * step, |
242 |
|
Math.min(graphHeight, (step + 1) * pixels_step) - 1); |
243 |
|
} |
244 |
|
|
245 |
|
|
246 |
|
|
247 |
|
|
248 |
|
@param |
249 |
|
@return |
250 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
251 |
0 |
public contactInterval mapFor(int pCentre)... |
252 |
|
{ |
253 |
0 |
if (pCentre >= graphHeight + pixels_step) |
254 |
|
{ |
255 |
0 |
return null; |
256 |
|
} |
257 |
0 |
int step = Math.floorDiv(pCentre, pixels_step); |
258 |
0 |
return findStep(step); |
259 |
|
} |
260 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 4 |
Complexity Density: 0.4 |
|
261 |
0 |
public List<contactInterval> allSteps()... |
262 |
|
{ |
263 |
0 |
contactInterval[] array = new contactInterval[lastStep + 1]; |
264 |
0 |
int csum = 0, psum = 0; |
265 |
0 |
for (int i = 0; i <= lastStep; i++) |
266 |
|
{ |
267 |
0 |
array[i] = findStep(i); |
268 |
0 |
csum += 1 + array[i].cEnd - array[i].cStart; |
269 |
0 |
psum += 1 + array[i].pEnd - array[i].pStart; |
270 |
|
} |
271 |
0 |
if (csum != contact_height || psum != graphHeight) |
272 |
|
{ |
273 |
0 |
System.err.println("csum = " + csum + " not " + contact_height + "\n" |
274 |
|
+ "psum = " + psum + " not " + graphHeight); |
275 |
0 |
return null; |
276 |
|
} |
277 |
0 |
return Arrays.asList(array); |
278 |
|
} |
279 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
280 |
0 |
public Iterator<contactInterval> iterateOverContactIntervals(... |
281 |
|
int graphHeight) |
282 |
|
{ |
283 |
|
|
284 |
0 |
return null; |
285 |
|
|
286 |
|
|
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
|
291 |
|
|
292 |
|
|
293 |
|
|
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
|
299 |
|
|
300 |
|
|
301 |
|
|
302 |
|
|
303 |
|
|
304 |
|
|
305 |
|
|
306 |
|
|
307 |
|
|
308 |
|
|
309 |
|
|
310 |
|
|
311 |
|
} |
312 |
|
} |