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