Class DynamicImageResource
- java.lang.Object
-
- org.apache.wicket.request.resource.AbstractResource
-
- org.apache.wicket.request.resource.DynamicImageResource
-
- All Implemented Interfaces:
java.io.Serializable,IResource,org.apache.wicket.util.io.IClusterable
- Direct Known Subclasses:
BlobImageResource,BufferedDynamicImageResource,RenderedDynamicImageResource
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.ContentRangeType, 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
CONTENT_DISPOSITION_HEADER_NAME, CONTENT_RANGE_ENDBYTE, CONTENT_RANGE_STARTBYTE, INTERNAL_HEADERS
-
-
Constructor Summary
Constructors Constructor Description DynamicImageResource()Construct.DynamicImageResource(java.lang.String format)Creates a dynamic resource from for the given locale
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidconfigureResponse(AbstractResource.ResourceResponse response, IResource.Attributes attributes)java.lang.StringgetFormat()protected abstract byte[]getImageData(IResource.Attributes attributes)Get image data for our dynamic image resource.protected AbstractResource.ResourceResponsenewResourceResponse(IResource.Attributes attributes)Override this method to return aAbstractResource.ResourceResponsefor the request.voidsetFormat(java.lang.String format)Sets the format of this resourceprotected voidsetLastModifiedTime(org.apache.wicket.util.time.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, setRequestMetaData, setRequestRangeMetaData, setResponseContentRangeHeaderFields, setResponseHeaders
-
-
-
-
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(org.apache.wicket.util.time.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 thesetLastModifiedTime(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.
nullmeans 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:AbstractResourceOverride this method to return aAbstractResource.ResourceResponsefor the request.- Specified by:
newResourceResponsein classAbstractResource- Parameters:
attributes- request attributes- Returns:
- resource data instance
-
-