Search in sources :

Example 1 with SubProcess

use of org.camunda.bpm.model.bpmn.instance.SubProcess 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 2 with SubProcess

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

the class EmbeddedSubProcessBuilder method eventSubProcess.

public EventSubProcessBuilder eventSubProcess(String id) {
    // Create a subprocess, triggered by an event, and add it to modelInstance
    SubProcess subProcess = subProcessBuilder.createChild(SubProcess.class, id);
    subProcess.setTriggeredByEvent(true);
    // Create Bpmn shape so subprocess will be drawn
    BpmnShape targetBpmnShape = subProcessBuilder.createBpmnShape(subProcess);
    // find the lowest shape in the process
    // place event sub process underneath
    setCoordinates(targetBpmnShape);
    subProcessBuilder.resizeSubProcess(targetBpmnShape);
    // Return the eventSubProcessBuilder
    EventSubProcessBuilder eventSubProcessBuilder = new EventSubProcessBuilder(subProcessBuilder.modelInstance, subProcess);
    return eventSubProcessBuilder;
}
Also used : SubProcess(org.camunda.bpm.model.bpmn.instance.SubProcess) BpmnShape(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape)

Example 3 with SubProcess

use of org.camunda.bpm.model.bpmn.instance.SubProcess 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 4 with SubProcess

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

the class ProcessBuilder method eventSubProcess.

public EventSubProcessBuilder eventSubProcess(String id) {
    // Create a subprocess, triggered by an event, and add it to modelInstance
    SubProcess subProcess = createChild(SubProcess.class, id);
    subProcess.setTriggeredByEvent(true);
    // Create Bpmn shape so subprocess will be drawn
    BpmnShape targetBpmnShape = createBpmnShape(subProcess);
    // find the lowest shape in the process
    // place event sub process underneath
    setEventSubProcessCoordinates(targetBpmnShape);
    resizeSubProcess(targetBpmnShape);
    // Return the eventSubProcessBuilder
    EventSubProcessBuilder eventSubProcessBuilder = new EventSubProcessBuilder(modelInstance, subProcess);
    return eventSubProcessBuilder;
}
Also used : SubProcess(org.camunda.bpm.model.bpmn.instance.SubProcess) BpmnShape(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape)

Aggregations

SubProcess (org.camunda.bpm.model.bpmn.instance.SubProcess)4 BpmnShape (org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape)4 Bounds (org.camunda.bpm.model.bpmn.instance.dc.Bounds)2