diff --git a/core/src/main/java/com/github/weisj/darklaf/components/ColoredRadioButton.java b/core/src/main/java/com/github/weisj/darklaf/components/ColoredRadioButton.java index 75550985..c9c688f7 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/ColoredRadioButton.java +++ b/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; } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/DefaultColorPipette.java b/core/src/main/java/com/github/weisj/darklaf/components/DefaultColorPipette.java index 339246af..9d01295d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/DefaultColorPipette.java +++ b/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; } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java b/core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java index dd46b51d..92c6941c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java @@ -208,7 +208,7 @@ public class SmallColorChooser extends JPanel implements ChooserComponent 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, diff --git a/core/src/main/java/com/github/weisj/darklaf/components/iconeditor/IconEditorPanel.java b/core/src/main/java/com/github/weisj/darklaf/components/iconeditor/IconEditorPanel.java index 6d4d6d1c..1f57ea43 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/iconeditor/IconEditorPanel.java +++ b/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); }); diff --git a/core/src/main/java/com/github/weisj/darklaf/task/ColorAdjustmentTask.java b/core/src/main/java/com/github/weisj/darklaf/task/ColorAdjustmentTask.java index 4ce6fd1e..1e29882d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/ColorAdjustmentTask.java +++ b/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> 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); diff --git a/core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java b/core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java index 1e3e8a33..f543c501 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java +++ b/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, Font> mapper) { diff --git a/core/src/main/java/com/github/weisj/darklaf/task/SystemDefaultsInitTask.java b/core/src/main/java/com/github/weisj/darklaf/task/SystemDefaultsInitTask.java index cd194437..7ddddbae 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/SystemDefaultsInitTask.java +++ b/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()); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/task/ThemeDefaultsInitTask.java b/core/src/main/java/com/github/weisj/darklaf/task/ThemeDefaultsInitTask.java index 094c9c8d..e41fe1b6 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/ThemeDefaultsInitTask.java +++ b/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) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/util/DarkUIUtil.java b/core/src/main/java/com/github/weisj/darklaf/ui/util/DarkUIUtil.java index 0d6012b5..a585eb17 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/util/DarkUIUtil.java +++ b/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(); diff --git a/core/src/test/java/com/github/weisj/darklaf/core/test/IconCacheTest.java b/core/src/test/java/com/github/weisj/darklaf/core/test/IconCacheTest.java index 98997bac..e1e7bc3f 100644 --- a/core/src/test/java/com/github/weisj/darklaf/core/test/IconCacheTest.java +++ b/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()); diff --git a/core/src/test/java/com/github/weisj/darklaf/core/theme/MyCustomTheme.java b/core/src/test/java/com/github/weisj/darklaf/core/theme/MyCustomTheme.java index 0e903b7a..97aeec3b 100644 --- a/core/src/test/java/com/github/weisj/darklaf/core/theme/MyCustomTheme.java +++ b/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 diff --git a/core/src/test/java/com/github/weisj/darklaf/core/theme/ThemeEditor.java b/core/src/test/java/com/github/weisj/darklaf/core/theme/ThemeEditor.java index 7706cced..d3ac464f 100644 --- a/core/src/test/java/com/github/weisj/darklaf/core/theme/ThemeEditor.java +++ b/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; diff --git a/iconset/src/main/java/com/github/weisj/darklaf/iconset/IconSet.java b/iconset/src/main/java/com/github/weisj/darklaf/iconset/IconSet.java index ed50506d..f2be4e4c 100644 --- a/iconset/src/main/java/com/github/weisj/darklaf/iconset/IconSet.java +++ b/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; } } diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/properties/PropertyLoader.java b/property-loader/src/main/java/com/github/weisj/darklaf/properties/PropertyLoader.java index be780f14..68c88d04 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/properties/PropertyLoader.java +++ b/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 properties, final Set keys, - final Map accumulator, final UIDefaults currentDefaults, final IconLoader iconLoader) { - ParserContext context = new ParserContext(accumulator, currentDefaults, iconLoader); + final Map 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); diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/properties/icons/IconLoader.java b/property-loader/src/main/java/com/github/weisj/darklaf/properties/icons/IconLoader.java index ffe43071..046405cb 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/properties/icons/IconLoader.java +++ b/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, IconLoader> iconLoaderMap = new HashMap<>(); private static final LazyValue 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 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 lightIconSupplier, + public @NotNull UIAwareIcon createUIAwareIcon(final IconSupplier lightIconSupplier, final IconSupplier 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 iconMap, + private @Nullable CacheableIcon getWildcardIcon(final SoftCache 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 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 { } - 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; diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/properties/icons/IconResolver.java b/property-loader/src/main/java/com/github/weisj/darklaf/properties/icons/IconResolver.java new file mode 100644 index 00000000..e66fb611 --- /dev/null +++ b/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); +} diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/properties/icons/IconUtil.java b/property-loader/src/main/java/com/github/weisj/darklaf/properties/icons/IconUtil.java index 917fc2ca..379101c0 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/properties/icons/IconUtil.java +++ b/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; diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/properties/parser/IconParser.java b/property-loader/src/main/java/com/github/weisj/darklaf/properties/parser/IconParser.java index 179b6891..fdfe61f1 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/properties/parser/IconParser.java +++ b/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); } diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/properties/parser/ParserContext.java b/property-loader/src/main/java/com/github/weisj/darklaf/properties/parser/ParserContext.java index 210d24e6..028f4b5a 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/properties/parser/ParserContext.java +++ b/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 accumulator; public final Map defaults; - public final IconLoader iconLoader; + public final IconResolver iconResolver; public ParserContext(final Map accumulator, final Map defaults, - final IconLoader iconLoader) { + final IconResolver iconResolver) { this.accumulator = accumulator; this.defaults = defaults; - this.iconLoader = iconLoader; + this.iconResolver = iconResolver; } } diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/DarculaTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/DarculaTheme.java index 9afc3e43..d78b1426 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/DarculaTheme.java +++ b/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); } } diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastDarkTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastDarkTheme.java index 3a399e01..6d3652ca 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastDarkTheme.java +++ b/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); } } diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastLightTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastLightTheme.java index cf0ba80b..b9e140ce 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastLightTheme.java +++ b/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); } } diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java index e466f6bd..b7022e4e 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java +++ b/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 diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/OneDarkTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/OneDarkTheme.java index dcc4aa9b..8e54def6 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/OneDarkTheme.java +++ b/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); } } diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedDarkTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedDarkTheme.java index c47ce5e6..f50ce354 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedDarkTheme.java +++ b/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 diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedLightTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedLightTheme.java index 60482f31..9eadf0b7 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedLightTheme.java +++ b/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 diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java index 1cbb0f1f..16229754 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java +++ b/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, Comparator, 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, Comparator, 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, Comparator, 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, Comparator, 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, Comparator, 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, Comparator, 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, Comparator, 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, Comparator, 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); } /** diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/ThemeDelegate.java b/theme/src/main/java/com/github/weisj/darklaf/theme/ThemeDelegate.java index 95231510..947ff9d6 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/ThemeDelegate.java +++ b/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