From c8059e3b01704e56723e2e753670853e20a604f6 Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 20 Oct 2020 09:42:28 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-41479=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E7=95=8C=E9=9D=A2=E5=AE=BD=E5=BA=A6=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=8B=96=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/parameter/FormParaDesigner.java | 24 +++++++++++++++++++ .../mainframe/EditingMouseListener.java | 11 +-------- .../com/fr/design/mainframe/FormDesigner.java | 9 +++++++ .../fr/design/mainframe/FormDesignerUI.java | 15 +++++++----- 4 files changed, 43 insertions(+), 16 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java index 8956125eb3..8d13f3ab42 100644 --- a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java +++ b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java @@ -30,6 +30,7 @@ import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.FormArea; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesignerModeForSpecial; +import com.fr.design.mainframe.FormDesignerUI; import com.fr.design.mainframe.FormParaPane; import com.fr.design.mainframe.FormWidgetDetailPane; import com.fr.design.mainframe.JTemplate; @@ -58,6 +59,7 @@ import java.awt.Graphics; import java.awt.Image; import java.awt.Insets; import java.awt.Rectangle; +import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -467,6 +469,21 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP return ((FormParameterUI) getTarget()).getDesignSize(); } + /** + * 设置其UI类为DesignerUI,负责渲染 + */ + @Override + public void updateUI() { + setUI(new FormDesignerUI(){ + @Override + protected Rectangle getFitPaintBounds(Component component, Component parent) { + return new Rectangle(0, 0, parent.getSize().width, parent.getSize().height); + } + + }); + } + + /** * 设置高度 * @@ -722,4 +739,11 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP return new JComponent[]{new CutAction(this).createToolBarComponent(), new CopyAction(this).createToolBarComponent(), new PasteAction(this).createToolBarComponent(), new FormDeleteAction(this).createToolBarComponent()}; } + + @Override + public boolean checkIfBeyondValidArea(MouseEvent e){ + return false; + } + + } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index 21b210a3bf..524dd8bf14 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java @@ -166,7 +166,7 @@ public class EditingMouseListener extends MouseInputAdapter { // 获取焦点,以便获取热键 designer.requestFocus(); } - if (e.getButton() == MouseEvent.BUTTON1 && !beyondValidArea(e)) { + if (e.getButton() == MouseEvent.BUTTON1 && !designer.checkIfBeyondValidArea(e)) { Direction dir = selectionModel.getDirectionAt(e); if (!DesignerMode.isAuthorityEditing()) { @@ -194,15 +194,6 @@ public class EditingMouseListener extends MouseInputAdapter { e.translatePoint(oldX - e.getX(), oldY - e.getY()); } - private boolean beyondValidArea(MouseEvent e) { - if (e.getX() < 0 || e.getY() < 0 || - e.getX() > designer.getRootComponent().getWidth() || - e.getY() > (designer.getRootComponent().getHeight() + designer.getParaHeight())) { - return true; - } - return false; - } - private void offsetEventPoint(MouseEvent e){ int x = designer.getRelativeX(e.getX()); int y = designer.getRelativeY(e.getY()); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java index a80032ed6f..62c89b9cae 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java @@ -1733,4 +1733,13 @@ public class FormDesigner extends TargetComponent
implements TreeSelection return (int) (this.getArea().getVerticalValue() / this.scale); } + public boolean checkIfBeyondValidArea(MouseEvent e){ + if (e.getX() < 0 || e.getY() < 0 || + e.getX() > this.getRootComponent().getWidth() || + e.getY() > (this.getRootComponent().getHeight() + this.getParaHeight())) { + return true; + } + return false; + } + } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java index 233ee2a96a..a21a2efad5 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java @@ -424,12 +424,8 @@ public class FormDesignerUI extends ComponentUI { // 禁止双缓冲 ComponentUtils.disableBuffer(component, dbcomponents); Graphics clipg; - clipg = g.create( - -designer.getHorizontalScaleValue(), - -designer.getVerticalScaleValue() + designer.getParaHeight(), - component.getSize().width + designer.getHorizontalScaleValue(), - component.getSize().height + designer.getVerticalScaleValue()); - + Rectangle clipgBounds = getFitPaintBounds(component, parent); + clipg = g.create(clipgBounds.x, clipgBounds.y, clipgBounds.width, clipgBounds.height); designer.paintContent(clipg); paintWatermark((Graphics2D) clipg); clipg.dispose(); @@ -439,6 +435,13 @@ public class FormDesignerUI extends ComponentUI { designer.resetEditorComponentBounds(); } + protected Rectangle getFitPaintBounds(Component component, Component parent) { + return new Rectangle(-designer.getHorizontalScaleValue(), + -designer.getVerticalScaleValue() + designer.getParaHeight(), + component.getSize().width + designer.getHorizontalScaleValue(), + component.getSize().height + designer.getVerticalScaleValue()); + } + /** * 画参数面板 */