Search in sources :

Example 11 with BpmnShape

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);
}
Also used : BpmnShape(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape) ProcessBuilder(org.camunda.bpm.model.bpmn.builder.ProcessBuilder) Test(org.junit.Test)

Example 12 with BpmnShape

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);
}
Also used : BpmnShape(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape) ProcessBuilder(org.camunda.bpm.model.bpmn.builder.ProcessBuilder) Test(org.junit.Test)

Example 13 with BpmnShape

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());
}
Also used : BpmnShape(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape) ProcessBuilder(org.camunda.bpm.model.bpmn.builder.ProcessBuilder) Test(org.junit.Test)

Example 14 with BpmnShape

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);
    }
}
Also used : BpmnShape(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape) Bounds(org.camunda.bpm.model.bpmn.instance.dc.Bounds) Waypoint(org.camunda.bpm.model.bpmn.instance.di.Waypoint)

Example 15 with BpmnShape

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;
        }
    }
}
Also used : BpmnShape(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) Bounds(org.camunda.bpm.model.bpmn.instance.dc.Bounds)

Aggregations

BpmnShape (org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape)46 ProcessBuilder (org.camunda.bpm.model.bpmn.builder.ProcessBuilder)21 Test (org.junit.Test)21 Bounds (org.camunda.bpm.model.bpmn.instance.dc.Bounds)12 SubProcess (org.camunda.bpm.model.bpmn.instance.SubProcess)4 StartEvent (org.camunda.bpm.model.bpmn.instance.StartEvent)3 BoundaryEvent (org.camunda.bpm.model.bpmn.instance.BoundaryEvent)2 Waypoint (org.camunda.bpm.model.bpmn.instance.di.Waypoint)2 ModelElementInstance (org.camunda.bpm.model.xml.instance.ModelElementInstance)2 ArrayList (java.util.ArrayList)1 BpmnPlane (org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnPlane)1 LabeledShape (org.camunda.bpm.model.bpmn.instance.di.LabeledShape)1 ModelTypeInstanceContext (org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)1 ModelElementTypeBuilder (org.camunda.bpm.model.xml.type.ModelElementTypeBuilder)1 SequenceBuilder (org.camunda.bpm.model.xml.type.child.SequenceBuilder)1