| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.analysis; |
| 22 |
|
|
| 23 |
|
import java.util.Locale; |
| 24 |
|
|
| 25 |
|
import jalview.datamodel.AlignmentAnnotation; |
| 26 |
|
import jalview.datamodel.AlignmentI; |
| 27 |
|
import jalview.datamodel.BinaryNode; |
| 28 |
|
import jalview.datamodel.SequenceI; |
| 29 |
|
import jalview.datamodel.SequenceNode; |
| 30 |
|
|
| 31 |
|
import java.util.ArrayList; |
| 32 |
|
import java.util.Arrays; |
| 33 |
|
import java.util.Collections; |
| 34 |
|
import java.util.Comparator; |
| 35 |
|
import java.util.HashMap; |
| 36 |
|
import java.util.LinkedHashSet; |
| 37 |
|
import java.util.List; |
| 38 |
|
import java.util.Map; |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
@author |
| 45 |
|
|
| 46 |
|
|
| |
|
| 0% |
Uncovered Elements: 256 (256) |
Complexity: 86 |
Complexity Density: 0.61 |
|
| 47 |
|
public class AnnotationSorter |
| 48 |
|
{ |
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
@author |
| 56 |
|
|
| 57 |
|
|
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 4 |
Complexity Density: 0.67 |
|
| 58 |
|
public enum SequenceAnnotationOrder |
| 59 |
|
{ |
| 60 |
|
|
| 61 |
|
SEQUENCE_AND_LABEL("Sequence"), LABEL_AND_SEQUENCE("Label"), |
| 62 |
|
NONE("No sort"); |
| 63 |
|
|
| 64 |
|
private String description; |
| 65 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 66 |
0 |
private SequenceAnnotationOrder(String s)... |
| 67 |
|
{ |
| 68 |
0 |
description = s; |
| 69 |
|
} |
| 70 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 71 |
0 |
@Override... |
| 72 |
|
public String toString() |
| 73 |
|
{ |
| 74 |
0 |
return description; |
| 75 |
|
} |
| 76 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 77 |
0 |
public static SequenceAnnotationOrder forDescription(String d)... |
| 78 |
|
{ |
| 79 |
0 |
for (SequenceAnnotationOrder order : values()) |
| 80 |
|
{ |
| 81 |
0 |
if (order.toString().equals(d)) |
| 82 |
|
{ |
| 83 |
0 |
return order; |
| 84 |
|
} |
| 85 |
|
} |
| 86 |
0 |
return null; |
| 87 |
|
} |
| 88 |
|
} |
| 89 |
|
|
| 90 |
|
|
| 91 |
|
private final AlignmentI alignment; |
| 92 |
|
|
| 93 |
|
|
| 94 |
|
private boolean showAutocalcAbove; |
| 95 |
|
|
| 96 |
|
|
| 97 |
|
private final Map<SequenceI, Integer> sequenceIndices = new HashMap<SequenceI, Integer>(); |
| 98 |
|
|
| 99 |
|
static TreeModel lastTree = null; |
| 100 |
|
|
| 101 |
|
static boolean sortTreeAscending = true; |
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 106 |
|
@param |
| 107 |
|
@param |
| 108 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 109 |
0 |
public AnnotationSorter(AlignmentI alignmentI,... |
| 110 |
|
boolean showAutocalculatedAbove) |
| 111 |
|
{ |
| 112 |
0 |
this.alignment = alignmentI; |
| 113 |
0 |
this.showAutocalcAbove = showAutocalculatedAbove; |
| 114 |
|
} |
| 115 |
|
|
| 116 |
|
|
| 117 |
|
|
| 118 |
|
|
| 119 |
|
|
| 120 |
|
|
| 121 |
|
|
| 122 |
|
|
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 126 |
|
|
| 127 |
|
private final Comparator<? super AlignmentAnnotation> bySequenceAndLabel = new Comparator<AlignmentAnnotation>() |
| 128 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 40 (40) |
Complexity: 13 |
Complexity Density: 0.65 |
|
| 129 |
0 |
@Override... |
| 130 |
|
public int compare(AlignmentAnnotation o1, AlignmentAnnotation o2) |
| 131 |
|
{ |
| 132 |
0 |
if (o1 == null && o2 == null) |
| 133 |
|
{ |
| 134 |
0 |
return 0; |
| 135 |
|
} |
| 136 |
0 |
if (o1 == null) |
| 137 |
|
{ |
| 138 |
0 |
return -1; |
| 139 |
|
} |
| 140 |
0 |
if (o2 == null) |
| 141 |
|
{ |
| 142 |
0 |
return 1; |
| 143 |
|
} |
| 144 |
|
|
| 145 |
|
|
| 146 |
0 |
boolean o1auto = o1.autoCalculated && o1.sequenceRef == null; |
| 147 |
0 |
boolean o2auto = o2.autoCalculated && o2.sequenceRef == null; |
| 148 |
|
|
| 149 |
|
|
| 150 |
|
|
| 151 |
|
|
| 152 |
0 |
if (o1auto && o2auto) |
| 153 |
|
{ |
| 154 |
0 |
return 0; |
| 155 |
|
} |
| 156 |
|
|
| 157 |
|
|
| 158 |
|
|
| 159 |
|
|
| 160 |
0 |
if (o1auto) |
| 161 |
|
{ |
| 162 |
0 |
return showAutocalcAbove ? -1 : 1; |
| 163 |
|
} |
| 164 |
0 |
if (o2auto) |
| 165 |
|
{ |
| 166 |
0 |
return showAutocalcAbove ? 1 : -1; |
| 167 |
|
} |
| 168 |
0 |
int computedOrder = compareSequences(o1, o2); |
| 169 |
0 |
if (computedOrder == 0) |
| 170 |
|
{ |
| 171 |
0 |
computedOrder = compareLabels(o1, o2); |
| 172 |
|
} |
| 173 |
0 |
if (computedOrder == 0) |
| 174 |
|
{ |
| 175 |
0 |
computedOrder = compareDescriptions(o1, o2); |
| 176 |
|
} |
| 177 |
0 |
return computedOrder; |
| 178 |
|
} |
| 179 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 180 |
0 |
@Override... |
| 181 |
|
public String toString() |
| 182 |
|
{ |
| 183 |
0 |
return "Sort by sequence and label"; |
| 184 |
|
} |
| 185 |
|
}; |
| 186 |
|
|
| 187 |
|
|
| 188 |
|
|
| 189 |
|
|
| 190 |
|
|
| 191 |
|
|
| 192 |
|
|
| 193 |
|
|
| 194 |
|
|
| 195 |
|
|
| 196 |
|
|
| 197 |
|
private final Comparator<? super AlignmentAnnotation> byLabelAndSequence = new Comparator<AlignmentAnnotation>() |
| 198 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 34 (34) |
Complexity: 12 |
Complexity Density: 0.75 |
|
| 199 |
0 |
@Override... |
| 200 |
|
public int compare(AlignmentAnnotation o1, AlignmentAnnotation o2) |
| 201 |
|
{ |
| 202 |
0 |
if (o1 == null && o2 == null) |
| 203 |
|
{ |
| 204 |
0 |
return 0; |
| 205 |
|
} |
| 206 |
0 |
if (o1 == null) |
| 207 |
|
{ |
| 208 |
0 |
return -1; |
| 209 |
|
} |
| 210 |
0 |
if (o2 == null) |
| 211 |
|
{ |
| 212 |
0 |
return 1; |
| 213 |
|
} |
| 214 |
|
|
| 215 |
|
|
| 216 |
0 |
boolean o1auto = o1.autoCalculated && o1.sequenceRef == null; |
| 217 |
0 |
boolean o2auto = o2.autoCalculated && o2.sequenceRef == null; |
| 218 |
|
|
| 219 |
|
|
| 220 |
|
|
| 221 |
|
|
| 222 |
0 |
if (o1auto && o2auto) |
| 223 |
|
{ |
| 224 |
0 |
return 0; |
| 225 |
|
} |
| 226 |
|
|
| 227 |
|
|
| 228 |
|
|
| 229 |
|
|
| 230 |
0 |
if (o1auto) |
| 231 |
|
{ |
| 232 |
0 |
return showAutocalcAbove ? -1 : 1; |
| 233 |
|
} |
| 234 |
0 |
if (o2auto) |
| 235 |
|
{ |
| 236 |
0 |
return showAutocalcAbove ? 1 : -1; |
| 237 |
|
} |
| 238 |
0 |
int labelOrder = compareLabels(o1, o2); |
| 239 |
0 |
return labelOrder == 0 ? compareSequences(o1, o2) : labelOrder; |
| 240 |
|
} |
| 241 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 242 |
0 |
@Override... |
| 243 |
|
public String toString() |
| 244 |
|
{ |
| 245 |
0 |
return "Sort by label and sequence"; |
| 246 |
|
} |
| 247 |
|
}; |
| 248 |
|
|
| 249 |
|
|
| 250 |
|
|
| 251 |
|
|
| 252 |
|
|
| 253 |
|
|
| 254 |
|
|
| 255 |
|
private Comparator<? super AlignmentAnnotation> noSort = new Comparator<AlignmentAnnotation>() |
| 256 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 9 |
Complexity Density: 1.12 |
|
| 257 |
0 |
@Override... |
| 258 |
|
public int compare(AlignmentAnnotation o1, AlignmentAnnotation o2) |
| 259 |
|
{ |
| 260 |
|
|
| 261 |
0 |
boolean o1auto = o1.autoCalculated && o1.sequenceRef == null; |
| 262 |
0 |
boolean o2auto = o2.autoCalculated && o2.sequenceRef == null; |
| 263 |
|
|
| 264 |
|
|
| 265 |
0 |
if (o1 != null && o2 != null) |
| 266 |
|
{ |
| 267 |
0 |
if (o1auto && !o2auto) |
| 268 |
|
{ |
| 269 |
0 |
return showAutocalcAbove ? -1 : 1; |
| 270 |
|
} |
| 271 |
0 |
if (!o1auto && o2auto) |
| 272 |
|
{ |
| 273 |
0 |
return showAutocalcAbove ? 1 : -1; |
| 274 |
|
} |
| 275 |
|
} |
| 276 |
0 |
return 0; |
| 277 |
|
} |
| 278 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 279 |
0 |
@Override... |
| 280 |
|
public String toString() |
| 281 |
|
{ |
| 282 |
0 |
return "No sort"; |
| 283 |
|
} |
| 284 |
|
}; |
| 285 |
|
|
| 286 |
|
|
| 287 |
|
|
| 288 |
|
|
| 289 |
|
@param |
| 290 |
|
@param |
| 291 |
|
|
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 292 |
0 |
public void sort(AlignmentAnnotation[] alignmentAnnotations,... |
| 293 |
|
SequenceAnnotationOrder order) |
| 294 |
|
{ |
| 295 |
0 |
if (alignmentAnnotations == null) |
| 296 |
|
{ |
| 297 |
0 |
return; |
| 298 |
|
} |
| 299 |
|
|
| 300 |
0 |
saveSequenceIndices(alignmentAnnotations); |
| 301 |
|
|
| 302 |
0 |
Comparator<? super AlignmentAnnotation> comparator = getComparator( |
| 303 |
|
order); |
| 304 |
|
|
| 305 |
0 |
if (alignmentAnnotations != null) |
| 306 |
|
{ |
| 307 |
0 |
synchronized (alignmentAnnotations) |
| 308 |
|
{ |
| 309 |
0 |
Arrays.sort(alignmentAnnotations, comparator); |
| 310 |
|
} |
| 311 |
|
} |
| 312 |
|
} |
| 313 |
|
|
| 314 |
|
|
| 315 |
|
|
| 316 |
|
|
| 317 |
|
|
| 318 |
|
|
| 319 |
|
|
| 320 |
|
|
| 321 |
|
@param |
| 322 |
|
|
| 323 |
|
|
| 324 |
|
@param |
| 325 |
|
|
| 326 |
|
|
| |
|
| 0% |
Uncovered Elements: 31 (31) |
Complexity: 9 |
Complexity Density: 0.43 |
|
| 327 |
0 |
public void sortByTree(AlignmentAnnotation[] alignmentAnnotations,... |
| 328 |
|
TreeModel tree) |
| 329 |
|
{ |
| 330 |
0 |
if(tree == null || alignmentAnnotations == null || alignmentAnnotations.length < 1) { |
| 331 |
0 |
return; |
| 332 |
|
} |
| 333 |
|
|
| 334 |
|
|
| 335 |
|
|
| 336 |
0 |
if (lastTree != tree) |
| 337 |
|
{ |
| 338 |
0 |
sortTreeAscending = true; |
| 339 |
0 |
lastTree = tree; |
| 340 |
|
} |
| 341 |
|
|
| 342 |
|
|
| 343 |
|
else |
| 344 |
|
{ |
| 345 |
0 |
sortTreeAscending = !sortTreeAscending; |
| 346 |
|
} |
| 347 |
|
|
| 348 |
|
|
| 349 |
0 |
List<AlignmentAnnotation> annotOrderByTree = new ArrayList<>(); |
| 350 |
0 |
annotOrderByTree = _sortByTree(tree.getTopNode(), annotOrderByTree); |
| 351 |
|
|
| 352 |
|
|
| 353 |
0 |
LinkedHashSet<AlignmentAnnotation> sortedSet = new LinkedHashSet<>(); |
| 354 |
|
|
| 355 |
0 |
if (annotOrderByTree != null && !annotOrderByTree.isEmpty()) |
| 356 |
|
{ |
| 357 |
|
|
| 358 |
|
|
| 359 |
0 |
if (!sortTreeAscending) |
| 360 |
|
{ |
| 361 |
0 |
Collections.reverse(annotOrderByTree); |
| 362 |
|
} |
| 363 |
|
|
| 364 |
|
|
| 365 |
0 |
for (AlignmentAnnotation aa : annotOrderByTree) |
| 366 |
|
{ |
| 367 |
0 |
sortedSet.add(aa); |
| 368 |
|
} |
| 369 |
|
|
| 370 |
0 |
int index = 0; |
| 371 |
|
|
| 372 |
|
|
| 373 |
0 |
for (AlignmentAnnotation aa : alignmentAnnotations) |
| 374 |
|
{ |
| 375 |
|
|
| 376 |
|
|
| 377 |
0 |
if(aa.autoCalculated) { |
| 378 |
0 |
alignmentAnnotations[index++] = aa; |
| 379 |
|
} |
| 380 |
|
|
| 381 |
|
else { |
| 382 |
0 |
sortedSet.add(aa); |
| 383 |
|
} |
| 384 |
|
} |
| 385 |
|
|
| 386 |
|
|
| 387 |
|
|
| 388 |
|
|
| 389 |
0 |
for (AlignmentAnnotation aa : sortedSet) |
| 390 |
|
{ |
| 391 |
0 |
alignmentAnnotations[index++] = aa; |
| 392 |
|
} |
| 393 |
|
|
| 394 |
|
} |
| 395 |
|
} |
| 396 |
|
|
| 397 |
|
|
| 398 |
|
|
| 399 |
|
|
| 400 |
|
|
| 401 |
|
|
| 402 |
|
|
| 403 |
|
@param |
| 404 |
|
@param |
| 405 |
|
@return |
| 406 |
|
|
| |
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 8 |
Complexity Density: 0.67 |
|
| 407 |
0 |
private List<AlignmentAnnotation> _sortByTree(BinaryNode node,... |
| 408 |
|
List<AlignmentAnnotation> annotOrderByTree) |
| 409 |
|
{ |
| 410 |
|
|
| 411 |
0 |
if (node == null) |
| 412 |
|
{ |
| 413 |
0 |
return annotOrderByTree; |
| 414 |
|
} |
| 415 |
|
|
| 416 |
|
|
| 417 |
0 |
BinaryNode left = (BinaryNode) node.left(); |
| 418 |
0 |
BinaryNode right = (BinaryNode) node.right(); |
| 419 |
|
|
| 420 |
|
|
| 421 |
0 |
if ((left == null) && (right == null)) |
| 422 |
|
{ |
| 423 |
0 |
if (!(node instanceof SequenceNode |
| 424 |
|
&& ((SequenceNode) node).isPlaceholder()) |
| 425 |
|
&& (node.getAlignmentAnnotation() != null )) |
| 426 |
|
{ |
| 427 |
|
|
| 428 |
|
|
| 429 |
0 |
if (!annotOrderByTree.contains(node.getAlignmentAnnotation())) |
| 430 |
|
{ |
| 431 |
0 |
annotOrderByTree.add(node.getAlignmentAnnotation()); |
| 432 |
|
} |
| 433 |
|
|
| 434 |
|
} |
| 435 |
|
|
| 436 |
|
|
| 437 |
0 |
return annotOrderByTree; |
| 438 |
|
} |
| 439 |
|
else |
| 440 |
|
{ |
| 441 |
|
|
| 442 |
0 |
_sortByTree(left, annotOrderByTree); |
| 443 |
0 |
_sortByTree(right, annotOrderByTree); |
| 444 |
|
} |
| 445 |
|
|
| 446 |
|
|
| 447 |
0 |
return annotOrderByTree; |
| 448 |
|
} |
| 449 |
|
|
| 450 |
|
|
| 451 |
|
|
| 452 |
|
|
| 453 |
|
|
| 454 |
|
|
| 455 |
|
@param |
| 456 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 457 |
0 |
private void saveSequenceIndices(... |
| 458 |
|
AlignmentAnnotation[] alignmentAnnotations) |
| 459 |
|
{ |
| 460 |
0 |
sequenceIndices.clear(); |
| 461 |
0 |
for (AlignmentAnnotation ann : alignmentAnnotations) |
| 462 |
|
{ |
| 463 |
0 |
SequenceI seq = ann.sequenceRef; |
| 464 |
0 |
if (seq != null) |
| 465 |
|
{ |
| 466 |
0 |
int index = AlignmentUtils.getSequenceIndex(alignment, seq); |
| 467 |
0 |
sequenceIndices.put(seq, index); |
| 468 |
|
} |
| 469 |
|
} |
| 470 |
|
} |
| 471 |
|
|
| 472 |
|
|
| 473 |
|
|
| 474 |
|
|
| 475 |
|
@param |
| 476 |
|
@return |
| 477 |
|
|
| |
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 5 |
Complexity Density: 0.45 |
|
| 478 |
0 |
private Comparator<? super AlignmentAnnotation> getComparator(... |
| 479 |
|
SequenceAnnotationOrder order) |
| 480 |
|
{ |
| 481 |
0 |
if (order == null) |
| 482 |
|
{ |
| 483 |
0 |
return noSort; |
| 484 |
|
} |
| 485 |
0 |
switch (order) |
| 486 |
|
{ |
| 487 |
0 |
case NONE: |
| 488 |
0 |
return this.noSort; |
| 489 |
0 |
case SEQUENCE_AND_LABEL: |
| 490 |
0 |
return this.bySequenceAndLabel; |
| 491 |
0 |
case LABEL_AND_SEQUENCE: |
| 492 |
0 |
return this.byLabelAndSequence; |
| 493 |
0 |
default: |
| 494 |
0 |
throw new UnsupportedOperationException(order.toString()); |
| 495 |
|
} |
| 496 |
|
} |
| 497 |
|
|
| 498 |
|
|
| 499 |
|
|
| 500 |
|
|
| 501 |
|
|
| 502 |
|
@param |
| 503 |
|
@param |
| 504 |
|
@return |
| 505 |
|
|
| |
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 506 |
0 |
private int compareLabels(AlignmentAnnotation o1, AlignmentAnnotation o2)... |
| 507 |
|
{ |
| 508 |
0 |
if (o1 == null || o2 == null) |
| 509 |
|
{ |
| 510 |
0 |
return 0; |
| 511 |
|
} |
| 512 |
0 |
String label1 = o1.label; |
| 513 |
0 |
String label2 = o2.label; |
| 514 |
0 |
return compareString(label1, label2); |
| 515 |
|
} |
| 516 |
|
|
| 517 |
|
|
| 518 |
|
|
| 519 |
|
|
| 520 |
|
|
| 521 |
|
@param |
| 522 |
|
@param |
| 523 |
|
@return |
| 524 |
|
|
| |
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 525 |
0 |
private int compareDescriptions(AlignmentAnnotation o1,... |
| 526 |
|
AlignmentAnnotation o2) |
| 527 |
|
{ |
| 528 |
0 |
if (o1 == null || o2 == null) |
| 529 |
|
{ |
| 530 |
0 |
return 0; |
| 531 |
|
} |
| 532 |
0 |
String label1 = o1.description; |
| 533 |
0 |
String label2 = o2.description; |
| 534 |
0 |
return compareString(label1, label2); |
| 535 |
|
} |
| 536 |
|
|
| |
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 5 |
Complexity Density: 0.71 |
|
| 537 |
0 |
private int compareString(String label1, String label2)... |
| 538 |
|
{ |
| 539 |
0 |
if (label1 == null && label2 == null) |
| 540 |
|
{ |
| 541 |
0 |
return 0; |
| 542 |
|
} |
| 543 |
0 |
if (label1 == null) |
| 544 |
|
{ |
| 545 |
0 |
return -1; |
| 546 |
|
} |
| 547 |
0 |
if (label2 == null) |
| 548 |
|
{ |
| 549 |
0 |
return 1; |
| 550 |
|
} |
| 551 |
0 |
return label1.toUpperCase(Locale.ROOT) |
| 552 |
|
.compareTo(label2.toUpperCase(Locale.ROOT)); |
| 553 |
|
} |
| 554 |
|
|
| 555 |
|
|
| 556 |
|
|
| 557 |
|
|
| 558 |
|
|
| 559 |
|
@param |
| 560 |
|
@param |
| 561 |
|
@return |
| 562 |
|
|
| |
|
| 0% |
Uncovered Elements: 33 (33) |
Complexity: 10 |
Complexity Density: 0.59 |
|
| 563 |
0 |
private int compareSequences(AlignmentAnnotation o1,... |
| 564 |
|
AlignmentAnnotation o2) |
| 565 |
|
{ |
| 566 |
0 |
SequenceI seq1 = o1.sequenceRef; |
| 567 |
0 |
SequenceI seq2 = o2.sequenceRef; |
| 568 |
0 |
if (seq1 == null && seq2 == null) |
| 569 |
|
{ |
| 570 |
0 |
return 0; |
| 571 |
|
} |
| 572 |
|
|
| 573 |
|
|
| 574 |
|
|
| 575 |
0 |
if (seq1 == null) |
| 576 |
|
{ |
| 577 |
0 |
return showAutocalcAbove ? -1 : 1; |
| 578 |
|
} |
| 579 |
0 |
if (seq2 == null) |
| 580 |
|
{ |
| 581 |
0 |
return showAutocalcAbove ? 1 : -1; |
| 582 |
|
} |
| 583 |
|
|
| 584 |
0 |
int index1 = sequenceIndices.get(seq1); |
| 585 |
0 |
int index2 = sequenceIndices.get(seq2); |
| 586 |
0 |
if (index1 == index2) |
| 587 |
|
{ |
| 588 |
0 |
return 0; |
| 589 |
|
} |
| 590 |
0 |
if (index1 == -1) |
| 591 |
|
{ |
| 592 |
0 |
return -1; |
| 593 |
|
} |
| 594 |
0 |
if (index2 == -1) |
| 595 |
|
{ |
| 596 |
0 |
return 1; |
| 597 |
|
} |
| 598 |
0 |
return Integer.compare(index1, index2); |
| 599 |
|
} |
| 600 |
|
} |