use of org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape in project camunda-bpmn-model by camunda.
the class DiGeneratorForFlowNodesTest method shouldGenerateShapeForCatchingIntermediateEvent.
@Test
public void shouldGenerateShapeForCatchingIntermediateEvent() {
// given
ProcessBuilder processBuilder = Bpmn.createExecutableProcess();
// when
instance = processBuilder.startEvent(START_EVENT_ID).intermediateCatchEvent(CATCH_ID).endEvent(END_EVENT_ID).done();
// then
Collection<BpmnShape> allShapes = instance.getModelElementsByType(BpmnShape.class);
assertEquals(3, allShapes.size());
assertEventShapeProperties(CATCH_ID);
}
use of org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape in project camunda-bpmn-model by camunda.
the class DiGeneratorForFlowNodesTest method shouldGenerateShapeForStartEvent.
@Test
public void shouldGenerateShapeForStartEvent() {
// given
ProcessBuilder processBuilder = Bpmn.createExecutableProcess();
// when
instance = processBuilder.startEvent(START_EVENT_ID).endEvent(END_EVENT_ID).done();
// then
Collection<BpmnShape> allShapes = instance.getModelElementsByType(BpmnShape.class);
assertEquals(2, allShapes.size());
assertEventShapeProperties(START_EVENT_ID);
}
use of org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape in project camunda-bpmn-model by camunda.
the class DiGeneratorForFlowNodesTest method shouldGenerateShapesForNestedFlowNodes.
@Test
public void shouldGenerateShapesForNestedFlowNodes() {
// given
ProcessBuilder processBuilder = Bpmn.createExecutableProcess();
// when
instance = processBuilder.startEvent(START_EVENT_ID).subProcess(SUB_PROCESS_ID).embeddedSubProcess().startEvent("innerStartEvent").userTask("innerUserTask").endEvent("innerEndEvent").subProcessDone().endEvent(END_EVENT_ID).done();
// then
Collection<BpmnShape> allShapes = instance.getModelElementsByType(BpmnShape.class);
assertEquals(6, allShapes.size());
assertEventShapeProperties("innerStartEvent");
assertTaskShapeProperties("innerUserTask");
assertEventShapeProperties("innerEndEvent");
BpmnShape bpmnShapeSubProcess = findBpmnShape(SUB_PROCESS_ID);
assertNotNull(bpmnShapeSubProcess);
assertTrue(bpmnShapeSubProcess.isExpanded());
}
use of org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape in project camunda-bpmn-model by camunda.
the class AbstractBaseElementBuilder method setWaypointsWithSourceAndTarget.
protected void setWaypointsWithSourceAndTarget(BpmnEdge edge, FlowNode edgeSource, FlowNode edgeTarget) {
BpmnShape source = findBpmnShape(edgeSource);
BpmnShape target = findBpmnShape(edgeTarget);
if (source != null && target != null) {
Bounds sourceBounds = source.getBounds();
Bounds targetBounds = target.getBounds();
double sourceX = sourceBounds.getX();
double sourceY = sourceBounds.getY();
double sourceWidth = sourceBounds.getWidth();
double sourceHeight = sourceBounds.getHeight();
double targetX = targetBounds.getX();
double targetY = targetBounds.getY();
double targetHeight = targetBounds.getHeight();
Waypoint w1 = createInstance(Waypoint.class);
if (edgeSource.getOutgoing().size() == 1) {
w1.setX(sourceX + sourceWidth);
w1.setY(sourceY + sourceHeight / 2);
edge.addChildElement(w1);
} else {
w1.setX(sourceX + sourceWidth / 2);
w1.setY(sourceY + sourceHeight);
edge.addChildElement(w1);
Waypoint w2 = createInstance(Waypoint.class);
w2.setX(sourceX + sourceWidth / 2);
w2.setY(targetY + targetHeight / 2);
edge.addChildElement(w2);
}
Waypoint w3 = createInstance(Waypoint.class);
w3.setX(targetX);
w3.setY(targetY + targetHeight / 2);
edge.addChildElement(w3);
}
}
use of org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape in project camunda-bpmn-model by camunda.
the class AbstractBaseElementBuilder method resizeSubProcess.
protected void resizeSubProcess(BpmnShape innerShape) {
BaseElement innerElement = innerShape.getBpmnElement();
Bounds innerShapeBounds = innerShape.getBounds();
ModelElementInstance parent = innerElement.getParentElement();
while (parent instanceof SubProcess) {
BpmnShape subProcessShape = findBpmnShape((SubProcess) parent);
if (subProcessShape != null) {
Bounds subProcessBounds = subProcessShape.getBounds();
double innerX = innerShapeBounds.getX();
double innerWidth = innerShapeBounds.getWidth();
double innerY = innerShapeBounds.getY();
double innerHeight = innerShapeBounds.getHeight();
double subProcessY = subProcessBounds.getY();
double subProcessHeight = subProcessBounds.getHeight();
double subProcessX = subProcessBounds.getX();
double subProcessWidth = subProcessBounds.getWidth();
double tmpWidth = innerX + innerWidth + SPACE;
double tmpHeight = innerY + innerHeight + SPACE;
if (innerY == subProcessY) {
subProcessBounds.setY(subProcessY - SPACE);
subProcessBounds.setHeight(subProcessHeight + SPACE);
}
if (tmpWidth >= subProcessX + subProcessWidth) {
double newWidth = tmpWidth - subProcessX;
subProcessBounds.setWidth(newWidth);
}
if (tmpHeight >= subProcessY + subProcessHeight) {
double newHeight = tmpHeight - subProcessY;
subProcessBounds.setHeight(newHeight);
}
innerElement = (SubProcess) parent;
innerShapeBounds = subProcessBounds;
parent = innerElement.getParentElement();
} else {
break;
}
}
}
Aggregations