Search in sources :

Example 1 with NodeSizeProvider

use of org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeSizeProvider 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 NodeSizeProvider

use of org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeSizeProvider in project sirius-components by eclipse-sirius.

the class NodeSizeProviderTests method testNodeSizeWithExistingSize.

@Test
public void testNodeSizeWithExistingSize() {
    ImageSizeProvider imageSizeProvider = new ImageSizeProvider();
    NodeSizeProvider nodeSizeProvider = new NodeSizeProvider(imageSizeProvider);
    ISiriusWebLayoutConfigurator layoutConfigurator = new LayoutConfiguratorRegistry(List.of()).getDefaultLayoutConfigurator();
    Size size = nodeSizeProvider.getSize(Optional.empty(), this.createNodeLayoutData(Size.of(WIDTH_80, HEIGHT_50)), layoutConfigurator);
    assertThat(size).extracting(Size::getHeight).isEqualTo(Double.valueOf(HEIGHT_50));
    assertThat(size).extracting(Size::getWidth).isEqualTo(Double.valueOf(WIDTH_80));
    imageSizeProvider.dispose();
}
Also used : ISiriusWebLayoutConfigurator(org.eclipse.sirius.components.diagrams.layout.ISiriusWebLayoutConfigurator) Size(org.eclipse.sirius.components.diagrams.Size) NodeSizeProvider(org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeSizeProvider) LayoutConfiguratorRegistry(org.eclipse.sirius.components.diagrams.layout.LayoutConfiguratorRegistry) ImageSizeProvider(org.eclipse.sirius.components.diagrams.layout.incremental.provider.ImageSizeProvider) Test(org.junit.jupiter.api.Test)

Example 3 with NodeSizeProvider

use of org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeSizeProvider 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 4 with NodeSizeProvider

use of org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeSizeProvider 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 5 with NodeSizeProvider

use of org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeSizeProvider in project sirius-components by eclipse-sirius.

the class BorderNodePositionTests method testSnap.

/**
 * Test the snap of the border nodes on their parent container.<br/>
 * The border nodes are voluntary at an invalid position to make sure they properly snap done at the first layout
 */
@Test
public void testSnap() {
    DiagramLayoutData initializeDiagram = this.initializeDiagram();
    List<NodeLayoutData> borderNodes = initializeDiagram.getChildrenNodes().get(0).getBorderNodes();
    NodeSizeProvider nodeSizeProvider = new NodeSizeProvider(new ImageSizeProvider());
    IncrementalLayoutEngine incrementalLayoutEngine = new IncrementalLayoutEngine(nodeSizeProvider);
    incrementalLayoutEngine.layout(Optional.empty(), initializeDiagram, new LayoutConfiguratorRegistry(List.of()).getDefaultLayoutConfigurator());
    this.checkBorderNodesAtInitialPosition(borderNodes);
    this.checkBorderNodeLabel(borderNodes.get(0).getLabel(), BORDER_NODE_LABEL_TEXT_POSITION, BORDER_NODE_LABEL_TEXT_BOUNDS);
}
Also used : DiagramLayoutData(org.eclipse.sirius.components.diagrams.layout.incremental.data.DiagramLayoutData) NodeSizeProvider(org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeSizeProvider) LayoutConfiguratorRegistry(org.eclipse.sirius.components.diagrams.layout.LayoutConfiguratorRegistry) ImageSizeProvider(org.eclipse.sirius.components.diagrams.layout.incremental.provider.ImageSizeProvider) NodeLayoutData(org.eclipse.sirius.components.diagrams.layout.incremental.data.NodeLayoutData) Test(org.junit.jupiter.api.Test)

Aggregations

LayoutConfiguratorRegistry (org.eclipse.sirius.components.diagrams.layout.LayoutConfiguratorRegistry)14 ImageSizeProvider (org.eclipse.sirius.components.diagrams.layout.incremental.provider.ImageSizeProvider)14 NodeSizeProvider (org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeSizeProvider)14 Test (org.junit.jupiter.api.Test)10 NodeLayoutData (org.eclipse.sirius.components.diagrams.layout.incremental.data.NodeLayoutData)8 IDiagramEvent (org.eclipse.sirius.components.diagrams.events.IDiagramEvent)7 DiagramLayoutData (org.eclipse.sirius.components.diagrams.layout.incremental.data.DiagramLayoutData)7 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 ResizeEvent (org.eclipse.sirius.components.diagrams.events.ResizeEvent)4 ELKLayoutedDiagramProvider (org.eclipse.sirius.components.diagrams.layout.ELKLayoutedDiagramProvider)4 LayoutService (org.eclipse.sirius.components.diagrams.layout.LayoutService)4 IRepresentationDescription (org.eclipse.sirius.components.representations.IRepresentationDescription)4 Size (org.eclipse.sirius.components.diagrams.Size)3 IELKDiagramConverter (org.eclipse.sirius.components.diagrams.layout.IELKDiagramConverter)3 ISiriusWebLayoutConfigurator (org.eclipse.sirius.components.diagrams.layout.ISiriusWebLayoutConfigurator)3 TestDiagramCreationService (org.eclipse.sirius.components.diagrams.layout.services.TestDiagramCreationService)3 MoveEvent (org.eclipse.sirius.components.diagrams.events.MoveEvent)2