use of org.eclipse.sirius.components.diagrams.layout.ELKDiagramConverter in project sirius-components by eclipse-sirius.
the class DiagramConverterTests method testDiagramOneNodeAndOneBorderNode.
@Test
public void testDiagramOneNodeAndOneBorderNode() {
ImageSizeProvider imageSizeProvider = new ImageSizeProvider();
ELKDiagramConverter diagramConverter = new ELKDiagramConverter(this.textBoundsService, imageSizeProvider);
// @formatter:off
TestDiagramBuilder diagramBuilder = new TestDiagramBuilder();
Node borderNode = Node.newNode(diagramBuilder.getNode(FIRST_NODE_ID)).style(diagramBuilder.getRectangularNodeStyle()).build();
Node node = Node.newNode(diagramBuilder.getNode(SECOND_NODE_ID)).style(diagramBuilder.getImageNodeStyle()).borderNodes(List.of(borderNode)).build();
Diagram diagram = Diagram.newDiagram(diagramBuilder.getDiagram(DIAGRAM_ID)).nodes(List.of(node)).build();
// @formatter:on
ELKConvertedDiagram convertedDiagram = diagramConverter.convert(diagram);
ElkNode elkDiagram = convertedDiagram.getElkDiagram();
assertThat(elkDiagram.getChildren().size()).isEqualTo(1);
ElkNode elkNode = elkDiagram.getChildren().get(0);
assertThat(elkNode.getPorts().size()).isEqualTo(1);
ElkPort elkPort = elkNode.getPorts().get(0);
assertThat(elkPort.getIdentifier()).isEqualTo(borderNode.getId().toString());
imageSizeProvider.dispose();
}
use of org.eclipse.sirius.components.diagrams.layout.ELKDiagramConverter in project sirius-components by eclipse-sirius.
the class DiagramConverterTests method testDiagramOneEdgeBetweenTwoBorderNodes.
@Test
public void testDiagramOneEdgeBetweenTwoBorderNodes() {
ImageSizeProvider imageSizeProvider = new ImageSizeProvider();
ELKDiagramConverter diagramConverter = new ELKDiagramConverter(this.textBoundsService, imageSizeProvider);
// @formatter:off
TestDiagramBuilder diagramBuilder = new TestDiagramBuilder();
Node firstBorderNode = Node.newNode(diagramBuilder.getNode(FIRST_NODE_ID)).style(diagramBuilder.getRectangularNodeStyle()).build();
Node secondBorderNode = Node.newNode(diagramBuilder.getNode(SECOND_NODE_ID)).style(diagramBuilder.getRectangularNodeStyle()).build();
Node node = Node.newNode(diagramBuilder.getNode(THIRD_NODE_ID)).style(diagramBuilder.getImageNodeStyle()).borderNodes(List.of(firstBorderNode, secondBorderNode)).build();
Edge edge = Edge.newEdge(diagramBuilder.getEdge(FIRST_EDGE_ID, firstBorderNode.getId(), secondBorderNode.getId())).build();
Diagram diagram = Diagram.newDiagram(diagramBuilder.getDiagram(DIAGRAM_ID)).nodes(List.of(node)).edges(List.of(edge)).build();
// @formatter:on
ELKConvertedDiagram convertedDiagram = diagramConverter.convert(diagram);
ElkNode elkDiagram = convertedDiagram.getElkDiagram();
assertThat(elkDiagram.getChildren().size()).isEqualTo(1);
assertThat(elkDiagram.getChildren().get(0)).isInstanceOf(ElkNode.class);
assertThat(elkDiagram.getContainedEdges().size()).isEqualTo(1);
assertThat(elkDiagram.getContainedEdges().get(0)).isInstanceOf(ElkEdge.class);
ElkEdge elkEdge = elkDiagram.getContainedEdges().get(0);
assertThat(elkEdge.getSources().size()).isEqualTo(1);
assertThat(elkEdge.getSources().get(0).getIdentifier()).isEqualTo(firstBorderNode.getId().toString());
assertThat(elkEdge.getTargets().size()).isEqualTo(1);
assertThat(elkEdge.getTargets().get(0).getIdentifier()).isEqualTo(secondBorderNode.getId().toString());
imageSizeProvider.dispose();
}
use of org.eclipse.sirius.components.diagrams.layout.ELKDiagramConverter in project sirius-components by eclipse-sirius.
the class DiagramConverterTests method testDiagramOneNodeAndOneEdge.
@Test
public void testDiagramOneNodeAndOneEdge() {
ImageSizeProvider imageSizeProvider = new ImageSizeProvider();
ELKDiagramConverter diagramConverter = new ELKDiagramConverter(this.textBoundsService, imageSizeProvider);
// @formatter:off
TestDiagramBuilder diagramBuilder = new TestDiagramBuilder();
Node node = Node.newNode(diagramBuilder.getNode(FIRST_NODE_ID)).style(diagramBuilder.getImageNodeStyle()).build();
Edge edge = Edge.newEdge(diagramBuilder.getEdge(FIRST_EDGE_ID, node.getId(), node.getId())).build();
Diagram diagram = Diagram.newDiagram(diagramBuilder.getDiagram(DIAGRAM_ID)).nodes(List.of(node)).edges(List.of(edge)).build();
// @formatter:on
ELKConvertedDiagram convertedDiagram = diagramConverter.convert(diagram);
ElkNode elkDiagram = convertedDiagram.getElkDiagram();
assertThat(elkDiagram.getContainedEdges().size()).isEqualTo(1);
ElkEdge elkEdge = elkDiagram.getContainedEdges().get(0);
assertThat(elkEdge.getIdentifier()).isEqualTo(edge.getId().toString());
imageSizeProvider.dispose();
}
use of org.eclipse.sirius.components.diagrams.layout.ELKDiagramConverter in project sirius-components by eclipse-sirius.
the class DiagramConverterTests method testDiagramOneImageNode.
@Test
public void testDiagramOneImageNode() {
ImageSizeProvider imageSizeProvider = new ImageSizeProvider();
ELKDiagramConverter diagramConverter = new ELKDiagramConverter(this.textBoundsService, imageSizeProvider);
// @formatter:off
TestDiagramBuilder diagramBuilder = new TestDiagramBuilder();
Node node = Node.newNode(diagramBuilder.getNode(FIRST_NODE_ID)).style(diagramBuilder.getImageNodeStyle()).build();
Diagram diagram = Diagram.newDiagram(diagramBuilder.getDiagram(DIAGRAM_ID)).nodes(List.of(node)).build();
// @formatter:on
ELKConvertedDiagram convertedDiagram = diagramConverter.convert(diagram);
ElkNode elkDiagram = convertedDiagram.getElkDiagram();
assertThat(elkDiagram.getChildren().size()).isEqualTo(1);
Map<String, ElkGraphElement> id2ElkGraphElements = convertedDiagram.getId2ElkGraphElements();
assertThat(id2ElkGraphElements.get(node.getId().toString())).isInstanceOf(ElkNode.class);
assertThat(id2ElkGraphElements.get(node.getLabel().getId().toString())).isInstanceOf(ElkLabel.class);
ElkNode elkNode = (ElkNode) id2ElkGraphElements.get(node.getId().toString());
this.assertSize(elkNode, TEXT_WIDTH, TEXT_HEIGHT);
assertThat(elkNode.getChildren().size()).isEqualTo(1);
ElkNode elkImage = elkNode.getChildren().get(0);
this.assertSize(elkImage, IMAGE_WIDTH, IMAGE_HEIGHT);
assertThat(elkNode.getLabels().size()).isEqualTo(1);
ElkLabel elkLabel = elkNode.getLabels().get(0);
this.assertSize(elkLabel, TEXT_WIDTH, TEXT_HEIGHT);
imageSizeProvider.dispose();
}
use of org.eclipse.sirius.components.diagrams.layout.ELKDiagramConverter in project sirius-components by eclipse-sirius.
the class DiagramConverterTests method testDiagramOneRectangularNode.
@Test
public void testDiagramOneRectangularNode() {
ImageSizeProvider imageSizeProvider = new ImageSizeProvider();
ELKDiagramConverter diagramConverter = new ELKDiagramConverter(this.textBoundsService, imageSizeProvider);
// @formatter:off
TestDiagramBuilder diagramBuilder = new TestDiagramBuilder();
Node node = diagramBuilder.getNode(FIRST_NODE_ID);
Diagram diagram = Diagram.newDiagram(diagramBuilder.getDiagram(DIAGRAM_ID)).nodes(List.of(node)).build();
// @formatter:on
ELKConvertedDiagram convertedDiagram = diagramConverter.convert(diagram);
ElkNode elkDiagram = convertedDiagram.getElkDiagram();
assertThat(elkDiagram.getChildren().size()).isEqualTo(1);
Map<String, ElkGraphElement> id2ElkGraphElements = convertedDiagram.getId2ElkGraphElements();
assertThat(id2ElkGraphElements.get(node.getId().toString())).isInstanceOf(ElkNode.class);
assertThat(id2ElkGraphElements.get(node.getLabel().getId().toString())).isInstanceOf(ElkLabel.class);
ElkNode elkNode = (ElkNode) id2ElkGraphElements.get(node.getId().toString());
this.assertSize(elkNode, TEXT_WIDTH, TEXT_HEIGHT);
assertThat(elkNode.getLabels().size()).isEqualTo(1);
ElkLabel elkLabel = elkNode.getLabels().get(0);
this.assertSize(elkLabel, TEXT_WIDTH, TEXT_HEIGHT);
imageSizeProvider.dispose();
}
Aggregations