Skip to content

Commit

Permalink
fixed wrong computation of drop point
Browse files Browse the repository at this point in the history
and skip invalid participant elements in gmodel

Issue #298
  • Loading branch information
rsoika committed Sep 28, 2023
1 parent 3b0bf21 commit c3578e5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ public GGraph buildGGraph(final BPMNModel model) {
if (model.isCollaborationDiagram()) {
Set<Participant> participants = model.getParticipants();
for (Participant participant : participants) {
if (participant.getProcessRef().isEmpty() && !"Public".equals(participant.getType())) {
// in case the participant does not refer to a process then we skip this element
continue;
}
logger.debug(
"participant: " + participant.getName() + " BPMNProcess=" + participant.getProcessRef());
BPMNProcess bpmnProcess = model.openProcess(participant.getProcessRef());
Expand Down Expand Up @@ -262,6 +266,7 @@ public GGraph buildGGraph(final BPMNModel model) {
poolGNodeList.put(participant.getId(), pool);
} else {
// add default process without a pool
// here it is important to verify if the participant refers this process!
gRootNodeList.addAll(computeGModelElements(bpmnProcess, null, gRootNodeList));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,13 @@ private void executeOperation(PasteOperation operation) {
* position according to the mouse position.
*/
private BPMNPoint computeRefPoint(List<String> ids) {
double x = 0;
double y = 0;

if (ids == null || ids.size() == 0) {
// no list provided
return new BPMNPoint(0, 0);
}
BPMNPoint result = null;

for (String id : ids) {
// find the BPMNNode
BPMNElement bpmnElement = modelState.getBpmnModel().findElementById(id);
Expand All @@ -192,22 +197,24 @@ private BPMNPoint computeRefPoint(List<String> ids) {
BPMNElementNode bpmnElementNode = (BPMNElementNode) bpmnElement;
// compute most upper left ref position...
BPMNPoint _point = bpmnElementNode.getBounds().getPosition();
if (_point.getX() > 0) {
if ((x > 0 && _point.getX() < x) || x == 0) {
x = _point.getX();
// The first element in the list is the default result
if (result == null) {
result = new BPMNPoint(_point.getX(), _point.getY());
} else {
// test if the current point is outside of our best guest....
if (_point.getX() < result.getX()) {
result.setX(_point.getX());
}
}
if (_point.getY() > 0) {
if ((y > 0 && _point.getY() < y) || y == 0) {
y = _point.getY();
if (_point.getY() < result.getY()) {
result.setY(_point.getY());
}
logger.debug("... x=" + result.getX() + " y=" + result.getY());
}
logger.debug("... x=" + x + " y=" + y);
} catch (BPMNModelException e) {
e.printStackTrace();
}
}
}
return new BPMNPoint(x, y);
return result;
}
}

0 comments on commit c3578e5

Please sign in to comment.