java.lang.Object
org.apache.wicket.request.resource.AbstractResource
org.apache.wicket.request.resource.DynamicImageResource
- All Implemented Interfaces:
Serializable
,IResource
,IClusterable
- Direct Known Subclasses:
BlobImageResource
,BufferedDynamicImageResource
,CaptchaImageResource
,RenderedDynamicImageResource
,ThumbnailImageResource
Base class for dynamically generated ImageResources.
- See Also:
-
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
ConstructorDescriptionConstruct.DynamicImageResource
(String format) Creates a dynamic resource from for the given locale -
Method Summary
Modifier and TypeMethodDescriptionprotected void
configureResponse
(AbstractResource.ResourceResponse response, IResource.Attributes attributes) final String
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.final void
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 Details
-
DynamicImageResource
public DynamicImageResource()Construct. -
DynamicImageResource
Creates a dynamic resource from for the given locale- Parameters:
format
- The image format ("png", "jpeg", etc)
-
-
Method Details
-
getFormat
- Returns:
- Returns the image format.
-
setFormat
Sets the format of this resource- Parameters:
format
- The format (jpg, png or gif..)
-
setLastModifiedTime
set the last modified time for this resource.- Parameters:
time
-
-
toImageData
- Parameters:
image
- The image to turn into data- Returns:
- The image data for this dynamic image
-
getImageData
Get image data for our dynamic image resource. If the subclass regenerates the data, it should set thesetLastModifiedTime(Instant)
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
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
-