From fac5fe81c48a02ada920e437b2e80195c4a68fbf Mon Sep 17 00:00:00 2001 From: weisj Date: Wed, 4 Nov 2020 20:40:48 +0100 Subject: [PATCH] Improve preview for UIManagerDefaults. --- core/src/test/java/defaults/UIManagerDefaults.java | 5 ++++- core/src/test/resources/icon/sound.svg | 9 +++++++++ .../darklaf/uiresource/DarkColorUIResource.java | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 core/src/test/resources/icon/sound.svg diff --git a/core/src/test/java/defaults/UIManagerDefaults.java b/core/src/test/java/defaults/UIManagerDefaults.java index 2c8c7fba..97bc054f 100644 --- a/core/src/test/java/defaults/UIManagerDefaults.java +++ b/core/src/test/java/defaults/UIManagerDefaults.java @@ -40,6 +40,7 @@ import javax.swing.table.DefaultTableModel; import ui.ComponentDemo; import com.github.weisj.darklaf.components.OverlayScrollPane; +import com.github.weisj.darklaf.icons.IconLoader; import com.github.weisj.darklaf.ui.table.renderer.DarkColorTableCellRendererEditor; public class UIManagerDefaults implements ItemListener, ComponentDemo { @@ -298,9 +299,11 @@ public class UIManagerDefaults implements ItemListener, ComponentDemo { final Vector row = new Vector<>(3); row.add(attribute); if (value != null) { - row.add(value instanceof Boolean ? value : value.toString()); + row.add(value.toString()); if (value instanceof Icon) { value = new SafeIcon((Icon) value); + } else if (value instanceof String && value.toString().endsWith(".wav")) { + value = IconLoader.get().getIcon("icon/sound.svg", 24, 24); } row.add(value); } else { diff --git a/core/src/test/resources/icon/sound.svg b/core/src/test/resources/icon/sound.svg new file mode 100644 index 00000000..d687fd2f --- /dev/null +++ b/core/src/test/resources/icon/sound.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/uiresource/DarkColorUIResource.java b/property-loader/src/main/java/com/github/weisj/darklaf/uiresource/DarkColorUIResource.java index b3e18b41..36b1db3e 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/uiresource/DarkColorUIResource.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/uiresource/DarkColorUIResource.java @@ -52,4 +52,18 @@ public class DarkColorUIResource extends ColorUIResource { public Color brighter() { return new DarkColorUIResource(super.brighter()); } + + @Override + public String toString() { + String s = "UIColor[r=" + format(getRed()) + ", g=" + format(getGreen()) + ",b=" + format(getBlue()); + if (getAlpha() != 255) { + s += ",a=" + format(getAlpha()); + } + s += "]"; + return s; + } + + private String format(final int value) { + return String.format("%03d", value); + } }