Browse Source

Improve preview for UIManagerDefaults.

pull/222/head
weisj 4 years ago
parent
commit
fac5fe81c4
  1. 5
      core/src/test/java/defaults/UIManagerDefaults.java
  2. 9
      core/src/test/resources/icon/sound.svg
  3. 14
      property-loader/src/main/java/com/github/weisj/darklaf/uiresource/DarkColorUIResource.java

5
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<Object> 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 {

9
core/src/test/resources/icon/sound.svg

@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<defs id="colors">
<linearGradient id="menuIconEnabled">
<stop offset="0" stop-color="#AFB1B3"/>
<stop offset="1" stop-color="#AFB1B3"/>
</linearGradient>
</defs>
<path fill="url(#menuIconEnabled)" d="M1 13h-1v-1h1v1zm22-1h-1v1h1v-1zm-20-1h-1v3h1v-3zm18 0h-1v3h1v-3zm-14 0h-1v3h1v-3zm10-1h-1v5h1v-5zm-12 0h-1v5h1v-5zm14-1h-1v7h1v-7zm-10 0h-1v7h1v-7zm2-2h-1v10h1v-10zm4 0h-1v10h1v-10zm-2-2h-1v14h1v-14z"/>
</svg>

After

Width:  |  Height:  |  Size: 548 B

14
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);
}
}

Loading…
Cancel
Save