Skip to content

Commit

Permalink
impl, refactoring
Browse files Browse the repository at this point in the history
Issue imixs#208
  • Loading branch information
rsoika committed Mar 11, 2023
1 parent 13fa9b5 commit bebd12b
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,13 @@ private void updatePool(final GNode gNode, final BPMNElementNode bpmnElementNode

BPMNBounds bpmnBounds = bpmnElementNode.getBounds();
// update BPMNElement bounds....
if (bpmnBounds != null) {
bpmnBounds.setPosition(bpmnBounds.getPosition().getX() + offsetX,
bpmnBounds.getPosition().getY() + offsetY);
bpmnBounds.setDimension(newSize.getWidth(), newSize.getHeight());
}
// The BPMN Position is always absolute so we can simply update the element
// bounds by the new offset and new dimensions.
// @see https://github.com/imixs/open-bpmn/issues/208
bpmnElementNode.setBounds(bpmnBounds.getPosition().getX() + offsetX,
bpmnBounds.getPosition().getY() + offsetY, newSize.getWidth(),
newSize.getHeight());

// if we have a Participant element selected than we also need to update
// all embedded FlowElements and also the LaneSet if available.
Participant participant = modelState.getBpmnModel().findParticipantById(id);
Expand Down Expand Up @@ -410,14 +412,14 @@ private void updateLaneSet(final Participant participant, final double offsetWid
if (_node.isPresent()) {
gNode = _node.get();
}
if (bpmnLaneBounds == null || gNode == null) {
if (gNode == null) {
logger.warn("invalid LaneSet - model can not be synchronized!");
continue;
}

if (offsetWidth == 0 && offsetHeight == 0) {
// Update absolute BPMN position
bpmnLaneBounds.setPosition(bpmnLaneX, bpmnLaneY);
lane.setPosition(bpmnLaneX, bpmnLaneY);
// adjust laneY for the next iteration
bpmnLaneY = (int) (bpmnLaneY + bpmnLaneBounds.getDimension().getHeight());
// no further update needed
Expand All @@ -439,7 +441,7 @@ private void updateLaneSet(final Participant participant, final double offsetWid

logger.debug(" ===> Lane " + lane.getId() + " new Height = " + bpmnLaneBounds.getDimension().getHeight());

bpmnLaneBounds.setPosition(bpmnLaneX, bpmnLaneY);
lane.setPosition(bpmnLaneX, bpmnLaneY);
// adjust laneY for the next iteration
bpmnLaneY = (int) (bpmnLaneY + bpmnLaneBounds.getDimension().getHeight());

Expand Down Expand Up @@ -480,10 +482,9 @@ void updateEmbeddedElementNodes(final BPMNProcess process, final double offsetX,
logger.debug("update element bounds: " + flowElement.getId());
try {
BPMNBounds bounds = flowElement.getBounds();
if (bounds != null) {
bounds.setPosition(bounds.getPosition().getX() + offsetX, bounds.getPosition().getY() + offsetY);
}
// if the flowElemen has a BPMNLabel element we adjust position of the label too
flowElement.setPosition(bounds.getPosition().getX() + offsetX, bounds.getPosition().getY() + offsetY);
// if the flowElement has a BPMNLabel element we adjust position of the label
// too
BPMNLabel bpmnLabel = flowElement.getLabel();
if (bpmnLabel != null) {
bpmnLabel.updateLocation(bpmnLabel.getPosition().getX() + offsetX,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import org.openbpmn.bpmn.BPMNModel;
import org.openbpmn.bpmn.BPMNNS;
import org.openbpmn.bpmn.elements.core.BPMNBounds;
import org.openbpmn.bpmn.elements.core.BPMNElementNode;
import org.openbpmn.bpmn.exceptions.BPMNMissingElementException;
import org.openbpmn.bpmn.exceptions.BPMNModelException;
import org.w3c.dom.Element;

Expand Down Expand Up @@ -43,18 +41,20 @@ public double getDefaultHeight() {

/**
* Remove any embedded bpmndi:BPMNLabel element within the bpmndi:BPMNShape
*
* Positioning of the label is part of the client. Any position update should
* ignore these settings in Open-BPMN.
*
*/
@Override
public BPMNBounds setBounds(double x, double y, double width, double height) throws BPMNMissingElementException {

BPMNBounds result = super.setBounds(x, y, width, height);
public void setPosition(double x, double y) {
super.setPosition(x, y);

// remove optional BPMNLabel
Element bpmnLabel = getModel().findChildNodeByName(this.bpmnShape, BPMNNS.BPMNDI, "BPMNLabel");
if (bpmnLabel != null) {
this.bpmnShape.removeChild(bpmnLabel);
}
return result;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,21 @@ public double getDefaultHeight() {
return DEFAULT_HEIGHT;
}

/**
* Remove any embedded bpmndi:BPMNLabel element within the bpmndi:BPMNShape
*
* Positioning of the label is part of the client. Any position update should
* ignore these settings in Open-BPMN.
*
*/
@Override
public void setPosition(double x, double y) {
super.setPosition(x, y);
// remove optional BPMNLabel
Element bpmnLabel = getModel().findChildNodeByName(this.bpmnShape, BPMNNS.BPMNDI, "BPMNLabel");
if (bpmnLabel != null) {
this.bpmnShape.removeChild(bpmnLabel);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.openbpmn.bpmn.elements;

import org.openbpmn.bpmn.BPMNModel;
import org.openbpmn.bpmn.BPMNNS;
import org.openbpmn.bpmn.elements.core.BPMNElementNode;
import org.openbpmn.bpmn.elements.core.BPMNLabel;
import org.openbpmn.bpmn.exceptions.BPMNModelException;
Expand Down Expand Up @@ -92,4 +93,20 @@ public double getDefaultHeight() {
return DEFAULT_HEIGHT;
}

/**
* Remove any embedded bpmndi:BPMNLabel element within the bpmndi:BPMNShape
*
* Positioning of the label is part of the client. Any position update should
* ignore these settings in Open-BPMN.
*/
@Override
public void setPosition(double x, double y) {
super.setPosition(x, y);

// remove optional BPMNLabel
Element bpmnLabel = getModel().findChildNodeByName(this.bpmnShape, BPMNNS.BPMNDI, "BPMNLabel");
if (bpmnLabel != null) {
this.bpmnShape.removeChild(bpmnLabel);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ public BPMNBounds getBounds() throws BPMNMissingElementException {
return bounds;
}

/**
* Updates the BPMN Shape bounds.
*
* @param x
* @param y
* @param height
* @param width
* @return
* @throws BPMNMissingElementException
*/
public BPMNBounds setBounds(double x, double y, double width, double height) throws BPMNMissingElementException {
// update bounds
setDimension(width, height);
setPosition(x, y);
return bounds;
}

public void setPosition(double x, double y) {
try {
this.getBounds().setPosition(x, y);
Expand All @@ -102,27 +119,6 @@ public void setDimension(double width, double height) {
}
}

/**
* Updates the BPMN Shape bounds.
*
* @param x
* @param y
* @param height
* @param width
* @return
* @throws BPMNMissingElementException
*/
public BPMNBounds setBounds(double x, double y, double width, double height) throws BPMNMissingElementException {
// init bound if not yet loaded
getBounds();

// update bounds
bounds.setDimension(width, height);
bounds.setPosition(x, y);

return bounds;
}

/**
* Returns the BPMNShape element
*
Expand Down

0 comments on commit bebd12b

Please sign in to comment.