use of org.camunda.bpm.model.bpmn.instance.dc.Bounds in project camunda-bpmn-model by camunda.
the class CoordinatesGenerationTest method shouldPlaceManyBranchesForInclusiveGateway.
@Test
public void shouldPlaceManyBranchesForInclusiveGateway() {
ProcessBuilder builder = Bpmn.createExecutableProcess();
instance = builder.startEvent(START_EVENT_ID).inclusiveGateway("id").userTask(USER_TASK_ID).moveToNode("id").endEvent(END_EVENT_ID).moveToNode("id").serviceTask(SERVICE_TASK_ID).moveToNode("id").sequenceFlowId("s1").sendTask(SEND_TASK_ID).done();
Bounds userTaskBounds = findBpmnShape(USER_TASK_ID).getBounds();
assertShapeCoordinates(userTaskBounds, 286, 78);
Bounds endEventBounds = findBpmnShape(END_EVENT_ID).getBounds();
assertShapeCoordinates(endEventBounds, 286, 208);
Bounds serviceTaskBounds = findBpmnShape(SERVICE_TASK_ID).getBounds();
assertShapeCoordinates(serviceTaskBounds, 286, 294);
Bounds sendTaskBounds = findBpmnShape(SEND_TASK_ID).getBounds();
assertShapeCoordinates(sendTaskBounds, 286, 424);
Collection<Waypoint> sequenceFlowWaypoints = findBpmnEdge("s1").getWaypoints();
Iterator<Waypoint> iterator = sequenceFlowWaypoints.iterator();
Waypoint waypoint = iterator.next();
assertWaypointCoordinates(waypoint, 211, 143);
while (iterator.hasNext()) {
waypoint = iterator.next();
}
assertWaypointCoordinates(waypoint, 286, 464);
}
use of org.camunda.bpm.model.bpmn.instance.dc.Bounds 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.dc.Bounds 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.dc.Bounds 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)
}
use of org.camunda.bpm.model.bpmn.instance.dc.Bounds in project camunda-bpmn-model by camunda.
the class CoordinatesGenerationTest method shouldPlaceFollowingFlowNodeProperlyForTask.
@Test
public void shouldPlaceFollowingFlowNodeProperlyForTask() {
ProcessBuilder builder = Bpmn.createExecutableProcess();
instance = builder.startEvent(START_EVENT_ID).userTask(USER_TASK_ID).boundaryEvent("boundary").sequenceFlowId(SEQUENCE_FLOW_ID).endEvent(END_EVENT_ID).moveToActivity(USER_TASK_ID).endEvent().done();
Bounds endEventBounds = findBpmnShape(END_EVENT_ID).getBounds();
assertShapeCoordinates(endEventBounds, 266.5, 208);
Collection<Waypoint> sequenceFlowWaypoints = findBpmnEdge(SEQUENCE_FLOW_ID).getWaypoints();
Iterator<Waypoint> iterator = sequenceFlowWaypoints.iterator();
Waypoint waypoint = iterator.next();
assertWaypointCoordinates(waypoint, 236, 176);
while (iterator.hasNext()) {
waypoint = iterator.next();
}
assertWaypointCoordinates(waypoint, 266.5, 226);
}
Aggregations