Search in sources :

Example 26 with Bounds

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

the class SequenceFlowPropertyReaderTest method boundsOf.

private Bounds boundsOf(float x, float y, float width, float height) {
    Bounds bounds = dc.createBounds();
    bounds.setX(x);
    bounds.setY(y);
    bounds.setWidth(width);
    bounds.setHeight(height);
    return bounds;
}
Also used : Bounds(org.eclipse.dd.dc.Bounds)

Example 27 with Bounds

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

the class SequenceFlowPropertyReaderTest method getConnectionsNoWaypoints.

@Test
public void getConnectionsNoWaypoints() {
    TestDefinitionsWriter d = new TestDefinitionsWriter();
    PropertyReaderFactory factory = new PropertyReaderFactory(d.getDefinitionResolver());
    Bounds sourceBounds = boundsOf(10, 10, 50, 50);
    FlowNode source = d.mockNode(SOURCE_ID, sourceBounds);
    Bounds targetBounds = boundsOf(100, 100, 60, 60);
    FlowNode target = d.mockNode(TARGET_ID, targetBounds);
    List<Point> noWaypoints = Collections.emptyList();
    SequenceFlow el = d.sequenceFlowOf(SEQ_ID, source, target, noWaypoints);
    SequenceFlowPropertyReader p = factory.of(el);
    // this is inferred from behavior of the old marshallers
    Connection sourceConnection = p.getSourceConnection();
    assertEquals(sourceBounds.getWidth(), (float) sourceConnection.getLocation().getX(), 0);
    assertEquals(sourceBounds.getHeight() / 2f, (float) sourceConnection.getLocation().getY(), 0);
    Connection targetConnection = p.getTargetConnection();
    assertEquals(0.0f, (float) targetConnection.getLocation().getX(), 0);
    assertEquals(targetBounds.getHeight() / 2.0f, (float) targetConnection.getLocation().getY(), 0);
}
Also used : SequenceFlow(org.eclipse.bpmn2.SequenceFlow) Bounds(org.eclipse.dd.dc.Bounds) Connection(org.kie.workbench.common.stunner.core.graph.content.view.Connection) Point(org.eclipse.dd.dc.Point) TestDefinitionsWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.TestDefinitionsWriter) FlowNode(org.eclipse.bpmn2.FlowNode) Test(org.junit.Test)

Example 28 with Bounds

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

the class SequenceFlowPropertyReaderTest method get1Waypoint.

@Test
public void get1Waypoint() {
    TestDefinitionsWriter d = new TestDefinitionsWriter();
    PropertyReaderFactory factory = new PropertyReaderFactory(d.getDefinitionResolver());
    Bounds sourceBounds = boundsOf(10, 10, 50, 50);
    FlowNode source = d.mockNode(SOURCE_ID, sourceBounds);
    Bounds targetBounds = boundsOf(100, 100, 60, 60);
    FlowNode target = d.mockNode(TARGET_ID, targetBounds);
    Point sourcePoint = pointOf(10, 20);
    Point mid1 = pointOf(15, 25);
    Point targetPoint = pointOf(100, 120);
    List<Point> waypoints = asList(sourcePoint, mid1, targetPoint);
    SequenceFlow el = d.sequenceFlowOf(SEQ_ID, source, target, waypoints);
    SequenceFlowPropertyReader p = factory.of(el);
    List<Point2D> controlPoints = p.getControlPoints();
    List<Point2D> expected = Collections.singletonList(Point2D.create(mid1.getX(), mid1.getY()));
    assertEquals(expected, controlPoints);
}
Also used : Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) SequenceFlow(org.eclipse.bpmn2.SequenceFlow) Bounds(org.eclipse.dd.dc.Bounds) Point(org.eclipse.dd.dc.Point) TestDefinitionsWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.TestDefinitionsWriter) FlowNode(org.eclipse.bpmn2.FlowNode) Test(org.junit.Test)

Example 29 with Bounds

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

the class AbstractBasePropertyWriterTest method testSetBounds.

@Test
public void testSetBounds() {
    org.kie.workbench.common.stunner.core.graph.content.Bounds bounds = org.kie.workbench.common.stunner.core.graph.content.Bounds.create(X1, Y1, X2, Y2);
    propertyWriter.setBounds(bounds);
    BPMNShape shape = propertyWriter.getShape();
    assertNotNull(shape);
    assertEquals("shape_" + ID, shape.getId());
    assertEquals(element, shape.getBpmnElement());
    Bounds shapeBounds = shape.getBounds();
    assertEquals(X1.floatValue(), shapeBounds.getX(), 0);
    assertEquals(Y1.floatValue(), shapeBounds.getY(), 0);
    assertEquals(X2.floatValue() - X1.floatValue(), shapeBounds.getWidth(), 0);
    assertEquals(Y2.floatValue() - Y1.floatValue(), shapeBounds.getHeight(), 0);
}
Also used : Bounds(org.eclipse.dd.dc.Bounds) BPMNShape(org.eclipse.bpmn2.di.BPMNShape) Test(org.junit.Test)

Example 30 with Bounds

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

the class AbstractBasePropertyWriterTest method testSetAbsoluteBounds.

protected void testSetAbsoluteBounds(Node<View, ?> node) {
    org.kie.workbench.common.stunner.core.graph.content.Bounds relativeBounds = node.getContent().getBounds();
    double absoluteX = PARENT_ABSOLUTE_X1 + relativeBounds.getUpperLeft().getX();
    double absoluteY = PARENT_ABSOLUTE_Y1 + relativeBounds.getUpperLeft().getY();
    propertyWriter.setAbsoluteBounds(node);
    Bounds shapeBounds = propertyWriter.getShape().getBounds();
    assertEquals(absoluteX, shapeBounds.getX(), 0);
    assertEquals(absoluteY, shapeBounds.getY(), 0);
    assertEquals(relativeBounds.getWidth(), shapeBounds.getWidth(), 0);
    assertEquals(relativeBounds.getHeight(), shapeBounds.getHeight(), 0);
}
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