|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.wicket.Resource
org.apache.wicket.markup.html.WebResource
org.apache.wicket.markup.html.DynamicWebResource
org.apache.wicket.markup.html.image.resource.DynamicImageResource
public abstract class DynamicImageResource
An ImageResource subclass for dynamic images (images created programmatically). Subclasses override getImageData() to provide the image data to send back to the user. A given subclass may decide how to produce this data and whether/how to buffer it.
The RenderedDynamicImageResource subclass is designed for images that can be regenerated when the component is deserialized (the image data is transient). A good example of a RenderedDynamicImageResource is the DefaultButtonImageResource class, which can regenerate a given button image at any time. This makes it very lightweight when clustered. The BufferedDynamicImageResource class, on the other hand, is designed for images that cannot be regenerated on demand. It buffers its image data in a non-transient way, which means that the entire image will be serialized and copied when the resource is replicated in a cluster!
The helper method toImageData(BufferedImage) is provided so that subclasses can easily turn a BufferedImage into a suitable return value when implementing getImageData().
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.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.apache.wicket.markup.html.DynamicWebResource |
---|
DynamicWebResource.ResourceState |
Field Summary |
---|
Fields inherited from interface org.apache.wicket.IResourceListener |
---|
INTERFACE |
Constructor Summary | |
---|---|
DynamicImageResource()
Creates a dynamic image resource. |
|
DynamicImageResource(Locale locale)
Creates a dynamic resource from for the given locale |
|
DynamicImageResource(String format)
Creates a dynamic resource from for the given locale |
|
DynamicImageResource(String format,
Locale locale)
Creates a dynamic resource from for the given locale |
Method Summary | |
---|---|
String |
getFormat()
|
protected abstract byte[] |
getImageData()
Get image data for our dynamic image resource. |
protected DynamicWebResource.ResourceState |
getResourceState()
Gets the byte array for our dynamic resource. |
void |
setFormat(String format)
Sets the format of this resource |
protected void |
setLastModifiedTime(Time time)
set the last modified time for this resource. |
protected byte[] |
toImageData(BufferedImage image)
|
Methods inherited from class org.apache.wicket.markup.html.DynamicWebResource |
---|
getLocale, getResourceStream, setHeaders |
Methods inherited from class org.apache.wicket.markup.html.WebResource |
---|
configureResponse, getCacheDuration |
Methods inherited from class org.apache.wicket.Resource |
---|
getParameters, invalidate, isCacheable, onResourceRequested, setCacheable, setParameters |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DynamicImageResource()
public DynamicImageResource(Locale locale)
locale
- The locale of this resourcepublic DynamicImageResource(String format)
format
- The image format ("png", "jpeg", etc)public DynamicImageResource(String format, Locale locale)
format
- The image format ("png", "jpeg", etc)locale
- The locale of this resourceMethod Detail |
---|
public final String getFormat()
public final void setFormat(String format)
format
- The format (jpg, png or gif..)protected void setLastModifiedTime(Time time)
time
- protected byte[] toImageData(BufferedImage image)
image
- The image to turn into data
protected DynamicWebResource.ResourceState getResourceState()
DynamicWebResource
getResourceState
in class DynamicWebResource
DynamicWebResource.getResourceState()
protected abstract byte[] getImageData()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |