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