Package com.github.weisj.darklaf.icons
Class DarkUIAwareIcon
- java.lang.Object
-
- com.github.weisj.darklaf.icons.DarkUIAwareIcon
-
- All Implemented Interfaces:
DynamicIcon,UIAwareIcon,Serializable,Icon,UIResource
public class DarkUIAwareIcon extends Object implements UIAwareIcon, UIResource, Serializable
Icon that is aware of the current ui theme and adjusts the icon accordingly. Icons are loaded lazily at their point of usage.- Since:
- 2019
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DarkUIAwareIcon(String darkKey, String lightKey, int w, int h, Class<?> parentClass)Create new ui aware icon.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidensureLoaded()DarkUIAwareIcongetDual()Return the dual version of the icon.intgetIconHeight()intgetIconWidth()booleanisDark()protected booleanisLoaded()protected voidloadIcon()voidpaintIcon(Component c, Graphics g, int x, int y)voidpaintIcon(Component c, Graphics g2, int x, int y, double scale)protected voidupdateStyle()
-
-
-
Constructor Detail
-
DarkUIAwareIcon
public DarkUIAwareIcon(String darkKey, String lightKey, int w, int h, Class<?> parentClass)
Create new ui aware icon.- Parameters:
darkKey- key to load icon for dark mode.lightKey- key to load icon for light mode.w- width of icon.h- height of icon.parentClass- the class to resolve the path while lazy loading.
-
-
Method Detail
-
ensureLoaded
protected void ensureLoaded()
-
updateStyle
protected void updateStyle()
-
isLoaded
protected boolean isLoaded()
-
isDark
public boolean isDark()
-
loadIcon
protected void loadIcon()
-
getIconWidth
public int getIconWidth()
- Specified by:
getIconWidthin interfaceIcon
-
getIconHeight
public int getIconHeight()
- Specified by:
getIconHeightin interfaceIcon
-
getDual
public DarkUIAwareIcon getDual()
Description copied from interface:UIAwareIconReturn the dual version of the icon. i.e. if the current icon is light then the dual version will be dark and vice versa. Implementations of this method should respect that the appearance of the icon after invoking this method twice should be the same.- Specified by:
getDualin interfaceUIAwareIcon- Returns:
- the dual icon.
-
-