From 2f814b1ce6f4d753957d01eef5ded864cc8c6e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvan-=E6=AC=A7=E9=98=B3=E5=B8=86?= Date: Wed, 22 Mar 2023 12:07:59 +0800 Subject: [PATCH 01/23] =?UTF-8?q?REPORT-91503=20=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E9=A2=91=E7=B9=81=E6=8A=A5=E9=94=99=E9=94=81?= =?UTF-8?q?=E5=AE=9A=E4=BF=A1=E6=81=AF=E4=B8=8D=E4=B8=80=E8=87=B4=EF=BC=8C?= =?UTF-8?q?=E5=9C=A8=E8=BF=99=E4=B8=AA=E5=BC=B9=E7=AA=97=E5=8F=A6=E5=AD=98?= =?UTF-8?q?=E4=B8=BA=E4=B8=80=E5=AE=9A=E4=BC=9A=E5=A4=B1=E8=B4=A5=E3=80=82?= =?UTF-8?q?=20=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91REPORT?= =?UTF-8?q?-70481=E8=BF=AD=E4=BB=A3=E5=BC=95=E8=B5=B7=EF=BC=8C=E5=8E=9F?= =?UTF-8?q?=E5=9B=A0=E6=98=AF=E5=9C=A8=E6=A8=A1=E6=9D=BF=E9=94=81=E5=AE=9A?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=B8=8D=E4=B8=80=E8=87=B4=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=EF=BC=8C=E5=8E=9F=E6=9C=AC=E7=9A=84=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E6=98=AF=E5=B0=86=E5=BD=93=E5=89=8D=E6=A8=A1=E6=9D=BF=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E4=B8=BA=E5=A4=87=E4=BB=BD=E6=96=87=E4=BB=B6=20+=20?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E5=BD=93=E5=89=8D=E6=A8=A1=E6=9D=BF=EF=BC=8C?= =?UTF-8?q?=E4=BD=86=E6=98=AF=E4=BF=9D=E5=AD=98=E7=9A=84=E5=8A=A8=E4=BD=9C?= =?UTF-8?q?=E6=98=AF=E9=80=9A=E8=BF=87SwingWorker=E5=81=9A=E7=9A=84?= =?UTF-8?q?=EF=BC=8C=E5=85=B3=E9=97=AD=E5=BD=93=E5=89=8D=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E7=9A=84=E5=8A=A8=E4=BD=9C=E6=9C=AA=E8=A2=AB=E5=8C=85=E5=90=AB?= =?UTF-8?q?=E5=9C=A8SwingWorker=E4=B8=AD=EF=BC=8C=E5=9B=A0=E6=AD=A4?= =?UTF-8?q?=E4=BC=9A=E5=AF=BC=E8=87=B4=E5=85=88=E5=85=B3=E9=97=AD=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E6=A8=A1=E6=9D=BF=E9=87=8A=E6=94=BE=E8=B5=84=E6=BA=90?= =?UTF-8?q?=EF=BC=8C=E5=86=8D=E8=AF=BB=E5=8F=96=E5=BD=93=E5=89=8D=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=86=99=E5=85=A5=E6=96=B0=E6=96=87=E4=BB=B6=EF=BC=88?= =?UTF-8?q?=E6=AD=A4=E6=97=B6=E6=9C=89=E8=B5=84=E6=BA=90=E5=B7=B2=E8=A2=AB?= =?UTF-8?q?=E9=87=8A=E6=94=BE=EF=BC=8C=E4=BC=9A=E5=9C=A8=E5=86=99=E5=85=A5?= =?UTF-8?q?=E6=97=B6=E5=BC=95=E8=B5=B7NPE=EF=BC=89=20=E3=80=90=E6=94=B9?= =?UTF-8?q?=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=91=E5=B0=86=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E6=A8=A1=E6=9D=BF=E7=9A=84=E5=8A=A8=E4=BD=9C?= =?UTF-8?q?=E6=94=BE=E5=88=B0=E4=BF=9D=E5=AD=98=E7=9A=84SwingWorker?= =?UTF-8?q?=E7=9A=84done=E6=96=B9=E6=B3=95=E4=B8=AD=EF=BC=8C=E5=8D=B3?= =?UTF-8?q?=E5=85=88=E4=BF=9D=E5=AD=98=E6=88=90=E5=8A=9F=EF=BC=8C=E5=86=8D?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E6=A8=A1=E6=9D=BF=EF=BC=9B=E5=8F=A6=E5=A4=96?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E4=B8=80=E4=B8=8B=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81=EF=BC=8C=E4=BD=BF=E5=85=B6=E6=9B=B4?= =?UTF-8?q?=E7=AC=A6=E5=90=88=E5=BC=80=E5=8F=91=E8=A7=84=E8=8C=83=20?= =?UTF-8?q?=E3=80=90review=E5=BB=BA=E8=AE=AE=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/utils/TemplateUtils.java | 74 ++++++++++++------- .../worker/save/SaveFailureHandler.java | 8 +- 2 files changed, 53 insertions(+), 29 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java b/designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java index 9fb1e632af..e82251f4b8 100644 --- a/designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java @@ -16,6 +16,7 @@ import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.CoreConstants; import com.fr.stable.ProductConstants; +import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.server.lock.TplOperator; @@ -33,6 +34,7 @@ public class TemplateUtils { /** * 创建新的模板文件并打开模板 + * * @param prefix 模板文件名称前缀 * @param file 模板文件 * @param createByEditingTemplate 是否根据 当前编辑模板 来创建新模板 @@ -41,6 +43,21 @@ public class TemplateUtils { * @param openNewTemplate 是否需要在创建后打开模板 */ public static void createAndOpenTemplate(String prefix, FILE file, boolean createByEditingTemplate, boolean openNewTemplate) { + createAndOpenTemplate(prefix, file, createByEditingTemplate, openNewTemplate, () -> {}); + } + + /** + * 创建新的模板文件并打开模板,并在创建备份模板成功后执行doAfterCreate + * + * @param prefix 模板文件名称前缀 + * @param file 模板文件 + * @param createByEditingTemplate 是否根据 当前编辑模板 来创建新模板 + * 为true时以CurrentEditingTemplate为准创建新模板 + * 为false时以传入的File文件为准创建新模板,此文件可以不是编辑状态 + * @param openNewTemplate 是否需要在创建后打开模板 + * @param doAfterCreateTemplate 创建备份模板成功后调用 + */ + public static void createAndOpenTemplate(String prefix, FILE file, boolean createByEditingTemplate, boolean openNewTemplate, Runnable doAfterCreateTemplate) { String fileName = file.getName(); String oldPath = file.getPath(); int indexOfLastDot = fileName.lastIndexOf(CoreConstants.DOT); @@ -62,43 +79,25 @@ public class TemplateUtils { if (isOk(result)) { file = fileChooserPane.getSelectedFILE(); - _createAndOpenTemplate(file, oldPath, createByEditingTemplate, openNewTemplate); + createAndOpenTemplate0(file, oldPath, createByEditingTemplate, openNewTemplate, doAfterCreateTemplate); } } - private static void _createAndOpenTemplate(FILE file, String oldPath, boolean createByEditingTemplate, boolean openNewTemplate){ + private static void createAndOpenTemplate0(FILE file, String oldPath, boolean createByEditingTemplate, boolean openNewTemplate, Runnable doAfterCreateTemplate) { new SwingWorker() { @Override protected Void doInBackground() throws Exception { - byte[] content = new byte[0]; - if (createByEditingTemplate) { - // 从当前编辑模板中生成备份文件 - JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - content = template.exportData(); - } else { - content = WorkContext.getWorkResource().readFully(oldPath); - } - if (ArrayUtils.isEmpty(content)) { - throw new Exception(oldPath + " content is empty" ); - } - OutputStream out = null; - try { + // 读取模板数据 + byte[] content = getTemplateData(createByEditingTemplate, oldPath); + try(OutputStream out = file.asOutputStream()) { // 加锁 WorkContext.getCurrent().get(TplOperator.class).saveAs(file.getPath()); - out = file.asOutputStream(); out.write(content); } finally { - try { - if (out != null) { - out.close(); - } - } finally { - // 解锁 - WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(file.getPath()); - } - + // 解锁 + WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(file.getPath()); } return null; } @@ -107,6 +106,8 @@ public class TemplateUtils { protected void done() { try { get(); + // 创建备份成功后 + doAfterCreateTemplate.run(); if (openNewTemplate) { DesignerContext.getDesignerFrame().openTemplate(file); } @@ -118,7 +119,30 @@ public class TemplateUtils { } } }.execute(); + } + /** + * 读取模板文件数据 + * + * @param readCurrentEditingTemplate 是否读取当前编辑模板 + * @param path 模板路径 + * @return + */ + private static byte[] getTemplateData(boolean readCurrentEditingTemplate, String path) throws Exception { + byte[] content = new byte[0]; + if (readCurrentEditingTemplate) { + // 从当前编辑模板中生成备份文件 + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (JTemplate.isValid(template)) { + content = template.exportData(); + } + } else { + content = WorkContext.getWorkResource().readFully(path); + } + if (ArrayUtils.isEmpty(content)) { + throw new Exception(StringUtils.messageFormat("{} content is empty", path)); + } + return content; } private static boolean isCancel(int result) { diff --git a/designer-base/src/main/java/com/fr/design/worker/save/SaveFailureHandler.java b/designer-base/src/main/java/com/fr/design/worker/save/SaveFailureHandler.java index 080b9ddbcd..128064301e 100644 --- a/designer-base/src/main/java/com/fr/design/worker/save/SaveFailureHandler.java +++ b/designer-base/src/main/java/com/fr/design/worker/save/SaveFailureHandler.java @@ -133,14 +133,14 @@ public class SaveFailureHandler implements ThrowableHandler { new Object[] {Toolkit.i18nText("Fine_Design_Template_SaveAs_Backup"), Toolkit.i18nText("Fine-Design_Basic_Button_Cancel")}, null); if (option == JOptionPane.YES_OPTION) { JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (template != null) { + if (JTemplate.isValid(template)) { TemplateUtils.createAndOpenTemplate( Toolkit.i18nText("Fine_Design_Template_Backup"), new FileNodeFILE(new FileNode(template.getPath(), false)), true, - true); - // 创建并打开备份模板后,关闭原模板 - HistoryTemplateListCache.getInstance().closeSelectedReport(template); + true, + // 创建并打开备份模板后,关闭原模板 + () -> HistoryTemplateListCache.getInstance().closeSelectedReport(template)); } } } From be3c8395be08a09eaf08d75c6db2718fb0b211ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvan-=E6=AC=A7=E9=98=B3=E5=B8=86?= Date: Thu, 23 Mar 2023 09:35:36 +0800 Subject: [PATCH 02/23] =?UTF-8?q?REPORT-91503=20=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E9=A2=91=E7=B9=81=E6=8A=A5=E9=94=99=E9=94=81?= =?UTF-8?q?=E5=AE=9A=E4=BF=A1=E6=81=AF=E4=B8=8D=E4=B8=80=E8=87=B4=EF=BC=8C?= =?UTF-8?q?=E5=9C=A8=E8=BF=99=E4=B8=AA=E5=BC=B9=E7=AA=97=E5=8F=A6=E5=AD=98?= =?UTF-8?q?=E4=B8=BA=E4=B8=80=E5=AE=9A=E4=BC=9A=E5=A4=B1=E8=B4=A5=E3=80=82?= =?UTF-8?q?=20=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E5=8C=96=E3=80=81?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/utils/TemplateUtils.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java b/designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java index e82251f4b8..e7d3c3dca3 100644 --- a/designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java @@ -35,12 +35,12 @@ public class TemplateUtils { /** * 创建新的模板文件并打开模板 * - * @param prefix 模板文件名称前缀 - * @param file 模板文件 + * @param prefix 模板文件名称前缀 + * @param file 模板文件 * @param createByEditingTemplate 是否根据 当前编辑模板 来创建新模板 * 为true时以CurrentEditingTemplate为准创建新模板 * 为false时以传入的File文件为准创建新模板,此文件可以不是编辑状态 - * @param openNewTemplate 是否需要在创建后打开模板 + * @param openNewTemplate 是否需要在创建后打开模板 */ public static void createAndOpenTemplate(String prefix, FILE file, boolean createByEditingTemplate, boolean openNewTemplate) { createAndOpenTemplate(prefix, file, createByEditingTemplate, openNewTemplate, () -> {}); @@ -49,13 +49,13 @@ public class TemplateUtils { /** * 创建新的模板文件并打开模板,并在创建备份模板成功后执行doAfterCreate * - * @param prefix 模板文件名称前缀 - * @param file 模板文件 - * @param createByEditingTemplate 是否根据 当前编辑模板 来创建新模板 - * 为true时以CurrentEditingTemplate为准创建新模板 - * 为false时以传入的File文件为准创建新模板,此文件可以不是编辑状态 - * @param openNewTemplate 是否需要在创建后打开模板 - * @param doAfterCreateTemplate 创建备份模板成功后调用 + * @param prefix 模板文件名称前缀 + * @param file 模板文件 + * @param createByEditingTemplate 是否根据 当前编辑模板 来创建新模板 + * 为true时以CurrentEditingTemplate为准创建新模板 + * 为false时以传入的File文件为准创建新模板,此文件可以不是编辑状态 + * @param openNewTemplate 是否需要在创建后打开模板 + * @param doAfterCreateTemplate 创建备份模板成功后调用 */ public static void createAndOpenTemplate(String prefix, FILE file, boolean createByEditingTemplate, boolean openNewTemplate, Runnable doAfterCreateTemplate) { String fileName = file.getName(); @@ -65,7 +65,7 @@ public class TemplateUtils { return; } String suffix = fileName.substring(indexOfLastDot + 1); - FILEChooserPane fileChooserPane = FILEChooserPane.getInstance(true, true); + FILEChooserPane fileChooserPane = FILEChooserPane.getInstance(true, true); fileChooserPane.setFileNameTextField(prefix + fileName, suffix); FileExtension fileExtension = FileExtension.parse(suffix); fileChooserPane.addChooseFILEFilter(new ChooseFileFilter(fileExtension, ProductConstants.APP_NAME + Toolkit.i18nText("Fine-Design_Report_Template_File"))); @@ -91,7 +91,7 @@ public class TemplateUtils { protected Void doInBackground() throws Exception { // 读取模板数据 byte[] content = getTemplateData(createByEditingTemplate, oldPath); - try(OutputStream out = file.asOutputStream()) { + try (OutputStream out = file.asOutputStream()) { // 加锁 WorkContext.getCurrent().get(TplOperator.class).saveAs(file.getPath()); out.write(content); @@ -124,19 +124,20 @@ public class TemplateUtils { /** * 读取模板文件数据 * - * @param readCurrentEditingTemplate 是否读取当前编辑模板 - * @param path 模板路径 - * @return + * @param readCurrentEditingTemplate 是否读取当前编辑模板 + * @param path 模板路径 + * @return 模板文件数据 */ private static byte[] getTemplateData(boolean readCurrentEditingTemplate, String path) throws Exception { byte[] content = new byte[0]; if (readCurrentEditingTemplate) { - // 从当前编辑模板中生成备份文件 + // 从当前编辑模板中读取模板文件数据 JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (JTemplate.isValid(template)) { content = template.exportData(); } } else { + // 从给定的模板路径中读取模板文件数据 content = WorkContext.getWorkResource().readFully(path); } if (ArrayUtils.isEmpty(content)) { From 9f0f3de839867f4de9640c053c3bee0bcf521a7b Mon Sep 17 00:00:00 2001 From: obo Date: Thu, 23 Mar 2023 11:30:02 +0800 Subject: [PATCH 03/23] =?UTF-8?q?REPORT-92304=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8-=E5=9B=BE=E6=A0=87-=E4=B8=89=E8=A7=92=E5=BD=A2?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/constants/UIConstants.java | 20 +++++++++--------- .../icontainer/UIEastResizableContainer.java | 19 ++++++++++++++--- .../mainframe/EastRegionContainerPane.java | 5 ++++- .../fr/design/images/control/down_arrow.png | Bin 218 -> 0 bytes .../fr/design/images/control/east_arrow.png | Bin 241 -> 0 bytes .../com/fr/design/images/control/up_arrow.png | Bin 190 -> 0 bytes .../fr/design/images/control/west_arrow.png | Bin 242 -> 0 bytes .../standard/arrowlinear/down_arrow.svg | 3 +++ .../standard/arrowlinear/east_arrow.svg | 3 +++ .../design/standard/arrowlinear/up_arrow.svg | 3 +++ .../standard/arrowlinear/west_arrow.svg | 3 +++ .../com/fr/design/standard/fileicon/minus.svg | 6 +++--- .../com/fr/design/standard/fileicon/plus.svg | 4 ++-- .../fr/design/standard/floatpop_normal.svg | 13 ++++++------ .../standard/poparrow/pop_down_arrow.svg | 10 +++++++++ .../design/standard/poparrow/pop_up_arrow.svg | 3 +++ .../standard/preview_down_icon_normal.svg | 3 +++ .../standard/triangle.arrow/down_hover.svg | 4 ++-- .../standard/triangle.arrow/down_normal.svg | 2 +- .../standard/triangle.arrow/up_hover.svg | 2 +- .../standard/triangle.arrow/up_normal.svg | 2 +- .../design/cell/bar/DynamicScrollButton.java | 13 ++++++++++-- 22 files changed, 85 insertions(+), 33 deletions(-) delete mode 100644 designer-base/src/main/resources/com/fr/design/images/control/down_arrow.png delete mode 100644 designer-base/src/main/resources/com/fr/design/images/control/east_arrow.png delete mode 100644 designer-base/src/main/resources/com/fr/design/images/control/up_arrow.png delete mode 100644 designer-base/src/main/resources/com/fr/design/images/control/west_arrow.png create mode 100644 designer-base/src/main/resources/com/fr/design/standard/arrowlinear/down_arrow.svg create mode 100644 designer-base/src/main/resources/com/fr/design/standard/arrowlinear/east_arrow.svg create mode 100644 designer-base/src/main/resources/com/fr/design/standard/arrowlinear/up_arrow.svg create mode 100644 designer-base/src/main/resources/com/fr/design/standard/arrowlinear/west_arrow.svg create mode 100644 designer-base/src/main/resources/com/fr/design/standard/poparrow/pop_down_arrow.svg create mode 100644 designer-base/src/main/resources/com/fr/design/standard/poparrow/pop_up_arrow.svg create mode 100644 designer-base/src/main/resources/com/fr/design/standard/preview_down_icon_normal.svg diff --git a/designer-base/src/main/java/com/fr/design/constants/UIConstants.java b/designer-base/src/main/java/com/fr/design/constants/UIConstants.java index da05a79dd5..eba4a5634a 100644 --- a/designer-base/src/main/java/com/fr/design/constants/UIConstants.java +++ b/designer-base/src/main/java/com/fr/design/constants/UIConstants.java @@ -153,10 +153,10 @@ public interface UIConstants { public static final BufferedImage DRAG_BAR = IOUtils.readImage("com/fr/design/images/control/bar.png"); public static final BufferedImage DRAG_BAR_LIGHT = IOUtils.readImage("com/fr/design/images/control/bar-light.png"); - public static final BufferedImage ARROW_NORTH = IOUtils.readImage("com/fr/design/images/control/up_arrow.png"); - public static final BufferedImage ARROW_SOUTH = IOUtils.readImage("com/fr/design/images/control/down_arrow.png"); - public static final BufferedImage ARROW_EAST = IOUtils.readImage("com/fr/design/images/control/east_arrow.png"); - public static final BufferedImage ARROW_WEST = IOUtils.readImage("com/fr/design/images/control/west_arrow.png"); + public static final Image ARROW_NORTH = SVGLoader.load("/com/fr/design/standard/arrowlinear/up_arrow.svg"); + public static final Image ARROW_SOUTH = SVGLoader.load("/com/fr/design/standard/arrowlinear/down_arrow.svg"); + public static final Image ARROW_EAST = SVGLoader.load("/com/fr/design/standard/arrowlinear/east_arrow.svg"); + public static final Image ARROW_WEST = SVGLoader.load("/com/fr/design/standard/arrowlinear/west_arrow.svg"); public static final BufferedImage DRAG_BAR_RIGHT = IOUtils.readImage("com/fr/design/images/control/barm.png"); public static final BufferedImage DRAG_BAR_LEFT = IOUtils.readImage("com/fr/design/images/control/barl.png"); @@ -172,24 +172,24 @@ public interface UIConstants { public static final Image DRAG_LINE = SVGLoader.load("/com/fr/design/standard/dot_line_normal.svg"); public static final BufferedImage ACCESSIBLE_EDITOR_DOT = IOUtils.readImage("com/fr/design/images/control/dot.png"); public static final BufferedImage DRAG_DOT_VERTICAL = IOUtils.readImage("com/fr/design/images/control/dotv.png"); - public static final BufferedImage POP_BUTTON_DOWN = IOUtils.readImage("com/fr/design/images/buttonicon/popdownarrow.png"); - public static final BufferedImage POP_BUTTON_UP = IOUtils.readImage("com/fr/design/images/buttonicon/popuparrow.png"); + public static final Image POP_BUTTON_DOWN = SVGLoader.load("/com/fr/design/standard/poparrow/pop_down_arrow.svg"); + public static final Image POP_BUTTON_UP = SVGLoader.load("/com/fr/design/standard/poparrow/pop_up_arrow.svg"); public static final BufferedImage DRAG_DOWN_SELECTED_SMALL = IOUtils.readImage("com/fr/design/images/buttonicon/downSelected.png"); public static final BufferedImage DRAG_LEFT_NORMAL_SMALL = IOUtils.readImage("com/fr/design/images/buttonicon/leftNormal.png"); public static final BufferedImage WATERMARK_BACKGROUND = IOUtils.readImage("/com/fr/design/images/dialog/watermark/" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_WaterMark_Background_Icon_File_Name")); public static final int MODEL_NORMAL = 0; public static final int MODEL_PRESS = 1; - public static final Icon ARROW_DOWN_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/arrowdown.png"); + public static final Icon ARROW_DOWN_ICON = IconUtils.readIcon("/com/fr/design/standard/arrowlinear/down_arrow.svg"); public static final Icon ARROW_UP_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/arrowup.png"); public static final Icon YES_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/yes.png"); public static final Icon CHOOSEN_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/select_item.png"); public static final Icon PRE_WIDGET_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/prewidget.png"); public static final Icon PRE_WIDGET_NORMAL_ICON = IconUtils.readIcon("com/fr/design/images/buttonicon/prewidget"); public static final Icon EDIT_NORMAL_ICON = IconUtils.readIcon("/com/fr/design/standard/uimode/edit"); - public static final Icon EDIT_PRESSED_ICON = IconUtils.readIcon("/com/fr/design/standard/uimode/edit"); + public static final Icon EDIT_PRESSED_ICON = IconUtils.readIcon("/com/fr/design/standard/uimode/edit_pressed.svg"); public static final Icon HIDE_NORMAL_ICON = IconUtils.readIcon("/com/fr/design/standard/uimode/hide"); - public static final Icon HIDE_PRESSED_ICON = IconUtils.readIcon("/com/fr/design/standard/uimode/hide"); + public static final Icon HIDE_PRESSED_ICON = IconUtils.readIcon("/com/fr/design/standard/uimode/hide_pressed.svg"); public static final Icon VIEW_NORMAL_ICON = IconUtils.readIcon("/com/fr/design/standard/uimode/view"); //public static final Icon VIEW_PRESSED_ICON = IconUtils.readIcon("/com/fr/design/standard/uimode/view"); @@ -221,7 +221,7 @@ public interface UIConstants { public static final int BUTTON_GROUP_ARC = 0; public static final int LARGEARC = 6; public static final Stroke BS = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 2f, new float[]{3, 1}, 0); - public static final Icon PREVIEW_DOWN = IOUtils.readIcon("com/fr/design/images/buttonicon/prevew_down_icon.png"); + public static final Icon PREVIEW_DOWN = IconUtils.readIcon("/com/fr/design/standard/preview_down_icon"); public static final Icon CLOSE_OF_AUTHORITY = IOUtils.readIcon("/com/fr/design/images/m_report/close.png"); public static final Icon CLOSE_OVER_AUTHORITY = IOUtils.readIcon("/com/fr/design/images/m_report/close_over.png"); public static final Icon CLOSE_PRESS_AUTHORITY = IOUtils.readIcon("/com/fr/design/images/m_report/close_press.png"); 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 f00fbee498..ff75221627 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 @@ -5,10 +5,22 @@ import com.fr.design.base.mode.DesignModeContext; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.utils.SvgPaintUtils; import com.fr.design.utils.gui.GUICoreUtils; -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; @@ -313,7 +325,7 @@ public class UIEastResizableContainer extends JPanel { @Override public void paint(Graphics g) { Image button; - + SvgPaintUtils.beforePaint((Graphics2D) g); if (containerWidth == leftPaneWidth) { if (model == UIConstants.MODEL_NORMAL) { button = UIConstants.DRAG_LEFT_NORMAL; @@ -328,6 +340,7 @@ public class UIEastResizableContainer extends JPanel { } } g.drawImage(button, 18, 7, this); + SvgPaintUtils.afterPaint((Graphics2D) g); } } } \ No newline at end of file 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 b033fa6171..00405d6093 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 @@ -19,6 +19,7 @@ import com.fr.design.notification.SnapChat; import com.fr.design.notification.SnapChatFactory; import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.DesignUtils; +import com.fr.design.utils.SvgPaintUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.log.FineLoggerFactory; @@ -1313,7 +1314,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } else { button = UIConstants.POP_BUTTON_UP; } - g.drawImage(button, ARROW_RANGE_START + 8, 4, 16, 16, null); + SvgPaintUtils.beforePaint((Graphics2D) g); + g.drawImage(button, ARROW_RANGE_START + 8, 4, null); + SvgPaintUtils.afterPaint((Graphics2D) g); } } diff --git a/designer-base/src/main/resources/com/fr/design/images/control/down_arrow.png b/designer-base/src/main/resources/com/fr/design/images/control/down_arrow.png deleted file mode 100644 index 26a780d5e2858e01e9c1fa4baa98674754d3a238..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 218 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|rg*wIhFAzD zCrGef;cZ;DOzm!48=G;=vZf~vSreYloM8F?-`~e9k8~YeznyrbU>2~M*@JHhTV$W) z%;E|G%P#T*`y{`|HCuZ`jas?fP|j=WB;M&NOaxlyYcm zFljiF@MhPpUCjoj22!gT6+Bl=4sX1n(7Yj&?c_sN2j?>m66+TQdY*D-U?}x+agbD+ RQU`P&gQu&X%Q~loCIE&}SR?=d diff --git a/designer-base/src/main/resources/com/fr/design/images/control/east_arrow.png b/designer-base/src/main/resources/com/fr/design/images/control/east_arrow.png deleted file mode 100644 index 918d75a9f910fdabb1e3f79faac235803684e51a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 241 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|R(rZQhFAzD zCrHd&uyUp6_Js=%_DI|}Obq_={=U7R!aXLF6LPa{Hc1#8u^+Q5cyJ&%J^gub{l7nv zyoTd0x1ULBNs1z{BnPPeK_;WW`*escQa&5EYLo5{CGBl zhCpNE&aT#0RS^m8qa90 diff --git a/designer-base/src/main/resources/com/fr/design/images/control/west_arrow.png b/designer-base/src/main/resources/com/fr/design/images/control/west_arrow.png deleted file mode 100644 index 5693190f9646d3cf5fca20ff24bf9d114e07c833..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 242 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|)_A%&hFAzD zCrC&xSh(=unw2X(#b@Ww+`y^S&1h=<=lAz~Zh>N@?!z}Kco}YG@n6}|)!M2ml5s(E zhFZ!j!I{lx*fRfpette{!n0kwb~T?UI+3%6t>F((k(uIIh2{@cj5pO{a?)~y*!g5C zUcGr!!}Ww!U~m2Zf9*G}G#=R?#W0B>Q|Xw%9JT{Ig(W36f4{%Kf7Ria!iiLc!W0Js po(9IMhR)8D>>c}+vt`_J820A+P5iQ={VdSk44$rjF6*2UngD4wV8H+Y diff --git a/designer-base/src/main/resources/com/fr/design/standard/arrowlinear/down_arrow.svg b/designer-base/src/main/resources/com/fr/design/standard/arrowlinear/down_arrow.svg new file mode 100644 index 0000000000..fc5d318bf7 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/standard/arrowlinear/down_arrow.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/standard/arrowlinear/east_arrow.svg b/designer-base/src/main/resources/com/fr/design/standard/arrowlinear/east_arrow.svg new file mode 100644 index 0000000000..b4b54dea89 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/standard/arrowlinear/east_arrow.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/standard/arrowlinear/up_arrow.svg b/designer-base/src/main/resources/com/fr/design/standard/arrowlinear/up_arrow.svg new file mode 100644 index 0000000000..cf615f3f37 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/standard/arrowlinear/up_arrow.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/standard/arrowlinear/west_arrow.svg b/designer-base/src/main/resources/com/fr/design/standard/arrowlinear/west_arrow.svg new file mode 100644 index 0000000000..d5260bfd0f --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/standard/arrowlinear/west_arrow.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/standard/fileicon/minus.svg b/designer-base/src/main/resources/com/fr/design/standard/fileicon/minus.svg index 067df99f84..db4e76f2a9 100644 --- a/designer-base/src/main/resources/com/fr/design/standard/fileicon/minus.svg +++ b/designer-base/src/main/resources/com/fr/design/standard/fileicon/minus.svg @@ -1,3 +1,3 @@ - - - + + + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/standard/fileicon/plus.svg b/designer-base/src/main/resources/com/fr/design/standard/fileicon/plus.svg index c2b0e9d9c4..f012490aee 100644 --- a/designer-base/src/main/resources/com/fr/design/standard/fileicon/plus.svg +++ b/designer-base/src/main/resources/com/fr/design/standard/fileicon/plus.svg @@ -1,3 +1,3 @@ - - + + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/standard/floatpop_normal.svg b/designer-base/src/main/resources/com/fr/design/standard/floatpop_normal.svg index 95806104dc..a9e45f1c8d 100644 --- a/designer-base/src/main/resources/com/fr/design/standard/floatpop_normal.svg +++ b/designer-base/src/main/resources/com/fr/design/standard/floatpop_normal.svg @@ -1,9 +1,8 @@ - - icon_悬浮元素&三角_normal - - - - + + + + + - + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/standard/poparrow/pop_down_arrow.svg b/designer-base/src/main/resources/com/fr/design/standard/poparrow/pop_down_arrow.svg new file mode 100644 index 0000000000..8e4260b37d --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/standard/poparrow/pop_down_arrow.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/standard/poparrow/pop_up_arrow.svg b/designer-base/src/main/resources/com/fr/design/standard/poparrow/pop_up_arrow.svg new file mode 100644 index 0000000000..5c797c1f03 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/standard/poparrow/pop_up_arrow.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/standard/preview_down_icon_normal.svg b/designer-base/src/main/resources/com/fr/design/standard/preview_down_icon_normal.svg new file mode 100644 index 0000000000..da4dd8c300 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/standard/preview_down_icon_normal.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/down_hover.svg b/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/down_hover.svg index f83d881a5d..68870b99dd 100644 --- a/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/down_hover.svg +++ b/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/down_hover.svg @@ -1,3 +1,3 @@ - - + + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/down_normal.svg b/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/down_normal.svg index 478b58eba7..db4e76f2a9 100644 --- a/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/down_normal.svg +++ b/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/down_normal.svg @@ -1,3 +1,3 @@ - + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/up_hover.svg b/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/up_hover.svg index 67045e796a..1b7312ff6e 100644 --- a/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/up_hover.svg +++ b/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/up_hover.svg @@ -1,3 +1,3 @@ - + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/up_normal.svg b/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/up_normal.svg index 2297284274..f767fbcf31 100644 --- a/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/up_normal.svg +++ b/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/up_normal.svg @@ -1,3 +1,3 @@ - + \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/cell/bar/DynamicScrollButton.java b/designer-realize/src/main/java/com/fr/design/cell/bar/DynamicScrollButton.java index 20bb70d668..b250119510 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/bar/DynamicScrollButton.java +++ b/designer-realize/src/main/java/com/fr/design/cell/bar/DynamicScrollButton.java @@ -1,11 +1,18 @@ package com.fr.design.cell.bar; import com.fr.design.constants.UIConstants; +import com.fr.design.utils.SvgPaintUtils; import com.fr.general.ComparatorUtils; -import javax.swing.*; +import javax.swing.SwingConstants; import javax.swing.plaf.basic.BasicArrowButton; -import java.awt.*; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GradientPaint; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Insets; import java.awt.image.BufferedImage; import java.util.HashMap; @@ -62,6 +69,7 @@ public class DynamicScrollButton extends BasicArrowButton { private void paintArrow(Graphics g, Dimension size) { + SvgPaintUtils.beforePaint((Graphics2D) g); switch (direction) { case SwingConstants.NORTH: g.drawImage(UIConstants.ARROW_NORTH, 0, 0, this); @@ -76,6 +84,7 @@ public class DynamicScrollButton extends BasicArrowButton { g.drawImage(UIConstants.ARROW_WEST, 0, 0, this); break; } + SvgPaintUtils.afterPaint((Graphics2D) g); } From 83ecaed30f28ba13630f5c594283ea284eb3e686 Mon Sep 17 00:00:00 2001 From: obo Date: Thu, 23 Mar 2023 12:07:02 +0800 Subject: [PATCH 04/23] =?UTF-8?q?REPORT-92304=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8-=E5=9B=BE=E6=A0=87-=E4=B8=89=E8=A7=92=E5=BD=A2?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E6=9B=B4=E6=96=B0,=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E4=B8=8BSvgPaintUtils=E7=9A=84=E5=A4=84=E7=90=86=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/icontainer/UIEastResizableContainer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ff75221627..c8cfadd0fd 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 @@ -325,7 +325,6 @@ public class UIEastResizableContainer extends JPanel { @Override public void paint(Graphics g) { Image button; - SvgPaintUtils.beforePaint((Graphics2D) g); if (containerWidth == leftPaneWidth) { if (model == UIConstants.MODEL_NORMAL) { button = UIConstants.DRAG_LEFT_NORMAL; @@ -339,6 +338,7 @@ public class UIEastResizableContainer extends JPanel { button = UIConstants.DRAG_RIGHT_PRESS; } } + SvgPaintUtils.beforePaint((Graphics2D) g); g.drawImage(button, 18, 7, this); SvgPaintUtils.afterPaint((Graphics2D) g); } From 6c34870789d45bfb4eacc25eec6348455a3ced1b Mon Sep 17 00:00:00 2001 From: loy Date: Thu, 23 Mar 2023 13:50:45 +0800 Subject: [PATCH 05/23] =?UTF-8?q?REPORT-92325=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=88=9D=E5=A7=8B=E5=8C=96=E4=B9=8B=E5=89=8D?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E8=BF=9C=E7=A8=8B=E8=AE=BE=E8=AE=A1=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=AF=BC=E8=87=B4NPE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/mainframe/vcs/common/VcsHelper.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java index 0c8924e9d0..dd7187be23 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java @@ -68,7 +68,11 @@ public class VcsHelper implements JTemplateActionListener { } private VcsHelper() { - legacyMode = WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); + VcsOperator op = WorkContext.getCurrent().get(VcsOperator.class); + // 开了设计器启动页面时一开始取不到VcsOperator,通过下面的切换环境事件再取,这边判断下 + if (op != null) { + legacyMode = op.isLegacyMode(); + } EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener() { @Override public void on(Event event, Workspace param) { From 006ae013d30f39735859f7150c8882786fb788da Mon Sep 17 00:00:00 2001 From: loy Date: Thu, 23 Mar 2023 20:09:39 +0800 Subject: [PATCH 06/23] =?UTF-8?q?REPORT-80651=20=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E7=AE=A1=E7=90=86=E9=87=8D=E6=9E=84=E4=B8=80?= =?UTF-8?q?=E6=9C=9F=EF=BC=88=E5=9C=A811.0.15=E4=B8=8A=E5=9B=9E=E6=BB=9A?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Revert "REPORT-92325 修复环境初始化之前调用远程设计接口导致NPE问题" Revert "REPORT-92308 版本管理可用性判断逻辑适配新模式" Revert "REPORT-80651 模板版本管理重构一期" --- .../design/actions/file/PreferencePane.java | 5 +-- .../DesignerFrameFileDealerPane.java | 9 +--- .../mainframe/vcs/common/VcsHelper.java | 41 ++++--------------- 3 files changed, 10 insertions(+), 45 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index a83bcfd771..46485409bb 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -390,10 +390,7 @@ public class PreferencePane extends BasicPane { vcsPane.add(enableVcsPanel); vcsPane.add(intervalPanel); vcsPane.add(saveCommitCheckBox); - if (VcsHelper.getInstance().isLegacyMode()) { - // 老版本时才显示gc选项 - vcsPane.add(gcControlPane); - } + vcsPane.add(gcControlPane); } /** diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index d21dd1b7cf..8cfd263421 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -325,7 +325,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt if (VcsHelper.getInstance().needInit()) { vcsAction = new VcsAction(); - if (!isLegacyOnCluster()) { + if (!WorkContext.getCurrent().isCluster()) { vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_Title")); } else { vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_NotSupportRemote")); @@ -509,7 +509,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt private void fireVcsActionChange(boolean enable) { if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() || VcsHelper.getInstance().isUnSelectedTemplate() - || isLegacyOnCluster()) { + || WorkContext.getCurrent().isCluster()) { setEnabled(false); return; } @@ -810,11 +810,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt } } - private boolean isLegacyOnCluster() { - // 老模式且为集群,用于代替之前的只判断集群逻辑 - return WorkContext.getCurrent().isCluster() && VcsHelper.getInstance().isLegacyMode(); - } - private String doCheck (String userInput, String suffix) { String errorMsg = StringUtils.EMPTY; if (selectedOperation.duplicated(userInput, suffix, true)) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java index dd7187be23..980ccb5a3a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java @@ -12,9 +12,6 @@ import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplateActionListener; import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.mainframe.vcs.ui.FileVersionTable; -import com.fr.event.Event; -import com.fr.event.EventDispatcher; -import com.fr.event.Listener; import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginContext; @@ -23,14 +20,11 @@ import com.fr.report.entity.VcsEntity; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; -import com.fr.workspace.Workspace; -import com.fr.workspace.WorkspaceEvent; import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.filesystem.VcsFileSystem; import com.fr.workspace.server.vcs.git.config.GcConfig; import javax.swing.Icon; -import javax.swing.SwingUtilities; import javax.swing.border.EmptyBorder; import java.awt.Color; import java.util.List; @@ -61,26 +55,10 @@ public class VcsHelper implements JTemplateActionListener { private final static String SERVICE_NAME_MOVE = "moveVcs"; private static final VcsHelper INSTANCE = new VcsHelper(); - private volatile boolean legacyMode; - public static VcsHelper getInstance() { return INSTANCE; } - private VcsHelper() { - VcsOperator op = WorkContext.getCurrent().get(VcsOperator.class); - // 开了设计器启动页面时一开始取不到VcsOperator,通过下面的切换环境事件再取,这边判断下 - if (op != null) { - legacyMode = op.isLegacyMode(); - } - EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener() { - @Override - public void on(Event event, Workspace param) { - legacyMode = WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); - } - }); - } - private int containsFolderCounts() { TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); if (fileTree.getSelectionPaths() == null) { @@ -159,18 +137,20 @@ public class VcsHelper implements JTemplateActionListener { String fileName = getEditingFilename(); VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class); VcsEntity entity = operator.getFileVersionByIndex(fileName, 0); - boolean replace = needDeleteVersion(entity); int latestFileVersion = 0; if (entity != null) { latestFileVersion = entity.getVersion(); } if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) { - operator.saveVersionFromCache(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1, replace); + operator.saveVersionFromCache(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1); String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); - List updatedList = WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY)); - SwingUtilities.invokeLater(() -> FileVersionTable.getInstance().updateModel(1, updatedList)); + FileVersionTable.getInstance().updateModel(1, WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY))); } else { - operator.saveVersion(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1, replace); + operator.saveVersion(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1); + } + VcsEntity oldEntity = WorkContext.getCurrent().get(VcsOperator.class).getFileVersionByIndexAndUsername(fileName, getCurrentUsername(), 1); + if (needDeleteVersion(oldEntity)) { + operator.deleteVersion(oldEntity.getFilename(), oldEntity.getVersion()); } if (GcConfig.getInstance().isGcEnable()) { operator.gc(); @@ -208,13 +188,6 @@ public class VcsHelper implements JTemplateActionListener { moveVcs.shutdown(); } - /** - * 判断是否为老模式 - * @return 是否为老模式 - */ - public boolean isLegacyMode() { - return legacyMode; - } @Override public void templateOpened(JTemplate jt) { From fe85bf97116dc844a808cbfcb1f439222f56131d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvan-=E6=AC=A7=E9=98=B3=E5=B8=86?= Date: Fri, 24 Mar 2023 11:44:32 +0800 Subject: [PATCH 07/23] =?UTF-8?q?REPORT-91503=20=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E9=A2=91=E7=B9=81=E6=8A=A5=E9=94=99=E9=94=81?= =?UTF-8?q?=E5=AE=9A=E4=BF=A1=E6=81=AF=E4=B8=8D=E4=B8=80=E8=87=B4=EF=BC=8C?= =?UTF-8?q?=E5=9C=A8=E8=BF=99=E4=B8=AA=E5=BC=B9=E7=AA=97=E5=8F=A6=E5=AD=98?= =?UTF-8?q?=E4=B8=BA=E4=B8=80=E5=AE=9A=E4=BC=9A=E5=A4=B1=E8=B4=A5=E3=80=82?= =?UTF-8?q?=20=E5=A4=84=E7=90=86=E5=88=9B=E5=BB=BA=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=A4=87=E4=BB=BD=E6=96=87=E4=BB=B6=E6=97=B6=E7=9A=84=E9=94=81?= =?UTF-8?q?=E5=AE=9A=E9=97=AE=E9=A2=98=EF=BC=8C=E4=BB=A5=E5=8F=8A=E9=94=81?= =?UTF-8?q?=E5=AE=9A=E5=8F=AF=E8=83=BD=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/utils/TemplateUtils.java | 34 +++++++++++++------ .../worker/save/SaveFailureHandler.java | 2 +- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java b/designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java index e7d3c3dca3..ce01d9992f 100644 --- a/designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java @@ -85,28 +85,42 @@ public class TemplateUtils { private static void createAndOpenTemplate0(FILE file, String oldPath, boolean createByEditingTemplate, boolean openNewTemplate, Runnable doAfterCreateTemplate) { - new SwingWorker() { + new SwingWorker() { @Override - protected Void doInBackground() throws Exception { + protected Boolean doInBackground() throws Exception { // 读取模板数据 byte[] content = getTemplateData(createByEditingTemplate, oldPath); - try (OutputStream out = file.asOutputStream()) { + OutputStream out = null; + try { // 加锁 - WorkContext.getCurrent().get(TplOperator.class).saveAs(file.getPath()); + boolean saveAsLock = WorkContext.getCurrent().get(TplOperator.class).saveAs(file.getPath()); + if (!saveAsLock) { + // 加锁失败时,直接返回 + return false; + } + out = file.asOutputStream(); out.write(content); } finally { - // 解锁 - WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(file.getPath()); + try { + if (out != null) { + out.close(); + } + } finally { + // 解锁 + WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(file.getPath()); + } } - return null; + return true; } @Override protected void done() { try { - get(); - // 创建备份成功后 + if (!get()) { + throw new Exception("[RemoteDesign] back up template file failed"); + } + // 创建备份成功后,关闭原模板 doAfterCreateTemplate.run(); if (openNewTemplate) { DesignerContext.getDesignerFrame().openTemplate(file); @@ -126,7 +140,7 @@ public class TemplateUtils { * * @param readCurrentEditingTemplate 是否读取当前编辑模板 * @param path 模板路径 - * @return 模板文件数据 + * @return 模板文件数据 */ private static byte[] getTemplateData(boolean readCurrentEditingTemplate, String path) throws Exception { byte[] content = new byte[0]; diff --git a/designer-base/src/main/java/com/fr/design/worker/save/SaveFailureHandler.java b/designer-base/src/main/java/com/fr/design/worker/save/SaveFailureHandler.java index 128064301e..119668ec68 100644 --- a/designer-base/src/main/java/com/fr/design/worker/save/SaveFailureHandler.java +++ b/designer-base/src/main/java/com/fr/design/worker/save/SaveFailureHandler.java @@ -139,7 +139,7 @@ public class SaveFailureHandler implements ThrowableHandler { new FileNodeFILE(new FileNode(template.getPath(), false)), true, true, - // 创建并打开备份模板后,关闭原模板 + // 创建并打开备份模板后,关闭原模板,无需释放原模板锁(锁定信息不一致 = 此用户模板锁信息已被清除) () -> HistoryTemplateListCache.getInstance().closeSelectedReport(template)); } } From f51f25b8598a5403eb0b470b8767d48a167e097a Mon Sep 17 00:00:00 2001 From: obo Date: Fri, 24 Mar 2023 14:58:12 +0800 Subject: [PATCH 08/23] =?UTF-8?q?REPORT-92304=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8-=E5=9B=BE=E6=A0=87-=E4=B8=89=E8=A7=92=E5=BD=A2?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/com/fr/design/standard/drag/left_normal.svg | 2 +- .../main/resources/com/fr/design/standard/drag/left_pressed.svg | 2 +- .../main/resources/com/fr/design/standard/drag/right_normal.svg | 2 +- .../resources/com/fr/design/standard/drag/right_pressed.svg | 2 +- .../com/fr/design/standard/triangle.arrow/down_hover.svg | 2 +- .../com/fr/design/standard/triangle.arrow/down_normal.svg | 2 +- .../com/fr/design/standard/triangle.arrow/up_hover.svg | 2 +- .../com/fr/design/standard/triangle.arrow/up_normal.svg | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/designer-base/src/main/resources/com/fr/design/standard/drag/left_normal.svg b/designer-base/src/main/resources/com/fr/design/standard/drag/left_normal.svg index 0809e2e261..d20fea5a83 100644 --- a/designer-base/src/main/resources/com/fr/design/standard/drag/left_normal.svg +++ b/designer-base/src/main/resources/com/fr/design/standard/drag/left_normal.svg @@ -1,3 +1,3 @@ - + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/standard/drag/left_pressed.svg b/designer-base/src/main/resources/com/fr/design/standard/drag/left_pressed.svg index 7f293e9a15..db0dca3958 100644 --- a/designer-base/src/main/resources/com/fr/design/standard/drag/left_pressed.svg +++ b/designer-base/src/main/resources/com/fr/design/standard/drag/left_pressed.svg @@ -1,3 +1,3 @@ - + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/standard/drag/right_normal.svg b/designer-base/src/main/resources/com/fr/design/standard/drag/right_normal.svg index a9bc6d2c6b..4b3cb3aadd 100644 --- a/designer-base/src/main/resources/com/fr/design/standard/drag/right_normal.svg +++ b/designer-base/src/main/resources/com/fr/design/standard/drag/right_normal.svg @@ -1,3 +1,3 @@ - + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/standard/drag/right_pressed.svg b/designer-base/src/main/resources/com/fr/design/standard/drag/right_pressed.svg index 7fa6c4e056..fafe763882 100644 --- a/designer-base/src/main/resources/com/fr/design/standard/drag/right_pressed.svg +++ b/designer-base/src/main/resources/com/fr/design/standard/drag/right_pressed.svg @@ -1,3 +1,3 @@ - + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/down_hover.svg b/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/down_hover.svg index 68870b99dd..b89e826352 100644 --- a/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/down_hover.svg +++ b/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/down_hover.svg @@ -1,3 +1,3 @@ - + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/down_normal.svg b/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/down_normal.svg index db4e76f2a9..597fe8c9c6 100644 --- a/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/down_normal.svg +++ b/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/down_normal.svg @@ -1,3 +1,3 @@ - + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/up_hover.svg b/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/up_hover.svg index 1b7312ff6e..9ddff69714 100644 --- a/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/up_hover.svg +++ b/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/up_hover.svg @@ -1,3 +1,3 @@ - + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/up_normal.svg b/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/up_normal.svg index f767fbcf31..cfd49c95d1 100644 --- a/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/up_normal.svg +++ b/designer-base/src/main/resources/com/fr/design/standard/triangle.arrow/up_normal.svg @@ -1,3 +1,3 @@ - + \ No newline at end of file From e59b18264a0427e15c42c88b18a7aa4376d65a1e Mon Sep 17 00:00:00 2001 From: obo Date: Fri, 24 Mar 2023 14:59:25 +0800 Subject: [PATCH 09/23] =?UTF-8?q?REPORT-92440=20mac-=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=BA=90=E5=B8=A6=E5=8F=B9=E5=8F=B7=E7=9A=84=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/icon/WarningIcon.java | 26 +++++++++++++------ .../com/fr/design/utils/SvgPaintUtils.java | 3 ++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java b/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java index 08d5b5a55a..025033d735 100644 --- a/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java +++ b/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java @@ -1,12 +1,17 @@ package com.fr.design.icon; import com.fr.base.svg.SVGLoader; +import com.fr.base.svg.SystemScaleUtils; import com.fr.design.utils.SvgPaintUtils; import com.fr.log.FineLoggerFactory; import javax.swing.GrayFilter; import javax.swing.ImageIcon; -import java.awt.*; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.MediaTracker; import java.awt.image.ImageObserver; /** @@ -20,7 +25,8 @@ public class WarningIcon extends ImageIcon { }; protected final static MediaTracker TRACKER = new MediaTracker(COMPONENT); private final static Image WARNING_IMAGE = SVGLoader.load("/com/fr/design/standard/warning.svg"); - + private static final boolean HI_DPI_SUPPORT = SystemScaleUtils.isJreHiDPIEnabled(); + public static final float SYSTEM_SCALE = SystemScaleUtils.sysScale(); private Image mainImage = null; private ImageObserver imageObserver; private int width = -1; @@ -36,14 +42,16 @@ public class WarningIcon extends ImageIcon { @Override public synchronized void paintIcon(Component c, Graphics g, int x, int y) { - SvgPaintUtils.beforePaint((Graphics2D) g); + //裁剪绘制svg的位置,以免影响到图标右侧的文字 + Graphics2D graphics = (Graphics2D) g.create(x, y, WARNING_IMAGE.getWidth(null), WARNING_IMAGE.getHeight(null)); + SvgPaintUtils.beforePaint(graphics); if (mainImage != null) { - g.drawImage(mainImage, x, y, c); + graphics.drawImage(mainImage, x, y, null); } if (WARNING_IMAGE != null) { - g.drawImage(WARNING_IMAGE, x, y, c); + graphics.drawImage(WARNING_IMAGE, x, y, null); } - SvgPaintUtils.afterPaint((Graphics2D) g); + SvgPaintUtils.afterPaint(graphics); } /** @@ -91,7 +99,8 @@ public class WarningIcon extends ImageIcon { * @return the width in pixels of this icon */ public int getIconWidth() { - return width; + //如果环境支持高清化,drawImage可能会缩放绘制的图像比例,需要保证svg正常显示的同时调整绘制范围 + return HI_DPI_SUPPORT ? (int) (width / SYSTEM_SCALE) : width; } /** @@ -100,7 +109,8 @@ public class WarningIcon extends ImageIcon { * @return the height in pixels of this icon */ public int getIconHeight() { - return height; + //如果环境支持高清化,drawImage可能会缩放绘制的图像比例,需要保证svg正常显示的同时调整绘制范围 + return HI_DPI_SUPPORT ? (int) (height / SYSTEM_SCALE) : height; } { diff --git a/designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java b/designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java index fdb460eb41..a51783d8fa 100644 --- a/designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java @@ -2,6 +2,7 @@ package com.fr.design.utils; import com.fr.base.svg.SVGLoader; import com.fr.base.svg.SystemScaleUtils; + import java.awt.Graphics2D; /** @@ -21,7 +22,7 @@ public class SvgPaintUtils { public static void afterPaint(Graphics2D g2) { if (SystemScaleUtils.isJreHiDPIEnabled()) { - g2.scale(SVGLoader.SYSTEM_SCALE, SVGLoader.SYSTEM_SCALE); + g2.scale(1.0D, 1.0D); } } From 9277d913817c69db8796186844c66e5dc4e366f5 Mon Sep 17 00:00:00 2001 From: obo Date: Fri, 24 Mar 2023 15:00:40 +0800 Subject: [PATCH 10/23] =?UTF-8?q?REPORT-92439=20mac=E4=B8=8B-=E5=B1=95?= =?UTF-8?q?=E5=BC=80=E6=94=B6=E8=B5=B7=E5=9B=BE=E6=A0=87=E7=9A=84=E9=97=AE?= =?UTF-8?q?=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); } } From 5df6bf5477ff065e9d430c021fa2f7c42f01f76c Mon Sep 17 00:00:00 2001 From: obo Date: Fri, 24 Mar 2023 15:46:19 +0800 Subject: [PATCH 11/23] =?UTF-8?q?REPORT-92439=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BA=86=E8=AE=A1=E7=AE=97svg=E4=BD=8D=E7=BD=AEx,y=E7=9A=84?= =?UTF-8?q?=E5=86=99=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../icontainer/UIEastResizableContainer.java | 6 +---- .../gui/icontainer/UIResizableContainer.java | 18 ++++---------- .../mainframe/EastRegionContainerPane.java | 6 +---- .../com/fr/design/utils/SvgPaintUtils.java | 24 +++++++++++++++++-- 4 files changed, 28 insertions(+), 26 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 17511d391e..2a9fcacb82 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,8 +1,6 @@ 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; @@ -342,9 +340,7 @@ public class UIEastResizableContainer extends JPanel { } SvgPaintUtils.beforePaint((Graphics2D) g); //如果环境支持高清化,在调整缩放比例时绘制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); + g.drawImage(button, SvgPaintUtils.calculatePositionX(10), SvgPaintUtils.calculatePositionY(7), 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 cbc175a0d9..44806b3bf9 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,7 +1,5 @@ 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; @@ -29,8 +27,6 @@ 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; @@ -428,12 +424,9 @@ public class UIResizableContainer extends JPanel { g.drawImage(UIConstants.DRAG_BAR_LIGHT, 0, 0, getWidth(), getHeight(), null); SvgPaintUtils.beforePaint((Graphics2D) g); //如果环境支持高清化,在调整缩放比例时绘制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(UIConstants.DRAG_LINE, SvgPaintUtils.calculatePositionX((getWidth() - toolPaneHeight) / 2), SvgPaintUtils.calculatePositionY(3), null); g.drawImage(upButton, ARROW_MARGIN, 0, null); - g.drawImage(downButton, downButtonX, 0, null); + g.drawImage(downButton, SvgPaintUtils.calculatePositionX(getWidth() - toolPaneHeight - ARROW_MARGIN), 0, null); SvgPaintUtils.afterPaint((Graphics2D) g); } } @@ -533,9 +526,7 @@ public class UIResizableContainer extends JPanel { } 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); + g.drawImage(button, SvgPaintUtils.calculatePositionX(-6), SvgPaintUtils.calculatePositionY(ARROW_MARGIN_VERTICAL), this); SvgPaintUtils.afterPaint((Graphics2D) g); } else { g.drawImage(UIConstants.DRAG_BAR_LIGHT, 0, 0, toolPaneHeight, getHeight(), null); @@ -552,8 +543,7 @@ public class UIResizableContainer extends JPanel { button = UIConstants.DRAG_RIGHT_PRESS; } } - int x = HI_DPI_SUPPORT ? (int) (10 * SVGLoader.SYSTEM_SCALE) : 10; - g.drawImage(button, x, ARROW_MARGIN_VERTICAL, this); + g.drawImage(button, SvgPaintUtils.calculatePositionX(10), 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 7ac1aac409..b460e1e31d 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,8 +2,6 @@ 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; @@ -1318,9 +1316,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } SvgPaintUtils.beforePaint((Graphics2D) g); //如果环境支持高清化,在调整缩放比例时绘制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); + g.drawImage(button, SvgPaintUtils.calculatePositionX(ARROW_RANGE_START + 8), SvgPaintUtils.calculatePositionY(4), null); SvgPaintUtils.afterPaint((Graphics2D) g); } } diff --git a/designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java b/designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java index a51783d8fa..85e34caba2 100644 --- a/designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java @@ -14,16 +14,36 @@ import java.awt.Graphics2D; */ public class SvgPaintUtils { + private static final boolean HI_DPI_ENABLED = SystemScaleUtils.isJreHiDPIEnabled(); + public static void beforePaint(Graphics2D g2) { - if (SystemScaleUtils.isJreHiDPIEnabled()) { + if (HI_DPI_ENABLED) { g2.scale(1 / SVGLoader.SYSTEM_SCALE, 1 / SVGLoader.SYSTEM_SCALE); } } public static void afterPaint(Graphics2D g2) { - if (SystemScaleUtils.isJreHiDPIEnabled()) { + if (HI_DPI_ENABLED) { g2.scale(1.0D, 1.0D); } } + /** + * 计算高缩放下绘制svg图标时新的的位置x + * @param x 旧x的值 + * @return 新的x值 + * */ + public static int calculatePositionX(int x) { + return HI_DPI_ENABLED ? (int) (x * SVGLoader.SYSTEM_SCALE) : x; + } + + /** + * 计算高缩放下绘制svg图标时新的的位置y + * @param y 旧y的值 + * @return 新的y值 + * */ + public static int calculatePositionY(int y) { + return HI_DPI_ENABLED ? (int) (y * SVGLoader.SYSTEM_SCALE) : y; + } + } From 810f67af613136a1a293556314d3ba2c8b117e79 Mon Sep 17 00:00:00 2001 From: obo Date: Fri, 24 Mar 2023 19:59:13 +0800 Subject: [PATCH 12/23] =?UTF-8?q?REPORT-92440=20mac-=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=BA=90=E5=B8=A6=E5=8F=B9=E5=8F=B7=E7=9A=84=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/icon/WarningIcon.java | 19 ++++++++--- .../com/fr/design/utils/SvgPaintWorker.java | 33 +++++++++++++++++++ 2 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/utils/SvgPaintWorker.java diff --git a/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java b/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java index 025033d735..20e6462569 100644 --- a/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java +++ b/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java @@ -2,7 +2,7 @@ package com.fr.design.icon; import com.fr.base.svg.SVGLoader; import com.fr.base.svg.SystemScaleUtils; -import com.fr.design.utils.SvgPaintUtils; +import com.fr.design.utils.SvgPaintWorker; import com.fr.log.FineLoggerFactory; import javax.swing.GrayFilter; @@ -44,14 +44,23 @@ public class WarningIcon extends ImageIcon { public synchronized void paintIcon(Component c, Graphics g, int x, int y) { //裁剪绘制svg的位置,以免影响到图标右侧的文字 Graphics2D graphics = (Graphics2D) g.create(x, y, WARNING_IMAGE.getWidth(null), WARNING_IMAGE.getHeight(null)); - SvgPaintUtils.beforePaint(graphics); if (mainImage != null) { - graphics.drawImage(mainImage, x, y, null); + new SvgPaintWorker(graphics) { + @Override + protected void doPrint() { + this.drawImage(mainImage, x, y, null); + } + }.execute(); } if (WARNING_IMAGE != null) { - graphics.drawImage(WARNING_IMAGE, x, y, null); + new SvgPaintWorker(graphics) { + @Override + protected void doPrint() { + this.drawImage(WARNING_IMAGE, x, y, null); + } + }.execute(); } - SvgPaintUtils.afterPaint(graphics); + graphics.dispose(); } /** diff --git a/designer-base/src/main/java/com/fr/design/utils/SvgPaintWorker.java b/designer-base/src/main/java/com/fr/design/utils/SvgPaintWorker.java new file mode 100644 index 0000000000..321e8b05d7 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/utils/SvgPaintWorker.java @@ -0,0 +1,33 @@ +package com.fr.design.utils; + +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.image.ImageObserver; + +/** + * SVG图标绘制器 + * + * @author obo + * @since 11.0 + * Created on 2023/3/24 + */ +abstract public class SvgPaintWorker { + + private final Graphics graphics; + public SvgPaintWorker(Graphics g) { + graphics = g; + } + + protected abstract void doPrint(); + protected void drawImage(Image image, int x, int y, ImageObserver imageObserver) { + //如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整 + graphics.drawImage(image, SvgPaintUtils.calculatePosition(x), SvgPaintUtils.calculatePosition(y), imageObserver); + } + + public void execute() { + SvgPaintUtils.beforePaint((Graphics2D) graphics); + doPrint(); + SvgPaintUtils.afterPaint((Graphics2D) graphics); + } +} From d7d7fd53269f4650a00bcdbb1ed753eb4f875454 Mon Sep 17 00:00:00 2001 From: obo Date: Fri, 24 Mar 2023 20:03:35 +0800 Subject: [PATCH 13/23] =?UTF-8?q?REPORT-92439=20mac=E4=B8=8B-=E5=B1=95?= =?UTF-8?q?=E5=BC=80=E6=94=B6=E8=B5=B7=E5=9B=BE=E6=A0=87=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/base/svg/SVGIcon.java | 17 ++++--- .../icontainer/UIEastResizableContainer.java | 12 ++--- .../gui/icontainer/UIResizableContainer.java | 44 +++++++++++++------ .../mainframe/EastRegionContainerPane.java | 12 ++--- .../com/fr/design/utils/SvgPaintUtils.java | 22 +++------- 5 files changed, 62 insertions(+), 45 deletions(-) diff --git a/designer-base/src/main/java/com/fr/base/svg/SVGIcon.java b/designer-base/src/main/java/com/fr/base/svg/SVGIcon.java index 172b10dac5..a15b2118d3 100644 --- a/designer-base/src/main/java/com/fr/base/svg/SVGIcon.java +++ b/designer-base/src/main/java/com/fr/base/svg/SVGIcon.java @@ -1,9 +1,12 @@ package com.fr.base.svg; +import com.fr.design.utils.SvgPaintWorker; import com.fr.general.IOUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.Icon; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -34,10 +37,12 @@ public class SVGIcon implements Icon { public void paintIcon(Component c, Graphics g, int x, int y) { if (HI_DPI_SURPORT) { Graphics2D graphics = (Graphics2D) g.create(x, y, image.getWidth(null), image.getHeight(null)); - float scale = SYSTEM_SCALE; - graphics.scale(1 / scale, 1 / scale); - graphics.drawImage(image, 0, 0, null); - graphics.scale(1.0D, 1.0D); + new SvgPaintWorker(graphics) { + @Override + protected void doPrint() { + this.drawImage(image, 0, 0, null); + } + }.execute(); graphics.dispose(); } else { g.drawImage(image, x, y, null); 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 2a9fcacb82..5029ccf98d 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 @@ -5,7 +5,7 @@ import com.fr.design.base.mode.DesignModeContext; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.utils.SvgPaintUtils; +import com.fr.design.utils.SvgPaintWorker; import com.fr.design.utils.gui.GUICoreUtils; import javax.swing.JComponent; @@ -18,7 +18,6 @@ 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; @@ -338,10 +337,13 @@ public class UIEastResizableContainer extends JPanel { button = UIConstants.DRAG_RIGHT_PRESS; } } - SvgPaintUtils.beforePaint((Graphics2D) g); //如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整 - g.drawImage(button, SvgPaintUtils.calculatePositionX(10), SvgPaintUtils.calculatePositionY(7), null); - SvgPaintUtils.afterPaint((Graphics2D) g); + new SvgPaintWorker(g) { + @Override + protected void doPrint() { + this.drawImage(button, 10, 7, null); + } + }.execute(); } } } \ No newline at end of file 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 44806b3bf9..ceaabe56e6 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 @@ -3,7 +3,7 @@ package com.fr.design.gui.icontainer; 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.design.utils.SvgPaintWorker; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.Constants; @@ -17,7 +17,6 @@ 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; @@ -422,12 +421,24 @@ public class UIResizableContainer extends JPanel { Image upButton = (upModel == UIConstants.MODEL_NORMAL ? UIConstants.DRAG_UP_NORMAL : UIConstants.DRAG_UP_PRESS); 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); - //如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整 - g.drawImage(UIConstants.DRAG_LINE, SvgPaintUtils.calculatePositionX((getWidth() - toolPaneHeight) / 2), SvgPaintUtils.calculatePositionY(3), null); - g.drawImage(upButton, ARROW_MARGIN, 0, null); - g.drawImage(downButton, SvgPaintUtils.calculatePositionX(getWidth() - toolPaneHeight - ARROW_MARGIN), 0, null); - SvgPaintUtils.afterPaint((Graphics2D) g); + new SvgPaintWorker(g) { + @Override + protected void doPrint() { + this.drawImage(UIConstants.DRAG_LINE, (getWidth() - toolPaneHeight) / 2, 3, null); + } + }.execute(); + new SvgPaintWorker(g) { + @Override + protected void doPrint() { + this.drawImage(upButton, ARROW_MARGIN, 0, null); + } + }.execute(); + new SvgPaintWorker(g) { + @Override + protected void doPrint() { + this.drawImage(downButton, (getWidth() - toolPaneHeight - ARROW_MARGIN), 0, null); + } + }.execute(); } } @@ -524,10 +535,12 @@ public class UIResizableContainer extends JPanel { button = UIConstants.DRAG_LEFT_PRESS; } } - SvgPaintUtils.beforePaint((Graphics2D) g); - //如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整 - g.drawImage(button, SvgPaintUtils.calculatePositionX(-6), SvgPaintUtils.calculatePositionY(ARROW_MARGIN_VERTICAL), this); - SvgPaintUtils.afterPaint((Graphics2D) g); + new SvgPaintWorker(g) { + @Override + protected void doPrint() { + this.drawImage(button, -6, ARROW_MARGIN_VERTICAL, VerticalToolPane.this); + } + }.execute(); } else { g.drawImage(UIConstants.DRAG_BAR_LIGHT, 0, 0, toolPaneHeight, getHeight(), null); if (containerWidth == toolPaneHeight) { @@ -543,7 +556,12 @@ public class UIResizableContainer extends JPanel { button = UIConstants.DRAG_RIGHT_PRESS; } } - g.drawImage(button, SvgPaintUtils.calculatePositionX(10), ARROW_MARGIN_VERTICAL, this); + new SvgPaintWorker(g) { + @Override + protected void doPrint() { + this.drawImage(button, 10, ARROW_MARGIN_VERTICAL, VerticalToolPane.this); + } + }.execute(); } 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 b460e1e31d..858e76048d 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 @@ -19,7 +19,7 @@ import com.fr.design.notification.SnapChat; import com.fr.design.notification.SnapChatFactory; import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.DesignUtils; -import com.fr.design.utils.SvgPaintUtils; +import com.fr.design.utils.SvgPaintWorker; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.log.FineLoggerFactory; @@ -1314,10 +1314,12 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } else { button = UIConstants.POP_BUTTON_UP; } - SvgPaintUtils.beforePaint((Graphics2D) g); - //如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整 - g.drawImage(button, SvgPaintUtils.calculatePositionX(ARROW_RANGE_START + 8), SvgPaintUtils.calculatePositionY(4), null); - SvgPaintUtils.afterPaint((Graphics2D) g); + new SvgPaintWorker(g) { + @Override + protected void doPrint() { + this.drawImage(button, (ARROW_RANGE_START + 8), 4, null); + } + }.execute(); } } diff --git a/designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java b/designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java index 85e34caba2..507768a047 100644 --- a/designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java @@ -24,26 +24,16 @@ public class SvgPaintUtils { public static void afterPaint(Graphics2D g2) { if (HI_DPI_ENABLED) { - g2.scale(1.0D, 1.0D); + g2.scale(SVGLoader.SYSTEM_SCALE, SVGLoader.SYSTEM_SCALE); } } /** - * 计算高缩放下绘制svg图标时新的的位置x - * @param x 旧x的值 - * @return 新的x值 + * 计算高缩放下绘制svg图标时新的的位置x,y + * @param position 旧坐标的值 + * @return 新的position值 * */ - public static int calculatePositionX(int x) { - return HI_DPI_ENABLED ? (int) (x * SVGLoader.SYSTEM_SCALE) : x; + public static int calculatePosition(int position) { + return HI_DPI_ENABLED ? (int) (position * SVGLoader.SYSTEM_SCALE) : position; } - - /** - * 计算高缩放下绘制svg图标时新的的位置y - * @param y 旧y的值 - * @return 新的y值 - * */ - public static int calculatePositionY(int y) { - return HI_DPI_ENABLED ? (int) (y * SVGLoader.SYSTEM_SCALE) : y; - } - } From df2bdb4ae1087ead62ccc98ee0c1f03246bc6240 Mon Sep 17 00:00:00 2001 From: obo Date: Fri, 24 Mar 2023 20:50:50 +0800 Subject: [PATCH 14/23] =?UTF-8?q?REPORT-92430=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8-=E5=9B=BE=E6=A0=87-mac=E4=B8=8B=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=9B=BE=E6=A0=87=E9=83=BD=E4=B8=A2=E5=A4=B1=E4=BA=86=EF=BC=8C?= =?UTF-8?q?windows=E4=B8=8B=E6=AD=A3=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/images/lookandfeel/TreeLeafIcon.svg | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 designer-base/src/main/resources/com/fr/design/images/lookandfeel/TreeLeafIcon.svg diff --git a/designer-base/src/main/resources/com/fr/design/images/lookandfeel/TreeLeafIcon.svg b/designer-base/src/main/resources/com/fr/design/images/lookandfeel/TreeLeafIcon.svg new file mode 100644 index 0000000000..c2971da642 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/images/lookandfeel/TreeLeafIcon.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From 905eac5f5b294a88b091e1fc97784d202a3abe48 Mon Sep 17 00:00:00 2001 From: obo Date: Mon, 27 Mar 2023 10:19:08 +0800 Subject: [PATCH 15/23] =?UTF-8?q?REPORT-92440=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=BA=86SvgPaintWorker=E7=9A=84execute=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E7=9A=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/utils/SvgPaintWorker.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/utils/SvgPaintWorker.java b/designer-base/src/main/java/com/fr/design/utils/SvgPaintWorker.java index 321e8b05d7..6202f608aa 100644 --- a/designer-base/src/main/java/com/fr/design/utils/SvgPaintWorker.java +++ b/designer-base/src/main/java/com/fr/design/utils/SvgPaintWorker.java @@ -25,6 +25,13 @@ abstract public class SvgPaintWorker { graphics.drawImage(image, SvgPaintUtils.calculatePosition(x), SvgPaintUtils.calculatePosition(y), imageObserver); } + /** + * 执行完整的svg绘制逻辑 + * + * @author obo + * @since 11.0 + * Created on 2023/3/24 + */ public void execute() { SvgPaintUtils.beforePaint((Graphics2D) graphics); doPrint(); From e977f6fc6fdd31a44e21c0a39dc9aa2076121c87 Mon Sep 17 00:00:00 2001 From: obo Date: Mon, 27 Mar 2023 15:54:51 +0800 Subject: [PATCH 16/23] =?UTF-8?q?REPORT-92439=20mac=E4=B8=8B-=E5=B1=95?= =?UTF-8?q?=E5=BC=80=E6=94=B6=E8=B5=B7=E5=9B=BE=E6=A0=87=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/base/svg/SVGIcon.java | 8 ++--- .../icontainer/UIEastResizableContainer.java | 8 ++--- .../gui/icontainer/UIResizableContainer.java | 32 +++++++++---------- .../mainframe/EastRegionContainerPane.java | 8 ++--- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/designer-base/src/main/java/com/fr/base/svg/SVGIcon.java b/designer-base/src/main/java/com/fr/base/svg/SVGIcon.java index a15b2118d3..613b6ddbde 100644 --- a/designer-base/src/main/java/com/fr/base/svg/SVGIcon.java +++ b/designer-base/src/main/java/com/fr/base/svg/SVGIcon.java @@ -1,6 +1,6 @@ package com.fr.base.svg; -import com.fr.design.utils.SvgPaintWorker; +import com.fr.design.utils.SvgPainter; import com.fr.general.IOUtils; import javax.swing.Icon; @@ -37,12 +37,12 @@ public class SVGIcon implements Icon { public void paintIcon(Component c, Graphics g, int x, int y) { if (HI_DPI_SURPORT) { Graphics2D graphics = (Graphics2D) g.create(x, y, image.getWidth(null), image.getHeight(null)); - new SvgPaintWorker(graphics) { + new SvgPainter(graphics) { @Override - protected void doPrint() { + protected void doPaint() { this.drawImage(image, 0, 0, null); } - }.execute(); + }.paint(); graphics.dispose(); } else { g.drawImage(image, x, y, null); 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 5029ccf98d..d078b747fb 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 @@ -5,7 +5,7 @@ import com.fr.design.base.mode.DesignModeContext; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.utils.SvgPaintWorker; +import com.fr.design.utils.SvgPainter; import com.fr.design.utils.gui.GUICoreUtils; import javax.swing.JComponent; @@ -338,12 +338,12 @@ public class UIEastResizableContainer extends JPanel { } } //如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整 - new SvgPaintWorker(g) { + new SvgPainter(g) { @Override - protected void doPrint() { + protected void doPaint() { this.drawImage(button, 10, 7, null); } - }.execute(); + }.paint(); } } } \ No newline at end of file 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 ceaabe56e6..20109fff1e 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 @@ -3,7 +3,7 @@ package com.fr.design.gui.icontainer; import com.fr.base.vcs.DesignerMode; import com.fr.design.constants.UIConstants; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.utils.SvgPaintWorker; +import com.fr.design.utils.SvgPainter; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.Constants; @@ -421,24 +421,24 @@ public class UIResizableContainer extends JPanel { Image upButton = (upModel == UIConstants.MODEL_NORMAL ? UIConstants.DRAG_UP_NORMAL : UIConstants.DRAG_UP_PRESS); 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); - new SvgPaintWorker(g) { + new SvgPainter(g) { @Override - protected void doPrint() { + protected void doPaint() { this.drawImage(UIConstants.DRAG_LINE, (getWidth() - toolPaneHeight) / 2, 3, null); } - }.execute(); - new SvgPaintWorker(g) { + }.paint(); + new SvgPainter(g) { @Override - protected void doPrint() { + protected void doPaint() { this.drawImage(upButton, ARROW_MARGIN, 0, null); } - }.execute(); - new SvgPaintWorker(g) { + }.paint(); + new SvgPainter(g) { @Override - protected void doPrint() { + protected void doPaint() { this.drawImage(downButton, (getWidth() - toolPaneHeight - ARROW_MARGIN), 0, null); } - }.execute(); + }.paint(); } } @@ -535,12 +535,12 @@ public class UIResizableContainer extends JPanel { button = UIConstants.DRAG_LEFT_PRESS; } } - new SvgPaintWorker(g) { + new SvgPainter(g) { @Override - protected void doPrint() { + protected void doPaint() { this.drawImage(button, -6, ARROW_MARGIN_VERTICAL, VerticalToolPane.this); } - }.execute(); + }.paint(); } else { g.drawImage(UIConstants.DRAG_BAR_LIGHT, 0, 0, toolPaneHeight, getHeight(), null); if (containerWidth == toolPaneHeight) { @@ -556,12 +556,12 @@ public class UIResizableContainer extends JPanel { button = UIConstants.DRAG_RIGHT_PRESS; } } - new SvgPaintWorker(g) { + new SvgPainter(g) { @Override - protected void doPrint() { + protected void doPaint() { this.drawImage(button, 10, ARROW_MARGIN_VERTICAL, VerticalToolPane.this); } - }.execute(); + }.paint(); } 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 858e76048d..0d3dfcae84 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 @@ -19,7 +19,7 @@ import com.fr.design.notification.SnapChat; import com.fr.design.notification.SnapChatFactory; import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.DesignUtils; -import com.fr.design.utils.SvgPaintWorker; +import com.fr.design.utils.SvgPainter; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.log.FineLoggerFactory; @@ -1314,12 +1314,12 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } else { button = UIConstants.POP_BUTTON_UP; } - new SvgPaintWorker(g) { + new SvgPainter(g) { @Override - protected void doPrint() { + protected void doPaint() { this.drawImage(button, (ARROW_RANGE_START + 8), 4, null); } - }.execute(); + }.paint(); } } From 567d3f67d4edb226ed1b9f658c8b0e2ddaf0a636 Mon Sep 17 00:00:00 2001 From: obo Date: Mon, 27 Mar 2023 15:55:22 +0800 Subject: [PATCH 17/23] =?UTF-8?q?REPORT-92440=20mac-=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=BA=90=E5=B8=A6=E5=8F=B9=E5=8F=B7=E7=9A=84=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/icon/WarningIcon.java | 14 +++++++------- .../utils/{SvgPaintWorker.java => SvgPainter.java} | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) rename designer-base/src/main/java/com/fr/design/utils/{SvgPaintWorker.java => SvgPainter.java} (84%) diff --git a/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java b/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java index 20e6462569..cadf64fd94 100644 --- a/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java +++ b/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java @@ -2,7 +2,7 @@ package com.fr.design.icon; import com.fr.base.svg.SVGLoader; import com.fr.base.svg.SystemScaleUtils; -import com.fr.design.utils.SvgPaintWorker; +import com.fr.design.utils.SvgPainter; import com.fr.log.FineLoggerFactory; import javax.swing.GrayFilter; @@ -45,20 +45,20 @@ public class WarningIcon extends ImageIcon { //裁剪绘制svg的位置,以免影响到图标右侧的文字 Graphics2D graphics = (Graphics2D) g.create(x, y, WARNING_IMAGE.getWidth(null), WARNING_IMAGE.getHeight(null)); if (mainImage != null) { - new SvgPaintWorker(graphics) { + new SvgPainter(graphics) { @Override - protected void doPrint() { + protected void doPaint() { this.drawImage(mainImage, x, y, null); } - }.execute(); + }.paint(); } if (WARNING_IMAGE != null) { - new SvgPaintWorker(graphics) { + new SvgPainter(graphics) { @Override - protected void doPrint() { + protected void doPaint() { this.drawImage(WARNING_IMAGE, x, y, null); } - }.execute(); + }.paint(); } graphics.dispose(); } diff --git a/designer-base/src/main/java/com/fr/design/utils/SvgPaintWorker.java b/designer-base/src/main/java/com/fr/design/utils/SvgPainter.java similarity index 84% rename from designer-base/src/main/java/com/fr/design/utils/SvgPaintWorker.java rename to designer-base/src/main/java/com/fr/design/utils/SvgPainter.java index 6202f608aa..766dc3fc6b 100644 --- a/designer-base/src/main/java/com/fr/design/utils/SvgPaintWorker.java +++ b/designer-base/src/main/java/com/fr/design/utils/SvgPainter.java @@ -12,14 +12,14 @@ import java.awt.image.ImageObserver; * @since 11.0 * Created on 2023/3/24 */ -abstract public class SvgPaintWorker { +public abstract class SvgPainter { private final Graphics graphics; - public SvgPaintWorker(Graphics g) { + public SvgPainter(Graphics g) { graphics = g; } - protected abstract void doPrint(); + protected abstract void doPaint(); protected void drawImage(Image image, int x, int y, ImageObserver imageObserver) { //如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整 graphics.drawImage(image, SvgPaintUtils.calculatePosition(x), SvgPaintUtils.calculatePosition(y), imageObserver); @@ -32,9 +32,9 @@ abstract public class SvgPaintWorker { * @since 11.0 * Created on 2023/3/24 */ - public void execute() { + public void paint() { SvgPaintUtils.beforePaint((Graphics2D) graphics); - doPrint(); + doPaint(); SvgPaintUtils.afterPaint((Graphics2D) graphics); } } From efbfb9ecbef6aae1ed9527e30af621ab453b08a8 Mon Sep 17 00:00:00 2001 From: obo Date: Mon, 27 Mar 2023 19:00:19 +0800 Subject: [PATCH 18/23] =?UTF-8?q?REPORT-92440=20mac-=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=BA=90=E5=B8=A6=E5=8F=B9=E5=8F=B7=E7=9A=84=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/icon/WarningIcon.java | 16 ++------- .../com/fr/design/utils/SvgPaintUtils.java | 28 +++++++++++++++ .../java/com/fr/design/utils/SvgPainter.java | 34 +++---------------- 3 files changed, 36 insertions(+), 42 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java b/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java index cadf64fd94..b4d7f33174 100644 --- a/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java +++ b/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java @@ -2,7 +2,7 @@ package com.fr.design.icon; import com.fr.base.svg.SVGLoader; import com.fr.base.svg.SystemScaleUtils; -import com.fr.design.utils.SvgPainter; +import com.fr.design.utils.SvgPaintUtils; import com.fr.log.FineLoggerFactory; import javax.swing.GrayFilter; @@ -45,20 +45,10 @@ public class WarningIcon extends ImageIcon { //裁剪绘制svg的位置,以免影响到图标右侧的文字 Graphics2D graphics = (Graphics2D) g.create(x, y, WARNING_IMAGE.getWidth(null), WARNING_IMAGE.getHeight(null)); if (mainImage != null) { - new SvgPainter(graphics) { - @Override - protected void doPaint() { - this.drawImage(mainImage, x, y, null); - } - }.paint(); + SvgPaintUtils.doDrawSVG(graphics, () -> SvgPaintUtils.drawImage(graphics, mainImage, x, y, null)); } if (WARNING_IMAGE != null) { - new SvgPainter(graphics) { - @Override - protected void doPaint() { - this.drawImage(WARNING_IMAGE, x, y, null); - } - }.paint(); + SvgPaintUtils.doDrawSVG(graphics, () -> SvgPaintUtils.drawImage(graphics, WARNING_IMAGE, x, y, null)); } graphics.dispose(); } diff --git a/designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java b/designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java index 507768a047..103aaf0acb 100644 --- a/designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java @@ -2,8 +2,12 @@ package com.fr.design.utils; import com.fr.base.svg.SVGLoader; import com.fr.base.svg.SystemScaleUtils; +import org.jetbrains.annotations.NotNull; +import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.image.ImageObserver; /** * 用于绘制svg图片缩放(高分屏下) @@ -36,4 +40,28 @@ public class SvgPaintUtils { public static int calculatePosition(int position) { return HI_DPI_ENABLED ? (int) (position * SVGLoader.SYSTEM_SCALE) : position; } + + /** + * 绘制svg图像的完整逻辑 + * @param graphics 绘图 + * @param svgPainter 具体绘制逻辑 + * */ + public static void doDrawSVG(@NotNull Graphics graphics, @NotNull final SvgPainter svgPainter) { + SvgPaintUtils.beforePaint((Graphics2D) graphics); + svgPainter.drawSVG(); + SvgPaintUtils.afterPaint((Graphics2D) graphics); + } + + /** + * 绘制前对坐标x和y进行处理 + * @param graphics 绘图 + * @param image svg的Image对象 + * @param x x坐标 + * @param y y坐标 + * @param imageObserver 图像观察器 + * */ + public static void drawImage(Graphics graphics, Image image, int x, int y, ImageObserver imageObserver) { + //如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整 + graphics.drawImage(image, SvgPaintUtils.calculatePosition(x), SvgPaintUtils.calculatePosition(y), imageObserver); + } } diff --git a/designer-base/src/main/java/com/fr/design/utils/SvgPainter.java b/designer-base/src/main/java/com/fr/design/utils/SvgPainter.java index 766dc3fc6b..67c066b2c6 100644 --- a/designer-base/src/main/java/com/fr/design/utils/SvgPainter.java +++ b/designer-base/src/main/java/com/fr/design/utils/SvgPainter.java @@ -1,40 +1,16 @@ package com.fr.design.utils; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.image.ImageObserver; - /** - * SVG图标绘制器 + * 绘制SVG图标的函数式接口 * * @author obo * @since 11.0 * Created on 2023/3/24 */ -public abstract class SvgPainter { - - private final Graphics graphics; - public SvgPainter(Graphics g) { - graphics = g; - } - - protected abstract void doPaint(); - protected void drawImage(Image image, int x, int y, ImageObserver imageObserver) { - //如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整 - graphics.drawImage(image, SvgPaintUtils.calculatePosition(x), SvgPaintUtils.calculatePosition(y), imageObserver); - } +public interface SvgPainter { /** - * 执行完整的svg绘制逻辑 - * - * @author obo - * @since 11.0 - * Created on 2023/3/24 - */ - public void paint() { - SvgPaintUtils.beforePaint((Graphics2D) graphics); - doPaint(); - SvgPaintUtils.afterPaint((Graphics2D) graphics); - } + * 绘制svg图标的具体逻辑,方法体 + * */ + void drawSVG(); } From 8ac5a7e5ea17ae0852b4eaafdf25ad153a6cfbb5 Mon Sep 17 00:00:00 2001 From: obo Date: Mon, 27 Mar 2023 19:02:30 +0800 Subject: [PATCH 19/23] =?UTF-8?q?REPORT-92439=20mac=E4=B8=8B-=E5=B1=95?= =?UTF-8?q?=E5=BC=80=E6=94=B6=E8=B5=B7=E5=9B=BE=E6=A0=87=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/base/svg/SVGIcon.java | 9 +---- .../icontainer/UIEastResizableContainer.java | 10 +---- .../gui/icontainer/UIResizableContainer.java | 37 +++---------------- .../mainframe/EastRegionContainerPane.java | 9 +---- 4 files changed, 12 insertions(+), 53 deletions(-) diff --git a/designer-base/src/main/java/com/fr/base/svg/SVGIcon.java b/designer-base/src/main/java/com/fr/base/svg/SVGIcon.java index 613b6ddbde..1280fbf737 100644 --- a/designer-base/src/main/java/com/fr/base/svg/SVGIcon.java +++ b/designer-base/src/main/java/com/fr/base/svg/SVGIcon.java @@ -1,6 +1,6 @@ package com.fr.base.svg; -import com.fr.design.utils.SvgPainter; +import com.fr.design.utils.SvgPaintUtils; import com.fr.general.IOUtils; import javax.swing.Icon; @@ -37,12 +37,7 @@ public class SVGIcon implements Icon { public void paintIcon(Component c, Graphics g, int x, int y) { if (HI_DPI_SURPORT) { Graphics2D graphics = (Graphics2D) g.create(x, y, image.getWidth(null), image.getHeight(null)); - new SvgPainter(graphics) { - @Override - protected void doPaint() { - this.drawImage(image, 0, 0, null); - } - }.paint(); + SvgPaintUtils.doDrawSVG(graphics, () -> SvgPaintUtils.drawImage(graphics, image, 0, 0, null)); graphics.dispose(); } else { g.drawImage(image, x, y, null); 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 d078b747fb..c018e622f1 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 @@ -5,7 +5,7 @@ import com.fr.design.base.mode.DesignModeContext; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.utils.SvgPainter; +import com.fr.design.utils.SvgPaintUtils; import com.fr.design.utils.gui.GUICoreUtils; import javax.swing.JComponent; @@ -337,13 +337,7 @@ public class UIEastResizableContainer extends JPanel { button = UIConstants.DRAG_RIGHT_PRESS; } } - //如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整 - new SvgPainter(g) { - @Override - protected void doPaint() { - this.drawImage(button, 10, 7, null); - } - }.paint(); + SvgPaintUtils.doDrawSVG(g, () -> SvgPaintUtils.drawImage(g, button, 10, 7, null)); } } } \ No newline at end of file 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 20109fff1e..0c69d47e74 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 @@ -3,7 +3,7 @@ package com.fr.design.gui.icontainer; import com.fr.base.vcs.DesignerMode; import com.fr.design.constants.UIConstants; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.utils.SvgPainter; +import com.fr.design.utils.SvgPaintUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.Constants; @@ -421,24 +421,9 @@ public class UIResizableContainer extends JPanel { Image upButton = (upModel == UIConstants.MODEL_NORMAL ? UIConstants.DRAG_UP_NORMAL : UIConstants.DRAG_UP_PRESS); 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); - new SvgPainter(g) { - @Override - protected void doPaint() { - this.drawImage(UIConstants.DRAG_LINE, (getWidth() - toolPaneHeight) / 2, 3, null); - } - }.paint(); - new SvgPainter(g) { - @Override - protected void doPaint() { - this.drawImage(upButton, ARROW_MARGIN, 0, null); - } - }.paint(); - new SvgPainter(g) { - @Override - protected void doPaint() { - this.drawImage(downButton, (getWidth() - toolPaneHeight - ARROW_MARGIN), 0, null); - } - }.paint(); + SvgPaintUtils.doDrawSVG(g, () -> SvgPaintUtils.drawImage(g, UIConstants.DRAG_LINE, (getWidth() - toolPaneHeight) / 2, 3, null)); + SvgPaintUtils.doDrawSVG(g, () -> SvgPaintUtils.drawImage(g, upButton, ARROW_MARGIN, 0, null)); + SvgPaintUtils.doDrawSVG(g, () -> SvgPaintUtils.drawImage(g, downButton, (getWidth() - toolPaneHeight - ARROW_MARGIN), 0, null)); } } @@ -535,12 +520,7 @@ public class UIResizableContainer extends JPanel { button = UIConstants.DRAG_LEFT_PRESS; } } - new SvgPainter(g) { - @Override - protected void doPaint() { - this.drawImage(button, -6, ARROW_MARGIN_VERTICAL, VerticalToolPane.this); - } - }.paint(); + SvgPaintUtils.doDrawSVG(g, () -> SvgPaintUtils.drawImage(g, button, -6, ARROW_MARGIN_VERTICAL, VerticalToolPane.this)); } else { g.drawImage(UIConstants.DRAG_BAR_LIGHT, 0, 0, toolPaneHeight, getHeight(), null); if (containerWidth == toolPaneHeight) { @@ -556,12 +536,7 @@ public class UIResizableContainer extends JPanel { button = UIConstants.DRAG_RIGHT_PRESS; } } - new SvgPainter(g) { - @Override - protected void doPaint() { - this.drawImage(button, 10, ARROW_MARGIN_VERTICAL, VerticalToolPane.this); - } - }.paint(); + SvgPaintUtils.doDrawSVG(g, () -> SvgPaintUtils.drawImage(g, button, 10, ARROW_MARGIN_VERTICAL, VerticalToolPane.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 0d3dfcae84..e6490b84de 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 @@ -19,7 +19,7 @@ import com.fr.design.notification.SnapChat; import com.fr.design.notification.SnapChatFactory; import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.DesignUtils; -import com.fr.design.utils.SvgPainter; +import com.fr.design.utils.SvgPaintUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.log.FineLoggerFactory; @@ -1314,12 +1314,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } else { button = UIConstants.POP_BUTTON_UP; } - new SvgPainter(g) { - @Override - protected void doPaint() { - this.drawImage(button, (ARROW_RANGE_START + 8), 4, null); - } - }.paint(); + SvgPaintUtils.doDrawSVG(g, () -> SvgPaintUtils.drawImage(g, button, (ARROW_RANGE_START + 8), 4, null)); } } From 3b09ea22b35e23f36553357e1330ee7f101d5da0 Mon Sep 17 00:00:00 2001 From: obo Date: Mon, 27 Mar 2023 20:09:55 +0800 Subject: [PATCH 20/23] =?UTF-8?q?REPORT-92439=20mac=E4=B8=8B-=E5=B1=95?= =?UTF-8?q?=E5=BC=80=E6=94=B6=E8=B5=B7=E5=9B=BE=E6=A0=87=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/base/svg/SVGIcon.java | 4 ++-- .../gui/icontainer/UIEastResizableContainer.java | 4 ++-- .../design/gui/icontainer/UIResizableContainer.java | 12 ++++++------ .../fr/design/mainframe/EastRegionContainerPane.java | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/designer-base/src/main/java/com/fr/base/svg/SVGIcon.java b/designer-base/src/main/java/com/fr/base/svg/SVGIcon.java index 1280fbf737..832fd33e91 100644 --- a/designer-base/src/main/java/com/fr/base/svg/SVGIcon.java +++ b/designer-base/src/main/java/com/fr/base/svg/SVGIcon.java @@ -1,6 +1,6 @@ package com.fr.base.svg; -import com.fr.design.utils.SvgPaintUtils; +import com.fr.design.utils.SvgDrawUtils; import com.fr.general.IOUtils; import javax.swing.Icon; @@ -37,7 +37,7 @@ public class SVGIcon implements Icon { public void paintIcon(Component c, Graphics g, int x, int y) { if (HI_DPI_SURPORT) { Graphics2D graphics = (Graphics2D) g.create(x, y, image.getWidth(null), image.getHeight(null)); - SvgPaintUtils.doDrawSVG(graphics, () -> SvgPaintUtils.drawImage(graphics, image, 0, 0, null)); + SvgDrawUtils.doDrawSVG(graphics, () -> SvgDrawUtils.drawImage(graphics, image, 0, 0, null)); graphics.dispose(); } else { g.drawImage(image, x, y, null); 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 c018e622f1..cec4b840a7 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 @@ -5,7 +5,7 @@ import com.fr.design.base.mode.DesignModeContext; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.utils.SvgPaintUtils; +import com.fr.design.utils.SvgDrawUtils; import com.fr.design.utils.gui.GUICoreUtils; import javax.swing.JComponent; @@ -337,7 +337,7 @@ public class UIEastResizableContainer extends JPanel { button = UIConstants.DRAG_RIGHT_PRESS; } } - SvgPaintUtils.doDrawSVG(g, () -> SvgPaintUtils.drawImage(g, button, 10, 7, null)); + SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, button, 10, 7, null)); } } } \ No newline at end of file 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 0c69d47e74..a7682107ec 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 @@ -3,7 +3,7 @@ package com.fr.design.gui.icontainer; 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.design.utils.SvgDrawUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.Constants; @@ -421,9 +421,9 @@ public class UIResizableContainer extends JPanel { Image upButton = (upModel == UIConstants.MODEL_NORMAL ? UIConstants.DRAG_UP_NORMAL : UIConstants.DRAG_UP_PRESS); 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.doDrawSVG(g, () -> SvgPaintUtils.drawImage(g, UIConstants.DRAG_LINE, (getWidth() - toolPaneHeight) / 2, 3, null)); - SvgPaintUtils.doDrawSVG(g, () -> SvgPaintUtils.drawImage(g, upButton, ARROW_MARGIN, 0, null)); - SvgPaintUtils.doDrawSVG(g, () -> SvgPaintUtils.drawImage(g, downButton, (getWidth() - toolPaneHeight - ARROW_MARGIN), 0, null)); + SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, UIConstants.DRAG_LINE, (getWidth() - toolPaneHeight) / 2, 3, null)); + SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, upButton, ARROW_MARGIN, 0, null)); + SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, downButton, (getWidth() - toolPaneHeight - ARROW_MARGIN), 0, null)); } } @@ -520,7 +520,7 @@ public class UIResizableContainer extends JPanel { button = UIConstants.DRAG_LEFT_PRESS; } } - SvgPaintUtils.doDrawSVG(g, () -> SvgPaintUtils.drawImage(g, button, -6, ARROW_MARGIN_VERTICAL, VerticalToolPane.this)); + SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, button, -6, ARROW_MARGIN_VERTICAL, VerticalToolPane.this)); } else { g.drawImage(UIConstants.DRAG_BAR_LIGHT, 0, 0, toolPaneHeight, getHeight(), null); if (containerWidth == toolPaneHeight) { @@ -536,7 +536,7 @@ public class UIResizableContainer extends JPanel { button = UIConstants.DRAG_RIGHT_PRESS; } } - SvgPaintUtils.doDrawSVG(g, () -> SvgPaintUtils.drawImage(g, button, 10, ARROW_MARGIN_VERTICAL, VerticalToolPane.this)); + SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, button, 10, ARROW_MARGIN_VERTICAL, VerticalToolPane.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 e6490b84de..c8f7281a32 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 @@ -19,7 +19,7 @@ import com.fr.design.notification.SnapChat; import com.fr.design.notification.SnapChatFactory; import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.DesignUtils; -import com.fr.design.utils.SvgPaintUtils; +import com.fr.design.utils.SvgDrawUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.log.FineLoggerFactory; @@ -1314,7 +1314,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } else { button = UIConstants.POP_BUTTON_UP; } - SvgPaintUtils.doDrawSVG(g, () -> SvgPaintUtils.drawImage(g, button, (ARROW_RANGE_START + 8), 4, null)); + SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, button, (ARROW_RANGE_START + 8), 4, null)); } } From 0b8b849e2e3992fd1a531838aa26242c6de992c8 Mon Sep 17 00:00:00 2001 From: obo Date: Mon, 27 Mar 2023 20:14:35 +0800 Subject: [PATCH 21/23] =?UTF-8?q?REPORT-92440=20mac-=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=BA=90=E5=B8=A6=E5=8F=B9=E5=8F=B7=E7=9A=84=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/icon/WarningIcon.java | 6 ++--- .../utils/{SvgPainter.java => SvgDraw.java} | 2 +- .../{SvgPaintUtils.java => SvgDrawUtils.java} | 24 ++++++++++++------- 3 files changed, 19 insertions(+), 13 deletions(-) rename designer-base/src/main/java/com/fr/design/utils/{SvgPainter.java => SvgDraw.java} (87%) rename designer-base/src/main/java/com/fr/design/utils/{SvgPaintUtils.java => SvgDrawUtils.java} (72%) diff --git a/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java b/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java index b4d7f33174..a50bb39969 100644 --- a/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java +++ b/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java @@ -2,7 +2,7 @@ package com.fr.design.icon; import com.fr.base.svg.SVGLoader; import com.fr.base.svg.SystemScaleUtils; -import com.fr.design.utils.SvgPaintUtils; +import com.fr.design.utils.SvgDrawUtils; import com.fr.log.FineLoggerFactory; import javax.swing.GrayFilter; @@ -45,10 +45,10 @@ public class WarningIcon extends ImageIcon { //裁剪绘制svg的位置,以免影响到图标右侧的文字 Graphics2D graphics = (Graphics2D) g.create(x, y, WARNING_IMAGE.getWidth(null), WARNING_IMAGE.getHeight(null)); if (mainImage != null) { - SvgPaintUtils.doDrawSVG(graphics, () -> SvgPaintUtils.drawImage(graphics, mainImage, x, y, null)); + SvgDrawUtils.doDrawSVG(graphics, () -> SvgDrawUtils.drawImage(graphics, mainImage, x, y, null)); } if (WARNING_IMAGE != null) { - SvgPaintUtils.doDrawSVG(graphics, () -> SvgPaintUtils.drawImage(graphics, WARNING_IMAGE, x, y, null)); + SvgDrawUtils.doDrawSVG(graphics, () -> SvgDrawUtils.drawImage(graphics, WARNING_IMAGE, x, y, null)); } graphics.dispose(); } diff --git a/designer-base/src/main/java/com/fr/design/utils/SvgPainter.java b/designer-base/src/main/java/com/fr/design/utils/SvgDraw.java similarity index 87% rename from designer-base/src/main/java/com/fr/design/utils/SvgPainter.java rename to designer-base/src/main/java/com/fr/design/utils/SvgDraw.java index 67c066b2c6..0ae7ff7af8 100644 --- a/designer-base/src/main/java/com/fr/design/utils/SvgPainter.java +++ b/designer-base/src/main/java/com/fr/design/utils/SvgDraw.java @@ -7,7 +7,7 @@ package com.fr.design.utils; * @since 11.0 * Created on 2023/3/24 */ -public interface SvgPainter { +public interface SvgDraw { /** * 绘制svg图标的具体逻辑,方法体 diff --git a/designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java b/designer-base/src/main/java/com/fr/design/utils/SvgDrawUtils.java similarity index 72% rename from designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java rename to designer-base/src/main/java/com/fr/design/utils/SvgDrawUtils.java index 103aaf0acb..0b141b9991 100644 --- a/designer-base/src/main/java/com/fr/design/utils/SvgPaintUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/SvgDrawUtils.java @@ -16,17 +16,23 @@ import java.awt.image.ImageObserver; * @version 11.0 * Created by hades on 2022/5/6 */ -public class SvgPaintUtils { +public class SvgDrawUtils { private static final boolean HI_DPI_ENABLED = SystemScaleUtils.isJreHiDPIEnabled(); - public static void beforePaint(Graphics2D g2) { + /** + * 绘制svg前若环境支持高清化则对缩放比例进行适配 + * */ + public static void beforeDraw(Graphics2D g2) { if (HI_DPI_ENABLED) { g2.scale(1 / SVGLoader.SYSTEM_SCALE, 1 / SVGLoader.SYSTEM_SCALE); } } - public static void afterPaint(Graphics2D g2) { + /** + * 绘制svg后还原缩放矩阵 + * */ + public static void afterDraw(Graphics2D g2) { if (HI_DPI_ENABLED) { g2.scale(SVGLoader.SYSTEM_SCALE, SVGLoader.SYSTEM_SCALE); } @@ -44,12 +50,12 @@ public class SvgPaintUtils { /** * 绘制svg图像的完整逻辑 * @param graphics 绘图 - * @param svgPainter 具体绘制逻辑 + * @param svgDraw 具体绘制逻辑 * */ - public static void doDrawSVG(@NotNull Graphics graphics, @NotNull final SvgPainter svgPainter) { - SvgPaintUtils.beforePaint((Graphics2D) graphics); - svgPainter.drawSVG(); - SvgPaintUtils.afterPaint((Graphics2D) graphics); + public static void doDrawSVG(@NotNull Graphics graphics, @NotNull final SvgDraw svgDraw) { + SvgDrawUtils.beforeDraw((Graphics2D) graphics); + svgDraw.drawSVG(); + SvgDrawUtils.afterDraw((Graphics2D) graphics); } /** @@ -62,6 +68,6 @@ public class SvgPaintUtils { * */ public static void drawImage(Graphics graphics, Image image, int x, int y, ImageObserver imageObserver) { //如果环境支持高清化,在调整缩放比例时绘制svg会影响到位置的变化,若图标无确定裁剪位置,则需要进行调整 - graphics.drawImage(image, SvgPaintUtils.calculatePosition(x), SvgPaintUtils.calculatePosition(y), imageObserver); + graphics.drawImage(image, SvgDrawUtils.calculatePosition(x), SvgDrawUtils.calculatePosition(y), imageObserver); } } From 3e253a43a7af337a4a2bfdf9149a03a223a73568 Mon Sep 17 00:00:00 2001 From: obo Date: Mon, 27 Mar 2023 20:15:51 +0800 Subject: [PATCH 22/23] =?UTF-8?q?REPORT-92440=20mac-=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=BA=90=E5=B8=A6=E5=8F=B9=E5=8F=B7=E7=9A=84=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/cell/bar/DynamicScrollButton.java | 6 +++--- .../alphafine/component/ProductNewsImagePanel.java | 11 +++++------ .../mainframe/alphafine/question/QuestionPane.java | 9 +++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/cell/bar/DynamicScrollButton.java b/designer-realize/src/main/java/com/fr/design/cell/bar/DynamicScrollButton.java index b250119510..cc0ab91809 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/bar/DynamicScrollButton.java +++ b/designer-realize/src/main/java/com/fr/design/cell/bar/DynamicScrollButton.java @@ -1,7 +1,7 @@ package com.fr.design.cell.bar; import com.fr.design.constants.UIConstants; -import com.fr.design.utils.SvgPaintUtils; +import com.fr.design.utils.SvgDrawUtils; import com.fr.general.ComparatorUtils; import javax.swing.SwingConstants; @@ -69,7 +69,7 @@ public class DynamicScrollButton extends BasicArrowButton { private void paintArrow(Graphics g, Dimension size) { - SvgPaintUtils.beforePaint((Graphics2D) g); + SvgDrawUtils.beforeDraw((Graphics2D) g); switch (direction) { case SwingConstants.NORTH: g.drawImage(UIConstants.ARROW_NORTH, 0, 0, this); @@ -84,7 +84,7 @@ public class DynamicScrollButton extends BasicArrowButton { g.drawImage(UIConstants.ARROW_WEST, 0, 0, this); break; } - SvgPaintUtils.afterPaint((Graphics2D) g); + SvgDrawUtils.afterDraw((Graphics2D) g); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsImagePanel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsImagePanel.java index b46d094d8b..1baa092cec 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsImagePanel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsImagePanel.java @@ -2,19 +2,18 @@ package com.fr.design.mainframe.alphafine.component; import com.fr.base.GraphHelper; import com.fr.base.svg.SVGLoader; -import com.fr.base.svg.SystemScaleUtils; import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.alphafine.model.ProductNews; -import com.fr.design.utils.SvgPaintUtils; +import com.fr.design.utils.SvgDrawUtils; + +import javax.swing.JPanel; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; - import java.awt.RenderingHints; import java.util.Set; -import javax.swing.JPanel; /** * @author hades @@ -58,9 +57,9 @@ public class ProductNewsImagePanel extends JPanel { } Set readSet = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getReadSet(); if (!readSet.contains(productNews.getId())) { - SvgPaintUtils.beforePaint(g2); + SvgDrawUtils.beforeDraw(g2); g2.drawImage(NEW_TIP_IMAGE, 0, 0, this); - SvgPaintUtils.afterPaint(g2); + SvgDrawUtils.afterDraw(g2); } g2.setColor(BACKGROUND_COLOR); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/question/QuestionPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/question/QuestionPane.java index b2c186a9ea..f96622d5ca 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/question/QuestionPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/question/QuestionPane.java @@ -4,13 +4,14 @@ import com.fr.base.svg.SVGLoader; import com.fr.base.svg.SystemScaleUtils; import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.alphafine.AlphaFineUtil; -import com.fr.design.utils.SvgPaintUtils; +import com.fr.design.utils.SvgDrawUtils; + +import javax.swing.JPanel; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; -import javax.swing.JPanel; /** * @author hades @@ -33,7 +34,7 @@ public class QuestionPane extends JPanel { protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; - SvgPaintUtils.beforePaint(g2); + SvgDrawUtils.beforeDraw(g2); // 宽高保持 int width = SystemScaleUtils.isJreHiDPIEnabled() ? (int) (getWidth() * SVGLoader.SYSTEM_SCALE) : getWidth(); int height = SystemScaleUtils.isJreHiDPIEnabled() ? (int) (getHeight() * SVGLoader.SYSTEM_SCALE) : getHeight(); @@ -47,7 +48,7 @@ public class QuestionPane extends JPanel { int imageWidth = QUESTION_IMAGE.getWidth(this); int imageHeight = QUESTION_IMAGE.getHeight(this); g2.drawImage(QUESTION_IMAGE, (width - imageWidth) / 2 - 2, (height - imageHeight) / 2 - 2,this); - SvgPaintUtils.afterPaint(g2); + SvgDrawUtils.afterDraw(g2); } From 94f9aadec21e8b3b0b84666ff2743608ac8173b2 Mon Sep 17 00:00:00 2001 From: obo Date: Tue, 28 Mar 2023 09:21:43 +0800 Subject: [PATCH 23/23] =?UTF-8?q?REPORT-92440=20mac-=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=BA=90=E5=B8=A6=E5=8F=B9=E5=8F=B7=E7=9A=84=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/utils/SvgDrawUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/utils/SvgDrawUtils.java b/designer-base/src/main/java/com/fr/design/utils/SvgDrawUtils.java index 0b141b9991..5754b2f8d7 100644 --- a/designer-base/src/main/java/com/fr/design/utils/SvgDrawUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/SvgDrawUtils.java @@ -13,8 +13,8 @@ import java.awt.image.ImageObserver; * 用于绘制svg图片缩放(高分屏下) * * @author hades - * @version 11.0 - * Created by hades on 2022/5/6 + * @since 11.0 + * Created on 2022/5/6 */ public class SvgDrawUtils {