fixed an issue where the spacing was decided by the first element and not the (vertically) largest

This commit is contained in:
Bjorn Pijnacker 2021-02-27 09:30:21 +01:00
parent 521ee92c0a
commit d238c521ea
No known key found for this signature in database
GPG Key ID: 68CC60CD9AC50D72
1 changed files with 7 additions and 3 deletions

View File

@ -78,11 +78,15 @@ public class AutoPositionAction extends AbstractAction {
*/
private void positionRelations(ArrayList<Relation> 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();