From 0c27d45923db075de9871cc2ad97493c6bd0f6b6 Mon Sep 17 00:00:00 2001 From: vito Date: Fri, 14 Jun 2024 15:06:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=8A=A5=E9=94=99=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fine/theme/icon/svg/SvgIcon.java | 24 +++++++++++++------ .../fine/theme/light/ui/fine_light.icon.json | 1 - 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/designer-base/src/main/java/com/fine/theme/icon/svg/SvgIcon.java b/designer-base/src/main/java/com/fine/theme/icon/svg/SvgIcon.java index 331c028a17..1789d74256 100644 --- a/designer-base/src/main/java/com/fine/theme/icon/svg/SvgIcon.java +++ b/designer-base/src/main/java/com/fine/theme/icon/svg/SvgIcon.java @@ -81,19 +81,24 @@ public class SvgIcon implements DisabledIcon, WhiteIcon, Icon { /** * 用于fallback渲染disable图像,这段代码来自异常分支,使用率要保持较低水平 */ - private void fallbackRender(Component c, Graphics g, int x, int y) { + private boolean fallbackRender(Component c, Graphics g, int x, int y) { if (resource instanceof UrlIconResource) { String path = ((UrlIconResource) resource).getPath(); - String[] names = path.split(IconManager.ICON_DISABLE_SUFFIX); - if (path.contains(IconManager.ICON_DISABLE_SUFFIX) && names.length == 2) { + int index = path.lastIndexOf(IconManager.ICON_DISABLE_SUFFIX); + if (path.contains(IconManager.ICON_DISABLE_SUFFIX) && index > 0) { SVGLoader loader = new SVGLoader(); - SVGDocument document = loader.load(new UrlIconResource(names[0] + names[1]).getInputStream()); + SVGDocument document = loader.load( + new UrlIconResource(path.substring(0, index) + + path.substring(index + IconManager.ICON_DISABLE_SUFFIX.length())) + .getInputStream()); if (document != null) { document.render((JComponent) c, grayGraphics(g), new ViewBox(x, y, scaleSize.width, scaleSize.height)); + return true; } } } + return false; } private Graphics2D grayGraphics(Graphics g) { @@ -123,13 +128,18 @@ public class SvgIcon implements DisabledIcon, WhiteIcon, Icon { } else { document = svgDocument.getValue(); } + // 由于 weisj 库中加载svg描述出现问题,则返回一个Null,这里补充一个默认图标 if (document == null) { document = defaultDoc.getValue(); } document.render((JComponent) c, (Graphics2D) g, new ViewBox(x, y, scaleSize.width, scaleSize.height)); } catch (Exception e) { - FineLoggerFactory.getLogger().error("SvgIcon from url: " + resource + "can not paint.", e); - fallbackRender.render(c, g, x, y); + boolean rendered = fallbackRender.render(c, g, x, y); + if (rendered) { + FineLoggerFactory.getLogger().warn("SvgIcon from url: " + resource + " paint with fallbackRender"); + } else { + FineLoggerFactory.getLogger().error("SvgIcon from url: " + resource + "can not paint.", e); + } } } @@ -177,6 +187,6 @@ public class SvgIcon implements DisabledIcon, WhiteIcon, Icon { @FunctionalInterface interface FallbackRender { - void render(Component c, Graphics g, int x, int y); + boolean render(Component c, Graphics g, int x, int y); } } diff --git a/designer-base/src/main/resources/com/fine/theme/light/ui/fine_light.icon.json b/designer-base/src/main/resources/com/fine/theme/light/ui/fine_light.icon.json index d86b0292d9..4e3213695b 100644 --- a/designer-base/src/main/resources/com/fine/theme/light/ui/fine_light.icon.json +++ b/designer-base/src/main/resources/com/fine/theme/light/ui/fine_light.icon.json @@ -134,7 +134,6 @@ "image": "insert/image.svg", "bias": "insert/bias.svg", "sub_report": "insert/sub_report.svg", - "chart_line": "chart/chart_line.svg", "popup": { "normal": "popup/popup.svg" },