From a28fc37a8a382702be7150da78965d04c6e73e06 Mon Sep 17 00:00:00 2001 From: obo Date: Wed, 19 Jul 2023 15:52:23 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-100623=20=E4=BC=98=E5=8C=96=E4=B8=8B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/creator/XEditorHolder.java | 23 +++++++++++-------- .../mainframe/EditingMouseListener.java | 20 +++++++++------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XEditorHolder.java b/designer-form/src/main/java/com/fr/design/designer/creator/XEditorHolder.java index d523010bf8..3291159a3a 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XEditorHolder.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XEditorHolder.java @@ -44,7 +44,7 @@ public class XEditorHolder extends XWidgetCreator { ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this); editingMouseListener.startEditing(this, adapter.getDesignerEditor(), adapter); Rectangle rect = this.getBounds(); - if (mouseEditRangeValid(e, rect, editingMouseListener)) { + if (checkMouseEditRangeValid(e, rect, editingMouseListener)) { ToolTipEditor.getInstance().showToolTip((XEditorHolder) this, e.getXOnScreen(), e.getYOnScreen()); } @@ -60,14 +60,19 @@ public class XEditorHolder extends XWidgetCreator { * @param editingMouseListener 位置处理器 * @return 是否位于可编辑区 */ - private boolean mouseEditRangeValid(MouseEvent e, Rectangle rect, EditingMouseListener editingMouseListener) { - int minHorizontal = rect.x + rect.width / 2 - editingMouseListener.getMinMoveSize(); - int maxHorizontal = rect.x + rect.width / 2 + editingMouseListener.getMinMoveSize(); - int minVertical = rect.y + rect.height / 2 - editingMouseListener.getMinMoveSize(); - int maxVertical = rect.y + rect.height / 2 + editingMouseListener.getMinMoveSize(); - - return e.getX() + editingMouseListener.getDesigner().getHorizontalScaleValue() > minHorizontal && e.getX() + editingMouseListener.getDesigner().getHorizontalScaleValue() < maxHorizontal - && e.getY() + editingMouseListener.getDesigner().getVerticalScaleValue() > minVertical && e.getY() + editingMouseListener.getDesigner().getVerticalScaleValue() < maxVertical; + private boolean checkMouseEditRangeValid(MouseEvent e, Rectangle rect, EditingMouseListener editingMouseListener) { + int horizontalValue = editingMouseListener.getDesigner().getHorizontalScaleValue(); + int verticalValue = editingMouseListener.getDesigner().getVerticalScaleValue(); + int minMoveSize = editingMouseListener.getMinMoveSize(); + + int minHorizontal = rect.x + rect.width / 2 - minMoveSize - horizontalValue; + int maxHorizontal = rect.x + rect.width / 2 + minMoveSize - horizontalValue; + int minVertical = rect.y + rect.height / 2 - minMoveSize - verticalValue; + int maxVertical = rect.y + rect.height / 2 + minMoveSize - verticalValue; + boolean xRangeValid = e.getX() > minHorizontal && e.getX() < maxHorizontal; + boolean yRangeValid = e.getY() > minVertical && e.getY() < maxVertical; + + return xRangeValid && yRangeValid; } @Override 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 64b07d50ce..801a342197 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 @@ -279,7 +279,7 @@ public class EditingMouseListener extends MouseInputAdapter { if (component instanceof XEditorHolder) { XEditorHolder xcreator = (XEditorHolder) component; Rectangle rect = xcreator.getBounds(); - if (creatorRangeValid(e, rect)) { + if (checkCreatorRangeValid(e, rect)) { if (designer.getCursor().getType() != Cursor.HAND_CURSOR) { designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } @@ -748,12 +748,16 @@ public class EditingMouseListener extends MouseInputAdapter { /** * 判断当前鼠标移动事件是否在Creator有效范围内 */ - private boolean creatorRangeValid(MouseEvent e, Rectangle rect) { - int minHorizontal = rect.x + rect.width / 2 - minMoveSize; - int maxHorizontal = rect.x + rect.width / 2 + minMoveSize; - int minVertical = rect.y + rect.height / 2 - minMoveSize; - int maxVertical = rect.y + rect.height / 2 + minMoveSize; - return e.getX() + designer.getHorizontalScaleValue() > minHorizontal && e.getX() + designer.getHorizontalScaleValue() < maxHorizontal - && e.getY() + designer.getVerticalScaleValue() > minVertical && e.getY() + designer.getVerticalScaleValue() < maxVertical; + private boolean checkCreatorRangeValid(MouseEvent e, Rectangle rect) { + int horizontalValue = designer.getHorizontalScaleValue(); + int verticalValue = designer.getVerticalScaleValue(); + + int minHorizontal = rect.x + rect.width / 2 - minMoveSize - horizontalValue; + int maxHorizontal = rect.x + rect.width / 2 + minMoveSize - horizontalValue; + int minVertical = rect.y + rect.height / 2 - minMoveSize - verticalValue; + int maxVertical = rect.y + rect.height / 2 + minMoveSize - verticalValue; + boolean xRangeValid = e.getX() > minHorizontal && e.getX() < maxHorizontal; + boolean yRangeValid = e.getY() > minVertical && e.getY() < maxVertical; + return xRangeValid && yRangeValid; } }