Package com.github.weisj.darklaf.icons
Class IconLoader
java.lang.Object
com.github.weisj.darklaf.icons.IconLoader
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic IconcreateDerivedIcon(Icon icon, int w, int h)Create an derived version of the icon with the given width and height.static ImagecreateFrameIcon(Icon icon, Window window)createUIAwareIcon(IconSupplier<Icon> lightIconSupplier, IconSupplier<Icon> darkIconSupplier)Creates a newUIAwareIconwhich is loaded lazily through the given supplier.protected DarkUIAwareIconcreateUIAwareIcon(String name, int w, int h)createUIAwareIcon(Icon light, Icon dark)Creates a newUIAwareIconfrom the given icon.static IconLoaderget()Get the default icon loader which resolves resources from the root directory of the jar.static IconLoaderGet an icon loader which resolves resources from the class directory of the parent class.static AwareIconStyleGet the current aware icon style.Get an icon at the specified location.Get an icon at the specified location.Get an icon at the specified location.Get an icon at the specified location.protected URLgetResource(String name)static ObjectGet the object associated to the current theme.getUIAwareIcon(String path)Get an aware icon.getUIAwareIcon(String path, int w, int h)Get an aware icon.booleanReturns whether icons are cached when creating them.loadSVGIcon(String path, boolean themed)Get an svg icon at the specified location.loadSVGIcon(String path, int w, int h, boolean themed)Get an svg icon at the specified location.loadSVGIcon(String path, int w, int h, boolean themed, Map<Object,Object> propertyMap)Get an svg icon at the specified location.static voidReload all created frame icons if necessary.voidsetCacheEnabled(boolean cacheEnabled)Sets whether icons should be cached orstatic voidupdateAwareStyle(AwareIconStyle style)Updates the style of aware icons.static voidupdateThemeStatus(Object theme)Updates the object associated with the current theme.
-
Method Details
-
get
Get the default icon loader which resolves resources from the root directory of the jar.- Returns:
- the default icon loader.
-
get
Get an icon loader which resolves resources from the class directory of the parent class.- Returns:
- the default icon loader.
-
setCacheEnabled
public void setCacheEnabled(boolean cacheEnabled)Sets whether icons should be cached or- Parameters:
cacheEnabled- true if caching is enabled.
-
isCacheEnabled
public boolean isCacheEnabled()Returns whether icons are cached when creating them.- Returns:
- true if caching is enabled.
-
updateAwareStyle
Updates the style of aware icons. Changing it will force aware icons to change their appearance accordingly.- Parameters:
style- the new style.
-
updateThemeStatus
Updates the object associated with the current theme. Changing it will force themed icons to refresh their colors. This doesn't need to be any specific type as it is simply a marker object.- Parameters:
theme- the new theme object.
-
reloadFrameIcons
public static void reloadFrameIcons()Reload all created frame icons if necessary. -
getAwareStyle
Get the current aware icon style.- Returns:
- the aware icon style.
-
getThemeStatus
Get the object associated to the current theme. This may not be any specific type as it is simply a marker object.- Returns:
- the current theme object.
-
getUIAwareIcon
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] Uses 16x16 icons by default.- Parameters:
path- the path to the icon resource described as above.- Returns:
- the icon.
-
createUIAwareIcon
public UIAwareIcon createUIAwareIcon(IconSupplier<Icon> lightIconSupplier, IconSupplier<Icon> darkIconSupplier)Creates a newUIAwareIconwhich is loaded lazily through the given supplier.- Parameters:
lightIconSupplier- the supplier for the light icon.darkIconSupplier- the supplier for the dark icon.- Returns:
- the
UIAwareIcon
-
createUIAwareIcon
Creates a newUIAwareIconfrom the given icon.- Parameters:
light- the light version of the icon.dark- the dark version of the icon.- Returns:
- the
UIAwareIcon.
-
getUIAwareIcon
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]- Parameters:
path- the path to the icon resource described as above.w- the icon width.h- the icon height.- Returns:
- the icon.
-
createUIAwareIcon
-
getIcon
Get an icon at the specified location. The icon type is deduced from the file name. i.e. "folder/icon.svg" will be loaded as an svg.icon. Uses 16x16 icons by default.- Parameters:
path- the path to the icon with respect to the IconLoader resource root.- Returns:
- the icon.
- See Also:
get(Class),get()
-
getIcon
Get an icon at the specified location. The icon type is deduced from the file name. i.e. "folder/icon.svg" will be loaded as an svg.icon. Uses 16x16 icons by default.- Parameters:
path- the path to the icon with respect to the IconLoader resource root.themed- determines whether the icon is themed. This only has an effect on svg icons.- Returns:
- the icon.
- See Also:
get(Class),get()
-
getIcon
Get an icon at the specified location. The icon type is deduced from the file name. i.e. "folder/icon.svg" will be loaded as an svg.icon.- Parameters:
path- the path to the icon with respect to the IconLoader resource root.w- the icon width.h- the icon height.- Returns:
- the icon.
- See Also:
get(Class),get()
-
getIcon
Get an icon at the specified location. The icon type is deduced from the file name. i.e. "folder/icon.svg" will be loaded as an svg.icon.- Parameters:
path- the path to the icon with respect to the IconLoader resource root.w- the icon width.h- the icon height.themed- determines whether the icon is themed. This only has an effect on svg icons.- Returns:
- the icon.
- See Also:
get(Class),get()
-
loadSVGIcon
Get an svg icon at the specified location. will be loaded as an svg.icon. Uses 16x16 icons by default.- Parameters:
path- the path to the icon with respect to the IconLoader resource root.themed- determines whether the icon is themed. This only has an effect on svg icons.- Returns:
- the icon.
- See Also:
get(Class),get()
-
loadSVGIcon
Get an svg icon at the specified location. will be loaded as an svg.icon.- Parameters:
path- the path to the icon with respect to the IconLoader resource root.w- the icon width.h- the icon height.themed- determines whether the icon is themed. This only has an effect on svg icons.- Returns:
- the icon.
- See Also:
get(Class),get()
-
loadSVGIcon
public Icon loadSVGIcon(String path, int w, int h, boolean themed, Map<Object,Object> propertyMap)Get an svg icon at the specified location. will be loaded as an svg.icon.- Parameters:
path- the path to the icon with respect to the IconLoader resource root.w- the icon width.h- the icon height.themed- determines whether the icon is themed. This only has an effect on svg icons.propertyMap- the property map for resolving themed icon properties. If null the UIDefaults will be used.- Returns:
- the icon.
- See Also:
get(Class),get()
-
createFrameIcon
Create anImagefrom anIconsuitable for a window icon. If the window is moved to a screen with a different scaling factor or the theme changes the icon automatically gets updated.- Parameters:
icon- the icon.window- the window.- Returns:
- the converted
Image.
-
createDerivedIcon
Create an derived version of the icon with the given width and height. This method will return the best possible result if the given icon implementsDerivableIconorImageSource.- Parameters:
icon- the icon to drive.w- the new width.h- the new height.- Returns:
- the derived icon.
-
getResource
-