Search in sources :

Example 31 with Bounds

use of org.eclipse.dd.dc.Bounds in project kie-wb-common by kiegroup.

the class BoundaryEventPropertyWriterTest method testSetAbsoluteBounds.

@Test
@SuppressWarnings("unchecked")
public void testSetAbsoluteBounds() {
    Node<View, Edge> node = (Node<View, Edge>) super.createNode();
    Node<View, ?> dockSourceParentNode = mockNode(new Object(), org.kie.workbench.common.stunner.core.graph.content.Bounds.create(PARENT_ABSOLUTE_X1, PARENT_ABSOLUTE_Y1, PARENT_ABSOLUTE_X2, PARENT_ABSOLUTE_Y2));
    double dockSourceRelativeX1 = 15d;
    double dockSourceRelativeY1 = 20d;
    double dockSourceRelativeX2 = 50d;
    double dockSourceAbsoluteY2 = 45d;
    Node<View, ?> dockSourceNode = mockNode(new Object(), org.kie.workbench.common.stunner.core.graph.content.Bounds.create(dockSourceRelativeX1, dockSourceRelativeY1, dockSourceRelativeX2, dockSourceAbsoluteY2), dockSourceParentNode);
    Edge dockEdge = mock(Edge.class);
    when(dockEdge.getSourceNode()).thenReturn(dockSourceNode);
    Dock dock = mock(Dock.class);
    when(dockEdge.getContent()).thenReturn(dock);
    node.getInEdges().clear();
    node.getInEdges().add(dockEdge);
    propertyWriter.setAbsoluteBounds(node);
    Bounds shapeBounds = propertyWriter.getShape().getBounds();
    org.kie.workbench.common.stunner.core.graph.content.Bounds relativeBounds = node.getContent().getBounds();
    double dockSourceAbsoluteX = PARENT_ABSOLUTE_X1 + dockSourceRelativeX1;
    double dockSourceAbsoluteY = PARENT_ABSOLUTE_Y1 + dockSourceRelativeY1;
    assertEquals(dockSourceAbsoluteX + relativeBounds.getX(), shapeBounds.getX(), 0);
    assertEquals(dockSourceAbsoluteY + relativeBounds.getY(), shapeBounds.getY(), 0);
    assertEquals(relativeBounds.getWidth(), shapeBounds.getWidth(), 0);
    assertEquals(relativeBounds.getHeight(), shapeBounds.getHeight(), 0);
    verifyDockerInfoWasSet(relativeBounds);
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Bounds(org.eclipse.dd.dc.Bounds) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Dock(org.kie.workbench.common.stunner.core.graph.content.relationship.Dock) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Example 32 with Bounds

use of org.eclipse.dd.dc.Bounds in project kie-wb-common by kiegroup.

the class PropertyWriterUtilsTest method mockShape.

public static BPMNShape mockShape(String id, float x, float y, float width, float height) {
    BPMNShape shape = mock(BPMNShape.class);
    when(shape.getId()).thenReturn(id);
    Bounds bounds = mock(Bounds.class);
    when(bounds.getX()).thenReturn(x);
    when(bounds.getY()).thenReturn(y);
    when(shape.getBounds()).thenReturn(bounds);
    return shape;
}
Also used : Bounds(org.eclipse.dd.dc.Bounds) BPMNShape(org.eclipse.bpmn2.di.BPMNShape)

Example 33 with Bounds

use of org.eclipse.dd.dc.Bounds in project kie-wb-common by kiegroup.

the class PropertyReaderUtils method getTargetPosition.

public static Point2D getTargetPosition(DefinitionResolver definitionResolver, String edgeId, String targetId) {
    final double resolutionFactor = definitionResolver.getResolutionFactor();
    final Bounds targetBounds = definitionResolver.getShape(targetId).getBounds();
    final List<Point> waypoint = definitionResolver.getEdge(edgeId).getWaypoint();
    return waypoint.isEmpty() ? targetPosition(targetBounds, resolutionFactor) : offsetPosition(targetBounds, waypoint.get(waypoint.size() - 1), resolutionFactor);
}
Also used : Bounds(org.eclipse.dd.dc.Bounds) Point(org.eclipse.dd.dc.Point)

Example 34 with Bounds

use of org.eclipse.dd.dc.Bounds in project kie-wb-common by kiegroup.

the class PropertyReaderUtils method getSourcePosition.

public static Point2D getSourcePosition(DefinitionResolver definitionResolver, String edgeId, String sourceId) {
    final double resolutionFactor = definitionResolver.getResolutionFactor();
    final Bounds sourceBounds = definitionResolver.getShape(sourceId).getBounds();
    final List<Point> waypoint = definitionResolver.getEdge(edgeId).getWaypoint();
    return waypoint.isEmpty() ? sourcePosition(sourceBounds, resolutionFactor) : offsetPosition(sourceBounds, waypoint.get(0), resolutionFactor);
}
Also used : Bounds(org.eclipse.dd.dc.Bounds) Point(org.eclipse.dd.dc.Point)

Example 35 with Bounds

use of org.eclipse.dd.dc.Bounds in project kie-wb-common by kiegroup.

the class TestUtils method mockBounds.

public static Bounds mockBounds(float x, float y) {
    Bounds bounds = mock(Bounds.class);
    when(bounds.getX()).thenReturn(x);
    when(bounds.getY()).thenReturn(y);
    return bounds;
}
Also used : Bounds(org.eclipse.dd.dc.Bounds)

Aggregations

Bounds (org.eclipse.dd.dc.Bounds)35 Point (org.eclipse.dd.dc.Point)17 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)11 SubProcess (org.eclipse.bpmn2.SubProcess)11 BPMNShape (org.eclipse.bpmn2.di.BPMNShape)11 DataObject (org.eclipse.bpmn2.DataObject)8 Process (org.eclipse.bpmn2.Process)8 SequenceFlow (org.eclipse.bpmn2.SequenceFlow)8 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)7 FlowElement (org.eclipse.bpmn2.FlowElement)7 FlowNode (org.eclipse.bpmn2.FlowNode)7 BPMNEdge (org.eclipse.bpmn2.di.BPMNEdge)7 LinkedHashMap (java.util.LinkedHashMap)6 List (java.util.List)4 Entry (java.util.Map.Entry)4 Lane (org.eclipse.bpmn2.Lane)4 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)4 TestDefinitionsWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.TestDefinitionsWriter)4 Artifact (org.eclipse.bpmn2.Artifact)3