Search in sources :

Example 1 with ILayoutData

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);
}
Also used : IncrementalLayoutConvertedDiagram(org.eclipse.sirius.components.diagrams.layout.incremental.IncrementalLayoutConvertedDiagram) ILayoutData(org.eclipse.sirius.components.diagrams.layout.incremental.data.ILayoutData) DiagramLayoutData(org.eclipse.sirius.components.diagrams.layout.incremental.data.DiagramLayoutData) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription)

Example 2 with ILayoutData

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);
}
Also used : EdgeLayoutData(org.eclipse.sirius.components.diagrams.layout.incremental.data.EdgeLayoutData) ILayoutData(org.eclipse.sirius.components.diagrams.layout.incremental.data.ILayoutData) HashMap(java.util.HashMap) DiagramLayoutData(org.eclipse.sirius.components.diagrams.layout.incremental.data.DiagramLayoutData) Node(org.eclipse.sirius.components.diagrams.Node) ArrayList(java.util.ArrayList) Edge(org.eclipse.sirius.components.diagrams.Edge) NodeLayoutData(org.eclipse.sirius.components.diagrams.layout.incremental.data.NodeLayoutData)

Aggregations

DiagramLayoutData (org.eclipse.sirius.components.diagrams.layout.incremental.data.DiagramLayoutData)2 ILayoutData (org.eclipse.sirius.components.diagrams.layout.incremental.data.ILayoutData)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Edge (org.eclipse.sirius.components.diagrams.Edge)1 Node (org.eclipse.sirius.components.diagrams.Node)1 DiagramDescription (org.eclipse.sirius.components.diagrams.description.DiagramDescription)1 IncrementalLayoutConvertedDiagram (org.eclipse.sirius.components.diagrams.layout.incremental.IncrementalLayoutConvertedDiagram)1 EdgeLayoutData (org.eclipse.sirius.components.diagrams.layout.incremental.data.EdgeLayoutData)1 NodeLayoutData (org.eclipse.sirius.components.diagrams.layout.incremental.data.NodeLayoutData)1