Search in sources :

Example 16 with Bounds

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

the class CoordinatesGenerationTest method shouldPlaceManyBranchesForInclusiveGateway.

@Test
public void shouldPlaceManyBranchesForInclusiveGateway() {
    ProcessBuilder builder = Bpmn.createExecutableProcess();
    instance = builder.startEvent(START_EVENT_ID).inclusiveGateway("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 17 with Bounds

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

the class AbstractBoundaryEventBuilder method setCoordinates.

@Override
protected void setCoordinates(BpmnShape shape) {
    BpmnShape source = findBpmnShape(element);
    Bounds shapeBounds = shape.getBounds();
    double x = 0;
    double y = 0;
    if (source != null) {
        Bounds sourceBounds = source.getBounds();
        double sourceX = sourceBounds.getX();
        double sourceWidth = sourceBounds.getWidth();
        double sourceY = sourceBounds.getY();
        double sourceHeight = sourceBounds.getHeight();
        double targetHeight = shapeBounds.getHeight();
        x = sourceX + sourceWidth + SPACE / 4;
        y = sourceY + sourceHeight - targetHeight / 2 + SPACE;
    }
    shapeBounds.setX(x);
    shapeBounds.setY(y);
}
Also used : BpmnShape(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape) Bounds(org.camunda.bpm.model.bpmn.instance.dc.Bounds)

Example 18 with Bounds

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

the class ProcessBuilder method setEventSubProcessCoordinates.

protected void setEventSubProcessCoordinates(BpmnShape targetBpmnShape) {
    SubProcess eventSubProcess = (SubProcess) targetBpmnShape.getBpmnElement();
    Bounds targetBounds = targetBpmnShape.getBounds();
    double lowestheight = 0;
    // find the lowest element in the model
    Collection<BpmnShape> allShapes = modelInstance.getModelElementsByType(BpmnShape.class);
    for (BpmnShape shape : allShapes) {
        Bounds bounds = shape.getBounds();
        double bottom = bounds.getY() + bounds.getHeight();
        if (bottom > lowestheight) {
            lowestheight = bottom;
        }
    }
    Double ycoord = lowestheight + 50.0;
    Double xcoord = 100.0;
    // move target
    targetBounds.setY(ycoord);
    targetBounds.setX(xcoord);
}
Also used : SubProcess(org.camunda.bpm.model.bpmn.instance.SubProcess) BpmnShape(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape) Bounds(org.camunda.bpm.model.bpmn.instance.dc.Bounds)

Example 19 with Bounds

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

the class EmbeddedSubProcessBuilder method setCoordinates.

protected void setCoordinates(BpmnShape targetBpmnShape) {
    SubProcess eventSubProcess = (SubProcess) targetBpmnShape.getBpmnElement();
    SubProcess parentSubProcess = (SubProcess) eventSubProcess.getParentElement();
    BpmnShape parentBpmnShape = subProcessBuilder.findBpmnShape(parentSubProcess);
    Bounds targetBounds = targetBpmnShape.getBounds();
    Bounds parentBounds = parentBpmnShape.getBounds();
    // these should just be offsets maybe
    Double ycoord = parentBounds.getHeight() + parentBounds.getY();
    Double xcoord = (parentBounds.getWidth() / 2) - (targetBounds.getWidth() / 2) + parentBounds.getX();
    if (xcoord - parentBounds.getX() < 50.0) {
        xcoord = 50.0 + parentBounds.getX();
    }
    // move target
    targetBounds.setY(ycoord);
    targetBounds.setX(xcoord);
// parent expands automatically
// nodes surrounding the parent subprocess will not be moved
// they may end up inside the subprocess (but only graphically)
}
Also used : SubProcess(org.camunda.bpm.model.bpmn.instance.SubProcess) BpmnShape(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape) Bounds(org.camunda.bpm.model.bpmn.instance.dc.Bounds)

Example 20 with Bounds

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

the class CoordinatesGenerationTest method shouldPlaceFollowingFlowNodeProperlyForTask.

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

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