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