From 842f4c621e2eeffc39cc297ed5731a079140bd00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Wed, 18 Aug 2021 15:39:27 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-57238=20=E8=A7=A3=E5=86=B3=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E9=97=B4=E8=B7=9D=E8=AE=A1=E7=AE=97=E4=B8=8D=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/MultiSelectionArrangement.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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 b9eb18f75..54298e186 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() {