FluentAPI Gateway Waypoints Issue

Hi @edobm,

I love hearing stories from academia. Thanks for sharing this!

As to your question, I assume that you are using the Java API (and not BPMN.io).
The in-build layouting is not very sophisticated, as you have observed yourself. In this particular example, the block-structured model makes it easy to improve the layout:

  1. find all gateways with more than one incoming sequence flow
  2. find all respective sequence flows
  3. add waypoints:
    1. Waypoint: right mid-point of source. If source and target are not horizontally aligned, add
    2. Waypoint: horizontally aligned with first source, vertically aligned with target.
    3. Waypoint: bottom mid-point of target

Note, calculating and adding these waypoints is not possible in the fluent API. I’d add a post-processing step instead.
The following snippet may aid as a starting point:


      List<SequenceFlow> sequenceFlows = (List<SequenceFlow>) model.getModelElementsByType(SequenceFlow.class);
      for (SequenceFlow sf : sequenceFlows) {
        if (!(sf.getTarget() instanceof Gateway)) {
          continue;
        }
        ...
        Waypoint wp = model.newInstance(Waypoint.class);
        wp.setX(...);
        wp.setY(...);
        sf.getDiagramElement().getWaypoints().add(wp);
      }