Skip to content

Commit d95b265

Browse files
committed
fixed autoLayout method (Issue #388)
1 parent c73c598 commit d95b265

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

open-bpmn.glsp-server/src/main/java/org/openbpmn/glsp/model/BPMNGModelFactory.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,7 @@ List<GModelElement> computeGModelElements(final BPMNProcess process, final Parti
704704
private void autoLayout(List<GModelElement> nodelist) {
705705
boolean samePos = true;
706706
GPoint lastPoint = null;
707+
int gnodeCount = 0;
707708
for (GModelElement gElement : nodelist) {
708709
if (gElement instanceof BPMNGNode) {
709710
BPMNGNode gn = (BPMNGNode) gElement;
@@ -714,6 +715,7 @@ private void autoLayout(List<GModelElement> nodelist) {
714715
if (gn instanceof LabelGNode) {
715716
continue;
716717
}
718+
gnodeCount++;
717719
if (lastPoint.getX() != position.getX()
718720
|| lastPoint.getY() != position.getY()) {
719721
samePos = false;
@@ -722,14 +724,16 @@ private void autoLayout(List<GModelElement> nodelist) {
722724
}
723725
}
724726
}
725-
if (samePos) {
727+
// See issue #388 and #386
728+
// Maybe we need another strategy here and recompute the source model instead of
729+
// the GModel....?
730+
if (samePos && gnodeCount > 1) {
726731
// all elements seem to have the same position!
727732
// start auto layout
728733
long xPos = 0;
729734
for (GModelElement gElement : nodelist) {
730735
if (gElement instanceof BPMNGNode) {
731736
BPMNGNode gn = (BPMNGNode) gElement;
732-
733737
gn.getPosition().setX(xPos);
734738
if (gn instanceof LabelGNode) {
735739
// ignore x offset for labels

0 commit comments

Comments
 (0)