use of org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape in project camunda-bpmn-model by camunda.
the class AbstractBaseElementBuilder method setCoordinates.
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();
x = sourceX + sourceWidth + SPACE;
if (element instanceof FlowNode) {
FlowNode flowNode = (FlowNode) element;
Collection<SequenceFlow> outgoing = flowNode.getOutgoing();
if (outgoing.size() == 0) {
double sourceY = sourceBounds.getY();
double sourceHeight = sourceBounds.getHeight();
double targetHeight = shapeBounds.getHeight();
y = sourceY + sourceHeight / 2 - targetHeight / 2;
} else {
SequenceFlow[] sequenceFlows = outgoing.toArray(new SequenceFlow[outgoing.size()]);
SequenceFlow last = sequenceFlows[outgoing.size() - 1];
BpmnShape targetShape = findBpmnShape(last.getTarget());
if (targetShape != null) {
Bounds targetBounds = targetShape.getBounds();
double lastY = targetBounds.getY();
double lastHeight = targetBounds.getHeight();
y = lastY + lastHeight + 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 AbstractBaseElementBuilder method findBpmnShape.
protected BpmnShape findBpmnShape(BaseElement node) {
Collection<BpmnShape> allShapes = modelInstance.getModelElementsByType(BpmnShape.class);
Iterator<BpmnShape> iterator = allShapes.iterator();
while (iterator.hasNext()) {
BpmnShape shape = iterator.next();
if (shape.getBpmnElement().equals(node)) {
return shape;
}
}
return null;
}
use of org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape in project camunda-bpmn-model by camunda.
the class AbstractBaseElementBuilder method createBpmnShape.
public BpmnShape createBpmnShape(FlowNode node) {
BpmnPlane bpmnPlane = findBpmnPlane();
if (bpmnPlane != null) {
BpmnShape bpmnShape = createInstance(BpmnShape.class);
bpmnShape.setBpmnElement(node);
Bounds nodeBounds = createInstance(Bounds.class);
if (node instanceof SubProcess) {
bpmnShape.setExpanded(true);
nodeBounds.setWidth(350);
nodeBounds.setHeight(200);
} else if (node instanceof Activity) {
nodeBounds.setWidth(100);
nodeBounds.setHeight(80);
} else if (node instanceof Event) {
nodeBounds.setWidth(36);
nodeBounds.setHeight(36);
} else if (node instanceof Gateway) {
nodeBounds.setWidth(50);
nodeBounds.setHeight(50);
if (node instanceof ExclusiveGateway) {
bpmnShape.setMarkerVisible(true);
}
}
nodeBounds.setX(0);
nodeBounds.setY(0);
bpmnShape.addChildElement(nodeBounds);
bpmnPlane.addChildElement(bpmnShape);
return bpmnShape;
}
return null;
}
use of org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape 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();
}
use of org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape 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;
}
Aggregations