Browse Source

Ensure uri is loaded when calling #getName.

pull/188/head
weisj 4 years ago
parent
commit
89b9ed5213
  1. 16
      property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkSVGIcon.java

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

@ -129,10 +129,7 @@ public class DarkSVGIcon implements DerivableIcon<DarkSVGIcon>, RotateIcon, Seri
private boolean ensureSVGLoaded() {
if (!loaded.get()) {
if (uri == null && uriSupplier != null) {
uri = uriSupplier.get();
uriSupplier = null;
}
ensureURILoaded();
LOGGER.fine(() -> "Loading icon '" + uri.toASCIIString() + "'.");
icon.setSvgURI(uri);
loaded.set(true);
@ -141,6 +138,16 @@ public class DarkSVGIcon implements DerivableIcon<DarkSVGIcon>, RotateIcon, Seri
return false;
}
private void ensureURILoaded() {
if (uri == null && uriSupplier != null) {
uri = uriSupplier.get();
uriSupplier = null;
}
if (uri == null) {
throw new IllegalStateException("Uri is null.");
}
}
protected void updateCache(final boolean update, final Component c) {
GraphicsConfiguration gc = c != null ? c.getGraphicsConfiguration() : null;
double sx = Scale.getScaleX(gc);
@ -175,6 +182,7 @@ public class DarkSVGIcon implements DerivableIcon<DarkSVGIcon>, RotateIcon, Seri
}
protected String getName() {
ensureURILoaded();
String name = uri.toASCIIString();
name = name.substring(Math.min(name.length() - 1, name.lastIndexOf('/') + 1));
return name;

Loading…
Cancel
Save