Search in sources :

Example 21 with BpmnShape

use of org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape in project camunda-bpm-platform by camunda.

the class ModifiableBpmnModelInstance method removeBpmnShape.

protected void removeBpmnShape(FlowNode flowNode) {
    Collection<BpmnShape> bpmnShapes = modelInstance.getModelElementsByType(BpmnShape.class);
    for (BpmnShape shape : bpmnShapes) {
        if (shape.getBpmnElement().equals(flowNode)) {
            ModelElementInstance bpmnPlane = shape.getParentElement();
            bpmnPlane.removeChildElement(shape);
            break;
        }
    }
}
Also used : BpmnShape(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance)

Example 22 with BpmnShape

use of org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape 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 23 with BpmnShape

use of org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape 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 24 with BpmnShape

use of org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape 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 25 with BpmnShape

use of org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape 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)

Aggregations

BpmnShape (org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape)46 ProcessBuilder (org.camunda.bpm.model.bpmn.builder.ProcessBuilder)21 Test (org.junit.Test)21 Bounds (org.camunda.bpm.model.bpmn.instance.dc.Bounds)12 SubProcess (org.camunda.bpm.model.bpmn.instance.SubProcess)4 StartEvent (org.camunda.bpm.model.bpmn.instance.StartEvent)3 BoundaryEvent (org.camunda.bpm.model.bpmn.instance.BoundaryEvent)2 Waypoint (org.camunda.bpm.model.bpmn.instance.di.Waypoint)2 ModelElementInstance (org.camunda.bpm.model.xml.instance.ModelElementInstance)2 ArrayList (java.util.ArrayList)1 BpmnPlane (org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnPlane)1 LabeledShape (org.camunda.bpm.model.bpmn.instance.di.LabeledShape)1 ModelTypeInstanceContext (org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)1 ModelElementTypeBuilder (org.camunda.bpm.model.xml.type.ModelElementTypeBuilder)1 SequenceBuilder (org.camunda.bpm.model.xml.type.child.SequenceBuilder)1