use of org.eclipse.elk.alg.layered.options.DirectionCongruency in project elk by eclipse.
the class GraphTransformer method process.
@Override
public void process(final LGraph layeredGraph, final IElkProgressMonitor monitor) {
monitor.begin("Graph transformation (" + mode + ")", 1);
// We need to add all layerless nodes as well as all nodes in layers since this processor
// is run twice -- once before layering, and once afterwards
List<LNode> nodes = Lists.newArrayList(layeredGraph.getLayerlessNodes());
for (Layer layer : layeredGraph.getLayers()) {
nodes.addAll(layer.getNodes());
}
// graph transformations for unusual layout directions
DirectionCongruency congruency = layeredGraph.getProperty(LayeredOptions.DIRECTION_CONGRUENCY);
if (congruency == DirectionCongruency.READING_DIRECTION) {
// --------------------------------------------------------------
switch(layeredGraph.getProperty(LayeredOptions.DIRECTION)) {
case LEFT:
mirrorAllX(layeredGraph, nodes);
break;
case DOWN:
transposeAll(layeredGraph, nodes);
break;
case UP:
if (mode == Mode.TO_INTERNAL_LTR) {
transposeAll(layeredGraph, nodes);
mirrorAllY(layeredGraph, nodes);
} else {
mirrorAllY(layeredGraph, nodes);
transposeAll(layeredGraph, nodes);
}
break;
}
} else {
if (mode == Mode.TO_INTERNAL_LTR) {
// --------------------------------------------------------------
switch(layeredGraph.getProperty(LayeredOptions.DIRECTION)) {
case LEFT:
mirrorAllX(layeredGraph, nodes);
mirrorAllY(layeredGraph, nodes);
break;
case DOWN:
rotate90Clockwise(layeredGraph, nodes);
break;
case UP:
rotate90CounterClockwise(layeredGraph, nodes);
break;
}
} else {
// --------------------------------------------------------------
switch(layeredGraph.getProperty(LayeredOptions.DIRECTION)) {
case LEFT:
mirrorAllX(layeredGraph, nodes);
mirrorAllY(layeredGraph, nodes);
break;
case DOWN:
rotate90CounterClockwise(layeredGraph, nodes);
break;
case UP:
rotate90Clockwise(layeredGraph, nodes);
break;
}
}
}
monitor.done();
}
Aggregations