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;
}
}
}
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);
}
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);
}
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;
}
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)
}
Aggregations