use of org.eclipse.sirius.components.diagrams.layout.LayoutConfiguratorRegistry 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.LayoutConfiguratorRegistry 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.LayoutConfiguratorRegistry 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.LayoutConfiguratorRegistry 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.LayoutConfiguratorRegistry in project sirius-components by eclipse-sirius.
the class NodeLabelPositionProviderTests method testNodeRectangleLabelBoundsPosition.
@Test
public void testNodeRectangleLabelBoundsPosition() {
DiagramLayoutData createDiagramLayoutData = this.createDiagramLayoutData();
NodeLayoutData nodeLayoutData = this.createNodeLayoutData(Position.at(0, 0), DEFAULT_NODE_SIZE, createDiagramLayoutData, NodeType.NODE_RECTANGLE);
NodeLabelPositionProvider labelBoundsProvider = new NodeLabelPositionProvider(new LayoutConfiguratorRegistry(List.of()).getDefaultLayoutConfigurator());
LabelLayoutData labelLayoutData = this.createLabelLayoutData();
Position position = labelBoundsProvider.getPosition(nodeLayoutData, labelLayoutData, new ArrayList<>());
assertThat(position).extracting(Position::getX).isEqualTo(Double.valueOf(DEFAULT_NODE_SIZE.getWidth() / 2));
assertThat(position).extracting(Position::getY).isEqualTo(Double.valueOf(5));
}
Aggregations