Browse Source

Ensure subtypes of SVGIcon return the correct icon type when being derived.

pull/188/head
weisj 4 years ago
parent
commit
d75362c572
  1. 10
      property-loader/src/main/java/com/github/weisj/darklaf/icons/CustomThemedIcon.java
  2. 6
      property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkSVGIcon.java
  3. 11
      property-loader/src/main/java/com/github/weisj/darklaf/icons/ThemedSVGIcon.java

10
property-loader/src/main/java/com/github/weisj/darklaf/icons/CustomThemedIcon.java

@ -45,6 +45,16 @@ public class CustomThemedIcon extends ThemedSVGIcon {
} }
} }
protected CustomThemedIcon(final int width, final int height, final CustomThemedIcon icon) {
super(width, height, icon);
this.defaults = icon.defaults;
}
@Override
public CustomThemedIcon derive(final int width, final int height) {
return new CustomThemedIcon(width, height, this);
}
@Override @Override
protected SVGIcon createSVGIcon() { protected SVGIcon createSVGIcon() {
SVGIcon icon = new SVGIcon(); SVGIcon icon = new SVGIcon();

6
property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkSVGIcon.java

@ -56,7 +56,7 @@ public class DarkSVGIcon implements DerivableIcon<DarkSVGIcon>, RotateIcon, Seri
private final Dimension size; private final Dimension size;
private final SVGIcon icon; private final SVGIcon icon;
protected final URI uri; private final URI uri;
private final AtomicBoolean loaded; private final AtomicBoolean loaded;
private boolean loadedWithExtraScale; private boolean loadedWithExtraScale;
@ -80,7 +80,7 @@ public class DarkSVGIcon implements DerivableIcon<DarkSVGIcon>, RotateIcon, Seri
loaded = new AtomicBoolean(false); loaded = new AtomicBoolean(false);
} }
private DarkSVGIcon(final int width, final int height, final DarkSVGIcon icon) { protected DarkSVGIcon(final int width, final int height, final DarkSVGIcon icon) {
this.size = new Dimension(width, height); this.size = new Dimension(width, height);
this.icon = icon.icon; this.icon = icon.icon;
this.uri = icon.uri; this.uri = icon.uri;
@ -148,7 +148,7 @@ public class DarkSVGIcon implements DerivableIcon<DarkSVGIcon>, RotateIcon, Seri
} }
} }
private String getName() { protected String getName() {
String name = uri.toASCIIString(); String name = uri.toASCIIString();
name = name.substring(Math.min(name.length() - 1, name.lastIndexOf('/') + 1)); name = name.substring(Math.min(name.length() - 1, name.lastIndexOf('/') + 1));
return name; return name;

11
property-loader/src/main/java/com/github/weisj/darklaf/icons/ThemedSVGIcon.java

@ -39,6 +39,17 @@ public class ThemedSVGIcon extends DarkSVGIcon implements ThemedIcon {
currentTheme = new Object(); currentTheme = new Object();
} }
protected ThemedSVGIcon(final int width, final int height, final ThemedSVGIcon icon) {
super(width, height, icon);
this.currentTheme = icon.currentTheme;
this.updatedNotDuringPaint = icon.updatedNotDuringPaint;
}
@Override
public ThemedSVGIcon derive(final int width, final int height) {
return new ThemedSVGIcon(width, height, this);
}
@Override @Override
protected boolean ensureLoaded(final boolean painting) { protected boolean ensureLoaded(final boolean painting) {
/* /*

Loading…
Cancel
Save