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;
}
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();
}
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();
}
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);
}
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);
}
Aggregations