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.awt.Color; |
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
@author |
29 |
|
@version |
30 |
|
|
|
|
| 56.7% |
Uncovered Elements: 52 (120) |
Complexity: 48 |
Complexity Density: 0.72 |
|
31 |
|
public class BinaryNode<T> |
32 |
|
{ |
33 |
|
T element; |
34 |
|
|
35 |
|
String name; |
36 |
|
|
37 |
|
String label = null; |
38 |
|
|
39 |
|
AlignmentAnnotation alignmentAnnotation = null; |
40 |
|
|
41 |
|
BinaryNode<T> left; |
42 |
|
|
43 |
|
BinaryNode<T> right; |
44 |
|
|
45 |
|
BinaryNode<T> parent; |
46 |
|
|
47 |
|
|
48 |
|
public int bootstrap; |
49 |
|
|
50 |
|
|
51 |
|
public double dist; |
52 |
|
|
53 |
|
|
54 |
|
public int count; |
55 |
|
|
56 |
|
|
57 |
|
public double height; |
58 |
|
|
59 |
|
|
60 |
|
public float ycount; |
61 |
|
|
62 |
|
|
63 |
|
public Color color = Color.black; |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
public boolean dummy = false; |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
74 |
563 |
public BinaryNode()... |
75 |
|
{ |
76 |
563 |
left = right = parent = null; |
77 |
563 |
bootstrap = 0; |
78 |
563 |
dist = 0; |
79 |
|
} |
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
@param |
85 |
|
|
86 |
|
@param |
87 |
|
|
88 |
|
@param |
89 |
|
|
90 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
91 |
396 |
public BinaryNode(T element, BinaryNode<T> parent, String name,... |
92 |
|
double dist) |
93 |
|
{ |
94 |
396 |
this(); |
95 |
396 |
this.element = element; |
96 |
396 |
this.parent = parent; |
97 |
396 |
this.name = name; |
98 |
396 |
this.dist = dist; |
99 |
|
} |
100 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
101 |
396 |
public BinaryNode(T element, BinaryNode<T> parent, String name,... |
102 |
|
double dist, int bootstrap) |
103 |
|
{ |
104 |
396 |
this(element, parent, name, dist); |
105 |
396 |
this.bootstrap = bootstrap; |
106 |
|
} |
107 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
108 |
396 |
public BinaryNode(T val, BinaryNode<T> parent, String name, double dist,... |
109 |
|
int bootstrap, boolean dummy) |
110 |
|
{ |
111 |
396 |
this(val, parent, name, dist, bootstrap); |
112 |
396 |
this.dummy = dummy; |
113 |
|
} |
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
@return |
119 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
120 |
114 |
public T element()... |
121 |
|
{ |
122 |
114 |
return element; |
123 |
|
} |
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
@param |
129 |
|
|
130 |
|
|
131 |
|
@return |
132 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
133 |
283 |
public T setElement(T v)... |
134 |
|
{ |
135 |
283 |
return element = v; |
136 |
|
} |
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
@return |
142 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
143 |
5487 |
public BinaryNode<T> left()... |
144 |
|
{ |
145 |
5487 |
return left; |
146 |
|
} |
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
@param |
152 |
|
|
153 |
|
|
154 |
|
@return |
155 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
156 |
260 |
public BinaryNode<T> setLeft(BinaryNode<T> n)... |
157 |
|
{ |
158 |
260 |
return left = n; |
159 |
|
} |
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
@return |
165 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
166 |
3785 |
public BinaryNode<T> right()... |
167 |
|
{ |
168 |
3785 |
return right; |
169 |
|
} |
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
@param |
175 |
|
|
176 |
|
|
177 |
|
@return |
178 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
179 |
280 |
public BinaryNode<T> setRight(BinaryNode<T> n)... |
180 |
|
{ |
181 |
280 |
return right = n; |
182 |
|
} |
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
@return |
188 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
189 |
2120 |
public BinaryNode<T> parent()... |
190 |
|
{ |
191 |
2120 |
return parent; |
192 |
|
} |
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
@param |
198 |
|
|
199 |
|
|
200 |
|
@return |
201 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
202 |
144 |
public BinaryNode<T> setParent(BinaryNode<T> n)... |
203 |
|
{ |
204 |
144 |
return parent = n; |
205 |
|
} |
206 |
|
|
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
@return |
211 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
212 |
278 |
public boolean isLeaf()... |
213 |
|
{ |
214 |
278 |
return (left == null) && (right == null); |
215 |
|
} |
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
|
221 |
|
|
222 |
|
|
223 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
224 |
0 |
public void SetChildren(BinaryNode<T> leftchild, BinaryNode<T> rightchild)... |
225 |
|
{ |
226 |
0 |
if (leftchild != null) |
227 |
|
{ |
228 |
0 |
this.setLeft(leftchild); |
229 |
0 |
leftchild.detach(); |
230 |
0 |
leftchild.setParent(this); |
231 |
|
} |
232 |
|
|
233 |
0 |
if (rightchild != null) |
234 |
|
{ |
235 |
0 |
this.setRight(rightchild); |
236 |
0 |
rightchild.detach(); |
237 |
0 |
rightchild.setParent(this); |
238 |
|
} |
239 |
|
} |
240 |
|
|
241 |
|
|
242 |
|
|
243 |
|
|
244 |
|
@return |
245 |
|
|
|
|
| 69.2% |
Uncovered Elements: 4 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
246 |
20 |
public BinaryNode<T> detach()... |
247 |
|
{ |
248 |
20 |
if (this.parent != null) |
249 |
|
{ |
250 |
20 |
if (this.parent.left == this) |
251 |
|
{ |
252 |
0 |
this.parent.left = null; |
253 |
|
} |
254 |
|
else |
255 |
|
{ |
256 |
20 |
if (this.parent.right == this) |
257 |
|
{ |
258 |
20 |
this.parent.right = null; |
259 |
|
} |
260 |
|
} |
261 |
|
} |
262 |
|
|
263 |
20 |
this.parent = null; |
264 |
|
|
265 |
20 |
return this; |
266 |
|
} |
267 |
|
|
268 |
|
|
269 |
|
|
270 |
|
|
271 |
|
|
272 |
|
@return |
273 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 4 |
Complexity Density: 1 |
|
274 |
0 |
public BinaryNode<T> ascendLeft()... |
275 |
|
{ |
276 |
0 |
BinaryNode<T> c = this; |
277 |
|
|
278 |
0 |
do |
279 |
|
{ |
280 |
0 |
c = c.parent(); |
281 |
0 |
} while ((c != null) && (c.left() != null) && !c.left().isLeaf()); |
282 |
|
|
283 |
0 |
return c; |
284 |
|
} |
285 |
|
|
286 |
|
|
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
|
291 |
|
@return |
292 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 4 |
Complexity Density: 1 |
|
293 |
0 |
public BinaryNode<T> ascendRight()... |
294 |
|
{ |
295 |
0 |
BinaryNode<T> c = this; |
296 |
|
|
297 |
0 |
do |
298 |
|
{ |
299 |
0 |
c = c.parent(); |
300 |
0 |
} while ((c != null) && (c.right() != null) && !c.right().isLeaf()); |
301 |
|
|
302 |
0 |
return c; |
303 |
|
} |
304 |
|
|
305 |
|
|
306 |
|
|
307 |
|
|
308 |
|
|
309 |
|
@param |
310 |
|
|
311 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
312 |
263 |
public void setName(String name)... |
313 |
|
{ |
314 |
263 |
this.name = name; |
315 |
|
} |
316 |
|
|
317 |
|
|
318 |
|
|
319 |
|
|
320 |
|
@return |
321 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
322 |
802 |
public String getName()... |
323 |
|
{ |
324 |
802 |
return this.name; |
325 |
|
} |
326 |
|
|
327 |
|
|
328 |
|
|
329 |
|
|
330 |
|
@param |
331 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
332 |
188 |
public void setBootstrap(int boot)... |
333 |
|
{ |
334 |
188 |
this.bootstrap = boot; |
335 |
|
} |
336 |
|
|
337 |
|
|
338 |
|
|
339 |
|
|
340 |
|
@return |
341 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
342 |
234 |
public int getBootstrap()... |
343 |
|
{ |
344 |
234 |
return bootstrap; |
345 |
|
} |
346 |
|
|
347 |
|
|
348 |
|
@param |
349 |
|
|
350 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
351 |
134 |
public boolean isDummy()... |
352 |
|
{ |
353 |
134 |
return dummy; |
354 |
|
} |
355 |
|
|
356 |
|
|
357 |
|
|
358 |
|
|
359 |
|
@param |
360 |
|
|
361 |
|
|
362 |
|
@return |
363 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
364 |
0 |
public boolean setDummy(boolean newstate)... |
365 |
|
{ |
366 |
0 |
boolean oldstate = dummy; |
367 |
0 |
dummy = newstate; |
368 |
|
|
369 |
0 |
return oldstate; |
370 |
|
} |
371 |
|
|
372 |
|
|
373 |
|
|
374 |
|
|
375 |
|
@return |
376 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
377 |
192 |
public boolean hasLabel()... |
378 |
|
{ |
379 |
192 |
return label != null && !label.isEmpty(); |
380 |
|
} |
381 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
382 |
0 |
public String getLabel()... |
383 |
|
{ |
384 |
0 |
return label; |
385 |
|
} |
386 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
387 |
0 |
public void setLabel(String label)... |
388 |
|
{ |
389 |
0 |
this.label = label; |
390 |
|
} |
391 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
392 |
0 |
public boolean hasAlignmentAnnotation()... |
393 |
|
{ |
394 |
0 |
return alignmentAnnotation != null; |
395 |
|
} |
396 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
397 |
0 |
public AlignmentAnnotation getAlignmentAnnotation()... |
398 |
|
{ |
399 |
0 |
return alignmentAnnotation; |
400 |
|
} |
401 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
402 |
0 |
public void setAlignmentAnnotation(AlignmentAnnotation alignmentAnnotation)... |
403 |
|
{ |
404 |
0 |
this.alignmentAnnotation = alignmentAnnotation; |
405 |
|
} |
406 |
|
|
407 |
|
|
408 |
|
|
409 |
|
|
410 |
|
|
411 |
|
|
|
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
412 |
188 |
public BinaryNode<T> AscendTree()... |
413 |
|
{ |
414 |
188 |
BinaryNode<T> c = this; |
415 |
|
|
416 |
188 |
do |
417 |
|
{ |
418 |
188 |
c = c.parent(); |
419 |
188 |
} while ((c != null) && c.dummy); |
420 |
|
|
421 |
188 |
return c; |
422 |
|
} |
423 |
|
|
|
|
| 45.5% |
Uncovered Elements: 6 (11) |
Complexity: 5 |
Complexity Density: 1 |
|
424 |
192 |
public String getDisplayName()... |
425 |
|
{ |
426 |
192 |
if (name != null && !name.isBlank()) |
427 |
|
{ |
428 |
|
|
429 |
192 |
if (hasLabel()) |
430 |
|
{ |
431 |
0 |
return getName() + "|" + label; |
432 |
|
} |
433 |
192 |
return name; |
434 |
|
} |
435 |
0 |
return hasLabel() ? label : ""; |
436 |
|
} |
437 |
|
} |