use of org.eclipse.sirius.components.diagrams.layout.ELKLayoutedDiagramProvider in project sirius-components by eclipse-sirius.
the class NodeResizeTests method createDiagramCreationService.
private TestDiagramCreationService createDiagramCreationService(Diagram diagram) {
IRepresentationDescriptionSearchService.NoOp representationDescriptionSearchService = new IRepresentationDescriptionSearchService.NoOp() {
@Override
public Optional<IRepresentationDescription> findById(IEditingContext editingContext, UUID representationDescriptionId) {
DiagramDescription diagramDescription = NodeResizeTests.this.defaultTestDiagramDescriptionProvider.getDefaultDiagramDescription(diagram);
return Optional.of(diagramDescription);
}
};
NodeSizeProvider nodeSizeProvider = new NodeSizeProvider(new ImageSizeProvider());
IncrementalLayoutEngine incrementalLayoutEngine = new IncrementalLayoutEngine(nodeSizeProvider);
LayoutService layoutService = new LayoutService(new IELKDiagramConverter.NoOp(), new IncrementalLayoutDiagramConverter(), new LayoutConfiguratorRegistry(List.of()), new ELKLayoutedDiagramProvider(), new IncrementalLayoutedDiagramProvider(), representationDescriptionSearchService, incrementalLayoutEngine);
return new TestDiagramCreationService(this.objectService, representationDescriptionSearchService, layoutService);
}
use of org.eclipse.sirius.components.diagrams.layout.ELKLayoutedDiagramProvider in project sirius-components by eclipse-sirius.
the class DiagramLayoutTest method createDiagramCreationService.
private TestDiagramCreationService createDiagramCreationService(Diagram diagram) {
IRepresentationDescriptionSearchService.NoOp representationDescriptionSearchService = new IRepresentationDescriptionSearchService.NoOp() {
@Override
public Optional<IRepresentationDescription> findById(IEditingContext editingContext, UUID representationDescriptionId) {
DiagramDescription diagramDescription = DiagramLayoutTest.this.defaultTestDiagramDescriptionProvider.getDefaultDiagramDescription(diagram);
return Optional.of(diagramDescription);
}
};
NodeSizeProvider nodeSizeProvider = new NodeSizeProvider(new ImageSizeProvider());
IncrementalLayoutEngine incrementalLayoutEngine = new IncrementalLayoutEngine(nodeSizeProvider);
LayoutService layoutService = new LayoutService(new IELKDiagramConverter.NoOp(), new IncrementalLayoutDiagramConverter(), new LayoutConfiguratorRegistry(List.of()), new ELKLayoutedDiagramProvider(), new IncrementalLayoutedDiagramProvider(), representationDescriptionSearchService, incrementalLayoutEngine);
return new TestDiagramCreationService(this.objectService, representationDescriptionSearchService, layoutService);
}
use of org.eclipse.sirius.components.diagrams.layout.ELKLayoutedDiagramProvider in project sirius-components by eclipse-sirius.
the class NodeCreationTests method createDiagramCreationService.
private TestDiagramCreationService createDiagramCreationService(Diagram diagram) {
IRepresentationDescriptionSearchService.NoOp representationDescriptionSearchService = new IRepresentationDescriptionSearchService.NoOp() {
@Override
public Optional<IRepresentationDescription> findById(IEditingContext editingContext, UUID representationDescriptionId) {
DiagramDescription diagramDescription = NodeCreationTests.this.defaultTestDiagramDescriptionProvider.getDefaultDiagramDescription(diagram);
return Optional.of(diagramDescription);
}
};
NodeSizeProvider nodeSizeProvider = new NodeSizeProvider(new ImageSizeProvider());
IncrementalLayoutEngine incrementalLayoutEngine = new IncrementalLayoutEngine(nodeSizeProvider);
LayoutService layoutService = new LayoutService(new IELKDiagramConverter.NoOp(), new IncrementalLayoutDiagramConverter(), new LayoutConfiguratorRegistry(List.of()), new ELKLayoutedDiagramProvider(), new IncrementalLayoutedDiagramProvider(), representationDescriptionSearchService, incrementalLayoutEngine);
return new TestDiagramCreationService(this.objectService, representationDescriptionSearchService, layoutService);
}
use of org.eclipse.sirius.components.diagrams.layout.ELKLayoutedDiagramProvider in project sirius-components by eclipse-sirius.
the class LayoutedDiagramProviderTests method testLayoutedDiagramProvider.
@Test
public void testLayoutedDiagramProvider() {
// @formatter:off
TestDiagramBuilder diagramBuilder = new TestDiagramBuilder();
Node node = Node.newNode(diagramBuilder.getNode(FIRST_NODE_ID)).build();
Edge edge = Edge.newEdge(diagramBuilder.getEdge(FIRST_EDGE_ID, node.getId(), node.getId())).build();
Diagram originalDiagram = Diagram.newDiagram(diagramBuilder.getDiagram(DIAGRAM_ID)).nodes(List.of(node)).edges(List.of(edge)).build();
// @formatter:on
ELKConvertedDiagram convertedDiagram = this.getConvertedDiagram(originalDiagram);
Diagram layoutedDiagram = new ELKLayoutedDiagramProvider().getLayoutedDiagram(originalDiagram, convertedDiagram.getElkDiagram(), convertedDiagram.getId2ElkGraphElements());
assertThat(layoutedDiagram).hasBounds(0, 0, 0, 0);
assertThat(layoutedDiagram.getNodes()).hasSizeGreaterThan(0);
assertThat(layoutedDiagram.getNodes().get(0)).hasBounds(NODE_X, NODE_Y, NODE_WIDTH, NODE_HEIGHT);
assertThat(layoutedDiagram).matchesRecursively(originalDiagram, IdPolicy.WITH_ID, LayoutPolicy.WITHOUT_LAYOUT);
}
use of org.eclipse.sirius.components.diagrams.layout.ELKLayoutedDiagramProvider in project sirius-components by eclipse-sirius.
the class DiagramELKLayoutTest method createDiagramCreationService.
private TestDiagramCreationService createDiagramCreationService(Diagram diagram) {
IRepresentationDescriptionSearchService.NoOp representationDescriptionSearchService = new IRepresentationDescriptionSearchService.NoOp() {
@Override
public Optional<IRepresentationDescription> findById(IEditingContext editingContext, UUID representationDescriptionId) {
DiagramDescription diagramDescription = DiagramELKLayoutTest.this.defaultTestDiagramDescriptionProvider.getDefaultDiagramDescription(diagram);
return Optional.of(diagramDescription);
}
};
NodeSizeProvider nodeSizeProvider = new NodeSizeProvider(new ImageSizeProvider());
IncrementalLayoutEngine incrementalLayoutEngine = new IncrementalLayoutEngine(nodeSizeProvider);
LayoutService layoutService = new LayoutService(new ELKDiagramConverter(new TextBoundsService(), new ImageSizeProvider()), new IncrementalLayoutDiagramConverter(), new LayoutConfiguratorRegistry(List.of()), new ELKLayoutedDiagramProvider(), new IncrementalLayoutedDiagramProvider(), representationDescriptionSearchService, incrementalLayoutEngine);
return new TestDiagramCreationService(this.objectService, representationDescriptionSearchService, layoutService);
}
Aggregations