use of org.eclipse.sirius.components.diagrams.layout.incremental.provider.EdgeLabelPositionProvider in project sirius-components by eclipse-sirius.
the class IncrementalLayoutEngine method layout.
public void layout(Optional<IDiagramEvent> optionalDiagramElementEvent, DiagramLayoutData diagram, ISiriusWebLayoutConfigurator layoutConfigurator) {
this.borderNodeLabelPositionProvider = new BorderNodeLabelPositionProvider();
this.nodeLabelPositionProvider = new NodeLabelPositionProvider(layoutConfigurator);
this.edgeLabelPositionProvider = new EdgeLabelPositionProvider(layoutConfigurator);
// first we layout all the nodes
for (NodeLayoutData node : diagram.getChildrenNodes()) {
this.layoutNode(optionalDiagramElementEvent, node, layoutConfigurator);
}
// resolve overlaps due to previous changes
new OverlapsUpdater().update(diagram);
// resize according to the content
new ContainmentUpdater().update(diagram);
// finally we recompute the edges that needs to
for (EdgeLayoutData edge : diagram.getEdges()) {
if (this.hasChanged(edge.getSource()) || this.hasChanged(edge.getTarget()) || !this.isLabelPositioned(edge) || !this.isEdgePositioned(edge)) {
this.layoutEdge(optionalDiagramElementEvent, edge);
}
}
}
use of org.eclipse.sirius.components.diagrams.layout.incremental.provider.EdgeLabelPositionProvider in project sirius-components by eclipse-sirius.
the class EdgeLabelPositionProviderTests method testEdgeLabelBoundsPosition.
@Test
public void testEdgeLabelBoundsPosition() {
EdgeLayoutData edgeLayoutData = this.createEdgeLayoutData(this.createDiagramLayoutData());
EdgeLabelPositionProvider labelBoundsProvider = new EdgeLabelPositionProvider(new LayoutConfiguratorRegistry(List.of()).getDefaultLayoutConfigurator());
Position centerPosition = labelBoundsProvider.getCenterPosition(edgeLayoutData, edgeLayoutData.getCenterLabel());
assertThat(centerPosition.getX()).isCloseTo(267.539, Offset.offset(0.0001));
assertThat(centerPosition.getY()).isCloseTo(103, Offset.offset(0.0001));
}
Aggregations