use of org.eclipse.elk.alg.layered.options.SelfLoopOrderingStrategy in project elk by eclipse.
the class LabelPlacer method assignSideAndAlignment.
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Side and Alignment
private void assignSideAndAlignment(final SelfLoopHolder slHolder) {
// Most loops are straightforward, but the one-sides northern and southern ones may not be. If the loops are
// stacked, we can simply center their labels. If they are sequenced, we want to go from the outer loops to the
// inner loops in pairs, and align their labels away from each other. To do so, we need to collect all of them
// first.
List<SelfHyperLoop> northernOneSidedSLLoops = null;
List<SelfHyperLoop> southernOneSidedSLLoops = null;
SelfLoopOrderingStrategy orderingStrategy = slHolder.getLNode().getProperty(LayeredOptions.EDGE_ROUTING_SELF_LOOP_ORDERING);
if (orderingStrategy == SelfLoopOrderingStrategy.SEQUENCED) {
northernOneSidedSLLoops = new ArrayList<>();
southernOneSidedSLLoops = new ArrayList<>();
}
// Assign sides and alignments; how this works differs for the different kinds of labels
for (SelfHyperLoop slLoop : slHolder.getSLHyperLoops()) {
// If this loop doesn't have any labels, don't bother
SelfHyperLoopLabels slLabels = slLoop.getSLLabels();
if (slLabels == null) {
continue;
}
assert !slLabels.getLLabels().isEmpty();
// How we place labels largely depends on the self loop type
switch(slLoop.getSelfLoopType()) {
case ONE_SIDE:
PortSide loopSide = slLoop.getOccupiedPortSides().iterator().next();
if (orderingStrategy == SelfLoopOrderingStrategy.SEQUENCED && (loopSide == PortSide.NORTH)) {
// Collect for deferred processing
northernOneSidedSLLoops.add(slLoop);
} else if (orderingStrategy == SelfLoopOrderingStrategy.SEQUENCED && (loopSide == PortSide.SOUTH)) {
// Collect for deferred processing
southernOneSidedSLLoops.add(slLoop);
} else {
assignOneSidedSimpleSideAndAlignment(slLoop, loopSide);
}
break;
case TWO_SIDES_CORNER:
assignTwoSidesCornerSideAndAlignment(slLoop);
break;
case TWO_SIDES_OPPOSING:
case THREE_SIDES:
assignTwoSidesOpposingAndThreeSidesSideAndAlignment(slLoop);
break;
case FOUR_SIDES:
assignFourSidesSideAndAlignment(slLoop);
break;
default:
assert false;
}
}
// Process deferred loops
if (northernOneSidedSLLoops != null) {
if (!northernOneSidedSLLoops.isEmpty()) {
assignOneSidedSequencedSideAndAlignment(northernOneSidedSLLoops, PortSide.NORTH);
}
if (!southernOneSidedSLLoops.isEmpty()) {
assignOneSidedSequencedSideAndAlignment(southernOneSidedSLLoops, PortSide.SOUTH);
}
}
}
Aggregations