Class ImageWrapperResizableIcon
- java.lang.Object
-
- org.pushingpixels.flamingo.api.common.icon.ImageWrapperResizableIcon
-
- All Implemented Interfaces:
Icon,AsynchronousLoading,ResizableIcon
public class ImageWrapperResizableIcon extends Object implements ResizableIcon
Implementation ofResizableIconinterface that wraps image files.
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,BufferedImage>cachedImagesContains all precomputed images.protected intheightThe height of the current image.protected ImageimageThe input stream of the original image.protected InputStreamimageInputStreamThe input stream of the original image.protected EventListenerListlistenerListThe listeners.protected BufferedImageoriginalImageThe original image.protected intwidthThe width of the current image.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAsynchronousLoadListener(AsynchronousLoadListener l)Adds listener on the asynchronous loading events.protected voidfireAsyncCompleted(Boolean event)Fires the asynchronous load event.static ImageWrapperResizableIcongetIcon(Image image, Dimension initialDim)Returns the icon for the specified URL.static ImageWrapperResizableIcongetIcon(InputStream inputStream, Dimension initialDim)Returns the icon for the specified input stream.static ImageWrapperResizableIcongetIcon(URL location, Dimension initialDim)Returns the icon for the specified URL.intgetIconHeight()intgetIconWidth()booleanisLoading()Returns indication whether the content is still loading.voidpaintIcon(Component c, Graphics g, int x, int y)voidremoveAsynchronousLoadListener(AsynchronousLoadListener l)Removes listener on the asynchronous loading events.protected voidrenderImage(int renderWidth, int renderHeight)Renders the image.voidsetDimension(Dimension dim)Changes the dimension ofthisicon.voidsetPreferredSize(Dimension dim)Sets the preferred size forthisicon.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.swing.Icon
getIconHeight, getIconWidth, paintIcon
-
-
-
-
Field Detail
-
originalImage
protected BufferedImage originalImage
The original image.
-
imageInputStream
protected InputStream imageInputStream
The input stream of the original image.
-
image
protected Image image
The input stream of the original image.
-
cachedImages
protected Map<String,BufferedImage> cachedImages
Contains all precomputed images.
-
width
protected int width
The width of the current image.
-
height
protected int height
The height of the current image.
-
listenerList
protected EventListenerList listenerList
The listeners.
-
-
Method Detail
-
getIcon
public static ImageWrapperResizableIcon getIcon(Image image, Dimension initialDim)
Returns the icon for the specified URL.- Parameters:
image- Image.initialDim- Initial dimension of the icon.- Returns:
- Icon instance.
-
getIcon
public static ImageWrapperResizableIcon getIcon(URL location, Dimension initialDim)
Returns the icon for the specified URL.- Parameters:
location- Icon URL.initialDim- Initial dimension of the icon.- Returns:
- Icon instance.
-
getIcon
public static ImageWrapperResizableIcon getIcon(InputStream inputStream, Dimension initialDim)
Returns the icon for the specified input stream.- Parameters:
inputStream- Icon input stream.initialDim- Initial dimension of the icon.- Returns:
- Icon instance.
-
setDimension
public void setDimension(Dimension dim)
Description copied from interface:ResizableIconChanges the dimension ofthisicon.- Specified by:
setDimensionin interfaceResizableIcon- Parameters:
dim- New dimension forthisicon.
-
addAsynchronousLoadListener
public void addAsynchronousLoadListener(AsynchronousLoadListener l)
Description copied from interface:AsynchronousLoadingAdds listener on the asynchronous loading events.- Specified by:
addAsynchronousLoadListenerin interfaceAsynchronousLoading- Parameters:
l- Listener to add.
-
removeAsynchronousLoadListener
public void removeAsynchronousLoadListener(AsynchronousLoadListener l)
Description copied from interface:AsynchronousLoadingRemoves listener on the asynchronous loading events.- Specified by:
removeAsynchronousLoadListenerin interfaceAsynchronousLoading- Parameters:
l- Listener to remove.
-
getIconWidth
public int getIconWidth()
- Specified by:
getIconWidthin interfaceIcon
-
getIconHeight
public int getIconHeight()
- Specified by:
getIconHeightin interfaceIcon
-
setPreferredSize
public void setPreferredSize(Dimension dim)
Sets the preferred size forthisicon. The rendering is scheduled automatically.- Parameters:
dim- Preferred size.
-
renderImage
protected void renderImage(int renderWidth, int renderHeight)Renders the image.- Parameters:
renderWidth- Requested rendering width.renderHeight- Requested rendering height.
-
fireAsyncCompleted
protected void fireAsyncCompleted(Boolean event)
Fires the asynchronous load event.- Parameters:
event- Event object.
-
isLoading
public boolean isLoading()
Description copied from interface:AsynchronousLoadingReturns indication whether the content is still loading.- Specified by:
isLoadingin interfaceAsynchronousLoading- Returns:
trueif the content is still loading,falseotherwise.
-
-