use of org.eclipse.sirius.components.diagrams.layout.incremental.data.ILayoutData in project sirius-components by eclipse-sirius.
the class LayoutService method incrementalLayout.
@Override
public Diagram incrementalLayout(IEditingContext editingContext, Diagram newDiagram, Optional<IDiagramEvent> optionalDiagramElementEvent) {
IncrementalLayoutConvertedDiagram convertedDiagram = this.incrementalLayoutDiagramConverter.convert(newDiagram);
DiagramLayoutData diagramLayoutData = convertedDiagram.getDiagramLayoutData();
var representationDescription = this.representationDescriptionSearchService.findById(editingContext, newDiagram.getDescriptionId());
ISiriusWebLayoutConfigurator layoutConfigurator;
if (representationDescription.isPresent() && representationDescription.get() instanceof DiagramDescription) {
layoutConfigurator = this.layoutConfiguratorRegistry.getLayoutConfigurator(newDiagram, (DiagramDescription) representationDescription.get());
} else {
layoutConfigurator = this.layoutConfiguratorRegistry.getDefaultLayoutConfigurator();
}
this.incrementalLayoutEngine.layout(optionalDiagramElementEvent, diagramLayoutData, layoutConfigurator);
Map<String, ILayoutData> id2LayoutData = convertedDiagram.getId2LayoutData();
return this.incrementalLayoutedDiagramProvider.getLayoutedDiagram(newDiagram, diagramLayoutData, id2LayoutData);
}
use of org.eclipse.sirius.components.diagrams.layout.incremental.data.ILayoutData in project sirius-components by eclipse-sirius.
the class IncrementalLayoutDiagramConverter method convert.
public IncrementalLayoutConvertedDiagram convert(Diagram diagram) {
Map<String, ILayoutData> id2LayoutData = new HashMap<>();
DiagramLayoutData layoutData = new DiagramLayoutData();
String id = diagram.getId();
layoutData.setId(id);
id2LayoutData.put(id, layoutData);
layoutData.setPosition(diagram.getPosition());
layoutData.setSize(diagram.getSize());
List<NodeLayoutData> nodes = new ArrayList<>();
for (Node node : diagram.getNodes()) {
nodes.add(this.convertNode(node, layoutData, id2LayoutData));
}
layoutData.setChildrenNodes(nodes);
List<EdgeLayoutData> edges = new ArrayList<>();
for (Edge edge : diagram.getEdges()) {
edges.add(this.convertEdge(edge, id2LayoutData));
}
layoutData.setEdges(edges);
return new IncrementalLayoutConvertedDiagram(layoutData, id2LayoutData);
}
Aggregations