From 9277d913817c69db8796186844c66e5dc4e366f5 Mon Sep 17 00:00:00 2001 From: obo Date: Fri, 24 Mar 2023 15:00:40 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-92439=20mac=E4=B8=8B-=E5=B1=95=E5=BC=80?= =?UTF-8?q?=E6=94=B6=E8=B5=B7=E5=9B=BE=E6=A0=87=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../icontainer/UIEastResizableContainer.java | 7 +++- .../gui/icontainer/UIResizableContainer.java | 41 +++++++++++++++---- .../mainframe/EastRegionContainerPane.java | 7 +++- 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java index c8cfadd0fd..17511d391e 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java @@ -1,6 +1,8 @@ package com.fr.design.gui.icontainer; +import com.fr.base.svg.SVGLoader; +import com.fr.base.svg.SystemScaleUtils; import com.fr.design.base.mode.DesignModeContext; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ibutton.UIButton; @@ -339,7 +341,10 @@ public class UIEastResizableContainer extends JPanel { } } SvgPaintUtils.beforePaint((Graphics2D) g); - g.drawImage(button, 18, 7, this); + //如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整 + int x = SystemScaleUtils.isJreHiDPIEnabled() ? (int) (10 * SVGLoader.SYSTEM_SCALE) : 10; + int y = SystemScaleUtils.isJreHiDPIEnabled() ? (int) (7 * SVGLoader.SYSTEM_SCALE) : 7; + g.drawImage(button, x, y, null); SvgPaintUtils.afterPaint((Graphics2D) g); } } diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java index 8e562cc3ce..cbc175a0d9 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java @@ -1,14 +1,27 @@ package com.fr.design.gui.icontainer; +import com.fr.base.svg.SVGLoader; +import com.fr.base.svg.SystemScaleUtils; import com.fr.base.vcs.DesignerMode; import com.fr.design.constants.UIConstants; import com.fr.design.mainframe.DesignerContext; import com.fr.design.utils.SvgPaintUtils; -import com.fr.stable.Constants; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.stable.Constants; -import javax.swing.*; -import java.awt.*; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.LayoutManager; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; @@ -16,6 +29,8 @@ import java.awt.event.MouseMotionListener; public class UIResizableContainer extends JPanel { private static final long serialVersionUID = 1854340560790476907L; private static final int MAX_PARA_HEIGHT = 240; + private final boolean HI_DPI_SUPPORT = SystemScaleUtils.isJreHiDPIEnabled(); + private int containerWidth = 240; private int preferredWidth = 240; private int toolPaneY = 300; @@ -412,9 +427,13 @@ public class UIResizableContainer extends JPanel { Image downButton = (downModel == UIConstants.MODEL_NORMAL ? UIConstants.DRAG_DOWN_NORMAL : UIConstants.DRAG_DOWN_PRESS); g.drawImage(UIConstants.DRAG_BAR_LIGHT, 0, 0, getWidth(), getHeight(), null); SvgPaintUtils.beforePaint((Graphics2D) g); - g.drawImage(UIConstants.DRAG_LINE, (getWidth() - toolPaneHeight) / 2, 3, null); - g.drawImage(upButton, ARROW_MARGIN, 1, null); - g.drawImage(downButton, getWidth() - toolPaneHeight - ARROW_MARGIN, 1, null); + //如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整 + int dragLineX = HI_DPI_SUPPORT ? (int) ((getWidth() - toolPaneHeight) / 2 * SVGLoader.SYSTEM_SCALE) : (getWidth() - toolPaneHeight) / 2; + int dragLineY = HI_DPI_SUPPORT ? (int) (3 * SVGLoader.SYSTEM_SCALE) : 3; + int downButtonX = HI_DPI_SUPPORT ? (int) ((getWidth() - toolPaneHeight - ARROW_MARGIN) * SVGLoader.SYSTEM_SCALE) : (getWidth() - toolPaneHeight - ARROW_MARGIN); + g.drawImage(UIConstants.DRAG_LINE, dragLineX, dragLineY, null); + g.drawImage(upButton, ARROW_MARGIN, 0, null); + g.drawImage(downButton, downButtonX, 0, null); SvgPaintUtils.afterPaint((Graphics2D) g); } } @@ -512,7 +531,12 @@ public class UIResizableContainer extends JPanel { button = UIConstants.DRAG_LEFT_PRESS; } } - g.drawImage(button, -1, ARROW_MARGIN_VERTICAL, this); + SvgPaintUtils.beforePaint((Graphics2D) g); + //如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整 + int x = HI_DPI_SUPPORT ? (int) (-6 * SVGLoader.SYSTEM_SCALE) : -6; + int y = HI_DPI_SUPPORT ? (int) (ARROW_MARGIN_VERTICAL * SVGLoader.SYSTEM_SCALE) : ARROW_MARGIN_VERTICAL; + g.drawImage(button, x, y, this); + SvgPaintUtils.afterPaint((Graphics2D) g); } else { g.drawImage(UIConstants.DRAG_BAR_LIGHT, 0, 0, toolPaneHeight, getHeight(), null); if (containerWidth == toolPaneHeight) { @@ -528,7 +552,8 @@ public class UIResizableContainer extends JPanel { button = UIConstants.DRAG_RIGHT_PRESS; } } - g.drawImage(button, 2, ARROW_MARGIN_VERTICAL, this); + int x = HI_DPI_SUPPORT ? (int) (10 * SVGLoader.SYSTEM_SCALE) : 10; + g.drawImage(button, x, ARROW_MARGIN_VERTICAL, this); } if (isLeftRightDragEnabled) { g.drawImage(UIConstants.DRAG_DOT_VERTICAL, 2, getHeight() / 2, 5, toolPaneHeight, null); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java index 00405d6093..7ac1aac409 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java @@ -2,6 +2,8 @@ package com.fr.design.mainframe; import com.fr.base.FRContext; import com.fr.base.svg.IconUtils; +import com.fr.base.svg.SVGLoader; +import com.fr.base.svg.SystemScaleUtils; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; @@ -1315,7 +1317,10 @@ public class EastRegionContainerPane extends UIEastResizableContainer { button = UIConstants.POP_BUTTON_UP; } SvgPaintUtils.beforePaint((Graphics2D) g); - g.drawImage(button, ARROW_RANGE_START + 8, 4, null); + //如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整 + int x = SystemScaleUtils.isJreHiDPIEnabled() ? (int) ((ARROW_RANGE_START + 8) * SVGLoader.SYSTEM_SCALE) : (ARROW_RANGE_START + 8); + int y = SystemScaleUtils.isJreHiDPIEnabled() ? (int) (4 * SVGLoader.SYSTEM_SCALE) : 4; + g.drawImage(button, x, y, null); SvgPaintUtils.afterPaint((Graphics2D) g); } }