Package org.ka2ddo.yaac.gui.util
Class EnumImageLoader
java.lang.Object
org.ka2ddo.yaac.gui.util.EnumImageLoader
This class maintains a mapping of Enum value instances to ImageIcons, so enumerations
can be identified in the UI by image picture.
- Author:
- Andrew Pavlin, KA2DDO
-
Method Summary
Modifier and TypeMethodDescriptionstatic Enum
getEnumForName
(String name) Look up an enum by name for which we have an icon image.static ImageIcon
getImageIcon
(Enum e) Look up the ImageIcon for an enumeration.static ImageIcon
Load an image into an ImageIcon from the specified relative pathname.static void
registerEnum
(Class<? extends Enum> clazz) Register an entire enum class using the specified prefix when building resource names for localized string lookups.
-
Method Details
-
registerEnum
Register an entire enum class using the specified prefix when building resource names for localized string lookups.- Parameters:
clazz
- Enum class whose elements should have images loaded- See Also:
-
loadIcon
Load an image into an ImageIcon from the specified relative pathname.- Parameters:
filename
- String pathname relative to the base installation directory of YAAC- Returns:
- ImageIcon from the specified file, or null if the file does not exist
-
getImageIcon
Look up the ImageIcon for an enumeration.- Parameters:
e
- Enum value to look up- Returns:
- ImageIcon corresponding to this enum value, or null if no such icon
-
getEnumForName
Look up an enum by name for which we have an icon image. Note this method will log an error if two registered enums have instances with the same name, but will only return the first match found.- Parameters:
name
- String name of enum- Returns:
- Enum for this name, or null if no match
-