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);
}
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();
}
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);
}
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);
}
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);
}
Aggregations