Search in sources :

Example 1 with BpmnShape

use of org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape in project camunda-bpmn-model by camunda.

the class AbstractActivityBuilder method calculateXCoordinate.

protected double calculateXCoordinate(Bounds boundaryEventBounds) {
    BpmnShape attachedToElement = findBpmnShape(element);
    double x = 0;
    if (attachedToElement != null) {
        Bounds attachedToBounds = attachedToElement.getBounds();
        Collection<BoundaryEvent> boundaryEvents = element.getParentElement().getChildElementsByType(BoundaryEvent.class);
        Collection<BoundaryEvent> attachedBoundaryEvents = new ArrayList<BoundaryEvent>();
        Iterator<BoundaryEvent> iterator = boundaryEvents.iterator();
        while (iterator.hasNext()) {
            BoundaryEvent tmp = iterator.next();
            if (tmp.getAttachedTo().equals(element)) {
                attachedBoundaryEvents.add(tmp);
            }
        }
        double attachedToX = attachedToBounds.getX();
        double attachedToWidth = attachedToBounds.getWidth();
        double boundaryWidth = boundaryEventBounds.getWidth();
        switch(attachedBoundaryEvents.size()) {
            case 2:
                {
                    x = attachedToX + attachedToWidth / 2 + boundaryWidth / 2;
                    break;
                }
            case 3:
                {
                    x = attachedToX + attachedToWidth / 2 - 1.5 * boundaryWidth;
                    break;
                }
            default:
                {
                    x = attachedToX + attachedToWidth / 2 - boundaryWidth / 2;
                    break;
                }
        }
    }
    return x;
}
Also used : BpmnShape(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape) BoundaryEvent(org.camunda.bpm.model.bpmn.instance.BoundaryEvent) Bounds(org.camunda.bpm.model.bpmn.instance.dc.Bounds) ArrayList(java.util.ArrayList)

Example 2 with BpmnShape

use of org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape in project camunda-bpmn-model by camunda.

the class AbstractActivityBuilder method boundaryEvent.

public BoundaryEventBuilder boundaryEvent(String id) {
    BoundaryEvent boundaryEvent = createSibling(BoundaryEvent.class, id);
    boundaryEvent.setAttachedTo(element);
    BpmnShape boundaryEventBpmnShape = createBpmnShape(boundaryEvent);
    setBoundaryEventCoordinates(boundaryEventBpmnShape);
    return boundaryEvent.builder();
}
Also used : BoundaryEvent(org.camunda.bpm.model.bpmn.instance.BoundaryEvent) BpmnShape(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape)

Example 3 with BpmnShape

use of org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape in project camunda-bpmn-model by camunda.

the class BpmnShapeImpl method registerType.

public static void registerType(ModelBuilder modelBuilder) {
    ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(BpmnShape.class, BPMNDI_ELEMENT_BPMN_SHAPE).namespaceUri(BPMNDI_NS).extendsType(LabeledShape.class).instanceProvider(new ModelTypeInstanceProvider<BpmnShape>() {

        public BpmnShape newInstance(ModelTypeInstanceContext instanceContext) {
            return new BpmnShapeImpl(instanceContext);
        }
    });
    bpmnElementAttribute = typeBuilder.stringAttribute(BPMNDI_ATTRIBUTE_BPMN_ELEMENT).qNameAttributeReference(BaseElement.class).build();
    isHorizontalAttribute = typeBuilder.booleanAttribute(BPMNDI_ATTRIBUTE_IS_HORIZONTAL).build();
    isExpandedAttribute = typeBuilder.booleanAttribute(BPMNDI_ATTRIBUTE_IS_EXPANDED).build();
    isMarkerVisibleAttribute = typeBuilder.booleanAttribute(BPMNDI_ATTRIBUTE_IS_MARKER_VISIBLE).build();
    isMessageVisibleAttribute = typeBuilder.booleanAttribute(BPMNDI_ATTRIBUTE_IS_MESSAGE_VISIBLE).build();
    participantBandKindAttribute = typeBuilder.enumAttribute(BPMNDI_ATTRIBUTE_PARTICIPANT_BAND_KIND, ParticipantBandKind.class).build();
    choreographyActivityShapeAttribute = typeBuilder.stringAttribute(BPMNDI_ATTRIBUTE_CHOREOGRAPHY_ACTIVITY_SHAPE).qNameAttributeReference(BpmnShape.class).build();
    SequenceBuilder sequenceBuilder = typeBuilder.sequence();
    bpmnLabelChild = sequenceBuilder.element(BpmnLabel.class).build();
    typeBuilder.build();
}
Also used : LabeledShape(org.camunda.bpm.model.bpmn.instance.di.LabeledShape) BpmnShape(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape) SequenceBuilder(org.camunda.bpm.model.xml.type.child.SequenceBuilder) ModelElementTypeBuilder(org.camunda.bpm.model.xml.type.ModelElementTypeBuilder) ModelTypeInstanceContext(org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)

Example 4 with BpmnShape

use of org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape in project camunda-bpmn-model by camunda.

the class DiGeneratorForFlowNodesTest method shouldGenerateShapeForEndEvent.

@Test
public void shouldGenerateShapeForEndEvent() {
    // 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(END_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 5 with BpmnShape

use of org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape in project camunda-bpmn-model by camunda.

the class DiGeneratorForFlowNodesTest method shouldGenerateShapeForBusinessRuleTask.

@Test
public void shouldGenerateShapeForBusinessRuleTask() {
    // given
    ProcessBuilder processBuilder = Bpmn.createExecutableProcess();
    // when
    instance = processBuilder.startEvent(START_EVENT_ID).businessRuleTask(TASK_ID).done();
    // then
    Collection<BpmnShape> allShapes = instance.getModelElementsByType(BpmnShape.class);
    assertEquals(2, allShapes.size());
    assertTaskShapeProperties(TASK_ID);
}
Also used : BpmnShape(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape) ProcessBuilder(org.camunda.bpm.model.bpmn.builder.ProcessBuilder) Test(org.junit.Test)

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