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 540c707d4..1ed4c6cca 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 @@ -31,6 +31,7 @@ public class FormSpacingLineDrawer { private FormDesigner designer; private XCreator hoverCreator = null; + private XCreator selectedCreator = null; private Rectangle selectedRec; private Rectangle hoveredRec; private boolean isMouseMoveEvent = false; @@ -40,19 +41,19 @@ public class FormSpacingLineDrawer { } public void updateMouseEvent(MouseEvent e, boolean isMouseMoveEvent) { - XCreator creator = designer.getSelectionModel().getSelection().getSelectedCreator(); - if (creator != null) { + selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); + if (selectedCreator != null) { this.hoverCreator = getHoverComponentAt(e.getX(), e.getY()); } this.isMouseMoveEvent = isMouseMoveEvent; } public void draw(Graphics g) { - if (!isDrawSpacingLine()) { + if (!isMouseMoveEvent || selectedCreator == null || hoverCreator == null) { return; } - if (!hoverCreator.isParentAbsolute()) { + if (!isDrawSpacingLine()) { return; } @@ -137,15 +138,15 @@ public class FormSpacingLineDrawer { } private boolean isSelectedParaComponent() { - return designer.getParaComponent() == designer.getSelectionModel().getSelection().getSelectedCreator(); + return designer.getParaComponent() == selectedCreator; } private boolean isSelectedRootComponent() { - return designer.isRoot(designer.getSelectionModel().getSelection().getSelectedCreator()); + return designer.isRoot(selectedCreator); } private boolean isSelectedForm() { - return designer.getSelectionModel().getSelection().getSelectedCreator().getParent() == null; + return selectedCreator.getParent() == null; } private boolean isNeedExtendedLine(AbstractFormParallelLine[] nearestSides) { @@ -158,33 +159,33 @@ public class FormSpacingLineDrawer { } // 当前组件是否在参数面板里面 - private boolean isCompInPara(XCreator creator) { + private boolean isCompInBody(XCreator creator) { XLayoutContainer container = XCreatorUtils.getHotspotContainer(creator); + return container != null && !container.acceptType(XWParameterLayout.class); + } - boolean xCreatorAccept = creator.acceptType(XWParameterLayout.class); - boolean containerAccept = container != null && container.acceptType(XWParameterLayout.class); - - return xCreatorAccept || containerAccept; + private boolean isSelectedCompInBody() { + return isCompInBody(selectedCreator); } - private boolean isBodyAbsoluteLayout() { - return !(designer instanceof FormParaDesigner) && FormDesignerUtils.isBodyAbsolute(designer); + private boolean isHoveredCompInBody() { + return isCompInBody(hoverCreator); } - private boolean isSelectedCompInPara() { - return isCompInPara(designer.getSelectionModel().getSelection().getSelectedCreator()); + private boolean isCompInBody() { + return isSelectedCompInBody() && isHoveredCompInBody(); } - private boolean isHoveredCompInPara() { - return isCompInPara(hoverCreator); + private boolean isBodyAbsoluteLayout() { + return !(designer instanceof FormParaDesigner) && FormDesignerUtils.isBodyAbsolute(designer); } - private boolean isSelectedCompOrHoveredCompInPara() { - return isSelectedCompInPara() || isHoveredCompInPara(); + private boolean isInAbsoluteLayout() { + return isBodyAbsoluteLayout() && hoverCreator.isParentAbsolute() && selectedCreator.isParentAbsolute(); } private boolean isDrawSpacingLine() { - return isBodyAbsoluteLayout() && !isSelectedRootPane() && hoverCreator != null && !isSelectedCompOrHoveredCompInPara() && isMouseMoveEvent; + return isInAbsoluteLayout() && !isSelectedRootPane() && isCompInBody(); } private AbstractFormParallelLine[] getNearestHorizontalSide() {