use of org.eclipse.elk.graph.ElkNode in project elk by eclipse.
the class AbstractElkGraphSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == ElkGraphPackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case ElkGraphPackage.ELK_BEND_POINT:
sequence_ElkBendPoint(context, (ElkBendPoint) semanticObject);
return;
case ElkGraphPackage.ELK_EDGE:
sequence_EdgeLayout_ElkEdge(context, (ElkEdge) semanticObject);
return;
case ElkGraphPackage.ELK_EDGE_SECTION:
if (rule == grammarAccess.getElkEdgeSectionRule()) {
sequence_ElkEdgeSection(context, (ElkEdgeSection) semanticObject);
return;
} else if (rule == grammarAccess.getElkSingleEdgeSectionRule()) {
sequence_ElkSingleEdgeSection(context, (ElkEdgeSection) semanticObject);
return;
} else
break;
case ElkGraphPackage.ELK_LABEL:
sequence_ElkLabel_ShapeLayout(context, (ElkLabel) semanticObject);
return;
case ElkGraphPackage.ELK_NODE:
if (rule == grammarAccess.getElkNodeRule()) {
sequence_ElkNode_ShapeLayout(context, (ElkNode) semanticObject);
return;
} else if (rule == grammarAccess.getRootNodeRule()) {
sequence_RootNode_ShapeLayout(context, (ElkNode) semanticObject);
return;
} else
break;
case ElkGraphPackage.ELK_PORT:
sequence_ElkPort_ShapeLayout(context, (ElkPort) semanticObject);
return;
case ElkGraphPackage.ELK_PROPERTY_TO_VALUE_MAP_ENTRY:
sequence_Property(context, (Map.Entry) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of org.eclipse.elk.graph.ElkNode in project elk by eclipse.
the class BasicCycleBreakerTest method interactiveConfigurator.
@Configurator
public void interactiveConfigurator(final ElkNode elkGraph) {
// This is a bit more involved. We not only have to set the proper cycle breaking strategy, but we also
// have to assign bogus coordinates to the nodes
Deque<ElkNode> nodeQueue = new LinkedList<>();
nodeQueue.add(elkGraph);
// Fixed seed to keep tests repeatable
Random rand = new Random(INTERACTIVE_RANDOM_SEED);
while (!nodeQueue.isEmpty()) {
ElkNode node = nodeQueue.poll();
nodeQueue.addAll(node.getChildren());
node.setProperty(LayeredOptions.CYCLE_BREAKING_STRATEGY, CycleBreakingStrategy.INTERACTIVE);
if (node.getX() == 0) {
node.setX(rand.nextInt(INTERACTIVE_MAX_POS));
}
if (node.getY() == 0) {
node.setY(rand.nextInt(INTERACTIVE_MAX_POS));
}
}
}
use of org.eclipse.elk.graph.ElkNode in project elk by eclipse.
the class BasicLayerAssignmentTest method interactiveConfigurator.
@Configurator
public void interactiveConfigurator(final ElkNode elkGraph) {
// This is a bit more involved. We not only have to set the proper cycle breaking strategy, but we also
// have to assign bogus coordinates to the nodes
Deque<ElkNode> nodeQueue = new LinkedList<>();
nodeQueue.add(elkGraph);
// Fixed seed to keep tests repeatable
Random rand = new Random(INTERACTIVE_RANDOM_SEED);
while (!nodeQueue.isEmpty()) {
ElkNode node = nodeQueue.poll();
nodeQueue.addAll(node.getChildren());
node.setProperty(LayeredOptions.LAYERING_STRATEGY, LayeringStrategy.INTERACTIVE);
if (node.getX() == 0) {
node.setX(rand.nextInt(INTERACTIVE_MAX_POS));
}
if (node.getY() == 0) {
node.setY(rand.nextInt(INTERACTIVE_MAX_POS));
}
}
}
use of org.eclipse.elk.graph.ElkNode in project elk by eclipse.
the class Issue682Test method testGraph.
public Triple<ElkNode, ElkNode, ElkLabel> testGraph() {
ElkNode graph = ElkGraphUtil.createGraph();
graph.setProperty(CoreOptions.ALGORITHM, LayeredOptions.ALGORITHM_ID);
graph.setProperty(LayeredOptions.EDGE_ROUTING, EdgeRouting.ORTHOGONAL);
graph.setProperty(LayeredOptions.DIRECTION, layoutDirection);
graph.setProperty(LayeredOptions.NODE_LABELS_PADDING, new ElkPadding(21, 32, 43, 54));
ElkNode parent = ElkGraphUtil.createNode(graph);
parent.setProperty(LayeredOptions.NODE_SIZE_CONSTRAINTS, EnumSet.of(SizeConstraint.NODE_LABELS));
parent.setProperty(LayeredOptions.NODE_LABELS_PLACEMENT, NodeLabelPlacement.insideTopCenter());
ElkLabel label = ElkGraphUtil.createLabel("foobar", parent);
// Arbitrary
label.setWidth(23);
label.setHeight(22);
return new Triple<>(graph, parent, label);
}
use of org.eclipse.elk.graph.ElkNode in project elk by eclipse.
the class Issue701Test method testFixedInsideLabels.
/**
* Check behavior for port labels that is fixed, empty {@link PortLabelPlacement) property, but partially located
* inside the node.
*/
@Test
public void testFixedInsideLabels(final ElkNode graph) {
ElkNode containerForInsideLabels = GraphTestUtils.getChild(graph, "ContainerWithFixedLabels", "Container_OneBorderNode_LabelFixedPartiallyInside");
// Ensure there is no label overlaps
if (GraphTestUtils.haveOverlaps(assembleLabels(containerForInsideLabels))) {
fail("Overlaps between labels detected in \"Container_OneBorderNode_LabelFixedPartiallyInside\"!");
}
// Port on north
ElkNode node1 = GraphTestUtils.getChild(containerForInsideLabels, "MyNode1");
ElkPort portOfNode1 = GraphTestUtils.getPort(node1, "P1");
assertNodeWidthAccordingToPortWidth(node1, portOfNode1, null, false);
assertNodeHeightAccordingToPortHeight(node1, portOfNode1, null, false);
// Port on south
ElkNode node3 = GraphTestUtils.getChild(containerForInsideLabels, "MyNode3");
ElkPort portOfNode3 = GraphTestUtils.getPort(node3, "P1");
assertNodeWidthAccordingToPortWidth(node3, portOfNode3, null, false);
assertNodeHeightAccordingToPortHeight(node3, portOfNode3, null, false);
// Port on east
ElkNode node2 = GraphTestUtils.getChild(containerForInsideLabels, "MyNode2");
ElkPort portOfNode2 = GraphTestUtils.getPort(node2, "P1");
assertNodeHeightAccordingToPortHeight(node2, portOfNode2, null, true);
assertNodeWidthAccordingToPortWidth(node2, portOfNode2, null, true);
// Port on east
// TODO: Specific case with label centered under the port
ElkNode node2Bis = GraphTestUtils.getChild(containerForInsideLabels, "MyNode2Bis");
ElkPort portOfNode2Bis = GraphTestUtils.getPort(node2, "P1");
// assertNodeHeightAccordingToPortHeight(node2Bis, portOfNode2Bis, null, true);
// assertNodeWidthAccordingToPortWidth(node2Bis, portOfNode2Bis, null, true);
// Port on west
ElkNode node4 = GraphTestUtils.getChild(containerForInsideLabels, "MyNode4");
ElkPort portOfNode4 = GraphTestUtils.getPort(node4, "P1");
assertNodeWidthAccordingToPortWidth(node4, portOfNode4, null, true);
assertNodeHeightAccordingToPortHeight(node4, portOfNode4, null, true);
// Port on west
// TODO: Specific case with label centered under the port
ElkNode node4Bis = GraphTestUtils.getChild(containerForInsideLabels, "MyNode4Bis");
ElkPort portOfNode4Bis = GraphTestUtils.getPort(node4Bis, "P1");
// assertNodeWidthAccordingToPortWidth(node4Bis, portOfNode4Bis, null, true);
// assertNodeHeightAccordingToPortHeight(node4Bis, portOfNode4Bis, null, true);
}
Aggregations