Search in sources :

Example 1 with Waypoint

use of org.camunda.bpm.model.bpmn.instance.di.Waypoint in project camunda-bpmn-model by camunda.

the class CoordinatesGenerationTest method shouldPlaceManyBranchesForExclusiveGateway.

@Test
public void shouldPlaceManyBranchesForExclusiveGateway() {
    ProcessBuilder builder = Bpmn.createExecutableProcess();
    instance = builder.startEvent(START_EVENT_ID).exclusiveGateway("id").userTask(USER_TASK_ID).moveToNode("id").endEvent(END_EVENT_ID).moveToNode("id").serviceTask(SERVICE_TASK_ID).moveToNode("id").sequenceFlowId("s1").sendTask(SEND_TASK_ID).done();
    Bounds userTaskBounds = findBpmnShape(USER_TASK_ID).getBounds();
    assertShapeCoordinates(userTaskBounds, 286, 78);
    Bounds endEventBounds = findBpmnShape(END_EVENT_ID).getBounds();
    assertShapeCoordinates(endEventBounds, 286, 208);
    Bounds serviceTaskBounds = findBpmnShape(SERVICE_TASK_ID).getBounds();
    assertShapeCoordinates(serviceTaskBounds, 286, 294);
    Bounds sendTaskBounds = findBpmnShape(SEND_TASK_ID).getBounds();
    assertShapeCoordinates(sendTaskBounds, 286, 424);
    Collection<Waypoint> sequenceFlowWaypoints = findBpmnEdge("s1").getWaypoints();
    Iterator<Waypoint> iterator = sequenceFlowWaypoints.iterator();
    Waypoint waypoint = iterator.next();
    assertWaypointCoordinates(waypoint, 211, 143);
    while (iterator.hasNext()) {
        waypoint = iterator.next();
    }
    assertWaypointCoordinates(waypoint, 286, 464);
}
Also used : ProcessBuilder(org.camunda.bpm.model.bpmn.builder.ProcessBuilder) Bounds(org.camunda.bpm.model.bpmn.instance.dc.Bounds) Waypoint(org.camunda.bpm.model.bpmn.instance.di.Waypoint) Test(org.junit.Test)

Example 2 with Waypoint

use of org.camunda.bpm.model.bpmn.instance.di.Waypoint in project camunda-bpmn-model by camunda.

the class CoordinatesGenerationTest method shouldPlaceTwoBranchesForExclusiveGateway.

@Test
public void shouldPlaceTwoBranchesForExclusiveGateway() {
    ProcessBuilder builder = Bpmn.createExecutableProcess();
    instance = builder.startEvent(START_EVENT_ID).exclusiveGateway("id").sequenceFlowId("s1").userTask(USER_TASK_ID).moveToNode("id").sequenceFlowId("s2").endEvent(END_EVENT_ID).done();
    Bounds userTaskBounds = findBpmnShape(USER_TASK_ID).getBounds();
    assertShapeCoordinates(userTaskBounds, 286, 78);
    Bounds endEventBounds = findBpmnShape(END_EVENT_ID).getBounds();
    assertShapeCoordinates(endEventBounds, 286, 208);
    Collection<Waypoint> sequenceFlowWaypoints = findBpmnEdge("s2").getWaypoints();
    Iterator<Waypoint> iterator = sequenceFlowWaypoints.iterator();
    Waypoint waypoint = iterator.next();
    assertWaypointCoordinates(waypoint, 211, 143);
    while (iterator.hasNext()) {
        waypoint = iterator.next();
    }
    assertWaypointCoordinates(waypoint, 286, 226);
}
Also used : ProcessBuilder(org.camunda.bpm.model.bpmn.builder.ProcessBuilder) Bounds(org.camunda.bpm.model.bpmn.instance.dc.Bounds) Waypoint(org.camunda.bpm.model.bpmn.instance.di.Waypoint) Test(org.junit.Test)

Example 3 with Waypoint

use of org.camunda.bpm.model.bpmn.instance.di.Waypoint in project camunda-bpmn-model by camunda.

the class AbstractBaseElementBuilder method setWaypointsWithSourceAndTarget.

protected void setWaypointsWithSourceAndTarget(BpmnEdge edge, FlowNode edgeSource, FlowNode edgeTarget) {
    BpmnShape source = findBpmnShape(edgeSource);
    BpmnShape target = findBpmnShape(edgeTarget);
    if (source != null && target != null) {
        Bounds sourceBounds = source.getBounds();
        Bounds targetBounds = target.getBounds();
        double sourceX = sourceBounds.getX();
        double sourceY = sourceBounds.getY();
        double sourceWidth = sourceBounds.getWidth();
        double sourceHeight = sourceBounds.getHeight();
        double targetX = targetBounds.getX();
        double targetY = targetBounds.getY();
        double targetHeight = targetBounds.getHeight();
        Waypoint w1 = createInstance(Waypoint.class);
        if (edgeSource.getOutgoing().size() == 1) {
            w1.setX(sourceX + sourceWidth);
            w1.setY(sourceY + sourceHeight / 2);
            edge.addChildElement(w1);
        } else {
            w1.setX(sourceX + sourceWidth / 2);
            w1.setY(sourceY + sourceHeight);
            edge.addChildElement(w1);
            Waypoint w2 = createInstance(Waypoint.class);
            w2.setX(sourceX + sourceWidth / 2);
            w2.setY(targetY + targetHeight / 2);
            edge.addChildElement(w2);
        }
        Waypoint w3 = createInstance(Waypoint.class);
        w3.setX(targetX);
        w3.setY(targetY + targetHeight / 2);
        edge.addChildElement(w3);
    }
}
Also used : BpmnShape(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape) Bounds(org.camunda.bpm.model.bpmn.instance.dc.Bounds) Waypoint(org.camunda.bpm.model.bpmn.instance.di.Waypoint)

Example 4 with Waypoint

use of org.camunda.bpm.model.bpmn.instance.di.Waypoint in project camunda-bpmn-model by camunda.

the class CoordinatesGenerationTest method shouldPlaceThrowingIntermediateEvent.

@Test
public void shouldPlaceThrowingIntermediateEvent() {
    ProcessBuilder builder = Bpmn.createExecutableProcess();
    instance = builder.startEvent(START_EVENT_ID).sequenceFlowId(SEQUENCE_FLOW_ID).intermediateThrowEvent("id").done();
    Bounds throwEventBounds = findBpmnShape("id").getBounds();
    assertShapeCoordinates(throwEventBounds, 186, 100);
    Collection<Waypoint> sequenceFlowWaypoints = findBpmnEdge(SEQUENCE_FLOW_ID).getWaypoints();
    Iterator<Waypoint> iterator = sequenceFlowWaypoints.iterator();
    Waypoint waypoint = iterator.next();
    assertWaypointCoordinates(waypoint, 136, 118);
    while (iterator.hasNext()) {
        waypoint = iterator.next();
    }
    assertWaypointCoordinates(waypoint, 186, 118);
}
Also used : ProcessBuilder(org.camunda.bpm.model.bpmn.builder.ProcessBuilder) Bounds(org.camunda.bpm.model.bpmn.instance.dc.Bounds) Waypoint(org.camunda.bpm.model.bpmn.instance.di.Waypoint) Test(org.junit.Test)

Example 5 with Waypoint

use of org.camunda.bpm.model.bpmn.instance.di.Waypoint in project camunda-bpmn-model by camunda.

the class CoordinatesGenerationTest method shouldPlaceThreeBranchesForEventBasedGateway.

@Test
public void shouldPlaceThreeBranchesForEventBasedGateway() {
    ProcessBuilder builder = Bpmn.createExecutableProcess();
    instance = builder.startEvent(START_EVENT_ID).eventBasedGateway().id("id").userTask(USER_TASK_ID).moveToNode("id").endEvent(END_EVENT_ID).moveToNode("id").sequenceFlowId("s1").serviceTask(SERVICE_TASK_ID).done();
    Bounds userTaskBounds = findBpmnShape(USER_TASK_ID).getBounds();
    assertShapeCoordinates(userTaskBounds, 286, 78);
    Bounds endEventBounds = findBpmnShape(END_EVENT_ID).getBounds();
    assertShapeCoordinates(endEventBounds, 286, 208);
    Bounds serviceTaskBounds = findBpmnShape(SERVICE_TASK_ID).getBounds();
    assertShapeCoordinates(serviceTaskBounds, 286, 294);
    Collection<Waypoint> sequenceFlowWaypoints = findBpmnEdge("s1").getWaypoints();
    Iterator<Waypoint> iterator = sequenceFlowWaypoints.iterator();
    Waypoint waypoint = iterator.next();
    assertWaypointCoordinates(waypoint, 211, 143);
    while (iterator.hasNext()) {
        waypoint = iterator.next();
    }
    assertWaypointCoordinates(waypoint, 286, 334);
}
Also used : ProcessBuilder(org.camunda.bpm.model.bpmn.builder.ProcessBuilder) Bounds(org.camunda.bpm.model.bpmn.instance.dc.Bounds) Waypoint(org.camunda.bpm.model.bpmn.instance.di.Waypoint) Test(org.junit.Test)

Aggregations

Waypoint (org.camunda.bpm.model.bpmn.instance.di.Waypoint)34 Bounds (org.camunda.bpm.model.bpmn.instance.dc.Bounds)33 Test (org.junit.Test)31 ProcessBuilder (org.camunda.bpm.model.bpmn.builder.ProcessBuilder)30 BpmnShape (org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape)2 Point (org.camunda.bpm.model.bpmn.instance.dc.Point)1 ModelTypeInstanceContext (org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)1 ModelElementTypeBuilder (org.camunda.bpm.model.xml.type.ModelElementTypeBuilder)1