Browse Source

Abstract usage of IconLoader away into an interface

This opens up the possibility of providing custom icons
through themes.
pull/270/head
weisj 3 years ago
parent
commit
98d398ba5c
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 21
      core/src/main/java/com/github/weisj/darklaf/components/ColoredRadioButton.java
  2. 2
      core/src/main/java/com/github/weisj/darklaf/components/DefaultColorPipette.java
  3. 2
      core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java
  4. 2
      core/src/main/java/com/github/weisj/darklaf/components/iconeditor/IconEditorPanel.java
  5. 2
      core/src/main/java/com/github/weisj/darklaf/task/ColorAdjustmentTask.java
  6. 8
      core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java
  7. 2
      core/src/main/java/com/github/weisj/darklaf/task/SystemDefaultsInitTask.java
  8. 30
      core/src/main/java/com/github/weisj/darklaf/task/ThemeDefaultsInitTask.java
  9. 12
      core/src/main/java/com/github/weisj/darklaf/ui/util/DarkUIUtil.java
  10. 2
      core/src/test/java/com/github/weisj/darklaf/core/test/IconCacheTest.java
  11. 20
      core/src/test/java/com/github/weisj/darklaf/core/theme/MyCustomTheme.java
  12. 27
      core/src/test/java/com/github/weisj/darklaf/core/theme/ThemeEditor.java
  13. 3
      iconset/src/main/java/com/github/weisj/darklaf/iconset/IconSet.java
  14. 14
      property-loader/src/main/java/com/github/weisj/darklaf/properties/PropertyLoader.java
  15. 99
      property-loader/src/main/java/com/github/weisj/darklaf/properties/icons/IconLoader.java
  16. 50
      property-loader/src/main/java/com/github/weisj/darklaf/properties/icons/IconResolver.java
  17. 6
      property-loader/src/main/java/com/github/weisj/darklaf/properties/icons/IconUtil.java
  18. 8
      property-loader/src/main/java/com/github/weisj/darklaf/properties/parser/IconParser.java
  19. 8
      property-loader/src/main/java/com/github/weisj/darklaf/properties/parser/ParserContext.java
  20. 8
      theme/src/main/java/com/github/weisj/darklaf/theme/DarculaTheme.java
  21. 20
      theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastDarkTheme.java
  22. 20
      theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastLightTheme.java
  23. 14
      theme/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java
  24. 12
      theme/src/main/java/com/github/weisj/darklaf/theme/OneDarkTheme.java
  25. 8
      theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedDarkTheme.java
  26. 8
      theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedLightTheme.java
  27. 28
      theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java
  28. 26
      theme/src/main/java/com/github/weisj/darklaf/theme/ThemeDelegate.java

21
core/src/main/java/com/github/weisj/darklaf/components/ColoredRadioButton.java

@ -190,18 +190,19 @@ public class ColoredRadioButton extends JRadioButton {
}
this.patchedColor = color;
this.patchedFocusColor = focusColor;
IconLoader loader = DarkUIUtil.iconLoader();
IconLoader iconLoader = DarkUIUtil.radioButtonLoader();
Theme theme = LafManager.getInstalledTheme();
Properties props = new Properties();
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
theme.loadDefaults(props, defaults, loader);
theme.loadDefaults(props, defaults, iconLoader);
Color accentCol = color == DEFAULT_COLOR ? (Color) props.get("widgetFillDefault") : color;
Color focusCol = focusColor == DEFAULT_COLOR ? accentCol : focusColor;
adjustment.applyColors(theme, props, accentCol, null);
PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, "radioButton", "ui/"),
props, defaults, loader);
props, defaults, iconLoader);
PropertyLoader.putProperties(PropertyLoader.loadProperties(IconSet.class, "radioButton", ""),
props, defaults, loader);
props, defaults, iconLoader);
propertyMap = new Properties();
for (String prop : PROPERTIES) {
propertyMap.put(prop, props.get(prop));
@ -221,12 +222,12 @@ public class ColoredRadioButton extends JRadioButton {
}
stateIcon = new StateIcon(new Icon[] {
load(loader, "control/radio.svg"),
load(loader, "control/radioDisabled.svg"),
load(loader, "control/radioFocused.svg"),
load(loader, "control/radioSelected.svg"),
load(loader, "control/radioSelectedDisabled.svg"),
load(loader, "control/radioSelectedFocused.svg")});
load(iconLoader, "control/radio.svg"),
load(iconLoader, "control/radioDisabled.svg"),
load(iconLoader, "control/radioFocused.svg"),
load(iconLoader, "control/radioSelected.svg"),
load(iconLoader, "control/radioSelectedDisabled.svg"),
load(iconLoader, "control/radioSelectedFocused.svg")});
patched = true;
}

2
core/src/main/java/com/github/weisj/darklaf/components/DefaultColorPipette.java

@ -176,7 +176,7 @@ public class DefaultColorPipette extends ColorPipetteBase {
protected Icon getPipetteIcon() {
Icon icon = UIManager.getIcon("ColorChooser.pipette.icon");
if (icon == null) icon = DarkUIUtil.iconLoader().getIcon("misc/pipette.svg", true);
if (icon == null) icon = DarkUIUtil.iconResolver().getIcon("misc/pipette.svg", true);
if (icon == null) icon = EmptyIcon.create(0);
return icon;
}

2
core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java

@ -208,7 +208,7 @@ public class SmallColorChooser extends JPanel implements ChooserComponent<Color>
private JButton createPipetteButton() {
Icon pipetteIcon = UIManager.getIcon("ColorChooser.pipette.icon");
if (pipetteIcon == null) pipetteIcon = DarkUIUtil.iconLoader().getIcon("misc/pipette.svg", true);
if (pipetteIcon == null) pipetteIcon = DarkUIUtil.iconResolver().getIcon("misc/pipette.svg", true);
Icon pipetteHoverIcon = UIManager.getIcon("ColorChooser.pipetteRollover.icon");
JButton pipetteButton = new JButton();
DefaultColorPipette defaultPipette = new DefaultColorPipette(this, (c, o) -> setColor(pipetteButton,

2
core/src/main/java/com/github/weisj/darklaf/components/iconeditor/IconEditorPanel.java

@ -378,7 +378,7 @@ public class IconEditorPanel extends JPanel {
}.getDefaults();
}
Properties props = new Properties();
theme.loadIconTheme(props, defaults, DarkUIUtil.iconLoader());
theme.loadIconTheme(props, defaults, DarkUIUtil.iconResolver());
props.entrySet().forEach(e -> e.setValue(defaults.get(e.getKey())));
return new ThemeIconDefaults(defaults, props);
});

2
core/src/main/java/com/github/weisj/darklaf/task/ColorAdjustmentTask.java

@ -57,7 +57,7 @@ public abstract class ColorAdjustmentTask implements DefaultsAdjustmentTask {
protected void adjust(final String listKey, final Properties listProperties, final Consumer<Map<?, ?>> action) {
ParseResult p = Parser.parse(Parser.createParseResult(listKey, listProperties.getProperty(listKey)),
new ParserContext(listProperties, DEFAULTS, DarkUIUtil.iconLoader()));
new ParserContext(listProperties, DEFAULTS, DarkUIUtil.iconResolver()));
Object obj = p.result;
if (obj instanceof Map<?, ?>) {
action.accept((Map<?, ?>) obj);

8
core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java

@ -35,7 +35,7 @@ import javax.swing.plaf.UIResource;
import com.github.weisj.darklaf.DarkLaf;
import com.github.weisj.darklaf.properties.PropertyLoader;
import com.github.weisj.darklaf.properties.icons.IconLoader;
import com.github.weisj.darklaf.properties.icons.IconResolver;
import com.github.weisj.darklaf.properties.uiresource.DarkFontUIResource;
import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.theme.info.FontSizeRule;
@ -176,12 +176,12 @@ public class FontDefaultsInitTask implements DefaultsInitTask {
}
private void loadFontProperties(final UIDefaults defaults) {
IconLoader iconLoader = DarkUIUtil.iconLoader();
IconResolver iconResolver = DarkUIUtil.iconResolver();
Properties fontSizeProps =
PropertyLoader.loadProperties(DarkLaf.class, FONT_SIZE_DEFAULTS_NAME, FONT_PROPERTY_PATH);
PropertyLoader.putProperties(fontSizeProps, defaults, iconLoader);
PropertyLoader.putProperties(fontSizeProps, defaults, iconResolver);
Properties fontProps = PropertyLoader.loadProperties(DarkLaf.class, FONT_DEFAULTS_NAME, FONT_PROPERTY_PATH);
PropertyLoader.putProperties(fontProps, defaults, iconLoader);
PropertyLoader.putProperties(fontProps, defaults, iconResolver);
}
private void patchOSFonts(final UIDefaults defaults, final Function<Map.Entry<Object, Font>, Font> mapper) {

2
core/src/main/java/com/github/weisj/darklaf/task/SystemDefaultsInitTask.java

@ -45,6 +45,6 @@ public class SystemDefaultsInitTask implements DefaultsInitTask {
overwrites.values().removeIf(v -> System.getProperty(DarkLaf.SYSTEM_PROPERTY_PREFIX + v.toString()) == null);
overwrites.entrySet()
.forEach(e -> e.setValue(System.getProperty(DarkLaf.SYSTEM_PROPERTY_PREFIX + e.getValue().toString())));
PropertyLoader.putProperties(overwrites, defaults, DarkUIUtil.iconLoader());
PropertyLoader.putProperties(overwrites, defaults, DarkUIUtil.iconResolver());
}
}

30
core/src/main/java/com/github/weisj/darklaf/task/ThemeDefaultsInitTask.java

@ -32,7 +32,7 @@ import com.github.weisj.darklaf.DarkLaf;
import com.github.weisj.darklaf.iconset.IconSet;
import com.github.weisj.darklaf.platform.DecorationsHandler;
import com.github.weisj.darklaf.properties.PropertyLoader;
import com.github.weisj.darklaf.properties.icons.IconLoader;
import com.github.weisj.darklaf.properties.icons.IconResolver;
import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.ui.util.DarkUIUtil;
import com.github.weisj.darklaf.util.PropertyUtil;
@ -66,7 +66,7 @@ public class ThemeDefaultsInitTask implements DefaultsInitTask {
private void loadThemeDefaults(final Theme currentTheme, final UIDefaults defaults) {
Properties uiProps = new Properties();
currentTheme.loadDefaults(uiProps, defaults, DarkUIUtil.iconLoader());
currentTheme.loadDefaults(uiProps, defaults, DarkUIUtil.iconResolver());
backupAccentColors(uiProps);
@ -111,11 +111,11 @@ public class ThemeDefaultsInitTask implements DefaultsInitTask {
}
private void initGlobals(final Theme currentTheme, final UIDefaults defaults, final Properties uiProps) {
IconLoader iconLoader = DarkUIUtil.iconLoader();
IconResolver iconResolver = DarkUIUtil.iconResolver();
PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, "globals", ""),
uiProps, defaults, iconLoader);
uiProps, defaults, iconResolver);
currentTheme.customizeGlobals(uiProps, defaults, iconLoader);
currentTheme.customizeGlobals(uiProps, defaults, iconResolver);
installGlobals(uiProps, defaults);
}
@ -135,30 +135,30 @@ public class ThemeDefaultsInitTask implements DefaultsInitTask {
}
private void initUIProperties(final Theme currentTheme, final UIDefaults defaults, final Properties uiProps) {
IconLoader iconLoader = DarkUIUtil.iconLoader();
IconResolver iconResolver = DarkUIUtil.iconResolver();
for (String property : UI_PROPERTIES) {
PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, property, "ui/"),
uiProps, defaults, iconLoader);
uiProps, defaults, iconResolver);
}
currentTheme.customizeUIProperties(uiProps, defaults, iconLoader);
currentTheme.customizeUIProperties(uiProps, defaults, iconResolver);
}
private void initIconTheme(final Theme currentTheme, final UIDefaults defaults, final Properties uiProps) {
IconLoader iconLoader = DarkUIUtil.iconLoader();
currentTheme.loadIconTheme(uiProps, defaults, iconLoader);
IconResolver iconResolver = DarkUIUtil.iconResolver();
currentTheme.loadIconTheme(uiProps, defaults, iconResolver);
for (String property : ICON_PROPERTIES) {
PropertyLoader.putProperties(PropertyLoader.loadProperties(IconSet.class, property, ""),
uiProps, defaults, iconLoader);
uiProps, defaults, iconResolver);
}
currentTheme.customizeIconTheme(uiProps, defaults, iconLoader);
currentTheme.customizeIconTheme(uiProps, defaults, iconResolver);
}
private void initPlatformProperties(final Theme currentTheme, final UIDefaults defaults, final Properties uiProps) {
IconLoader iconLoader = DarkUIUtil.iconLoader();
IconResolver iconResolver = DarkUIUtil.iconResolver();
PropertyLoader.putProperties(
PropertyLoader.loadProperties(DarkLaf.class, SystemInfo.getOsName(), "platform/"),
uiProps, defaults, iconLoader);
currentTheme.customizePlatformProperties(uiProps, defaults, iconLoader);
uiProps, defaults, iconResolver);
currentTheme.customizePlatformProperties(uiProps, defaults, iconResolver);
}
private void adjustPlatformSpecifics(final Properties uiProps) {

12
core/src/main/java/com/github/weisj/darklaf/ui/util/DarkUIUtil.java

@ -44,6 +44,7 @@ import javax.swing.tree.TreeCellRenderer;
import com.github.weisj.darklaf.focus.FocusParentHelper;
import com.github.weisj.darklaf.iconset.IconSet;
import com.github.weisj.darklaf.properties.icons.IconLoader;
import com.github.weisj.darklaf.properties.icons.IconResolver;
import com.github.weisj.darklaf.ui.cell.CellRenderer;
import com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuUI;
import com.github.weisj.darklaf.ui.table.header.DarkTableHeaderRendererPane;
@ -57,10 +58,19 @@ public final class DarkUIUtil {
private static final int CELL_SEARCH_DEPTH = 3;
public static IconLoader iconLoader() {
public static IconResolver iconResolver() {
return IconSet.iconLoader();
}
/**
* Only exists for {@link com.github.weisj.darklaf.components.ColoredRadioButton}
*
* @return the icon loader housing the radio button icons.
*/
public static IconLoader radioButtonLoader() {
return IconLoader.get(IconSet.class);
}
private static final Rectangle iconRect = new Rectangle();
private static final Rectangle textRect = new Rectangle();

2
core/src/test/java/com/github/weisj/darklaf/core/test/IconCacheTest.java

@ -38,7 +38,7 @@ class IconCacheTest implements NonThreadSafeTest {
@Test
void testIconCacheGetsReleased() {
IconLoader iconLoader = IconSet.iconLoader();
IconLoader iconLoader = (IconLoader) IconSet.iconLoader();
iconLoader.clearCache();
UIDefaults defaults = new DarkLaf().getDefaults();
Assertions.assertFalse(iconLoader.isCacheEmpty());

20
core/src/test/java/com/github/weisj/darklaf/core/theme/MyCustomTheme.java

@ -25,7 +25,7 @@ import java.util.Properties;
import javax.swing.UIDefaults;
import com.github.weisj.darklaf.properties.icons.IconLoader;
import com.github.weisj.darklaf.properties.icons.IconResolver;
import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.theme.info.ColorToneRule;
import com.github.weisj.darklaf.theme.info.PresetIconRule;
@ -35,33 +35,33 @@ public class MyCustomTheme extends Theme {
@Override
public void customizeGlobals(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
super.customizeGlobals(properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
super.customizeGlobals(properties, currentDefaults, iconResolver);
/*
* Properties in the globals file should have a 'globals.' to be applied globally.
*/
loadCustomProperties("globals", properties, currentDefaults, iconLoader);
loadCustomProperties("globals", properties, currentDefaults, iconResolver);
}
@Override
public void customizePlatformProperties(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
super.customizePlatformProperties(properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
super.customizePlatformProperties(properties, currentDefaults, iconResolver);
/*
* Loading this file (and having it present) is optional.
*/
final String osSuffix = SystemInfo.isMac ? "mac" : SystemInfo.isWindows ? "windows" : "linux";
loadCustomProperties(osSuffix, properties, currentDefaults, iconLoader);
loadCustomProperties(osSuffix, properties, currentDefaults, iconResolver);
}
@Override
public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
super.customizeUIProperties(properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
super.customizeUIProperties(properties, currentDefaults, iconResolver);
/*
* Loading this file (and having it present) is optional.
*/
loadCustomProperties("ui", properties, currentDefaults, iconLoader);
loadCustomProperties("ui", properties, currentDefaults, iconResolver);
}
@Override

27
core/src/test/java/com/github/weisj/darklaf/core/theme/ThemeEditor.java

@ -64,6 +64,7 @@ import com.github.weisj.darklaf.iconset.AllIcons;
import com.github.weisj.darklaf.layout.LayoutHelper;
import com.github.weisj.darklaf.properties.icons.DerivableIcon;
import com.github.weisj.darklaf.properties.icons.IconLoader;
import com.github.weisj.darklaf.properties.icons.IconResolver;
import com.github.weisj.darklaf.properties.icons.OverlayIcon;
import com.github.weisj.darklaf.properties.icons.TextIcon;
import com.github.weisj.darklaf.properties.uiresource.DarkColorUIResource;
@ -171,8 +172,8 @@ public class ThemeEditor extends JPanel {
@Override
public void loadDefaults(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
super.loadDefaults(properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
super.loadDefaults(properties, currentDefaults, iconResolver);
putAll(properties, themeDefaults);
properties.put(KEY_DARK, darkToggle.isSelected());
properties.put(KEY_HIGH_CONTRAST, contrastToggle.isSelected());
@ -180,25 +181,25 @@ public class ThemeEditor extends JPanel {
@Override
public void customizeGlobals(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
final IconResolver iconResolver) {
properties.putAll(globalDefaults);
}
@Override
public void customizePlatformProperties(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
final IconResolver iconResolver) {
properties.putAll(platformDefaults);
}
@Override
public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
final IconResolver iconResolver) {
properties.putAll(uiDefaults);
}
@Override
public void customizeIconTheme(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
final IconResolver iconResolver) {
properties.putAll(iconDefaults);
}
};
@ -221,25 +222,25 @@ public class ThemeEditor extends JPanel {
@Override
public void customizeGlobals(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
final IconResolver iconResolver) {
RecordingProperties props = new RecordingProperties(properties);
super.customizeGlobals(props, currentDefaults, iconLoader);
super.customizeGlobals(props, currentDefaults, iconResolver);
putAll(globalDefaults, props.getRecording());
}
@Override
public void customizePlatformProperties(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
final IconResolver iconResolver) {
RecordingProperties props = new RecordingProperties(properties);
super.customizePlatformProperties(props, currentDefaults, iconLoader);
super.customizePlatformProperties(props, currentDefaults, iconResolver);
putAll(platformDefaults, props.getRecording());
}
@Override
public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
final IconResolver iconResolver) {
RecordingProperties props = new RecordingProperties(properties);
super.customizeUIProperties(props, currentDefaults, iconLoader);
super.customizeUIProperties(props, currentDefaults, iconResolver);
putAll(uiDefaults, props.getRecording());
}
};
@ -282,7 +283,7 @@ public class ThemeEditor extends JPanel {
Font font = FontUtil.createFont(Font.MONOSPACED, Font.BOLD, 13);
return new TextIcon("42", new ThemedColor("menuIconEnabled"), font, 16, 16);
}).get()),
BOOLEAN("Add Boolean", false, DarkUIUtil.iconLoader().getIcon("control/checkBoxSelectedFocused.svg", true)),
BOOLEAN("Add Boolean", false, DarkUIUtil.iconResolver().getIcon("control/checkBoxSelectedFocused.svg", true)),
STRING("Add String", "", IconLoader.get(ThemeEditor.class).getIcon("word.svg", true));
private final String s;

3
iconset/src/main/java/com/github/weisj/darklaf/iconset/IconSet.java

@ -22,11 +22,12 @@
package com.github.weisj.darklaf.iconset;
import com.github.weisj.darklaf.properties.icons.IconLoader;
import com.github.weisj.darklaf.properties.icons.IconResolver;
public class IconSet {
private static final IconLoader ICON_LOADER = IconLoader.get(IconSet.class);
public static IconLoader iconLoader() {
public static IconResolver iconLoader() {
return ICON_LOADER;
}
}

14
property-loader/src/main/java/com/github/weisj/darklaf/properties/PropertyLoader.java

@ -31,7 +31,7 @@ import java.util.logging.Logger;
import javax.swing.*;
import com.github.weisj.darklaf.properties.icons.IconLoader;
import com.github.weisj.darklaf.properties.icons.IconResolver;
import com.github.weisj.darklaf.properties.parser.ParseResult;
import com.github.weisj.darklaf.properties.parser.Parser;
import com.github.weisj.darklaf.properties.parser.ParserContext;
@ -57,18 +57,18 @@ public final class PropertyLoader {
}
public static void putProperties(final Properties properties, final Properties accumulator,
final UIDefaults currentDefaults, final IconLoader iconLoader) {
putProperties(properties, properties.stringPropertyNames(), accumulator, currentDefaults, iconLoader);
final UIDefaults currentDefaults, final IconResolver iconResolver) {
putProperties(properties, properties.stringPropertyNames(), accumulator, currentDefaults, iconResolver);
}
public static void putProperties(final Properties properties, final UIDefaults defaults,
final IconLoader iconLoader) {
putProperties(properties, properties.stringPropertyNames(), defaults, defaults, iconLoader);
final IconResolver iconResolver) {
putProperties(properties, properties.stringPropertyNames(), defaults, defaults, iconResolver);
}
public static void putProperties(final Map<Object, Object> properties, final Set<String> keys,
final Map<Object, Object> accumulator, final UIDefaults currentDefaults, final IconLoader iconLoader) {
ParserContext context = new ParserContext(accumulator, currentDefaults, iconLoader);
final Map<Object, Object> accumulator, final UIDefaults currentDefaults, final IconResolver iconResolver) {
ParserContext context = new ParserContext(accumulator, currentDefaults, iconResolver);
for (final String key : keys) {
final String value = properties.get(key).toString();
ParseResult parseResult = Parser.parse(Parser.createParseResult(key, value), context);

99
property-loader/src/main/java/com/github/weisj/darklaf/properties/icons/IconLoader.java

@ -35,12 +35,16 @@ import java.util.logging.Logger;
import javax.swing.*;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.github.weisj.darklaf.util.LazyValue;
import com.github.weisj.darklaf.util.LogUtil;
import com.github.weisj.darklaf.util.cache.SoftCache;
/** @author Jannis Weis */
public final class IconLoader {
public final class IconLoader implements IconResolver {
private static final Logger LOGGER = LogUtil.getLogger(IconLoader.class);
private static final Map<Class<?>, IconLoader> iconLoaderMap = new HashMap<>();
private static final LazyValue<IconLoader> instance = new LazyValue<>(() -> get(null));
@ -51,7 +55,7 @@ public final class IconLoader {
// Infer size by default.
private static final int DEFAULT_WIDTH_SVG = -1;
private static final int DEFAULT_HEIGHT_SVG = -1;
private final Class<?> parentClass;
private final @Nullable Class<?> parentClass;
private boolean cacheEnabled = true;
private final SoftCache<IconKey, DarkUIAwareIcon> awareIconCache = new SoftCache<>();
@ -85,7 +89,7 @@ public final class IconLoader {
return awareIconCache.isEmpty() && iconCache.isEmpty();
}
private IconLoader(final Class<?> parentClass) {
private IconLoader(final @Nullable Class<?> parentClass) {
this.parentClass = parentClass;
iconLoaderMap.put(parentClass, this);
}
@ -95,7 +99,7 @@ public final class IconLoader {
*
* @return the default icon loader.
*/
public static IconLoader get() {
public static @NotNull IconLoader get() {
return instance.get();
}
@ -104,7 +108,7 @@ public final class IconLoader {
*
* @return the default icon loader.
*/
public static IconLoader get(final Class<?> parentClass) {
public static @NotNull IconLoader get(final @Nullable Class<?> parentClass) {
if (iconLoaderMap.containsKey(parentClass)) {
return iconLoaderMap.get(parentClass);
} else {
@ -195,10 +199,31 @@ public final class IconLoader {
* @param path the path to the icon resource described as above.
* @return the icon.
*/
public DarkUIAwareIcon getUIAwareIcon(final String path) {
@Override
public @NotNull DarkUIAwareIcon getUIAwareIcon(final @NotNull String path) {
return getUIAwareIcon(path, getDefaultWidth(path), getDefaultHeight(path));
}
/**
* Get an aware icon. If [path] is the search root of the current icon loader then the icon resource
* will be resolved to [path]/dark/[icon_path] and [path]/light/[icon_path]
*
* @param path the path to the icon resource described as above.
* @param w the icon width.
* @param h the icon height.
* @return the icon.
*/
@Override
public @NotNull DarkUIAwareIcon getUIAwareIcon(final @NotNull String path, final int w, final int h) {
IconKey key = new IconKey(path, w, h);
DarkUIAwareIcon icon;
if (!isCacheEnabled() || ((icon = awareIconCache.get(key)) == null)) {
icon = createUIAwareIcon(path, w, h);
cache(awareIconCache, key, icon);
}
return icon;
}
/**
* Creates a new {@link UIAwareIcon} which is loaded lazily through the given supplier.
*
@ -206,7 +231,7 @@ public final class IconLoader {
* @param darkIconSupplier the supplier for the dark icon.
* @return the {@link UIAwareIcon}
*/
public UIAwareIcon createUIAwareIcon(final IconSupplier<Icon> lightIconSupplier,
public @NotNull UIAwareIcon createUIAwareIcon(final IconSupplier<Icon> lightIconSupplier,
final IconSupplier<Icon> darkIconSupplier) {
return new LazyUIAwareIcon(lightIconSupplier, darkIconSupplier);
}
@ -218,33 +243,14 @@ public final class IconLoader {
* @param dark the dark version of the icon.
* @return the {@link UIAwareIcon}.
*/
public UIAwareIcon createUIAwareIcon(final Icon light, final Icon dark) {
public @NotNull UIAwareIcon createUIAwareIcon(final Icon light, final Icon dark) {
return new SimpleUIAwareIcon(light, dark);
}
/**
* Get an aware icon. If [path] is the search root of the current icon loader then the icon resource
* will be resolved to [path]/dark/[icon_path] and [path]/light/[icon_path]
*
* @param path the path to the icon resource described as above.
* @param w the icon width.
* @param h the icon height.
* @return the icon.
*/
public DarkUIAwareIcon getUIAwareIcon(final String path, final int w, final int h) {
IconKey key = new IconKey(path, w, h);
DarkUIAwareIcon icon;
if (!isCacheEnabled() || ((icon = awareIconCache.get(key)) == null)) {
icon = createUIAwareIcon(path, w, h);
cache(awareIconCache, key, icon);
}
return icon;
}
/*
* Helper method to create the icons.
*/
protected DarkUIAwareIcon createUIAwareIcon(final String name, final int w, final int h) {
protected @NotNull DarkUIAwareIcon createUIAwareIcon(final @NotNull String name, final int w, final int h) {
return new DarkUIAwareIcon("dark/" + name, "light/" + name, w, h, parentClass);
}
@ -257,7 +263,8 @@ public final class IconLoader {
* @param path the path to the icon with respect to the IconLoader resource root.
* @return the icon.
*/
public Icon getIcon(final String path) {
@Override
public @NotNull Icon getIcon(final @NotNull String path) {
return getIcon(path, getDefaultWidth(path), getDefaultHeight(path));
}
@ -271,7 +278,8 @@ public final class IconLoader {
* @param themed determines whether the icon is themed. This only has an effect on svg icons.
* @return the icon.
*/
public Icon getIcon(final String path, final boolean themed) {
@Override
public @NotNull Icon getIcon(final @NotNull String path, final boolean themed) {
return getIcon(path, getDefaultWidth(path), getDefaultHeight(path), themed);
}
@ -286,7 +294,8 @@ public final class IconLoader {
* @param h the icon height.
* @return the icon.
*/
public Icon getIcon(final String path, final int w, final int h) {
@Override
public @NotNull Icon getIcon(final @NotNull String path, final int w, final int h) {
return getIcon(path, w, h, false);
}
@ -302,11 +311,13 @@ public final class IconLoader {
* @param themed determines whether the icon is themed. This only has an effect on svg icons.
* @return the icon.
*/
public Icon getIcon(final String path, final int w, final int h, final boolean themed) {
@Override
public @NotNull Icon getIcon(final @NotNull String path, final int w, final int h, final boolean themed) {
return getIconImpl(path, w, h, themed);
}
private Icon getIconImpl(final String path, final int w, final int h, final boolean themed) {
@NotNull
private Icon getIconImpl(final @NotNull String path, final int w, final int h, final boolean themed) {
synchronized (this) {
IconKey key = new IconKey(path, w, h);
@ -330,7 +341,7 @@ public final class IconLoader {
}
}
private CacheableIcon getWildcardIcon(final SoftCache<IconKey, CacheableIcon> iconMap,
private @Nullable CacheableIcon getWildcardIcon(final SoftCache<IconKey, CacheableIcon> iconMap,
final IconKey iconKey, final int w, final int h) {
iconKey.isWildcardEnabled = true;
CacheableIcon icon = iconMap.get(iconKey);
@ -361,7 +372,7 @@ public final class IconLoader {
* @param themed determines whether the icon is themed. This only has an effect on svg icons.
* @return the icon.
*/
public Icon loadSVGIcon(final String path, final boolean themed) {
public @NotNull Icon loadSVGIcon(final @NotNull String path, final boolean themed) {
return loadSVGIcon(path, DEFAULT_WIDTH_SVG, DEFAULT_HEIGHT_SVG, themed);
}
@ -376,7 +387,7 @@ public final class IconLoader {
* @param themed determines whether the icon is themed. This only has an effect on svg icons.
* @return the icon.
*/
public Icon loadSVGIcon(final String path, final int w, final int h, final boolean themed) {
public @NotNull Icon loadSVGIcon(final @NotNull String path, final int w, final int h, final boolean themed) {
return loadSVGIcon(path, w, h, themed, null);
}
@ -393,7 +404,7 @@ public final class IconLoader {
* will be used.
* @return the icon.
*/
public Icon loadSVGIcon(final String path, final int w, final int h, final boolean themed,
public @NotNull Icon loadSVGIcon(final @NotNull String path, final int w, final int h, final boolean themed,
final Map<Object, Object> propertyMap) {
return loadSVGIconInternal(path, w, h, themed, propertyMap);
}
@ -439,7 +450,8 @@ public final class IconLoader {
* {@link ImageIcon#setDescription(String)}
* @return the ImageIcon.
*/
ImageIcon createImageIcon(final String path, final String description) {
@Nullable
ImageIcon createImageIcon(final @NotNull String path, final String description) {
URL imgURL = getResource(path);
if (imgURL != null) {
return new ImageIcon(imgURL, description);
@ -458,7 +470,8 @@ public final class IconLoader {
* @param window the window.
* @return the converted {@link Image}.
*/
public static Image createFrameIcon(final Icon icon, final Window window) {
@Contract("null,_ -> null")
public static Image createFrameIcon(final @Nullable Icon icon, final Window window) {
return IconUtil.createFrameIcon(icon, window);
}
@ -472,11 +485,11 @@ public final class IconLoader {
* @param h the new height.
* @return the derived icon.
*/
public static Icon createDerivedIcon(final Icon icon, final int w, final int h) {
public static @NotNull Icon createDerivedIcon(final @NotNull Icon icon, final int w, final int h) {
return IconUtil.createDerivedIcon(icon, w, h);
}
protected URL getResource(final String name) {
private URL getResource(final String name) {
if (parentClass != null) {
return parentClass.getResource(name);
} else {
@ -501,7 +514,7 @@ public final class IconLoader {
public interface CacheableIcon extends Icon, SoftCache.Cacheable<IconKey> {
}
protected static final class IconKey {
static final class IconKey {
final String path;
int w;
int h;
@ -526,7 +539,7 @@ public final class IconLoader {
IconKey iconKey = (IconKey) o;
if (iconKey.isWildcardEnabled || this.isWildcardEnabled) {
// Math any size.
// Match any size.
return Objects.equals(path, iconKey.path);
}
if (w != iconKey.w) return false;

50
property-loader/src/main/java/com/github/weisj/darklaf/properties/icons/IconResolver.java

@ -0,0 +1,50 @@
/*
* MIT License
*
* Copyright (c) 2021 Jannis Weis
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package com.github.weisj.darklaf.properties.icons;
import javax.swing.Icon;
import org.jetbrains.annotations.NotNull;
/**
* Responsible for resolving icons.
*/
public interface IconResolver {
@NotNull
Icon getIcon(final @NotNull String path);
@NotNull
Icon getIcon(final @NotNull String path, final boolean themed);
@NotNull
Icon getIcon(final @NotNull String path, final int width, final int height);
@NotNull
Icon getIcon(final @NotNull String path, final int width, final int height, final boolean themed);
@NotNull
UIAwareIcon getUIAwareIcon(final @NotNull String path);
@NotNull
UIAwareIcon getUIAwareIcon(final @NotNull String path, final int width, final int height);
}

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

@ -29,6 +29,9 @@ import java.util.WeakHashMap;
import javax.swing.*;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import com.github.weisj.darklaf.util.ImageUtil;
import com.github.weisj.darklaf.util.PropertyKey;
import com.github.weisj.darklaf.util.Scale;
@ -49,6 +52,7 @@ public final class IconUtil {
return windowIconSet.size();
}
@Contract("null,_ -> null")
public static Image createFrameIcon(final Icon icon, final Window c) {
if (icon == null) return null;
if (c != null) {
@ -103,7 +107,7 @@ public final class IconUtil {
}
}
public static Icon createDerivedIcon(final Icon icon, final int w, final int h) {
public static @NotNull Icon createDerivedIcon(final @NotNull Icon icon, final int w, final int h) {
int iconWidth = icon.getIconWidth();
int iconHeight = icon.getIconHeight();
if (iconHeight == h && iconWidth == w) return icon;

8
property-loader/src/main/java/com/github/weisj/darklaf/properties/parser/IconParser.java

@ -27,9 +27,9 @@ import java.util.List;
import javax.swing.Icon;
import com.github.weisj.darklaf.properties.icons.DarkUIAwareIcon;
import com.github.weisj.darklaf.properties.icons.EmptyIcon;
import com.github.weisj.darklaf.properties.icons.StateIcon;
import com.github.weisj.darklaf.properties.icons.UIAwareIcon;
public class IconParser extends KeyFilteredParser implements Delimiters {
@ -81,16 +81,16 @@ public class IconParser extends KeyFilteredParser implements Delimiters {
if (ICON_EMPTY.equals(parseResult.value)) {
icon = EmptyIcon.create(dim.width, dim.height);
} else if (themed) {
icon = context.iconLoader.getIcon(parseResult.value, dim.width, dim.height, true);
icon = context.iconResolver.getIcon(parseResult.value, dim.width, dim.height, true);
} else if (dual || aware) {
DarkUIAwareIcon awareIcon = context.iconLoader.getUIAwareIcon(parseResult.value, dim.width, dim.height);
UIAwareIcon awareIcon = context.iconResolver.getUIAwareIcon(parseResult.value, dim.width, dim.height);
if (dual) {
icon = awareIcon.getDual();
} else {
icon = awareIcon;
}
} else {
icon = context.iconLoader.getIcon(parseResult.value, dim.width, dim.height);
icon = context.iconResolver.getIcon(parseResult.value, dim.width, dim.height);
}
return ParserUtil.setNonNull(parseResult, icon);
}

8
property-loader/src/main/java/com/github/weisj/darklaf/properties/parser/ParserContext.java

@ -23,17 +23,17 @@ package com.github.weisj.darklaf.properties.parser;
import java.util.Map;
import com.github.weisj.darklaf.properties.icons.IconLoader;
import com.github.weisj.darklaf.properties.icons.IconResolver;
public class ParserContext {
public final Map<Object, Object> accumulator;
public final Map<Object, Object> defaults;
public final IconLoader iconLoader;
public final IconResolver iconResolver;
public ParserContext(final Map<Object, Object> accumulator, final Map<Object, Object> defaults,
final IconLoader iconLoader) {
final IconResolver iconResolver) {
this.accumulator = accumulator;
this.defaults = defaults;
this.iconLoader = iconLoader;
this.iconResolver = iconResolver;
}
}

8
theme/src/main/java/com/github/weisj/darklaf/theme/DarculaTheme.java

@ -26,7 +26,7 @@ import java.util.Properties;
import javax.swing.*;
import com.github.weisj.darklaf.annotations.SynthesiseLaf;
import com.github.weisj.darklaf.properties.icons.IconLoader;
import com.github.weisj.darklaf.properties.icons.IconResolver;
import com.github.weisj.darklaf.theme.info.ColorToneRule;
import com.github.weisj.darklaf.theme.info.PresetIconRule;
import com.google.auto.service.AutoService;
@ -78,8 +78,8 @@ public class DarculaTheme extends Theme {
@Override
public void loadIconTheme(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
super.loadIconTheme(properties, currentDefaults, iconLoader);
loadCustomProperties("icons", properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
super.loadIconTheme(properties, currentDefaults, iconResolver);
loadCustomProperties("icons", properties, currentDefaults, iconResolver);
}
}

20
theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastDarkTheme.java

@ -27,7 +27,7 @@ import javax.swing.*;
import com.github.weisj.darklaf.annotations.SynthesiseLaf;
import com.github.weisj.darklaf.properties.PropertyLoader;
import com.github.weisj.darklaf.properties.icons.IconLoader;
import com.github.weisj.darklaf.properties.icons.IconResolver;
import com.github.weisj.darklaf.theme.info.ColorToneRule;
import com.github.weisj.darklaf.theme.info.ContrastRule;
import com.github.weisj.darklaf.theme.info.PresetIconRule;
@ -74,24 +74,24 @@ public class HighContrastDarkTheme extends Theme {
@Override
public void loadIconTheme(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
final IconResolver iconResolver) {
// First load base theme
super.loadIconTheme(properties, currentDefaults, iconLoader);
super.loadIconTheme(properties, currentDefaults, iconResolver);
// Then customize using our own values.
PropertyLoader.putProperties(loadPropertyFile("icons"), properties, currentDefaults, iconLoader);
PropertyLoader.putProperties(loadPropertyFile("icons"), properties, currentDefaults, iconResolver);
}
@Override
public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
super.customizeUIProperties(properties, currentDefaults, iconLoader);
loadCustomProperties("ui", properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
super.customizeUIProperties(properties, currentDefaults, iconResolver);
loadCustomProperties("ui", properties, currentDefaults, iconResolver);
}
@Override
public void customizePlatformProperties(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
super.customizePlatformProperties(properties, currentDefaults, iconLoader);
loadCustomProperties("platform", properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
super.customizePlatformProperties(properties, currentDefaults, iconResolver);
loadCustomProperties("platform", properties, currentDefaults, iconResolver);
}
}

20
theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastLightTheme.java

@ -27,7 +27,7 @@ import javax.swing.*;
import com.github.weisj.darklaf.annotations.SynthesiseLaf;
import com.github.weisj.darklaf.properties.PropertyLoader;
import com.github.weisj.darklaf.properties.icons.IconLoader;
import com.github.weisj.darklaf.properties.icons.IconResolver;
import com.github.weisj.darklaf.theme.info.ColorToneRule;
import com.github.weisj.darklaf.theme.info.ContrastRule;
import com.github.weisj.darklaf.theme.info.PresetIconRule;
@ -74,24 +74,24 @@ public class HighContrastLightTheme extends Theme {
@Override
public void loadIconTheme(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
final IconResolver iconResolver) {
// First load base theme
super.loadIconTheme(properties, currentDefaults, iconLoader);
super.loadIconTheme(properties, currentDefaults, iconResolver);
// Then customize using our own values.
PropertyLoader.putProperties(loadPropertyFile("icons"), properties, currentDefaults, iconLoader);
PropertyLoader.putProperties(loadPropertyFile("icons"), properties, currentDefaults, iconResolver);
}
@Override
public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
super.customizeUIProperties(properties, currentDefaults, iconLoader);
loadCustomProperties("ui", properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
super.customizeUIProperties(properties, currentDefaults, iconResolver);
loadCustomProperties("ui", properties, currentDefaults, iconResolver);
}
@Override
public void customizePlatformProperties(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
super.customizePlatformProperties(properties, currentDefaults, iconLoader);
loadCustomProperties("platform", properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
super.customizePlatformProperties(properties, currentDefaults, iconResolver);
loadCustomProperties("platform", properties, currentDefaults, iconResolver);
}
}

14
theme/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java

@ -26,7 +26,7 @@ import java.util.Properties;
import javax.swing.*;
import com.github.weisj.darklaf.annotations.SynthesiseLaf;
import com.github.weisj.darklaf.properties.icons.IconLoader;
import com.github.weisj.darklaf.properties.icons.IconResolver;
import com.github.weisj.darklaf.theme.info.ColorToneRule;
import com.github.weisj.darklaf.theme.info.PresetIconRule;
import com.google.auto.service.AutoService;
@ -68,16 +68,16 @@ public class IntelliJTheme extends Theme {
@Override
public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
super.customizeUIProperties(properties, currentDefaults, iconLoader);
loadCustomProperties("ui", properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
super.customizeUIProperties(properties, currentDefaults, iconResolver);
loadCustomProperties("ui", properties, currentDefaults, iconResolver);
}
@Override
public void loadIconTheme(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
super.loadIconTheme(properties, currentDefaults, iconLoader);
loadCustomProperties("icons", properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
super.loadIconTheme(properties, currentDefaults, iconResolver);
loadCustomProperties("icons", properties, currentDefaults, iconResolver);
}
@Override

12
theme/src/main/java/com/github/weisj/darklaf/theme/OneDarkTheme.java

@ -26,7 +26,7 @@ import java.util.Properties;
import javax.swing.*;
import com.github.weisj.darklaf.annotations.SynthesiseLaf;
import com.github.weisj.darklaf.properties.icons.IconLoader;
import com.github.weisj.darklaf.properties.icons.IconResolver;
import com.github.weisj.darklaf.theme.info.ColorToneRule;
import com.github.weisj.darklaf.theme.info.PresetIconRule;
import com.google.auto.service.AutoService;
@ -66,9 +66,9 @@ public class OneDarkTheme extends Theme {
@Override
public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
super.customizeUIProperties(properties, currentDefaults, iconLoader);
loadCustomProperties("ui", properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
super.customizeUIProperties(properties, currentDefaults, iconResolver);
loadCustomProperties("ui", properties, currentDefaults, iconResolver);
}
@Override
@ -83,7 +83,7 @@ public class OneDarkTheme extends Theme {
@Override
public void customizeIconTheme(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
loadCustomProperties("icons_adjustments", properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
loadCustomProperties("icons_adjustments", properties, currentDefaults, iconResolver);
}
}

8
theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedDarkTheme.java

@ -26,7 +26,7 @@ import java.util.Properties;
import javax.swing.*;
import com.github.weisj.darklaf.annotations.SynthesiseLaf;
import com.github.weisj.darklaf.properties.icons.IconLoader;
import com.github.weisj.darklaf.properties.icons.IconResolver;
import com.github.weisj.darklaf.theme.info.ColorToneRule;
import com.github.weisj.darklaf.theme.info.PresetIconRule;
import com.google.auto.service.AutoService;
@ -67,9 +67,9 @@ public class SolarizedDarkTheme extends Theme {
@Override
public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
super.customizeUIProperties(properties, currentDefaults, iconLoader);
loadCustomProperties("ui", properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
super.customizeUIProperties(properties, currentDefaults, iconResolver);
loadCustomProperties("ui", properties, currentDefaults, iconResolver);
}
@Override

8
theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedLightTheme.java

@ -26,7 +26,7 @@ import java.util.Properties;
import javax.swing.*;
import com.github.weisj.darklaf.annotations.SynthesiseLaf;
import com.github.weisj.darklaf.properties.icons.IconLoader;
import com.github.weisj.darklaf.properties.icons.IconResolver;
import com.github.weisj.darklaf.theme.info.ColorToneRule;
import com.github.weisj.darklaf.theme.info.PresetIconRule;
import com.google.auto.service.AutoService;
@ -72,9 +72,9 @@ public class SolarizedLightTheme extends Theme {
@Override
public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
super.customizeUIProperties(properties, currentDefaults, iconLoader);
loadCustomProperties("ui", properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
super.customizeUIProperties(properties, currentDefaults, iconResolver);
loadCustomProperties("ui", properties, currentDefaults, iconResolver);
}
@Override

28
theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java

@ -33,7 +33,7 @@ import javax.swing.*;
import javax.swing.text.html.StyleSheet;
import com.github.weisj.darklaf.properties.PropertyLoader;
import com.github.weisj.darklaf.properties.icons.IconLoader;
import com.github.weisj.darklaf.properties.icons.IconResolver;
import com.github.weisj.darklaf.theme.info.*;
import com.github.weisj.darklaf.theme.laf.RenamedTheme;
import com.github.weisj.darklaf.util.LogUtil;
@ -124,11 +124,11 @@ public abstract class Theme implements Comparable<Theme>, Comparator<Theme>, Ser
*
* @param properties the properties to load the values into.
* @param currentDefaults the current ui defaults.
* @param iconLoader the icon loader.
* @param iconResolver the icon resolver.
*/
public void loadDefaults(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
PropertyLoader.putProperties(loadPropertyFile("defaults"), properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
PropertyLoader.putProperties(loadPropertyFile("defaults"), properties, currentDefaults, iconResolver);
}
/**
@ -143,7 +143,7 @@ public abstract class Theme implements Comparable<Theme>, Comparator<Theme>, Ser
* @param currentDefaults the current ui defaults.
*/
public void customizeGlobals(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {}
final IconResolver iconResolver) {}
/**
* Customize the icon defaults.
@ -157,7 +157,7 @@ public abstract class Theme implements Comparable<Theme>, Comparator<Theme>, Ser
* @param currentDefaults the current ui defaults.
*/
public void customizeIconTheme(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {}
final IconResolver iconResolver) {}
/**
* Load the general properties file for the icon themes.
@ -169,10 +169,10 @@ public abstract class Theme implements Comparable<Theme>, Comparator<Theme>, Ser
*
* @param properties the properties to load the value into.
* @param currentDefaults the current ui defaults.
* @param iconLoader the icon loader.
* @param iconResolver the icon resolver.
*/
public void loadIconTheme(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
final IconResolver iconResolver) {
PresetIconRule iconTheme = getPresetIconRule();
Properties props;
switch (iconTheme) {
@ -186,7 +186,7 @@ public abstract class Theme implements Comparable<Theme>, Comparator<Theme>, Ser
default:
props = loadPropertyFile("icons");
}
PropertyLoader.putProperties(props, properties, currentDefaults, iconLoader);
PropertyLoader.putProperties(props, properties, currentDefaults, iconResolver);
}
/**
@ -200,7 +200,7 @@ public abstract class Theme implements Comparable<Theme>, Comparator<Theme>, Ser
* @param currentDefaults the current ui defaults.
*/
public void customizePlatformProperties(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {}
final IconResolver iconResolver) {}
/**
* Customize the ui defaults.
@ -213,7 +213,7 @@ public abstract class Theme implements Comparable<Theme>, Comparator<Theme>, Ser
* @param currentDefaults the current ui defaults.
*/
public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {}
final IconResolver iconResolver) {}
/**
* The preset icon theme.
@ -233,11 +233,11 @@ public abstract class Theme implements Comparable<Theme>, Comparator<Theme>, Ser
* @param propertySuffix the property suffix.
* @param properties the properties to load into.
* @param currentDefaults the current ui defaults.
* @param iconLoader the icon loader.
* @param iconResolver the icon resolver.
*/
protected final void loadCustomProperties(final String propertySuffix, final Properties properties,
final UIDefaults currentDefaults, final IconLoader iconLoader) {
PropertyLoader.putProperties(loadPropertyFile(propertySuffix), properties, currentDefaults, iconLoader);
final UIDefaults currentDefaults, final IconResolver iconResolver) {
PropertyLoader.putProperties(loadPropertyFile(propertySuffix), properties, currentDefaults, iconResolver);
}
/**

26
theme/src/main/java/com/github/weisj/darklaf/theme/ThemeDelegate.java

@ -25,7 +25,7 @@ import java.util.Properties;
import javax.swing.*;
import com.github.weisj.darklaf.properties.icons.IconLoader;
import com.github.weisj.darklaf.properties.icons.IconResolver;
import com.github.weisj.darklaf.theme.info.*;
public class ThemeDelegate extends Theme {
@ -103,38 +103,38 @@ public class ThemeDelegate extends Theme {
@Override
public void loadDefaults(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
getDelegate().loadDefaults(properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
getDelegate().loadDefaults(properties, currentDefaults, iconResolver);
}
@Override
public void customizeGlobals(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
getDelegate().customizeGlobals(properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
getDelegate().customizeGlobals(properties, currentDefaults, iconResolver);
}
@Override
public void customizeIconTheme(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
getDelegate().customizeIconTheme(properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
getDelegate().customizeIconTheme(properties, currentDefaults, iconResolver);
}
@Override
public void loadIconTheme(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
getDelegate().loadIconTheme(properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
getDelegate().loadIconTheme(properties, currentDefaults, iconResolver);
}
@Override
public void customizePlatformProperties(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
getDelegate().customizePlatformProperties(properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
getDelegate().customizePlatformProperties(properties, currentDefaults, iconResolver);
}
@Override
public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults,
final IconLoader iconLoader) {
getDelegate().customizeUIProperties(properties, currentDefaults, iconLoader);
final IconResolver iconResolver) {
getDelegate().customizeUIProperties(properties, currentDefaults, iconResolver);
}
@Override

Loading…
Cancel
Save