Class ImageLoader
java.lang.Object
jmt.framework.gui.image.ImageLoader
- Direct Known Subclasses:
ImageLoaderImpl
Name: ImageLoader
Description:
A class used to load images. Each subclass must implement the getImageURL
method to retrieve URL of resource to be loaded. This class holds a cache of loaded images.
Cache size can be adjusted using the maxCache field.
Date: 23/gen/07 Time: 15:09:14
- Version:
- 1.0
- Author:
- Bertoli Marco
-
Field Summary
FieldsModifier and TypeFieldDescriptionInternal caching data structureprotected intMaximum number of cached elementsstatic final StringModifier to be used for mirror images (rotated on y axis)static final StringModifier to be used for mirror images and rotating images (rotated on y axis)static final StringModifier to be used for pressed button imagesstatic final StringModifier to be used for rollover button imagesstatic final StringModifier to be used for rotating images (rotated on y axis)static final StringModifier to be used for selected (toggled) button images -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ImageIconapplyModifier(ImageIcon base, String modifier) Apply known modifiers to given imageprotected ImageIconapplyModifier(ImageIcon base, String modifier, Double angle) Apply known modifiers to given imagestatic StringderiveIconName(String iconName, String modifier) Derives an icon name to apply suffixes before extensionprotected abstract URLgetImageURL(String resourceName) Returns the url of a given resourceLoads an icon with specified name, and caches it.Loads an icon with specified name and size, caches it and then resizes it.Loads an icon with specified name and modifier, and caches it.Loads an icon with specified name, modifier and size, caches it and then resizes it.Loads an icon with specified name, modifier and size, caches it and then resizes it.protected ImageIconMerge two icons together.protected ImageIconmirrorImage(ImageIcon base) Rotates image on y axisprotected ImageIconRotates image on y axis
-
Field Details
-
MODIFIER_MIRROR
Modifier to be used for mirror images (rotated on y axis)- See Also:
-
MODIFIER_ROTATE
Modifier to be used for rotating images (rotated on y axis)- See Also:
-
MODIFIER_MIRROR_AND_ROTATE
Modifier to be used for mirror images and rotating images (rotated on y axis)- See Also:
-
MODIFIER_PRESSED
-
MODIFIER_ROLLOVER
Modifier to be used for rollover button images- See Also:
-
MODIFIER_SELECTED
Modifier to be used for selected (toggled) button images- See Also:
-
maxCache
protected int maxCacheMaximum number of cached elements -
iconCache
-
-
Constructor Details
-
ImageLoader
public ImageLoader()
-
-
Method Details
-
getImageURL
-
loadIcon
-
loadIcon
-
loadIcon
-
loadIcon
Loads an icon with specified name, modifier and size, caches it and then resizes it.- Parameters:
iconName- name of the icon to be loadedmodifier- modifier to be appliedsize- target dimension of image- Returns:
- icon if found, null otherwise
-
loadIcon
Loads an icon with specified name, modifier and size, caches it and then resizes it.- Parameters:
iconName- name of the icon to be loadedmodifier- modifier to be appliedangle- rotation angle of the image in degrees- Returns:
- icon if found, null otherwise
-
deriveIconName
-
applyModifier
-
applyModifier
-
mergeIcons
protected ImageIcon mergeIcons(ImageIcon background, ImageIcon overlay, Point cropMin, Point cropMax, Point move) Merge two icons together. Output icon dimension is the same as background one.- Parameters:
background- background iconoverlay- overlay icon, needs to be transparent (will be moved and cropped)cropMin- minimum crop point for overlay icon (0,0 for no crop)cropMax- maximum crop point for overlay icon (width and height for no crop)move- upper left corner where cropped overlay image should be positioned on background image- Returns:
- merged icon
-
mirrorImage
-
rotate
-