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:
- find all gateways with more than one incoming sequence flow
- find all respective sequence flows
- add waypoints:
- Waypoint: right mid-point of source. If source and target are not horizontally aligned, add
- Waypoint: horizontally aligned with first source, vertically aligned with target.
- 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);
}