use of org.camunda.bpm.model.bpmn.instance.dc.Bounds in project camunda-bpmn-model by camunda.
the class AbstractActivityBuilder method setBoundaryEventCoordinates.
protected void setBoundaryEventCoordinates(BpmnShape bpmnShape) {
BpmnShape activity = findBpmnShape(element);
Bounds boundaryBounds = bpmnShape.getBounds();
double x = 0;
double y = 0;
if (activity != null) {
Bounds activityBounds = activity.getBounds();
double activityY = activityBounds.getY();
double activityHeight = activityBounds.getHeight();
double boundaryHeight = boundaryBounds.getHeight();
x = calculateXCoordinate(boundaryBounds);
y = activityY + activityHeight - boundaryHeight / 2;
}
boundaryBounds.setX(x);
boundaryBounds.setY(y);
}
use of org.camunda.bpm.model.bpmn.instance.dc.Bounds 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.dc.Bounds 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.dc.Bounds in project camunda-bpmn-model by camunda.
the class BpmnDiTest method shouldCreateValidBpmnDi.
@Test
public void shouldCreateValidBpmnDi() {
modelInstance = Bpmn.createProcess("process").startEvent("start").sequenceFlowId("flow").endEvent("end").done();
process = modelInstance.getModelElementById("process");
startEvent = modelInstance.getModelElementById("start");
sequenceFlow = modelInstance.getModelElementById("flow");
endEvent = modelInstance.getModelElementById("end");
// create bpmn diagram
BpmnDiagram bpmnDiagram = modelInstance.newInstance(BpmnDiagram.class);
bpmnDiagram.setId("diagram");
bpmnDiagram.setName("diagram");
bpmnDiagram.setDocumentation("bpmn diagram element");
bpmnDiagram.setResolution(120.0);
modelInstance.getDefinitions().addChildElement(bpmnDiagram);
// create plane for process
BpmnPlane processPlane = modelInstance.newInstance(BpmnPlane.class);
processPlane.setId("plane");
processPlane.setBpmnElement(process);
bpmnDiagram.setBpmnPlane(processPlane);
// create shape for start event
BpmnShape startEventShape = modelInstance.newInstance(BpmnShape.class);
startEventShape.setId("startShape");
startEventShape.setBpmnElement(startEvent);
processPlane.getDiagramElements().add(startEventShape);
// create bounds for start event shape
Bounds startEventBounds = modelInstance.newInstance(Bounds.class);
startEventBounds.setHeight(36.0);
startEventBounds.setWidth(36.0);
startEventBounds.setX(632.0);
startEventBounds.setY(312.0);
startEventShape.setBounds(startEventBounds);
// create shape for end event
BpmnShape endEventShape = modelInstance.newInstance(BpmnShape.class);
endEventShape.setId("endShape");
endEventShape.setBpmnElement(endEvent);
processPlane.getDiagramElements().add(endEventShape);
// create bounds for end event shape
Bounds endEventBounds = modelInstance.newInstance(Bounds.class);
endEventBounds.setHeight(36.0);
endEventBounds.setWidth(36.0);
endEventBounds.setX(718.0);
endEventBounds.setY(312.0);
endEventShape.setBounds(endEventBounds);
// create edge for sequence flow
BpmnEdge flowEdge = modelInstance.newInstance(BpmnEdge.class);
flowEdge.setId("flowEdge");
flowEdge.setBpmnElement(sequenceFlow);
flowEdge.setSourceElement(startEventShape);
flowEdge.setTargetElement(endEventShape);
processPlane.getDiagramElements().add(flowEdge);
// create waypoints for sequence flow edge
Waypoint startWaypoint = modelInstance.newInstance(Waypoint.class);
startWaypoint.setX(668.0);
startWaypoint.setY(330.0);
flowEdge.getWaypoints().add(startWaypoint);
Waypoint endWaypoint = modelInstance.newInstance(Waypoint.class);
endWaypoint.setX(718.0);
endWaypoint.setY(330.0);
flowEdge.getWaypoints().add(endWaypoint);
}
use of org.camunda.bpm.model.bpmn.instance.dc.Bounds in project camunda-bpmn-model by camunda.
the class CoordinatesGenerationTest method shouldPlaceBusinessRuleTask.
@Test
public void shouldPlaceBusinessRuleTask() {
ProcessBuilder builder = Bpmn.createExecutableProcess();
instance = builder.startEvent(START_EVENT_ID).sequenceFlowId(SEQUENCE_FLOW_ID).businessRuleTask(TASK_ID).done();
Bounds businessRuleTaskBounds = findBpmnShape(TASK_ID).getBounds();
assertShapeCoordinates(businessRuleTaskBounds, 186, 78);
Collection<Waypoint> sequenceFlowWaypoints = findBpmnEdge(SEQUENCE_FLOW_ID).getWaypoints();
Iterator<Waypoint> iterator = sequenceFlowWaypoints.iterator();
Waypoint waypoint = iterator.next();
assertWaypointCoordinates(waypoint, 136, 118);
while (iterator.hasNext()) {
waypoint = iterator.next();
}
assertWaypointCoordinates(waypoint, 186, 118);
}
Aggregations