Search in sources :

Example 1 with TestDiagramCreationService

use of org.eclipse.sirius.components.diagrams.layout.services.TestDiagramCreationService 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 TestDiagramCreationService

use of org.eclipse.sirius.components.diagrams.layout.services.TestDiagramCreationService 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 TestDiagramCreationService

use of org.eclipse.sirius.components.diagrams.layout.services.TestDiagramCreationService 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 TestDiagramCreationService

use of org.eclipse.sirius.components.diagrams.layout.services.TestDiagramCreationService in project sirius-components by eclipse-sirius.

the class NodeCreationTests method createNewNode.

private Diagram createNewNode(Diagram diagram, IEditingContext editingContext, Position eventCreationPosition) {
    TestDiagramCreationService diagramCreationService = this.createDiagramCreationService(diagram);
    Optional<Diagram> optionalRefreshedDiagram = diagramCreationService.performRefresh(editingContext, diagram);
    assertThat(optionalRefreshedDiagram).isNotEmpty();
    Diagram refreshedDiagram = optionalRefreshedDiagram.get();
    IDiagramEvent diagramEvent = new SinglePositionEvent(eventCreationPosition);
    return diagramCreationService.performLayout(editingContext, refreshedDiagram, diagramEvent);
}
Also used : TestDiagramCreationService(org.eclipse.sirius.components.diagrams.layout.services.TestDiagramCreationService) SinglePositionEvent(org.eclipse.sirius.components.diagrams.events.SinglePositionEvent) IDiagramEvent(org.eclipse.sirius.components.diagrams.events.IDiagramEvent) Diagram(org.eclipse.sirius.components.diagrams.Diagram)

Example 5 with TestDiagramCreationService

use of org.eclipse.sirius.components.diagrams.layout.services.TestDiagramCreationService in project sirius-components by eclipse-sirius.

the class NodeResizeTests method resizeNode.

private Optional<Node> resizeNode(String objectId, Diagram diagram, Position positionDelta, Size newSize) {
    // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ //$NON-NLS-5$
    Path path = Paths.get("src", "test", "resources", "editing-contexts", "testResizeWithNoPositionDelta");
    JsonBasedEditingContext editingContext = new JsonBasedEditingContext(path);
    TestDiagramCreationService diagramCreationService = this.createDiagramCreationService(diagram);
    Optional<Node> optionalFirstParent = this.getNode(diagram.getNodes(), objectId);
    assertThat(optionalFirstParent).isPresent();
    Node firstParent = optionalFirstParent.get();
    IDiagramEvent resizeEvent = new ResizeEvent(firstParent.getId(), positionDelta, newSize);
    Diagram layoutedDiagram = diagramCreationService.performLayout(editingContext, diagram, resizeEvent);
    Optional<Node> optionalResizedFirstParent = this.getNode(layoutedDiagram.getNodes(), objectId);
    assertThat(optionalResizedFirstParent).isPresent();
    return optionalResizedFirstParent;
}
Also used : Path(java.nio.file.Path) TestDiagramCreationService(org.eclipse.sirius.components.diagrams.layout.services.TestDiagramCreationService) Node(org.eclipse.sirius.components.diagrams.Node) JsonBasedEditingContext(org.eclipse.sirius.components.diagrams.tests.builder.JsonBasedEditingContext) IDiagramEvent(org.eclipse.sirius.components.diagrams.events.IDiagramEvent) ResizeEvent(org.eclipse.sirius.components.diagrams.events.ResizeEvent) Diagram(org.eclipse.sirius.components.diagrams.Diagram)

Aggregations

TestDiagramCreationService (org.eclipse.sirius.components.diagrams.layout.services.TestDiagramCreationService)6 UUID (java.util.UUID)3 IEditingContext (org.eclipse.sirius.components.core.api.IEditingContext)3 IRepresentationDescriptionSearchService (org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService)3 Diagram (org.eclipse.sirius.components.diagrams.Diagram)3 DiagramDescription (org.eclipse.sirius.components.diagrams.description.DiagramDescription)3 IDiagramEvent (org.eclipse.sirius.components.diagrams.events.IDiagramEvent)3 ELKLayoutedDiagramProvider (org.eclipse.sirius.components.diagrams.layout.ELKLayoutedDiagramProvider)3 IELKDiagramConverter (org.eclipse.sirius.components.diagrams.layout.IELKDiagramConverter)3 LayoutConfiguratorRegistry (org.eclipse.sirius.components.diagrams.layout.LayoutConfiguratorRegistry)3 LayoutService (org.eclipse.sirius.components.diagrams.layout.LayoutService)3 ImageSizeProvider (org.eclipse.sirius.components.diagrams.layout.incremental.provider.ImageSizeProvider)3 NodeSizeProvider (org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeSizeProvider)3 IRepresentationDescription (org.eclipse.sirius.components.representations.IRepresentationDescription)3 Path (java.nio.file.Path)2 Node (org.eclipse.sirius.components.diagrams.Node)2 SinglePositionEvent (org.eclipse.sirius.components.diagrams.events.SinglePositionEvent)2 JsonBasedEditingContext (org.eclipse.sirius.components.diagrams.tests.builder.JsonBasedEditingContext)2 ResizeEvent (org.eclipse.sirius.components.diagrams.events.ResizeEvent)1 Test (org.junit.jupiter.api.Test)1