Search in sources :

Example 1 with ELKLayoutedDiagramProvider

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);
}
Also used : TestDiagramCreationService(org.eclipse.sirius.components.diagrams.layout.services.TestDiagramCreationService) IRepresentationDescriptionSearchService(org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) ImageSizeProvider(org.eclipse.sirius.components.diagrams.layout.incremental.provider.ImageSizeProvider) IRepresentationDescription(org.eclipse.sirius.components.representations.IRepresentationDescription) IELKDiagramConverter(org.eclipse.sirius.components.diagrams.layout.IELKDiagramConverter) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) ELKLayoutedDiagramProvider(org.eclipse.sirius.components.diagrams.layout.ELKLayoutedDiagramProvider) NodeSizeProvider(org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeSizeProvider) LayoutService(org.eclipse.sirius.components.diagrams.layout.LayoutService) UUID(java.util.UUID) LayoutConfiguratorRegistry(org.eclipse.sirius.components.diagrams.layout.LayoutConfiguratorRegistry)

Example 2 with ELKLayoutedDiagramProvider

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);
}
Also used : TestDiagramCreationService(org.eclipse.sirius.components.diagrams.layout.services.TestDiagramCreationService) IRepresentationDescriptionSearchService(org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) ImageSizeProvider(org.eclipse.sirius.components.diagrams.layout.incremental.provider.ImageSizeProvider) IRepresentationDescription(org.eclipse.sirius.components.representations.IRepresentationDescription) IELKDiagramConverter(org.eclipse.sirius.components.diagrams.layout.IELKDiagramConverter) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) ELKLayoutedDiagramProvider(org.eclipse.sirius.components.diagrams.layout.ELKLayoutedDiagramProvider) NodeSizeProvider(org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeSizeProvider) LayoutService(org.eclipse.sirius.components.diagrams.layout.LayoutService) UUID(java.util.UUID) LayoutConfiguratorRegistry(org.eclipse.sirius.components.diagrams.layout.LayoutConfiguratorRegistry)

Example 3 with ELKLayoutedDiagramProvider

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);
}
Also used : TestDiagramCreationService(org.eclipse.sirius.components.diagrams.layout.services.TestDiagramCreationService) IRepresentationDescriptionSearchService(org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) ImageSizeProvider(org.eclipse.sirius.components.diagrams.layout.incremental.provider.ImageSizeProvider) IRepresentationDescription(org.eclipse.sirius.components.representations.IRepresentationDescription) IELKDiagramConverter(org.eclipse.sirius.components.diagrams.layout.IELKDiagramConverter) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) ELKLayoutedDiagramProvider(org.eclipse.sirius.components.diagrams.layout.ELKLayoutedDiagramProvider) NodeSizeProvider(org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeSizeProvider) LayoutService(org.eclipse.sirius.components.diagrams.layout.LayoutService) UUID(java.util.UUID) LayoutConfiguratorRegistry(org.eclipse.sirius.components.diagrams.layout.LayoutConfiguratorRegistry)

Example 4 with ELKLayoutedDiagramProvider

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);
}
Also used : ELKConvertedDiagram(org.eclipse.sirius.components.diagrams.layout.ELKConvertedDiagram) TestDiagramBuilder(org.eclipse.sirius.components.diagrams.tests.TestDiagramBuilder) Node(org.eclipse.sirius.components.diagrams.Node) ElkNode(org.eclipse.elk.graph.ElkNode) ELKLayoutedDiagramProvider(org.eclipse.sirius.components.diagrams.layout.ELKLayoutedDiagramProvider) Edge(org.eclipse.sirius.components.diagrams.Edge) ElkEdge(org.eclipse.elk.graph.ElkEdge) ELKConvertedDiagram(org.eclipse.sirius.components.diagrams.layout.ELKConvertedDiagram) Diagram(org.eclipse.sirius.components.diagrams.Diagram) Test(org.junit.jupiter.api.Test)

Example 5 with ELKLayoutedDiagramProvider

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);
}
Also used : IRepresentationDescriptionSearchService(org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) ImageSizeProvider(org.eclipse.sirius.components.diagrams.layout.incremental.provider.ImageSizeProvider) IRepresentationDescription(org.eclipse.sirius.components.representations.IRepresentationDescription) ELKDiagramConverter(org.eclipse.sirius.components.diagrams.layout.ELKDiagramConverter) IncrementalLayoutDiagramConverter(org.eclipse.sirius.components.diagrams.layout.incremental.IncrementalLayoutDiagramConverter) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) IncrementalLayoutedDiagramProvider(org.eclipse.sirius.components.diagrams.layout.incremental.IncrementalLayoutedDiagramProvider) TextBoundsService(org.eclipse.sirius.components.diagrams.layout.TextBoundsService) ELKLayoutedDiagramProvider(org.eclipse.sirius.components.diagrams.layout.ELKLayoutedDiagramProvider) NodeSizeProvider(org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeSizeProvider) LayoutService(org.eclipse.sirius.components.diagrams.layout.LayoutService) UUID(java.util.UUID) LayoutConfiguratorRegistry(org.eclipse.sirius.components.diagrams.layout.LayoutConfiguratorRegistry) IncrementalLayoutEngine(org.eclipse.sirius.components.diagrams.layout.incremental.IncrementalLayoutEngine)

Aggregations

ELKLayoutedDiagramProvider (org.eclipse.sirius.components.diagrams.layout.ELKLayoutedDiagramProvider)5 UUID (java.util.UUID)4 IEditingContext (org.eclipse.sirius.components.core.api.IEditingContext)4 IRepresentationDescriptionSearchService (org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService)4 DiagramDescription (org.eclipse.sirius.components.diagrams.description.DiagramDescription)4 LayoutConfiguratorRegistry (org.eclipse.sirius.components.diagrams.layout.LayoutConfiguratorRegistry)4 LayoutService (org.eclipse.sirius.components.diagrams.layout.LayoutService)4 ImageSizeProvider (org.eclipse.sirius.components.diagrams.layout.incremental.provider.ImageSizeProvider)4 NodeSizeProvider (org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeSizeProvider)4 IRepresentationDescription (org.eclipse.sirius.components.representations.IRepresentationDescription)4 IELKDiagramConverter (org.eclipse.sirius.components.diagrams.layout.IELKDiagramConverter)3 TestDiagramCreationService (org.eclipse.sirius.components.diagrams.layout.services.TestDiagramCreationService)3 ElkEdge (org.eclipse.elk.graph.ElkEdge)1 ElkNode (org.eclipse.elk.graph.ElkNode)1 Diagram (org.eclipse.sirius.components.diagrams.Diagram)1 Edge (org.eclipse.sirius.components.diagrams.Edge)1 Node (org.eclipse.sirius.components.diagrams.Node)1 ELKConvertedDiagram (org.eclipse.sirius.components.diagrams.layout.ELKConvertedDiagram)1 ELKDiagramConverter (org.eclipse.sirius.components.diagrams.layout.ELKDiagramConverter)1 TextBoundsService (org.eclipse.sirius.components.diagrams.layout.TextBoundsService)1