-
after a long while I am back with a new question ;-) One eternally open issue in our project open-bpmn is the routing. For all edge we are using the Manhattan Routing style public class BPMNGEdgeBuilder extends AbstractGEdgeBuilder<BPMNGEdge, BPMNGEdgeBuilder> {
....
@Override
protected void setProperties(final BPMNGEdge edge) {
edge.setRouterKind(GConstants.RouterKind.MANHATTAN);
...}
...
} And we have implemented a custom routing-view on the client side to show rounded corners. The server part is written in Java - GLSP Version 2.0.0 and the client code is based on GLSP Version 2.1.0. In many situations the default routing from the Manhattan router (or routing in general) is not very helpful and makes a diagram often more worse as before. So users waste a lot of time fumbling edges back into a reasonable position in a BPMN diagram. My question here is: What is the best approach to implement a custom routing? I would like to compute the routing way-points myself based on the knowledge about the element types and diagram size. For example if an edge-routing was placed manually around a lot of other elements, moving the source or target element should not destroy/reset the existing waypoints. I would like to tweak the waypoints just a little bit. How should I start implementing such a custom router? Java is what I prefer. But if not possible I go the stony way with JavaScript either. === |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Playing around with the Issue I came across an older problem. I have implemented the following public class BPMNChangeRoutingPointsOperationHandler extends GModelOperationHandler<ChangeRoutingPointsOperation> {
private static Logger logger = Logger.getLogger(BPMNChangeRoutingPointsOperationHandler.class.getName());
@Inject
protected BPMNGModelState modelState;
@Override
public Optional<Command> createCommand(ChangeRoutingPointsOperation operation) {
return commandOf(() -> executeOperation(operation));
}
private void executeOperation(final ChangeRoutingPointsOperation operation) {
List<ElementAndRoutingPoints> routingPoints = operation.getNewRoutingPoints();
logger.fine("=== ChangeRoutingPointsOperation - " + routingPoints.size() + " routing points");
try {
for (ElementAndRoutingPoints routingPoint : routingPoints) {
String id = routingPoint.getElementId();
List<GPoint> newGLSPRoutingPoints = routingPoint.getNewRoutingPoints();
// update the GModel.
GEdge edge = (GEdge) modelState.getIndex().get(id).orElse(null);
if (edge != null) {
logger.fine("===== Updating GLSP RoutingPoints =======");
edge.getRoutingPoints().clear();
edge.getRoutingPoints().addAll(newGLSPRoutingPoints);
}
}
} catch (Exception e) {
e.printStackTrace();
}
// no more action - the GModel is now up to date
}
} This code was needed to store the waypoints in my BPMN diagram file. (very strange). But the problem for my project is again - I can't save the routing points in my diagram :-/ At the end it seems like a simple question to be solved? Maybe this was all in the stage between GLSP v1 and GLSP v2 - and maybe (I hope) my old problem can be today solved easily? |
Beta Was this translation helpful? Give feedback.
-
It turned out that the problem was a BPMN-specific one. In the end, the solution was simply that the BPMN way points have to be updated already in the Only this combination does the correct update of the GModel and the BPMN model. I don't know if this monologue will help anyone - but maybe one day.... ;-) |
Beta Was this translation helpful? Give feedback.
It turned out that the problem was a BPMN-specific one.
It's a nasty combination of the two action events
ChangeRoutingPointsOperation
andComputedBoundsAction
. In BPMN, both events are necessary to compute the start and end points correctly (in BPMN, these are the anchor points on the element itself, which are not included in the routing point list of GLSP). And this was the root of the problem.In the end, the solution was simply that the BPMN way points have to be updated already in the
ChangeRoutingPointsOperation
and later once again in theComputedBoundsAction
(to add the missing BPMN start/end waypoints.Only this combination does the correct update of the GModel and the BPMN model.