Search in sources :

Example 56 with Bounds

use of org.camunda.bpm.model.bpmn.instance.dc.Bounds in project camunda-bpmn-model by camunda.

the class CoordinatesGenerationTest method shouldPlaceExclusiveGateway.

@Test
public void shouldPlaceExclusiveGateway() {
    ProcessBuilder builder = Bpmn.createExecutableProcess();
    instance = builder.startEvent(START_EVENT_ID).sequenceFlowId(SEQUENCE_FLOW_ID).exclusiveGateway("id").done();
    Bounds gatewayBounds = findBpmnShape("id").getBounds();
    assertShapeCoordinates(gatewayBounds, 186, 93);
    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 57 with Bounds

use of org.camunda.bpm.model.bpmn.instance.dc.Bounds in project camunda-bpmn-model by camunda.

the class CoordinatesGenerationTest method shouldPlaceUserTask.

@Test
public void shouldPlaceUserTask() {
    ProcessBuilder builder = Bpmn.createExecutableProcess();
    instance = builder.startEvent(START_EVENT_ID).sequenceFlowId(SEQUENCE_FLOW_ID).userTask(USER_TASK_ID).done();
    Bounds userTaskBounds = findBpmnShape(USER_TASK_ID).getBounds();
    assertShapeCoordinates(userTaskBounds, 186, 78);
    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 58 with Bounds

use of org.camunda.bpm.model.bpmn.instance.dc.Bounds in project camunda-bpmn-model by camunda.

the class AbstractEventSubProcessBuilder method startEvent.

public StartEventBuilder startEvent(String id) {
    StartEvent start = createChild(StartEvent.class, id);
    BpmnShape startShape = createBpmnShape(start);
    BpmnShape subProcessShape = findBpmnShape(getElement());
    if (subProcessShape != null) {
        Bounds subProcessBounds = subProcessShape.getBounds();
        Bounds startBounds = startShape.getBounds();
        double subProcessX = subProcessBounds.getX();
        double subProcessY = subProcessBounds.getY();
        double subProcessHeight = subProcessBounds.getHeight();
        double startHeight = startBounds.getHeight();
        startBounds.setX(subProcessX + SPACE);
        startBounds.setY(subProcessY + subProcessHeight / 2 - startHeight / 2);
    }
    return start.builder();
}
Also used : BpmnShape(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape) Bounds(org.camunda.bpm.model.bpmn.instance.dc.Bounds) StartEvent(org.camunda.bpm.model.bpmn.instance.StartEvent)

Example 59 with Bounds

use of org.camunda.bpm.model.bpmn.instance.dc.Bounds in project camunda-bpmn-model by camunda.

the class AbstractBoundaryEventBuilder method setWaypointsWithSourceAndTarget.

@Override
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);
        w1.setX(sourceX + sourceWidth / 2);
        w1.setY(sourceY + sourceHeight);
        Waypoint w2 = createInstance(Waypoint.class);
        w2.setX(sourceX + sourceWidth / 2);
        w2.setY(sourceY + sourceHeight + SPACE);
        Waypoint w3 = createInstance(Waypoint.class);
        w3.setX(targetX);
        w3.setY(targetY + targetHeight / 2);
        edge.addChildElement(w1);
        edge.addChildElement(w2);
        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 60 with Bounds

use of org.camunda.bpm.model.bpmn.instance.dc.Bounds in project camunda-bpmn-model by camunda.

the class CoordinatesGenerationTest method shouldPlaceFollowingFlowNodeForSubProcess.

@Test
public void shouldPlaceFollowingFlowNodeForSubProcess() {
    ProcessBuilder builder = Bpmn.createExecutableProcess();
    instance = builder.startEvent(START_EVENT_ID).subProcess(SUB_PROCESS_ID).boundaryEvent("boundary").sequenceFlowId(SEQUENCE_FLOW_ID).endEvent(END_EVENT_ID).moveToActivity(SUB_PROCESS_ID).endEvent().done();
    Bounds endEventBounds = findBpmnShape(END_EVENT_ID).getBounds();
    assertShapeCoordinates(endEventBounds, 391.5, 268);
    Collection<Waypoint> sequenceFlowWaypoints = findBpmnEdge(SEQUENCE_FLOW_ID).getWaypoints();
    Iterator<Waypoint> iterator = sequenceFlowWaypoints.iterator();
    Waypoint waypoint = iterator.next();
    assertWaypointCoordinates(waypoint, 361, 236);
    while (iterator.hasNext()) {
        waypoint = iterator.next();
    }
    assertWaypointCoordinates(waypoint, 391.5, 286);
}
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

Bounds (org.camunda.bpm.model.bpmn.instance.dc.Bounds)60 ProcessBuilder (org.camunda.bpm.model.bpmn.builder.ProcessBuilder)45 Test (org.junit.Test)45 Waypoint (org.camunda.bpm.model.bpmn.instance.di.Waypoint)33 BpmnShape (org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape)12 StartEvent (org.camunda.bpm.model.bpmn.instance.StartEvent)2 SubProcess (org.camunda.bpm.model.bpmn.instance.SubProcess)2 ArrayList (java.util.ArrayList)1 BoundaryEvent (org.camunda.bpm.model.bpmn.instance.BoundaryEvent)1 BpmnPlane (org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnPlane)1 ModelTypeInstanceContext (org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)1 ModelElementInstance (org.camunda.bpm.model.xml.instance.ModelElementInstance)1 ModelElementTypeBuilder (org.camunda.bpm.model.xml.type.ModelElementTypeBuilder)1