From bfd07764cdaf48ed219ed08b87ae84cd070ac81b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Fri, 3 Sep 2021 18:58:01 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-57722=20=E7=9C=8B=E7=9C=8B=E7=BB=98?= =?UTF-8?q?=E5=88=B6=E9=97=B4=E8=B7=9D=E7=BA=BF=E5=88=A4=E6=96=AD=E7=9A=84?= =?UTF-8?q?=E5=9C=B0=E6=96=B9=E6=9C=89=E6=B2=A1=E6=9C=89=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=9A=84=E7=A9=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/designer/creator/XCreator.java | 28 ++++++++++ .../creator/XWAbsoluteBodyLayout.java | 13 +++++ .../designer/creator/XWParameterLayout.java | 5 ++ .../mainframe/FormSpacingLineDrawer.java | 53 +++---------------- 4 files changed, 52 insertions(+), 47 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java index 55b9c191f..3ead13c05 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java @@ -68,6 +68,9 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo protected Widget data; protected JComponent editor; protected CoverReportPane coverPanel; + + protected boolean inAbsoluteBodyLayout; + // XCreator加入到某些XLayoutContainer中时,能调整宽度或者高度 private int[] directions; private Rectangle backupBound; @@ -887,4 +890,29 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo } return ((XCreator) this.getParent()).getLevel() + 1; } + + public boolean isAbleDrawSpacingLine() { + return !isBody() && !isParameter() && !isInPara() && isInAbsoluteBodyLayout(); + } + + public boolean isBody() { + return false; + } + + public boolean isParameter() { + return false; + } + + public boolean isInPara() { + XLayoutContainer container = XCreatorUtils.getHotspotContainer(this); + return container != null && container.acceptType(XWParameterLayout.class); + } + + public boolean isInAbsoluteBodyLayout() { + return inAbsoluteBodyLayout; + } + + public void setInAbsoluteBodyLayout(boolean inAbsoluteBodyLayout) { + this.inAbsoluteBodyLayout = inAbsoluteBodyLayout; + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java index aa5612c09..40786a6d5 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java @@ -12,6 +12,7 @@ import com.fr.stable.core.PropertyChangeAdapter; import java.awt.Component; import java.awt.Dimension; +import java.awt.event.ContainerEvent; import java.beans.IntrospectionException; /** @@ -135,4 +136,16 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout { return false; } + @Override + public void componentAdded(ContainerEvent e) { + super.componentAdded(e); + XWidgetCreator creator = (XWidgetCreator) e.getChild(); + creator.setInAbsoluteBodyLayout(true); + } + + @Override + public boolean isBody() { + return true; + } + } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java index fc01aefaa..9fa256f8a 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java @@ -260,4 +260,9 @@ public class XWParameterLayout extends XWAbsoluteLayout { public boolean isTopable() { return false; } + + @Override + public boolean isParameter() { + return true; + } } 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..d78290810 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 @@ -5,9 +5,6 @@ import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XElementCase; import com.fr.design.designer.creator.XLayoutContainer; -import com.fr.design.designer.creator.XWParameterLayout; -import com.fr.design.form.parameter.FormParaDesigner; -import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.utils.ComponentUtils; import com.fr.stable.Constants; import com.fr.stable.GraphDrawHelper; @@ -48,6 +45,10 @@ public class FormSpacingLineDrawer { } public void draw(Graphics g) { + if (!isMouseMoveEvent) { + return; + } + if (!isDrawSpacingLine()) { return; } @@ -136,55 +137,13 @@ public class FormSpacingLineDrawer { GraphDrawHelper.drawString(g2d, text, labelX, labelY); } - private boolean isSelectedParaComponent() { - return designer.getParaComponent() == designer.getSelectionModel().getSelection().getSelectedCreator(); - } - - private boolean isSelectedRootComponent() { - return designer.isRoot(designer.getSelectionModel().getSelection().getSelectedCreator()); - } - - private boolean isSelectedForm() { - return designer.getSelectionModel().getSelection().getSelectedCreator().getParent() == null; - } - private boolean isNeedExtendedLine(AbstractFormParallelLine[] nearestSides) { return nearestSides[0].isVerticalCenterLineBeforeTheParallelLine(nearestSides[1]) || nearestSides[0].isVerticalCenterLineBehindTheParallelLine(nearestSides[1]); } - private boolean isSelectedRootPane() { - // form、body、para这三个选中了,都不要画任何间距线 - return isSelectedForm() || isSelectedRootComponent() || isSelectedParaComponent(); - } - - // 当前组件是否在参数面板里面 - private boolean isCompInPara(XCreator creator) { - XLayoutContainer container = XCreatorUtils.getHotspotContainer(creator); - - boolean xCreatorAccept = creator.acceptType(XWParameterLayout.class); - boolean containerAccept = container != null && container.acceptType(XWParameterLayout.class); - - return xCreatorAccept || containerAccept; - } - - private boolean isBodyAbsoluteLayout() { - return !(designer instanceof FormParaDesigner) && FormDesignerUtils.isBodyAbsolute(designer); - } - - private boolean isSelectedCompInPara() { - return isCompInPara(designer.getSelectionModel().getSelection().getSelectedCreator()); - } - - private boolean isHoveredCompInPara() { - return isCompInPara(hoverCreator); - } - - private boolean isSelectedCompOrHoveredCompInPara() { - return isSelectedCompInPara() || isHoveredCompInPara(); - } - private boolean isDrawSpacingLine() { - return isBodyAbsoluteLayout() && !isSelectedRootPane() && hoverCreator != null && !isSelectedCompOrHoveredCompInPara() && isMouseMoveEvent; + XCreator selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); + return hoverCreator != null && selectedCreator != null && hoverCreator.isAbleDrawSpacingLine() && selectedCreator.isAbleDrawSpacingLine(); } private AbstractFormParallelLine[] getNearestHorizontalSide() { From 77fad47b9d56d5baea924c2ad05627c7f7271399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Fri, 3 Sep 2021 19:00:56 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-57722=20=E4=BF=AE=E6=AD=A3=E7=BC=BA?= =?UTF-8?q?=E5=B0=91=E7=9A=84=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/designer/creator/XCreator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java index 1e588c5c7..8b33d7532 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java @@ -69,7 +69,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo protected JComponent editor; protected CoverReportPane coverPanel; - protected boolean inAbsoluteBodyLayout; + protected boolean inAbsoluteBodyLayout = false; // XCreator加入到某些XLayoutContainer中时,能调整宽度或者高度 private int[] directions; From a5e44c538743761610591e133fb0177145b7330e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Mon, 6 Sep 2021 10:42:29 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-57722=20=E7=9C=8B=E7=9C=8B=E7=BB=98?= =?UTF-8?q?=E5=88=B6=E9=97=B4=E8=B7=9D=E7=BA=BF=E5=88=A4=E6=96=AD=E7=9A=84?= =?UTF-8?q?=E5=9C=B0=E6=96=B9=E6=9C=89=E6=B2=A1=E6=9C=89=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=9A=84=E7=A9=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/designer/creator/XCreator.java | 28 --------- .../creator/XWAbsoluteBodyLayout.java | 13 ---- .../designer/creator/XWParameterLayout.java | 5 -- .../mainframe/FormSpacingLineDrawer.java | 60 ++++++++++++++++--- 4 files changed, 51 insertions(+), 55 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java index 8b33d7532..e82528558 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java @@ -68,9 +68,6 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo protected Widget data; protected JComponent editor; protected CoverReportPane coverPanel; - - protected boolean inAbsoluteBodyLayout = false; - // XCreator加入到某些XLayoutContainer中时,能调整宽度或者高度 private int[] directions; private Rectangle backupBound; @@ -897,29 +894,4 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo } return ((XCreator) this.getParent()).getLevel() + 1; } - - public boolean isAbleDrawSpacingLine() { - return !isBody() && !isParameter() && !isInPara() && isInAbsoluteBodyLayout(); - } - - public boolean isBody() { - return false; - } - - public boolean isParameter() { - return false; - } - - public boolean isInPara() { - XLayoutContainer container = XCreatorUtils.getHotspotContainer(this); - return container != null && container.acceptType(XWParameterLayout.class); - } - - public boolean isInAbsoluteBodyLayout() { - return inAbsoluteBodyLayout; - } - - public void setInAbsoluteBodyLayout(boolean inAbsoluteBodyLayout) { - this.inAbsoluteBodyLayout = inAbsoluteBodyLayout; - } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java index 40786a6d5..aa5612c09 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java @@ -12,7 +12,6 @@ import com.fr.stable.core.PropertyChangeAdapter; import java.awt.Component; import java.awt.Dimension; -import java.awt.event.ContainerEvent; import java.beans.IntrospectionException; /** @@ -136,16 +135,4 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout { return false; } - @Override - public void componentAdded(ContainerEvent e) { - super.componentAdded(e); - XWidgetCreator creator = (XWidgetCreator) e.getChild(); - creator.setInAbsoluteBodyLayout(true); - } - - @Override - public boolean isBody() { - return true; - } - } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java index 9fa256f8a..fc01aefaa 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java @@ -260,9 +260,4 @@ public class XWParameterLayout extends XWAbsoluteLayout { public boolean isTopable() { return false; } - - @Override - public boolean isParameter() { - return true; - } } 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 d78290810..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 @@ -5,6 +5,9 @@ import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XElementCase; import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWParameterLayout; +import com.fr.design.form.parameter.FormParaDesigner; +import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.utils.ComponentUtils; import com.fr.stable.Constants; import com.fr.stable.GraphDrawHelper; @@ -28,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; @@ -37,15 +41,15 @@ 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 (!isMouseMoveEvent) { + if (!isMouseMoveEvent || selectedCreator == null || hoverCreator == null) { return; } @@ -53,10 +57,6 @@ public class FormSpacingLineDrawer { return; } - if (!hoverCreator.isParentAbsolute()) { - return; - } - this.selectedRec = designer.getSelectionModel().getSelection().getRelativeBounds(); this.hoveredRec = ComponentUtils.getRelativeBounds(hoverCreator); @@ -137,13 +137,55 @@ public class FormSpacingLineDrawer { GraphDrawHelper.drawString(g2d, text, labelX, labelY); } + private boolean isSelectedParaComponent() { + return designer.getParaComponent() == selectedCreator; + } + + private boolean isSelectedRootComponent() { + return designer.isRoot(selectedCreator); + } + + private boolean isSelectedForm() { + return selectedCreator.getParent() == null; + } + private boolean isNeedExtendedLine(AbstractFormParallelLine[] nearestSides) { return nearestSides[0].isVerticalCenterLineBeforeTheParallelLine(nearestSides[1]) || nearestSides[0].isVerticalCenterLineBehindTheParallelLine(nearestSides[1]); } + private boolean isSelectedRootPane() { + // form、body、para这三个选中了,都不要画任何间距线 + return isSelectedForm() || isSelectedRootComponent() || isSelectedParaComponent(); + } + + // 当前组件是否在参数面板里面 + private boolean isCompInBody(XCreator creator) { + XLayoutContainer container = XCreatorUtils.getHotspotContainer(creator); + return container != null && !container.acceptType(XWParameterLayout.class); + } + + private boolean isSelectedCompInBody() { + return isCompInBody(selectedCreator); + } + + private boolean isHoveredCompInBody() { + return isCompInBody(hoverCreator); + } + + private boolean isCompInBody() { + return isSelectedCompInBody() && isHoveredCompInBody(); + } + + private boolean isBodyAbsoluteLayout() { + return !(designer instanceof FormParaDesigner) && FormDesignerUtils.isBodyAbsolute(designer); + } + + private boolean isInAbsoluteLayout() { + return isBodyAbsoluteLayout() && hoverCreator.isParentAbsolute() && selectedCreator.isParentAbsolute(); + } + private boolean isDrawSpacingLine() { - XCreator selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); - return hoverCreator != null && selectedCreator != null && hoverCreator.isAbleDrawSpacingLine() && selectedCreator.isAbleDrawSpacingLine(); + return isInAbsoluteLayout() && !isSelectedRootPane() && isCompInBody(); } private AbstractFormParallelLine[] getNearestHorizontalSide() {