Browse Source

Moved icon loading message to where the icon is actually loaded.

Signed-off-by: weisj <weisj@arcor.de>
pull/27/head
weisj 5 years ago
parent
commit
da23a880b1
  1. 5
      src/main/java/com/github/weisj/darklaf/icons/DarkSVGIcon.java
  2. 1
      src/main/java/com/github/weisj/darklaf/icons/IconLoader.java
  3. 3
      src/main/java/com/github/weisj/darklaf/icons/LazyIcon.java

5
src/main/java/com/github/weisj/darklaf/icons/DarkSVGIcon.java

@ -30,9 +30,11 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import java.io.File;
import java.io.Serializable; import java.io.Serializable;
import java.net.URI; import java.net.URI;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Logger;
/** /**
* Icon from SVG image. * Icon from SVG image.
@ -42,6 +44,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
*/ */
public class DarkSVGIcon implements Icon, Serializable { public class DarkSVGIcon implements Icon, Serializable {
private static final Logger LOGGER = Logger.getLogger(DarkSVGIcon.class.getName());
private final Dimension size; private final Dimension size;
private final SVGIcon icon; private final SVGIcon icon;
private final URI uri; private final URI uri;
@ -87,6 +90,8 @@ public class DarkSVGIcon implements Icon, Serializable {
private void ensureLoaded() { private void ensureLoaded() {
if (!loaded.get()) { if (!loaded.get()) {
File file = new File(uri);
LOGGER.info("Loading icon '" + file.getName() + "'.");
icon.setSvgURI(uri); icon.setSvgURI(uri);
loaded.set(true); loaded.set(true);
} }

1
src/main/java/com/github/weisj/darklaf/icons/IconLoader.java

@ -136,7 +136,6 @@ public final class IconLoader {
@NotNull @NotNull
public Icon loadSVGIcon(@NotNull final String name, final int w, final int h, final boolean themed) { public Icon loadSVGIcon(@NotNull final String name, final int w, final int h, final boolean themed) {
try { try {
LOGGER.info("Loading icon '" + name + "'. Resolving from " + parentClass);
if (themed) { if (themed) {
return new ThemedSVGIcon(Objects.requireNonNull(parentClass.getResource(name).toURI()), w, h); return new ThemedSVGIcon(Objects.requireNonNull(parentClass.getResource(name).toURI()), w, h);
} else { } else {

3
src/main/java/com/github/weisj/darklaf/icons/LazyIcon.java

@ -28,12 +28,14 @@ import org.jetbrains.annotations.Contract;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.UIResource; import javax.swing.plaf.UIResource;
import java.awt.*; import java.awt.*;
import java.util.logging.Logger;
/** /**
* @author Jannis Weis * @author Jannis Weis
*/ */
public abstract class LazyIcon implements Icon, UIResource { public abstract class LazyIcon implements Icon, UIResource {
private static final Logger LOGGER = Logger.getLogger(LazyIcon.class.getName());
protected final String path; protected final String path;
protected final IconLoader.IconKey key; protected final IconLoader.IconKey key;
protected final Class<?> parentClass; protected final Class<?> parentClass;
@ -55,6 +57,7 @@ public abstract class LazyIcon implements Icon, UIResource {
private void ensureLoaded() { private void ensureLoaded() {
if (!loaded) { if (!loaded) {
LOGGER.info("Loading icon '" + path + "'. Resolving from " + parentClass);
icon = loadIcon(); icon = loadIcon();
loaded = true; loaded = true;
if (icon == null) { if (icon == null) {

Loading…
Cancel
Save