diff --git a/src/main/java/nl/andrewlalis/erme/control/actions/AutoPositionAction.java b/src/main/java/nl/andrewlalis/erme/control/actions/AutoPositionAction.java index ec3d2fe..ae1e378 100644 --- a/src/main/java/nl/andrewlalis/erme/control/actions/AutoPositionAction.java +++ b/src/main/java/nl/andrewlalis/erme/control/actions/AutoPositionAction.java @@ -78,11 +78,15 @@ public class AutoPositionAction extends AbstractAction { */ private void positionRelations(ArrayList orderList) { if (orderList.isEmpty()) return; - - int vertSpace = (int) orderList.get(0).getViewModel().getBounds(diagramPanel.getGraphics2D()).getHeight() + PADDING; + AtomicInteger vertSpace = new AtomicInteger(0); + orderList.forEach(r -> { + int height = (int) r.getViewModel().getBounds(diagramPanel.getGraphics2D()).getHeight(); + vertSpace.set(Math.max(vertSpace.get(), height)); + }); + vertSpace.addAndGet(PADDING); AtomicInteger vertPos = new AtomicInteger(MARGIN); orderList.forEach(r -> { - r.setPosition(new Point(MARGIN, vertPos.getAndAdd(vertSpace))); + r.setPosition(new Point(MARGIN, vertPos.getAndAdd(vertSpace.get()))); }); diagramPanel.centerModel();