Search in sources :

Example 11 with Bounds

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

the class PropertyWriterUtils method getTargetLocation.

private static Point2D getTargetLocation(BasePropertyWriter target, Connection targetConnection) {
    Point2D location = targetConnection.getLocation();
    if (location == null) {
        Bounds bounds = target.getShape().getBounds();
        location = Point2D.create(0, bounds.getHeight() / 2);
    }
    return location;
}
Also used : Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) Bounds(org.eclipse.dd.dc.Bounds)

Example 12 with Bounds

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

the class PropertyWriterUtils method getSourceLocation.

private static Point2D getSourceLocation(BasePropertyWriter source, Connection sourceConnection) {
    Point2D location = sourceConnection.getLocation();
    if (location == null) {
        Bounds bounds = source.getShape().getBounds();
        location = Point2D.create(bounds.getWidth(), bounds.getHeight() / 2);
    }
    return location;
}
Also used : Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) Bounds(org.eclipse.dd.dc.Bounds)

Example 13 with Bounds

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

the class BoundaryEventPropertyWriterTest method testSetAbsoluteBoundsWhenDockedSourceNodeIsNotPresent.

@Test
@SuppressWarnings("unchecked")
public void testSetAbsoluteBoundsWhenDockedSourceNodeIsNotPresent() {
    // no dock source is set
    Node<View, Edge> node = (Node<View, Edge>) super.createNode();
    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);
    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) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Example 14 with Bounds

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

the class BaseEventPropertyReaderTest method testComputeBounds.

@Test
public void testComputeBounds() {
    Bounds bounds = mockBounds(X, Y);
    org.kie.workbench.common.stunner.core.graph.content.Bounds result = propertyReader.computeBounds(bounds);
    assertBounds(X * RESOLUTION_FACTOR, Y * RESOLUTION_FACTOR, X * RESOLUTION_FACTOR + EventPropertyReader.WIDTH, Y * RESOLUTION_FACTOR + EventPropertyReader.HEIGHT, result);
}
Also used : TestUtils.assertBounds(org.kie.workbench.common.stunner.bpmn.backend.converters.TestUtils.assertBounds) TestUtils.mockBounds(org.kie.workbench.common.stunner.bpmn.backend.converters.TestUtils.mockBounds) Bounds(org.eclipse.dd.dc.Bounds) Test(org.junit.Test)

Example 15 with Bounds

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

the class SequenceFlowPropertyReaderTest method get2Waypoints.

@Test
public void get2Waypoints() {
    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 mid2 = pointOf(20, 30);
    Point targetPoint = pointOf(100, 120);
    List<Point> waypoints = asList(sourcePoint, mid1, mid2, targetPoint);
    SequenceFlow el = d.sequenceFlowOf(SEQ_ID, source, target, waypoints);
    SequenceFlowPropertyReader p = factory.of(el);
    List<Point2D> controlPoints = p.getControlPoints();
    List<Point2D> expected = asList(Point2D.create(mid1.getX(), mid1.getY()), Point2D.create(mid2.getX(), mid2.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)

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