Package org.pepsoft.util
Class IconUtils
java.lang.Object
org.pepsoft.util.IconUtils
Utility methods for loading and scaling images and icons, with automatic
support for HiDPI displays.
-
Method Summary
Modifier and TypeMethodDescriptionstatic IconcreateScaledColourIcon(int colour) Create a 16x16 pixel icon of a solid colour.static IconcreateScaledLetterIcon(char letter, Color colour) static StringgetTheme()static ImageIconloadScaledIcon(ClassLoader classLoader, String path) Load an icon from the classpath using a specific class loader.static ImageIconloadScaledIcon(String path) Load an icon from the classpath using the system class loader.static BufferedImageloadScaledImage(ClassLoader classLoader, String path) Load an image from the classpath using a specific class loader.static BufferedImageloadScaledImage(String path) Load an image from the classpath using the system class loader.static ImageIconloadUnscaledIcon(String path) Load an icon from the classpath using the system class loader.static BufferedImageloadUnscaledImage(String path) Load an image from the classpath using the system class loader.static IconrotateIcon(Icon icon, int degrees) Rotate a square icon clockwise by the specified number of degrees.static BufferedImageScale a square icon using bicubic scaling.static ImageIconScale a square icon using bicubic scaling.static void
-
Method Details
-
getTheme
-
setTheme
-
loadUnscaledIcon
Load an icon from the classpath using the system class loader.The icon will not be scaled.
- Parameters:
path- The path of the image to load.- Returns:
- The specified icon, or
nullif the specified path did not contain a resource.
-
loadScaledIcon
Load an icon from the classpath using the system class loader.The icon will automatically be scaled up for HiDPI displays.
- Parameters:
path- The path of the image to load.- Returns:
- The specified icon, or
nullif the specified path did not contain a resource.
-
loadScaledIcon
Load an icon from the classpath using a specific class loader.The icon will automatically be scaled up for HiDPI displays.
- Parameters:
classLoader- The class loader to use to load the image.path- The path of the image to load.- Returns:
- The specified icon, or
nullif the specified path did not contain a resource.
-
loadUnscaledImage
Load an image from the classpath using the system class loader. Ifthemeis set it will first look for a themed version of the image by looking in the_<theme>subdirectory.The image will be returned at its original resolution and not be rescaled.
- Parameters:
path- The path of the image to load.- Returns:
- The specified image, or
nullif the specified path did not contain a resource. - See Also:
-
loadScaledImage
Load an image from the classpath using the system class loader.The image will automatically be scaled up for HiDPI displays.
- Parameters:
path- The path of the image to load.- Returns:
- The specified image, or
nullif the specified path did not contain a resource.
-
loadScaledImage
Load an image from the classpath using a specific class loader. Ifthemeis set it will first look for a themed version of the image by looking in the_<theme>subdirectory.The image will automatically be scaled up for HiDPI displays.
- Parameters:
classLoader- The class loader to use to load the image.path- The path of the image to load.- Returns:
- The specified image, or
nullif the specified path did not contain a resource. - See Also:
-
createScaledColourIcon
Create a 16x16 pixel icon of a solid colour.The icon will automatically be scaled up for HiDPI displays.
- Parameters:
colour- The colour as a combined rgb value.- Returns:
- A 16x16 icon of the specified colour.
-
createScaledLetterIcon
-
scaleIcon
Scale a square icon using bicubic scaling.The icon will automatically be scaled up for HiDPI displays.
- Parameters:
icon- The icon to scale.size- The size (edge to edge) of the scaled icon.- Returns:
- The scaled icon.
-
scaleIcon
Scale a square icon using bicubic scaling.The icon will automatically be scaled up for HiDPI displays.
- Parameters:
iconImage- The icon to scale.size- The size (edge to edge) of the scaled icon.- Returns:
- The scaled icon.
-
rotateIcon
Rotate a square icon clockwise by the specified number of degrees.- Parameters:
icon- The icon to rotate.degrees- The number of degrees to rotate the icon.- Returns:
- The rotated icon.
-