From ea2a93476e2fc297c30f8d5f000b4b26fd384e65 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 13:50:16 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-57326&EPORT-57324&REPORT-57330&REPORT-56?= =?UTF-8?q?895=20=E5=B8=83=E5=B1=80=E6=8E=A8=E8=8D=90=E8=8B=A5=E5=B9=B2?= =?UTF-8?q?=E9=97=B4=E8=B7=9D=E7=BA=BF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/FormSpacingLineDrawer.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java index f70df03c3..e2982f041 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe; import com.fr.design.designer.creator.XCreator; +import com.fr.design.utils.ComponentUtils; import com.fr.stable.Constants; import com.fr.stable.GraphDrawHelper; @@ -23,6 +24,7 @@ public class FormSpacingLineDrawer { private FormDesigner designer; private XCreator hoverCreator = null; private Rectangle selectedRec; + private Rectangle hoveredRec; private boolean isMouseMoveEvent = false; public FormSpacingLineDrawer(FormDesigner designer) { @@ -38,7 +40,6 @@ public class FormSpacingLineDrawer { } public void draw(Graphics g) { - this.selectedRec = designer.getSelectionModel().getSelection().getSelctionBounds(); if (!isDrawSpacingLine()) { return; } @@ -47,6 +48,9 @@ public class FormSpacingLineDrawer { return; } + this.selectedRec = designer.getSelectionModel().getSelection().getRelativeBounds(); + this.hoveredRec = ComponentUtils.getRelativeBounds(hoverCreator); + drawHorizontalSpacingLine(g); drawVerticalSpacingLine(g); } @@ -158,8 +162,8 @@ public class FormSpacingLineDrawer { }; AbstractFormParallelLine[] hoveredCreatorSides = new AbstractFormParallelLine[] { - new FormHorizontalParallelLine(hoverCreator.getY(), hoverCreator.getX(), hoverCreator.getX() + hoverCreator.getWidth()), - new FormHorizontalParallelLine(hoverCreator.getY() + hoverCreator.getHeight(), hoverCreator.getX(), hoverCreator.getX() + hoverCreator.getWidth()) + new FormHorizontalParallelLine(hoveredRec.y, hoveredRec.x, hoveredRec.x + hoveredRec.width), + new FormHorizontalParallelLine(hoveredRec.y + hoveredRec.height, hoveredRec.x, hoveredRec.x + hoveredRec.width) }; return getNearestSide(selectedRecSides, hoveredCreatorSides); } @@ -171,19 +175,20 @@ public class FormSpacingLineDrawer { }; AbstractFormParallelLine[] hoveredCreatorSides = new AbstractFormParallelLine[] { - new FormVerticalParallelLine(hoverCreator.getX(), hoverCreator.getY(), hoverCreator.getY() + hoverCreator.getHeight()), - new FormVerticalParallelLine(hoverCreator.getX() + hoverCreator.getWidth(), hoverCreator.getY(), hoverCreator.getY() + hoverCreator.getHeight()) + new FormVerticalParallelLine(hoveredRec.x, hoveredRec.y, hoveredRec.y + hoveredRec.height), + new FormVerticalParallelLine(hoveredRec.x + hoveredRec.width, hoveredRec.y, hoveredRec.y + hoveredRec.height) }; return getNearestSide(selectedRecSides, hoveredCreatorSides); } private AbstractFormParallelLine[] getNearestSide(AbstractFormParallelLine[] lines1, AbstractFormParallelLine[] lines2) { - AbstractFormParallelLine[] nearestSides = new AbstractFormParallelLine[2]; + AbstractFormParallelLine[] nearestSides = new AbstractFormParallelLine[] {lines1[0], lines2[0]}; int minDistance = lines1[0].getDistanceWithLine(lines2[0]); for (int i = 0; i < lines1.length; i++) { for (int j = 0; j < lines2.length; j++) { int distance = lines1[i].getDistanceWithLine(lines2[j]); - if (distance <= minDistance) { + if (distance < minDistance) { + minDistance = distance; nearestSides[0] = lines1[i]; nearestSides[1] = lines2[j]; }