Class IconLoader

java.lang.Object
org.jorigin.swing.IconLoader

public class IconLoader extends Object
A class dedicated to SWING icon loading. It is possible to specify where the icon loader has to search for icons by setting the "org.jorigin.icon.dir" system property.
Since:
1.0.0
Version:
"1.0.14" - b202111241200L
Author:
Julien SEINTURIER - Université de Toulon / CNRS LIS umr 7020 - github.com/jorigin/jcommon (contact@jorigin.org)
  • Field Details

    • ICON_LOADER_DIR

      public static final String ICON_LOADER_DIR
      Specify where the icon loader has to search for icons (default empty string "").
      See Also:
    • PATH_TYPE_UNKNOWN

      public static int PATH_TYPE_UNKNOWN
      This flag identifies an unknown type for the resource path.
    • PATH_TYPE_FILESYSTEM

      public static int PATH_TYPE_FILESYSTEM
      This flag identifies an filesystem type (absolute) for the resource path.
    • PATH_TYPE_URL

      public static int PATH_TYPE_URL
      This flag identifies an URL type (HTTP, HTTPS, FTP, SFTP) for the resource path.
    • PATH_TYPE_EMBEDDED_JAR

      public static int PATH_TYPE_EMBEDDED_JAR
      This flag identifies a jar type for the resource path.
    • PATH_TYPE_EMBEDDED_ZIP

      public static int PATH_TYPE_EMBEDDED_ZIP
      This flag identifies a zup type for the resource path.
  • Constructor Details

    • IconLoader

      public IconLoader()
  • Method Details

    • getIcon

      public static ImageIcon getIcon(String path)
      Get an icon from the given path. If the icon path is relative, a complete path is created by concatenating the icon root path and the given one. If the icon path is absolute, the icon is directly loaded.
      Parameters:
      path - the path to the icon. Can be relative or absolute.
      Returns:
      the loaded icon or null if no icon was found.
    • getImage

      public static Image getImage(String path)
      Get an image from the given path. If the image path is relative, a complete path is created by concatenating the icon root path and the given one. If the image path is absolute, the image is directly loaded.
      Parameters:
      path - the path to the image. Can be relative or absolute.
      Returns:
      the loaded image or null if no image was found.
    • getScaledIcon

      public static ImageIcon getScaledIcon(String name, Dimension dimension)
      Get an icon and scale it to the desired size given in millimeters.
      Parameters:
      name - the name of the icon to load.
      dimension - the dimension in millimeters of the icon.
      Returns:
      a scaled image that represents the desired icon.
    • getScaledIcon

      public static ImageIcon getScaledIcon(String name, double width, double height)
      Get an icon and scale it to the desired size given in millimeters.
      Parameters:
      name - the name of the icon to load.
      width - the expected width in millimeter (mm)
      height - the expected height in millimeter (mm)
      Returns:
      a scaled image that represents the desired icon
      See Also:
    • getIconDirectory

      public static String getIconDirectory()
      Get the directory to use as root for the icon search. The icon path can be a system directory, a string that represents an URL or a string that represents an embedded (zip, jar, ...) directory.
      Returns:
      the path to use as root for the icon search.
      See Also:
    • setIconDirectory

      public static void setIconDirectory(String path)
      Set the path to use as root for the icon search. The icon path can be a system directory, a string that represents an URL or a string that represents an embedded (zip, jar, ...) directory.
      Parameters:
      path - the path to use as root for the icon search.
      See Also: