diff --git a/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java b/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java index b9eb18f753..54298e186d 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java @@ -69,6 +69,7 @@ public class MultiSelectionArrangement { // 水平分布,自动,间距由selectedCreators和border共同计算而来 public void horizontalAutoDistribution() { + sortHorizontal(); int gap = calculateHorizontalGap(); horizontalDistribution(gap); } @@ -80,7 +81,6 @@ public class MultiSelectionArrangement { } private void horizontalDistribution(int gap) { - sortHorizontal(); for (int i = 1; i < selectedCreators.size() - 1; i++) { XCreator creator = selectedCreators.get(i); XCreator preCreator = selectedCreators.get(i - 1); @@ -90,7 +90,6 @@ public class MultiSelectionArrangement { } private void reSizeRecByHorizontal(int gap) { - sortHorizontal(); int width = 0; for (XCreator creator : selectedCreators) { width += creator.getWidth(); @@ -138,10 +137,14 @@ public class MultiSelectionArrangement { for (XCreator creator : selectedCreators) { sum += creator.getWidth(); } - return (rec.width - sum) / (selectedCreators.size() - 1); + XCreator head = selectedCreators.get(0); + XCreator tail = selectedCreators.get(selectedCreators.size() - 1); + int distanceBetweenHeadAndTailCreators = Math.abs(head.getX() - tail.getX()) + tail.getWidth(); + return (distanceBetweenHeadAndTailCreators - sum) / (selectedCreators.size() - 1); } public void verticalAutoDistribution() { + sortVertical(); int gap = calculateVerticalGap(); verticalDistribution(gap); } @@ -152,7 +155,6 @@ public class MultiSelectionArrangement { } private void verticalDistribution(int gap) { - sortVertical(); for (int i = 1; i < selectedCreators.size() - 1; i++) { XCreator creator = selectedCreators.get(i); XCreator preCreator = selectedCreators.get(i - 1); @@ -162,7 +164,6 @@ public class MultiSelectionArrangement { } private void reSizeRecByVertical(int gap) { - sortVertical(); int height = 0; for (XCreator creator : selectedCreators) { height += creator.getHeight(); @@ -209,7 +210,10 @@ public class MultiSelectionArrangement { for (XCreator creator : selectedCreators) { sum += creator.getHeight(); } - return (rec.height - sum) / (selectedCreators.size() - 1); + XCreator head = selectedCreators.get(0); + XCreator tail = selectedCreators.get(selectedCreators.size() - 1); + int distanceBetweenHeadAndTailCreators = Math.abs(head.getY() - tail.getY()) + tail.getHeight(); + return (distanceBetweenHeadAndTailCreators - sum) / (selectedCreators.size() - 1); } private void update() {