Class IconLoader

java.lang.Object
com.github.weisj.darklaf.icons.IconLoader

public final class IconLoader extends Object
  • Method Details

    • get

      public static IconLoader get()
      Get the default icon loader which resolves resources from the root directory of the jar.
      Returns:
      the default icon loader.
    • get

      public static IconLoader get(Class<?> parentClass)
      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

      public static void updateAwareStyle(AwareIconStyle style)
      Updates the style of aware icons. Changing it will force aware icons to change their appearance accordingly.
      Parameters:
      style - the new style.
    • updateThemeStatus

      public static void updateThemeStatus(Object theme)
      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

      public static AwareIconStyle getAwareStyle()
      Get the current aware icon style.
      Returns:
      the aware icon style.
    • getThemeStatus

      public static Object 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

      public DarkUIAwareIcon getUIAwareIcon(String 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] 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 new UIAwareIcon which 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

      public UIAwareIcon createUIAwareIcon(Icon light, Icon dark)
      Creates a new UIAwareIcon from the given icon.
      Parameters:
      light - the light version of the icon.
      dark - the dark version of the icon.
      Returns:
      the UIAwareIcon.
    • getUIAwareIcon

      public DarkUIAwareIcon getUIAwareIcon(String path, int w, int h)
      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

      protected DarkUIAwareIcon createUIAwareIcon(String name, int w, int h)
    • getIcon

      public Icon getIcon(String path)
      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

      public Icon getIcon(String path, boolean themed)
      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

      public Icon getIcon(String path, int w, int h)
      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

      public Icon getIcon(String path, int w, int h, boolean themed)
      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

      public Icon loadSVGIcon(String path, boolean themed)
      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

      public Icon loadSVGIcon(String path, int w, int h, boolean themed)
      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

      public static Image createFrameIcon(Icon icon, Window window)
      Create an Image from an Icon suitable 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

      public static Icon createDerivedIcon(Icon icon, int w, int h)
      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 implements DerivableIcon or ImageSource.
      Parameters:
      icon - the icon to drive.
      w - the new width.
      h - the new height.
      Returns:
      the derived icon.
    • getResource

      protected URL getResource(String name)