java.lang.Object
org.jorigin.swing.IconLoader
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSpecify where the icon loader has to search for icons (default empty string "").static intThis flag identifies a jar type for the resource path.static intThis flag identifies a zup type for the resource path.static intThis flag identifies an filesystem type (absolute) for the resource path.static intThis flag identifies an unknown type for the resource path.static intThis flag identifies an URL type (HTTP, HTTPS, FTP, SFTP) for the resource path. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ImageIconGet aniconfrom the givenpath.static StringGet the directory to use as root for the icon search.static ImageGet animagefrom the givenpath.static ImageIcongetScaledIcon(String name, double width, double height) Get an icon and scale it to the desired size given in millimeters.static ImageIcongetScaledIcon(String name, Dimension dimension) Get an icon and scale it to the desired size given in millimeters.static voidsetIconDirectory(String path) Set the path to use as root for the icon search.
-
Field Details
-
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_UNKNOWNThis flag identifies an unknown type for the resource path. -
PATH_TYPE_FILESYSTEM
public static int PATH_TYPE_FILESYSTEMThis flag identifies an filesystem type (absolute) for the resource path. -
PATH_TYPE_URL
public static int PATH_TYPE_URLThis flag identifies an URL type (HTTP, HTTPS, FTP, SFTP) for the resource path. -
PATH_TYPE_EMBEDDED_JAR
public static int PATH_TYPE_EMBEDDED_JARThis flag identifies a jar type for the resource path. -
PATH_TYPE_EMBEDDED_ZIP
public static int PATH_TYPE_EMBEDDED_ZIPThis flag identifies a zup type for the resource path.
-
-
Constructor Details
-
IconLoader
public IconLoader()
-
-
Method Details
-
getIcon
Get aniconfrom the givenpath. If the iconpathis relative, a complete path is created by concatenating theicon root pathand the given one. If the iconpathis absolute, the icon is directly loaded.- Parameters:
path- the path to the icon. Can be relative or absolute.- Returns:
- the loaded icon or
nullif no icon was found.
-
getImage
Get animagefrom the givenpath. If the imagepathis relative, a complete path is created by concatenating theicon root pathand the given one. If the imagepathis absolute, the image is directly loaded.- Parameters:
path- the path to the image. Can be relative or absolute.- Returns:
- the loaded image or
nullif no image was found.
-
getScaledIcon
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
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
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
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:
-