use of org.eclipse.elk.graph.ElkBendPoint in project elk by eclipse.
the class Issue502Test method testLargeEnoughNode.
private void testLargeEnoughNode(final ElkNode node) {
ElkRectangle requiredSize = new ElkRectangle();
for (ElkNode child : node.getChildren()) {
ElkRectangle childRect = new ElkRectangle(child.getX(), child.getY(), child.getWidth(), child.getHeight());
requiredSize.union(childRect);
}
for (ElkEdge edge : node.getContainedEdges()) {
for (ElkEdgeSection section : edge.getSections()) {
for (ElkBendPoint bendPoint : section.getBendPoints()) {
requiredSize.width = Math.max(requiredSize.width, bendPoint.getX());
requiredSize.height = Math.max(requiredSize.height, bendPoint.getY());
}
}
}
assertTrue("Node not large enough for content. Size required: (" + requiredSize.width + ", " + requiredSize.height + "). " + "Actual size: (" + node.getWidth() + ", " + node.getHeight() + ")", node.getWidth() >= requiredSize.width && node.getHeight() >= requiredSize.height);
}
use of org.eclipse.elk.graph.ElkBendPoint in project sirius-components by eclipse-sirius.
the class LayoutedDiagramProviderTests method getConvertedDiagram.
private ELKConvertedDiagram getConvertedDiagram(Diagram originalDiagram) {
Map<String, ElkGraphElement> id2ElkGraphElements = new HashMap<>();
ElkNode elkDiagram = ElkGraphFactory.eINSTANCE.createElkNode();
elkDiagram.setIdentifier(originalDiagram.getId().toString());
Node node = originalDiagram.getNodes().get(0);
ElkNode elkNode = ElkGraphFactory.eINSTANCE.createElkNode();
elkNode.setIdentifier(node.getId().toString());
elkNode.setDimensions(NODE_WIDTH, NODE_HEIGHT);
elkNode.setX(NODE_X);
elkNode.setY(NODE_Y);
elkNode.setParent(elkDiagram);
ElkLabel elkLabel = ElkGraphFactory.eINSTANCE.createElkLabel();
elkLabel.setIdentifier(node.getLabel().getId().toString());
elkLabel.setDimensions(LABEL_WIDTH, LABEL_HEIGHT);
elkLabel.setX(LABEL_X);
elkLabel.setY(LABEL_Y);
elkLabel.setParent(elkNode);
id2ElkGraphElements.put(elkLabel.getIdentifier(), elkLabel);
id2ElkGraphElements.put(elkNode.getIdentifier(), elkNode);
String edgeId = originalDiagram.getEdges().get(0).getId();
ElkEdge elkEdge = ElkGraphFactory.eINSTANCE.createElkEdge();
elkEdge.setIdentifier(edgeId.toString());
elkEdge.getSources().add(elkNode);
elkEdge.getTargets().add(elkNode);
elkEdge.setContainingNode(elkDiagram);
ElkEdgeSection section = ElkGraphFactory.eINSTANCE.createElkEdgeSection();
section.setStartX(NODE_X);
section.setStartY(NODE_Y);
ElkBendPoint bendPoint = ElkGraphFactory.eINSTANCE.createElkBendPoint();
bendPoint.setX(EDGE_BENDPOINT_X);
bendPoint.setY(EDGE_BENDPOINT_Y);
section.getBendPoints().add(bendPoint);
section.setEndX(NODE_X);
section.setEndY(NODE_Y);
elkEdge.getSections().add(section);
id2ElkGraphElements.put(elkEdge.getIdentifier(), elkEdge);
return new ELKConvertedDiagram(elkDiagram, id2ElkGraphElements);
}
Aggregations