Search in sources :

Example 1 with DiagramLayoutData

use of org.eclipse.sirius.components.diagrams.layout.incremental.data.DiagramLayoutData in project sirius-components by eclipse-sirius.

the class EdgeLabelPositionProviderTests method createDiagramLayoutData.

private DiagramLayoutData createDiagramLayoutData() {
    DiagramLayoutData diagramLayoutData = new DiagramLayoutData();
    diagramLayoutData.setId(UUID.randomUUID().toString());
    diagramLayoutData.setPosition(Position.at(0, 0));
    diagramLayoutData.setSize(Size.of(1000, 1000));
    return diagramLayoutData;
}
Also used : DiagramLayoutData(org.eclipse.sirius.components.diagrams.layout.incremental.data.DiagramLayoutData)

Example 2 with DiagramLayoutData

use of org.eclipse.sirius.components.diagrams.layout.incremental.data.DiagramLayoutData in project sirius-components by eclipse-sirius.

the class EdgeRoutingPointsProviderTests method createDiagramLayoutData.

private DiagramLayoutData createDiagramLayoutData() {
    DiagramLayoutData diagramLayoutData = new DiagramLayoutData();
    diagramLayoutData.setId(UUID.randomUUID().toString());
    diagramLayoutData.setPosition(Position.at(0, 0));
    diagramLayoutData.setSize(Size.of(1000, 1000));
    return diagramLayoutData;
}
Also used : DiagramLayoutData(org.eclipse.sirius.components.diagrams.layout.incremental.data.DiagramLayoutData)

Example 3 with DiagramLayoutData

use of org.eclipse.sirius.components.diagrams.layout.incremental.data.DiagramLayoutData 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));
}
Also used : DiagramLayoutData(org.eclipse.sirius.components.diagrams.layout.incremental.data.DiagramLayoutData) Position(org.eclipse.sirius.components.diagrams.Position) LabelLayoutData(org.eclipse.sirius.components.diagrams.layout.incremental.data.LabelLayoutData) NodeLabelPositionProvider(org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeLabelPositionProvider) LayoutConfiguratorRegistry(org.eclipse.sirius.components.diagrams.layout.LayoutConfiguratorRegistry) NodeLayoutData(org.eclipse.sirius.components.diagrams.layout.incremental.data.NodeLayoutData) Test(org.junit.jupiter.api.Test)

Example 4 with DiagramLayoutData

use of org.eclipse.sirius.components.diagrams.layout.incremental.data.DiagramLayoutData in project sirius-components by eclipse-sirius.

the class NodeLabelPositionProviderTests method createDiagramLayoutData.

private DiagramLayoutData createDiagramLayoutData() {
    DiagramLayoutData diagramLayoutData = new DiagramLayoutData();
    diagramLayoutData.setId(UUID.randomUUID().toString());
    diagramLayoutData.setPosition(Position.at(0, 0));
    diagramLayoutData.setSize(Size.of(1000, 1000));
    return diagramLayoutData;
}
Also used : DiagramLayoutData(org.eclipse.sirius.components.diagrams.layout.incremental.data.DiagramLayoutData)

Example 5 with DiagramLayoutData

use of org.eclipse.sirius.components.diagrams.layout.incremental.data.DiagramLayoutData in project sirius-components by eclipse-sirius.

the class NodeLabelPositionProviderTests method testNodeImageLabelBoundsPosition.

@Test
public void testNodeImageLabelBoundsPosition() {
    DiagramLayoutData createDiagramLayoutData = this.createDiagramLayoutData();
    NodeLayoutData nodeLayoutData = this.createNodeLayoutData(Position.at(0, 0), DEFAULT_NODE_SIZE, createDiagramLayoutData, NodeType.NODE_IMAGE);
    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(-23.3984375));
}
Also used : DiagramLayoutData(org.eclipse.sirius.components.diagrams.layout.incremental.data.DiagramLayoutData) Position(org.eclipse.sirius.components.diagrams.Position) LabelLayoutData(org.eclipse.sirius.components.diagrams.layout.incremental.data.LabelLayoutData) NodeLabelPositionProvider(org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeLabelPositionProvider) LayoutConfiguratorRegistry(org.eclipse.sirius.components.diagrams.layout.LayoutConfiguratorRegistry) NodeLayoutData(org.eclipse.sirius.components.diagrams.layout.incremental.data.NodeLayoutData) Test(org.junit.jupiter.api.Test)

Aggregations

DiagramLayoutData (org.eclipse.sirius.components.diagrams.layout.incremental.data.DiagramLayoutData)26 NodeLayoutData (org.eclipse.sirius.components.diagrams.layout.incremental.data.NodeLayoutData)18 Test (org.junit.jupiter.api.Test)17 IDiagramEvent (org.eclipse.sirius.components.diagrams.events.IDiagramEvent)13 Position (org.eclipse.sirius.components.diagrams.Position)12 ArrayList (java.util.ArrayList)9 LayoutConfiguratorRegistry (org.eclipse.sirius.components.diagrams.layout.LayoutConfiguratorRegistry)9 ImageSizeProvider (org.eclipse.sirius.components.diagrams.layout.incremental.provider.ImageSizeProvider)7 NodePositionProvider (org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodePositionProvider)7 NodeSizeProvider (org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeSizeProvider)7 ResizeEvent (org.eclipse.sirius.components.diagrams.events.ResizeEvent)5 SinglePositionEvent (org.eclipse.sirius.components.diagrams.events.SinglePositionEvent)5 MoveEvent (org.eclipse.sirius.components.diagrams.events.MoveEvent)3 LabelLayoutData (org.eclipse.sirius.components.diagrams.layout.incremental.data.LabelLayoutData)3 Size (org.eclipse.sirius.components.diagrams.Size)2 EdgeLayoutData (org.eclipse.sirius.components.diagrams.layout.incremental.data.EdgeLayoutData)2 ILayoutData (org.eclipse.sirius.components.diagrams.layout.incremental.data.ILayoutData)2 NodeLabelPositionProvider (org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeLabelPositionProvider)2 HashMap (java.util.HashMap)1 Edge (org.eclipse.sirius.components.diagrams.Edge)1