Skip to content

Commit

Permalink
fixed lane divider computation
Browse files Browse the repository at this point in the history
Issue #329
  • Loading branch information
rsoika committed Mar 27, 2024
1 parent 3ff379c commit 6f809c2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ public int compare(Lane obj1, Lane obj2) {
double laneYPos = currentLane.getBounds().getPosition().getY() - poolYPos;
double laneHeight = currentLane.getBounds().getDimension().getHeight();
double laneDividerYPos = laneYPos + laneHeight - 1;
double laneMinYPos = laneDividerYPos - laneHeight + Lane.MIN_HEIGHT;
double laneMinYPos = laneDividerYPos - laneHeight + Lane.MIN_HEIGHT + 1;
double laneMaxYPos = laneDividerYPos + nextLane.getBounds().getDimension().getHeight()
- Lane.MIN_HEIGHT;
- Lane.MIN_HEIGHT + 1;
pool.getChildren()
.add(BPMNGModelUtil.createLaneDivider(participant, laneDividerYPos,
laneMinYPos,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ private void updateLaneSizeByDividerPos(GNode gNode, double offsetY) throws BPMN
String upperLaneID = gNode.getArgs().get("upperlaneid").toString();
String lowerLaneID = gNode.getArgs().get("lowerlaneid").toString();

logger.debug("--- Update Lane ---");
logger.debug("--- offsetY=" + offsetY);
logger.debug("--- gNodeID=" + gNode.getId());

// Upper Lane
GNode upperGLane = (GNode) modelState.getIndex().get(upperLaneID)
.orElse(null);
Expand All @@ -207,43 +211,38 @@ private void updateLaneSizeByDividerPos(GNode gNode, double offsetY) throws BPMN
throw new BPMNMissingElementException(BPMNMissingElementException.MISSING_ELEMENT,
"Lane " + upperLaneID + " not found in model!");
}

String poolID = upperGLane.getParent().getId();
participant = modelState.getBpmnModel().findParticipantById(poolID);

// Lane currentLane = participant.openProcess().findLaneById(gNode.getId());
// double myY = currentLane.getBounds().getPosition().getY();

upperBpmnLane = participant.openProcess().findLaneById(upperLaneID);
lowerBpmnLane = participant.openProcess().findLaneById(lowerLaneID);

logger.debug("--- " + poolID + " y=" + participant.getBounds().getPosition().getY());

// test if y-offset between min/max y range?
double yMin = Double.parseDouble(gNode.getArgs().get("ymin").toString());
double yMax = Double.parseDouble(gNode.getArgs().get("ymax").toString());

logger.info("-------------------");

logger.info(" upperLane - y=" + upperBpmnLane.getBounds().getPosition().getY() + " h="
logger.debug("--- divider ymin=" + yMin);
logger.debug("--- divider ymax=" + yMax);
logger.debug("--- upperLane - y=" + upperBpmnLane.getBounds().getPosition().getY() + " h="
+ upperBpmnLane.getBounds().getDimension().getHeight());

logger.info(" lowerBpmnLane - y=" + lowerBpmnLane.getBounds().getPosition().getY() + " h="
logger.debug("--- lowerBpmnLane - y=" + lowerBpmnLane.getBounds().getPosition().getY() + " h="
+ lowerBpmnLane.getBounds().getDimension().getHeight());
logger.info(" yMin = " + yMin + " yMax=" + yMax);

logger.info(" OffsetY = " + offsetY);
// Compute new lane dimensions....

if (upperBpmnLane.getBounds().getDimension().getHeight()
+ offsetY < lowerBpmnLane.getBounds().getPosition().getY() + yMin) {
logger.info("zu klein ");
offsetY = -(upperBpmnLane.getBounds().getDimension().getHeight() - yMin);
} else if (lowerBpmnLane.getBounds().getPosition().getY() + offsetY > yMax) {
logger.info("zu groß");
offsetY = yMax - lowerBpmnLane.getBounds().getPosition().getY();
if (upperBpmnLane.getBounds().getDimension().getHeight() + offsetY < Lane.MIN_HEIGHT) {
logger.debug("to small ");
offsetY = -(upperBpmnLane.getBounds().getDimension().getHeight() - Lane.MIN_HEIGHT);
} else if (lowerBpmnLane.getBounds().getDimension().getHeight() - offsetY < Lane.MIN_HEIGHT) {
logger.debug("to big");
offsetY = lowerBpmnLane.getBounds().getDimension().getHeight() - Lane.MIN_HEIGHT;
}
logger.debug("--- Final Offset = " + offsetY);

// recompute lane sizes....
// // recompute lane sizes....
upperBpmnLane.setDimension(upperBpmnLane.getBounds().getDimension().getWidth(),
upperBpmnLane.getBounds().getDimension().getHeight() + offsetY);

lowerBpmnLane.setPosition(lowerBpmnLane.getBounds().getPosition().getX(),
lowerBpmnLane.getBounds().getPosition().getY() + offsetY);
lowerBpmnLane.setDimension(lowerBpmnLane.getBounds().getDimension().getWidth(),
Expand Down

0 comments on commit 6f809c2

Please sign in to comment.