- java.lang.Object
-
- org.apache.wicket.request.resource.AbstractResource
-
- org.apache.wicket.request.resource.DynamicImageResource
-
- All Implemented Interfaces:
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(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 void
configureResponse(AbstractResource.ResourceResponse response, IResource.Attributes attributes)
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 aAbstractResource.ResourceResponse
for the request.void
setFormat(String format)
Sets the format of this resourceprotected void
setLastModifiedTime(Instant time)
set the last modified time for this resource.protected byte[]
toImageData(BufferedImage image)
-
Methods inherited from class org.apache.wicket.request.resource.AbstractResource
configureCache, getCachingStrategy, respond, setRequestMetaData, setRequestRangeMetaData, setResponseContentRangeHeaderFields, setResponseHeaders
-
-
-
-
Constructor Detail
-
DynamicImageResource
public DynamicImageResource()
Construct.
-
DynamicImageResource
public DynamicImageResource(String format)
Creates a dynamic resource from for the given locale- Parameters:
format
- The image format ("png", "jpeg", etc)
-
-
Method Detail
-
getFormat
public final String getFormat()
- Returns:
- Returns the image format.
-
setFormat
public final void setFormat(String format)
Sets the format of this resource- Parameters:
format
- The format (jpg, png or gif..)
-
setLastModifiedTime
protected void setLastModifiedTime(Instant time)
set the last modified time for this resource.- Parameters:
time
-
-
toImageData
protected byte[] toImageData(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 theDynamicImageResource#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 aAbstractResource.ResourceResponse
for the request.- Specified by:
newResourceResponse
in classAbstractResource
- Parameters:
attributes
- request attributes- Returns:
- resource data instance
-
-