Browse Source

无jira任务 代码质量

newui
vito 11 months ago
parent
commit
edb588e7bf
  1. 3
      designer-base/src/main/java/com/fine/theme/icon/GraphicsFilter.java
  2. 17
      designer-base/src/main/java/com/fine/theme/icon/svg/SvgIcon.java

3
designer-base/src/main/java/com/fine/theme/icon/GraphicsFilter.java

@ -41,8 +41,9 @@ public class GraphicsFilter
@Override @Override
public void setPaint(Paint paint) { public void setPaint(Paint paint) {
if (paint instanceof Color) if (paint instanceof Color) {
paint = filterColor((Color) paint); paint = filterColor((Color) paint);
}
super.setPaint(paint); super.setPaint(paint);
} }

17
designer-base/src/main/java/com/fine/theme/icon/svg/SvgIcon.java

@ -42,7 +42,18 @@ import static com.fine.theme.utils.FineUIScale.scale;
public class SvgIcon implements DisabledIcon, WhiteIcon, Icon { public class SvgIcon implements DisabledIcon, WhiteIcon, Icon {
public enum Type { public enum Type {
disable, white, origin /**
* 灰化图
*/
disable,
/**
* 白化图用于反白场景
*/
white,
/**
* 原始效果图
*/
origin
} }
private final Dimension size; private final Dimension size;
@ -74,14 +85,14 @@ public class SvgIcon implements DisabledIcon, WhiteIcon, Icon {
@Override @Override
public void paintIcon(Component c, Graphics g, int x, int y) { public void paintIcon(Component c, Graphics g, int x, int y) {
if (type == Type.disable) { if (type == Type.disable) {
g = GrayGraphics(g); g = grayGraphics(g);
} }
Object[] oldRenderingHints = FlatUIUtils.setRenderingHints(g); Object[] oldRenderingHints = FlatUIUtils.setRenderingHints(g);
render(c, g, x, y); render(c, g, x, y);
FlatUIUtils.resetRenderingHints(g, oldRenderingHints); FlatUIUtils.resetRenderingHints(g, oldRenderingHints);
} }
public Graphics2D GrayGraphics(Graphics g) { public Graphics2D grayGraphics(Graphics g) {
Object grayFilterObj = UIManager.get("Component.grayFilter"); Object grayFilterObj = UIManager.get("Component.grayFilter");
RGBImageFilter grayFilter = (grayFilterObj instanceof RGBImageFilter) RGBImageFilter grayFilter = (grayFilterObj instanceof RGBImageFilter)
? (RGBImageFilter) grayFilterObj ? (RGBImageFilter) grayFilterObj

Loading…
Cancel
Save