Class IconLoader


  • public class IconLoader
    extends java.lang.Object
    A class dedicated to the load of icons. This class enable to seek icons from a given directory and enable to scale icons in metric units.
    Since:
    1.0.3
    Author:
    Julien Seinturier - (c) 2016 - JOrigin project - http:/www.jorigin.org
    • Constructor Summary

      Constructors 
      Constructor Description
      IconLoader()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static javax.swing.ImageIcon getIcon​(java.lang.String path)
      Get an icon from the given path.
      static java.lang.String getIconPath()
      Get the path to use as root for the icon search.
      static java.awt.Image getImage​(java.lang.String path)
      Get an image from the given path.
      static javax.swing.ImageIcon getScaledIcon​(java.lang.String name, java.awt.Dimension dimension)
      Get an icon and scale it to the desired size given in millimeters.
      static void setIconPath​(java.lang.String path)
      Set the path to use as root for the icon search.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IconLoader

        public IconLoader()
    • Method Detail

      • getIcon

        public static javax.swing.ImageIcon getIcon​(java.lang.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 java.awt.Image getImage​(java.lang.String path)
        Get an image from the given path. If the image path is relative, a complete path is created by concatenating the image 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 javax.swing.ImageIcon getScaledIcon​(java.lang.String name,
                                                          java.awt.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.
      • getIconPath

        public static java.lang.String getIconPath()
        Get the path to use as root for the icon search.
        Returns:
        the path to use as root for the icon search.
        See Also:
        setIconPath(String)
      • setIconPath

        public static void setIconPath​(java.lang.String path)
        Set the path to use as root for the icon search.
        Parameters:
        path - the path to use as root for the icon search.
        See Also:
        getIconPath()