org.apache.wicket.request.resource
Class DynamicImageResource

java.lang.Object
  extended by org.apache.wicket.request.resource.AbstractResource
      extended by org.apache.wicket.request.resource.DynamicImageResource
All Implemented Interfaces:
java.io.Serializable, IClusterable, IResource
Direct Known Subclasses:
BlobImageResource, BufferedDynamicImageResource, CaptchaImageResource, RenderedDynamicImageResource, ThumbnailImageResource

public abstract class DynamicImageResource
extends AbstractResource

Base class for dynamically generated ImageResources.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.wicket.request.resource.AbstractResource
AbstractResource.ResourceResponse, AbstractResource.WriteCallback
 
Nested classes/interfaces inherited from interface org.apache.wicket.request.resource.IResource
IResource.Attributes
 
Field Summary
 
Fields inherited from class org.apache.wicket.request.resource.AbstractResource
INTERNAL_HEADERS
 
Constructor Summary
DynamicImageResource()
          Construct.
DynamicImageResource(java.lang.String format)
          Creates a dynamic resource from for the given locale
 
Method Summary
protected  void configureResponse(AbstractResource.ResourceResponse response, IResource.Attributes attributes)
           
 java.lang.String getFormat()
           
protected abstract  byte[] getImageData(IResource.Attributes attributes)
          Get image data for our dynamic image resource.
protected  AbstractResource.ResourceResponse newResourceResponse(IResource.Attributes attributes)
          Override this method to return a AbstractResource.ResourceResponse for the request.
 void setFormat(java.lang.String format)
          Sets the format of this resource
protected  void setLastModifiedTime(Time time)
          set the last modified time for this resource.
protected  byte[] toImageData(java.awt.image.BufferedImage image)
           
 
Methods inherited from class org.apache.wicket.request.resource.AbstractResource
configureCache, getCachingStrategy, respond, setResponseHeaders
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicImageResource

public DynamicImageResource()
Construct.


DynamicImageResource

public DynamicImageResource(java.lang.String format)
Creates a dynamic resource from for the given locale

Parameters:
format - The image format ("png", "jpeg", etc)
Method Detail

getFormat

public final java.lang.String getFormat()
Returns:
Returns the image format.

setFormat

public final void setFormat(java.lang.String format)
Sets the format of this resource

Parameters:
format - The format (jpg, png or gif..)

setLastModifiedTime

protected void setLastModifiedTime(Time time)
set the last modified time for this resource.

Parameters:
time -

toImageData

protected byte[] toImageData(java.awt.image.BufferedImage image)
Parameters:
image - The image to turn into data
Returns:
The image data for this dynamic image

getImageData

protected abstract byte[] getImageData(IResource.Attributes attributes)
Get image data for our dynamic image resource. If the subclass regenerates the data, it should set the setLastModifiedTime(Time) when it does so. This ensures that image caching works correctly.

Parameters:
attributes - the context bringing the request, response and the parameters
Returns:
The image data for this dynamic image. null means there is no image and 404 (Not found) response will be return.

configureResponse

protected void configureResponse(AbstractResource.ResourceResponse response,
                                 IResource.Attributes attributes)

newResourceResponse

protected AbstractResource.ResourceResponse newResourceResponse(IResource.Attributes attributes)
Description copied from class: AbstractResource
Override this method to return a AbstractResource.ResourceResponse for the request.

Specified by:
newResourceResponse in class AbstractResource
Parameters:
attributes - request attributes
Returns:
resource data instance


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.