- java.lang.Object
-
- org.icepdf.ri.images.Images
-
public class Images extends Object
Utility class providing a unified interface to all application icons. For a one-off, directly accessing the default icon pack, callget(String). When loading icons which are meant to be customizable by applications embedding ICEpdf, call:- for a single icon
getSingleIcon(String, Variant, IconSize) - for a button without different styles for its states,
applyIcon(AbstractButton, String, Variant, IconSize) - for a button with different styles per state,
applyIcons(AbstractButton, String, IconSize)
JMenus andJMenuItems are supported byapplyIcons(AbstractButton, String, IconSize)andapplyIcon(AbstractButton, String, Variant, IconSize).- Since:
- 2.0
- Author:
- Mark Collette, Alexander Leithner
- for a single icon
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImages.IconSizeEnum specifying the wanted size of the icon
-
Field Summary
Fields Modifier and Type Field Description static StringSIZE_LARGELegacy string, kept for compatibility reasons when reading old preferences files.static StringSIZE_SMALLLegacy string, kept for compatibility reasons when reading old preferences files.
-
Constructor Summary
Constructors Constructor Description Images()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidapplyIcon(AbstractButton button, String iconName, IconPack.Variant variant, Images.IconSize size)Apply the given icon in the given variant and size to the given buttonstatic voidapplyIcons(AbstractButton button, String iconName, Images.IconSize size)Apply normal, pressed, rollover and disabled variants of the given icon in the given size to the given buttonstatic URLget(String name)Get a single icon from the classpath (must be PNG or GIF); no icon packs involvedstatic Images.IconSizegetDefaultIconSizeOr(Preferences preferences, Images.IconSize elseValue)Get the current setting for the icon size or the given "else" value if preference is unset or is invalidstatic Images.IconSizegetDefaultIconSizeOr(ViewerPropertiesManager propertiesManager, Images.IconSize elseValue)Get the current setting for the icon size or the given "else" value if preference is unset or is invalidstatic IcongetSingleIcon(String iconName, IconPack.Variant variant, Images.IconSize size)Get a single icon in the given variant and size from the current icon pack
-
-
-
Field Detail
-
SIZE_LARGE
public static final String SIZE_LARGE
Legacy string, kept for compatibility reasons when reading old preferences files. Any new usage should instead switch toImages.IconSize.LARGE.- See Also:
- Constant Field Values
-
SIZE_SMALL
public static final String SIZE_SMALL
Legacy string, kept for compatibility reasons when reading old preferences files. Any new usage should instead switch toImages.IconSize.SMALL.- See Also:
- Constant Field Values
-
-
Method Detail
-
get
public static URL get(String name)
Get a single icon from the classpath (must be PNG or GIF); no icon packs involved- Parameters:
name- The file to retrieve- Returns:
- A URL referring to the requested icon on the classpath.
-
getDefaultIconSizeOr
public static Images.IconSize getDefaultIconSizeOr(ViewerPropertiesManager propertiesManager, Images.IconSize elseValue)
Get the current setting for the icon size or the given "else" value if preference is unset or is invalid This method is equivalent to callinggetDefaultIconSizeOr(propertiesManager.getPreferences(), elseValue)- Parameters:
propertiesManager- The Properties Manager to retrieve the preferences fromelseValue- The value to return if preference is unset or is invalid- Returns:
- The current preference for the icon size or the given default value
-
getDefaultIconSizeOr
public static Images.IconSize getDefaultIconSizeOr(Preferences preferences, Images.IconSize elseValue)
Get the current setting for the icon size or the given "else" value if preference is unset or is invalid- Parameters:
preferences- The preference store to retrieve the preference fromelseValue- The value to return if preference is unset or is invalid- Returns:
- The current preference for the icon size or the given default value
-
applyIcons
public static void applyIcons(AbstractButton button, String iconName, Images.IconSize size)
Apply normal, pressed, rollover and disabled variants of the given icon in the given size to the given button Pressed, rollover and disabled icons are only registered if the current icon pack supports those variants- Parameters:
button- The button to register the icons toiconName- The icon to registersize- The size of the icon to register
-
applyIcon
public static void applyIcon(AbstractButton button, String iconName, IconPack.Variant variant, Images.IconSize size)
Apply the given icon in the given variant and size to the given button No check is made whether the current icon pack provides the variant asked for. If it doesn't, calling this method may either fail with a runtime exception or a corrupted icon being displayed by the button.- Parameters:
button- The button to register the icon toiconName- The icon to registervariant- The wanted variant of the given iconsize- The wanted size
-
getSingleIcon
public static Icon getSingleIcon(String iconName, IconPack.Variant variant, Images.IconSize size) throws RuntimeException
Get a single icon in the given variant and size from the current icon pack If the icon pack encounters an error trying to create the icon, it may throw aRuntimeException, which will not be caught by this method but passed to the callee.- Parameters:
iconName- The icon to retrieve from the current icon packvariant- The variant of the icon to retrievesize- The size in which to retrieve the icon- Returns:
- The icon as fetched by the icon pack
- Throws:
RuntimeException- If the icon pack could not find or could not load the requested icon
-
-