Browse Source

Pull request #3679: REPORT-42238 【10.0.13】JDK11设计器图标模糊问题优化

Merge in DESIGN/design from ~YVAN/design:release/10.0 to release/10.0

* commit '1c4cf004df35e4218a30db43f94a7f661853e8a1':
  REPORT-42238 【10.0.13】JDK11设计器图标模糊问题优化 【问题原因】IOUtils.readResource()方法里会对实现了ResourcePathTransformer接口的某些插件资源进行文件路径的替换,而之前依靠IOUtils.readResource()判断文件是否存在时,没有考虑这一点,紧接着去读Icon的时候仍然使用了原始路径,造成了路径不一致的问题,可能导致bug 【改动思路】把IOUtils中的transformPath逻辑搬了一套过来,保证判断资源是否存在和读取资源的路径一致
feature/big-screen
ju|剧浩宇 4 years ago
parent
commit
46f82d7c99
  1. 38
      designer-base/src/main/java/com/fr/base/svg/IconUtils.java

38
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<ResourcePathTransformer> set = getResourcePathTransformers();
for (ResourcePathTransformer transformer : set) {
if (transformer.accept(path)) {
return transformer.transform(path);
}
}
return path;
}
private static Set<ResourcePathTransformer> getResourcePathTransformers() {
Set<ResourcePathTransformer> set = new HashSet<ResourcePathTransformer>();
ExtraClassManagerProvider provider = StableFactory.getExtraClassManager();
if (provider != null) {
Set<ResourcePathTransformer> 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;
}
}

Loading…
Cancel
Save