From 83f01ae956a08f58c8de8e58a4bd6fd2aa1dcd1f Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Mon, 20 Jul 2020 10:30:45 +0800 Subject: [PATCH 1/6] =?UTF-8?q?REPORT-35699=20=E5=9B=BD=E9=99=85=E5=8C=96?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=B9=E6=8A=A5=E8=A1=A8=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A1=86=E4=BA=A7=E7=94=9F=E5=BD=B1=E5=93=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/utils/gui/GUICoreUtils.java | 54 ++++++++++--------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java index 586047f5a..3723c775f 100644 --- a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java @@ -387,31 +387,35 @@ public final class GUICoreUtils { * @param y y坐标 */ public static void showPopupMenu(JPopupMenu popup, Component parentComponent, int x, int y) { - if (popup == null) {// check null. - return; - } - - Point point = new Point(x, y); - SwingUtilities.convertPointToScreen(point, parentComponent); - - Dimension size = popup.getPreferredSize(); - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - screen.setSize(screen.getSize().width, screen.height - HEIGHT_GAP); - - int showOnScreenX = Math.min(screen.width, parentComponent.getLocationOnScreen().x + parentComponent.getWidth()); - - // peter:调整X的高度. - if (point.x + size.width > showOnScreenX && size.width < showOnScreenX) { - x += (showOnScreenX - point.x - size.width); - } - - // peter:调整y高度. - if (point.y + size.height > screen.height && size.height < screen.height) { - y -= size.height; - } - - popup.show(parentComponent, x, y); - } + if (popup == null) {// check null. + return; + } + + Point point = new Point(x, y); + SwingUtilities.convertPointToScreen(point, parentComponent); + + Dimension size = popup.getPreferredSize(); + Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); + screen.setSize(screen.getSize().width, screen.height - HEIGHT_GAP); + //父元素右边界的坐标 + int parentComponentRightBorderPosition = parentComponent.getLocationOnScreen().x + parentComponent.getWidth(); + //设计器右边界的坐标 + Rectangle rectangle = DesignerContext.getDesignerFrame().getBounds(); + int designerRightBorderPosition = rectangle.x + rectangle.width; + rectangle = SwingUtilities.getWindowAncestor(parentComponent).getBounds(); + designerRightBorderPosition = Math.max(designerRightBorderPosition, rectangle.x + rectangle.width); + // peter:调整X的高度. + if (point.x + size.width > designerRightBorderPosition && size.width < designerRightBorderPosition) { + x += (parentComponentRightBorderPosition - point.x - size.width); + } + + // peter:调整y高度. + if (point.y + size.height > screen.height && size.height < screen.height) { + y -= size.height; + } + + popup.show(parentComponent, x, y); + } /** * Set enabled.
From fe878c0ffa375a812629dd6970dfd4e5d2bb3c92 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Mon, 20 Jul 2020 10:38:27 +0800 Subject: [PATCH 2/6] =?UTF-8?q?REPORT-35699=20=E5=9B=BD=E9=99=85=E5=8C=96?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=B9=E6=8A=A5=E8=A1=A8=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A1=86=E4=BA=A7=E7=94=9F=E5=BD=B1=E5=93=8D=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/utils/gui/GUICoreUtils.java | 1 + 1 file changed, 1 insertion(+) diff --git a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java index 3723c775f..9f5c7fbaa 100644 --- a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java @@ -27,6 +27,7 @@ import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.style.color.ColorCell; import com.fr.design.style.color.ColorFactory; import com.fr.design.style.color.ColorSelectBox; From 39fd9ae7e71b41facc712c8e06c4feb39efd4946 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Tue, 21 Jul 2020 11:57:38 +0800 Subject: [PATCH 3/6] =?UTF-8?q?REPORT-35692=20=E5=9B=BD=E9=99=85=E5=8C=96-?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=AE=BE=E7=BD=AE-=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E6=94=B9=E4=B8=BAINCH=EF=BC=8C=E6=98=BE=E7=A4=BA=E4=B8=8D?= =?UTF-8?q?=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/report/UnitFieldPane.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java b/designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java index 6da8957b2..c6a86de53 100644 --- a/designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java @@ -52,9 +52,9 @@ public class UnitFieldPane extends JPanel { this.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_MM")); } - //ajust the heigt of unitLabel. - Dimension unitDimension = new Dimension(this.getPreferredSize().width, - preferredHeight); + //自适应label宽度 + int width = this.getFontMetrics(this.getFont()).stringWidth(this.getText()); + Dimension unitDimension = new Dimension(width, preferredHeight); this.setMinimumSize(unitDimension); this.setMinimumSize(unitDimension); this.setSize(unitDimension); @@ -62,7 +62,8 @@ public class UnitFieldPane extends JPanel { } } - public UnitFieldPane(int unitType) { + public + UnitFieldPane(int unitType) { this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); this.unitType = unitType; From b30e6623d6de54430fd8a21c029299c330fad6d5 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Tue, 21 Jul 2020 11:59:56 +0800 Subject: [PATCH 4/6] =?UTF-8?q?REPORT-35692=20=E5=9B=BD=E9=99=85=E5=8C=96-?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=AE=BE=E7=BD=AE-=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E6=94=B9=E4=B8=BAINCH=EF=BC=8C=E6=98=BE=E7=A4=BA=E4=B8=8D?= =?UTF-8?q?=E5=85=A8=20=E8=B0=83=E6=95=B4=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/report/UnitFieldPane.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java b/designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java index c6a86de53..9ad44562f 100644 --- a/designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java @@ -62,8 +62,7 @@ public class UnitFieldPane extends JPanel { } } - public - UnitFieldPane(int unitType) { + public UnitFieldPane(int unitType) { this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); this.unitType = unitType; From 304a522cfb4f379d2a522a52e9c539a69c9bca19 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Tue, 21 Jul 2020 12:24:45 +0800 Subject: [PATCH 5/6] =?UTF-8?q?REPORT-35692=20=E5=9B=BD=E9=99=85=E5=8C=96-?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=AE=BE=E7=BD=AE-=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E6=94=B9=E4=B8=BAINCH=EF=BC=8C=E6=98=BE=E7=A4=BA=E4=B8=8D?= =?UTF-8?q?=E5=85=A8=20=E6=92=A4=E9=94=80=E4=B8=80=E4=BA=9B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/utils/gui/GUICoreUtils.java | 55 +++++++++---------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java index 9f5c7fbaa..586047f5a 100644 --- a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java @@ -27,7 +27,6 @@ import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.DesignerContext; import com.fr.design.style.color.ColorCell; import com.fr.design.style.color.ColorFactory; import com.fr.design.style.color.ColorSelectBox; @@ -388,35 +387,31 @@ public final class GUICoreUtils { * @param y y坐标 */ public static void showPopupMenu(JPopupMenu popup, Component parentComponent, int x, int y) { - if (popup == null) {// check null. - return; - } - - Point point = new Point(x, y); - SwingUtilities.convertPointToScreen(point, parentComponent); - - Dimension size = popup.getPreferredSize(); - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - screen.setSize(screen.getSize().width, screen.height - HEIGHT_GAP); - //父元素右边界的坐标 - int parentComponentRightBorderPosition = parentComponent.getLocationOnScreen().x + parentComponent.getWidth(); - //设计器右边界的坐标 - Rectangle rectangle = DesignerContext.getDesignerFrame().getBounds(); - int designerRightBorderPosition = rectangle.x + rectangle.width; - rectangle = SwingUtilities.getWindowAncestor(parentComponent).getBounds(); - designerRightBorderPosition = Math.max(designerRightBorderPosition, rectangle.x + rectangle.width); - // peter:调整X的高度. - if (point.x + size.width > designerRightBorderPosition && size.width < designerRightBorderPosition) { - x += (parentComponentRightBorderPosition - point.x - size.width); - } - - // peter:调整y高度. - if (point.y + size.height > screen.height && size.height < screen.height) { - y -= size.height; - } - - popup.show(parentComponent, x, y); - } + if (popup == null) {// check null. + return; + } + + Point point = new Point(x, y); + SwingUtilities.convertPointToScreen(point, parentComponent); + + Dimension size = popup.getPreferredSize(); + Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); + screen.setSize(screen.getSize().width, screen.height - HEIGHT_GAP); + + int showOnScreenX = Math.min(screen.width, parentComponent.getLocationOnScreen().x + parentComponent.getWidth()); + + // peter:调整X的高度. + if (point.x + size.width > showOnScreenX && size.width < showOnScreenX) { + x += (showOnScreenX - point.x - size.width); + } + + // peter:调整y高度. + if (point.y + size.height > screen.height && size.height < screen.height) { + y -= size.height; + } + + popup.show(parentComponent, x, y); + } /** * Set enabled.
From 8eda3e745d6421b3101164517b30ba2309ebd914 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Tue, 21 Jul 2020 14:49:52 +0800 Subject: [PATCH 6/6] =?UTF-8?q?REPORT-35692=20=E5=9B=BD=E9=99=85=E5=8C=96-?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=AE=BE=E7=BD=AE-=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E6=94=B9=E4=B8=BAINCH=EF=BC=8C=E6=98=BE=E7=A4=BA=E4=B8=8D?= =?UTF-8?q?=E5=85=A8=20=E6=96=B9=E6=B3=95=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/report/UnitFieldPane.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java b/designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java index 9ad44562f..6af6852d4 100644 --- a/designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java @@ -8,6 +8,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UIBasicSpinner; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.stable.Constants; +import com.fr.stable.GraphDrawHelper; import com.fr.stable.OperatingSystem; import com.fr.stable.unit.CM; import com.fr.stable.unit.INCH; @@ -53,7 +54,7 @@ public class UnitFieldPane extends JPanel { } //自适应label宽度 - int width = this.getFontMetrics(this.getFont()).stringWidth(this.getText()); + int width = GraphDrawHelper.getWidth(this.getText(), this.getFont()); Dimension unitDimension = new Dimension(width, preferredHeight); this.setMinimumSize(unitDimension); this.setMinimumSize(unitDimension);