wicket.markup.html.image.resource
Class RenderedDynamicImageResource
java.lang.Object
wicket.Resource
wicket.markup.html.WebResource
wicket.markup.html.DynamicWebResource
wicket.markup.html.image.resource.DynamicImageResource
wicket.markup.html.image.resource.RenderedDynamicImageResource
- All Implemented Interfaces:
- java.io.Serializable, IRequestListener, IResourceListener
- Direct Known Subclasses:
- DefaultButtonImageResource
public abstract class RenderedDynamicImageResource
- extends DynamicImageResource
A DynamicImageResource subclass that allows easy rendering of regenenerable
(unbuffered) dynamic images. A RenderedDynamicImageResource implements the
abstract method render(Graphics2D) to create/re-create a given image
on-the-fly. When a RenderedDynamicImageResource is serialized, the image
state is transient, which means it will disappear when the resource is sent
over the wire and then will be recreated when required.
The format of the image (and therefore the resource's extension) can be
specified with setFormat(String). The default format is "PNG" because JPEG is
lossy and makes generated images look bad and GIF has patent issues.
- Author:
- Jonathan Locke, Gili Tzabari, Johan Compagner
- See Also:
DefaultButtonImageResource
,
DefaultButtonImageResourceFactory
,
Serialized Form
Method Summary |
int |
getHeight()
|
protected byte[] |
getImageData()
Get image data for our dynamic image resource. |
int |
getType()
|
int |
getWidth()
|
void |
invalidate()
Causes the image to be redrawn the next time its requested. |
protected byte[] |
render()
Renders this image |
protected abstract boolean |
render(java.awt.Graphics2D graphics)
Override this method to provide your rendering code |
void |
setHeight(int height)
|
void |
setType(int type)
|
void |
setWidth(int width)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RenderedDynamicImageResource
public RenderedDynamicImageResource(int width,
int height)
- Constructor.
- Parameters:
width
- Width of imageheight
- Height of image
RenderedDynamicImageResource
public RenderedDynamicImageResource(int width,
int height,
java.lang.String format)
- Constructor.
- Parameters:
width
- Width of imageheight
- Height of imageformat
- The format of the image (jpg, png or gif)
getHeight
public int getHeight()
- Returns:
- Returns the height.
getType
public int getType()
- Returns:
- Returns the type (one of BufferedImage.TYPE_*).
getWidth
public int getWidth()
- Returns:
- Returns the width.
invalidate
public void invalidate()
- Causes the image to be redrawn the next time its requested.
- Overrides:
invalidate
in class Resource
- See Also:
Resource.invalidate()
setHeight
public void setHeight(int height)
- Parameters:
height
- The height to set.
setType
public void setType(int type)
- Parameters:
type
- The type to set (one of BufferedImage.TYPE_*).
setWidth
public void setWidth(int width)
- Parameters:
width
- The width to set.
getImageData
protected byte[] getImageData()
- Description copied from class:
DynamicImageResource
- Get image data for our dynamic image resource. If the subclass
regenerates the data, it should set the lastModifiedTime when it does so.
This ensures that image caching works correctly.
- Specified by:
getImageData
in class DynamicImageResource
- Returns:
- The image data for this dynamic image
render
protected byte[] render()
- Renders this image
- Returns:
- The image data
render
protected abstract boolean render(java.awt.Graphics2D graphics)
- Override this method to provide your rendering code
- Parameters:
graphics
- The graphics context to render on
- Returns:
- True if the image was rendered. False if the image size was
changed by the rendering implementation and the image should be
re-rendered at the new size.
Copyright © 2004-2007 Wicket developers. All Rights Reserved.