From 20447bef4137814ac58776a976edf1d6c022337b Mon Sep 17 00:00:00 2001 From: Yvan Date: Wed, 3 Mar 2021 14:25:48 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-42238=20=E3=80=9010.0.13=E3=80=91JDK11?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E5=9B=BE=E6=A0=87=E6=A8=A1=E7=B3=8A?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96=20=E3=80=90=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91IOUtils.readResource()?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E9=87=8C=E4=BC=9A=E5=AF=B9=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E4=BA=86ResourcePathTransformer=E6=8E=A5=E5=8F=A3=E7=9A=84?= =?UTF-8?q?=E6=9F=90=E4=BA=9B=E6=8F=92=E4=BB=B6=E8=B5=84=E6=BA=90=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84=E7=9A=84=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=EF=BC=8C=E8=80=8C=E4=B9=8B=E5=89=8D=E4=BE=9D=E9=9D=A0?= =?UTF-8?q?IOUtils.readResource()=E5=88=A4=E6=96=AD=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=AD=98=E5=9C=A8=E6=97=B6=EF=BC=8C=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E8=80=83=E8=99=91=E8=BF=99=E4=B8=80=E7=82=B9=EF=BC=8C?= =?UTF-8?q?=E7=B4=A7=E6=8E=A5=E7=9D=80=E5=8E=BB=E8=AF=BBIcon=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E4=BB=8D=E7=84=B6=E4=BD=BF=E7=94=A8=E4=BA=86?= =?UTF-8?q?=E5=8E=9F=E5=A7=8B=E8=B7=AF=E5=BE=84=EF=BC=8C=E9=80=A0=E6=88=90?= =?UTF-8?q?=E4=BA=86=E8=B7=AF=E5=BE=84=E4=B8=8D=E4=B8=80=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E5=8F=AF=E8=83=BD=E5=AF=BC=E8=87=B4?= =?UTF-8?q?bug=20=E3=80=90=E6=94=B9=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=91?= =?UTF-8?q?=E6=8A=8AIOUtils=E4=B8=AD=E7=9A=84transformPath=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E6=90=AC=E4=BA=86=E4=B8=80=E5=A5=97=E8=BF=87=E6=9D=A5?= =?UTF-8?q?=EF=BC=8C=E4=BF=9D=E8=AF=81=E5=88=A4=E6=96=AD=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=AD=98=E5=9C=A8=E5=92=8C=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E7=9A=84=E8=B7=AF=E5=BE=84=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/base/svg/IconUtils.java | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/base/svg/IconUtils.java b/designer-base/src/main/java/com/fr/base/svg/IconUtils.java index 4b5f1b881..79d3cef76 100644 --- a/designer-base/src/main/java/com/fr/base/svg/IconUtils.java +++ b/designer-base/src/main/java/com/fr/base/svg/IconUtils.java @@ -2,9 +2,15 @@ package com.fr.base.svg; import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; +import com.fr.stable.bridge.StableFactory; +import com.fr.stable.fun.ResourcePathTransformer; +import com.fr.stable.plugin.ExtraClassManagerProvider; import javax.swing.Icon; import javax.swing.ImageIcon; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; /** * 主要是用来读取svgIcon的工具类 @@ -36,7 +42,7 @@ public class IconUtils { // 判断是否以.svg结尾 if (resource.endsWith(ICON_SUFFIX_SVG)) { if (IOUtils.readResource(resource) != null) { - return SVGIcon.readSVGIcon(resource); + return SVGIcon.readSVGIcon(transformPath(resource)); } // 适配插件 return adjustPluginsPng(resource); @@ -68,15 +74,15 @@ public class IconUtils { private static Icon readNoSuffixResource(String resource, String svgIconType) { String svgPath = resource + svgIconType; if (IOUtils.readResource(svgPath) != null) { - return SVGIcon.readSVGIcon(svgPath); + return SVGIcon.readSVGIcon(transformPath(svgPath)); } String pngPath = resource + ICON_SUFFIX_PNG; if (IOUtils.readResource(pngPath) != null) { - return IOUtils.readIcon(pngPath); + return IOUtils.readIcon(transformPath(pngPath)); } String gifPath = resource + ICON_SUFFIX_GIF; if (IOUtils.readResource(gifPath) != null) { - return IOUtils.readIcon(gifPath); + return IOUtils.readIcon(transformPath(gifPath)); } FineLoggerFactory.getLogger().error("File not exists:{}", resource); return new ImageIcon(); @@ -113,8 +119,30 @@ public class IconUtils { private static Icon readSpecifiedTypeIcon(String resource, String oldSuffix, String newSuffix) { String iconPath = resource.replace(oldSuffix, newSuffix); if (IOUtils.readResource(iconPath) != null) { - return SVGIcon.readSVGIcon(iconPath); + return SVGIcon.readSVGIcon(transformPath(iconPath)); } return readIcon(resource); } + + private static String transformPath(String path) { + Set set = getResourcePathTransformers(); + for (ResourcePathTransformer transformer : set) { + if (transformer.accept(path)) { + return transformer.transform(path); + } + } + return path; + } + + private static Set getResourcePathTransformers() { + Set set = new HashSet(); + ExtraClassManagerProvider provider = StableFactory.getExtraClassManager(); + if (provider != null) { + Set pluginProvided = provider.getArray(ResourcePathTransformer.MARK_STRING); + set.addAll(pluginProvided); + } + ResourcePathTransformer[] oemSet = StableFactory.getMarkedObjectsFromCollection(ResourcePathTransformer.MARK_STRING, ResourcePathTransformer.class); + set.addAll(Arrays.asList(oemSet)); + return set; + } }