Module org.apache.wicket.core
Class BufferedDynamicImageResource
java.lang.Object
org.apache.wicket.request.resource.AbstractResource
org.apache.wicket.request.resource.DynamicImageResource
org.apache.wicket.markup.html.image.resource.BufferedDynamicImageResource
- All Implemented Interfaces:
Serializable
,IResource
,IClusterable
A DynamicImageResource subclass that holds a BufferedImage generated by code elsewhere. The image
is held in a non-transient field, and so if this resource is clustered, the entire image will be
serialized and copied. If you can regenerate your image by drawing on a Graphics2D, you should
prefer the RenderedDynamicImageResource class instead since its image data is transient and
therefore it is very lightweight when clustered.
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.
- Author:
- Jonathan Locke
- 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
-
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]
getImageData
(IResource.Attributes attributes) Get image data for our dynamic image resource.void
setImage
(BufferedImage image) Methods inherited from class org.apache.wicket.request.resource.DynamicImageResource
configureResponse, getFormat, newResourceResponse, setFormat, setLastModifiedTime, toImageData
Methods inherited from class org.apache.wicket.request.resource.AbstractResource
configureCache, getCachingStrategy, respond, setRequestMetaData, setRequestRangeMetaData, setResponseContentRangeHeaderFields, setResponseHeaders
-
Constructor Details
-
BufferedDynamicImageResource
public BufferedDynamicImageResource()Construct. -
BufferedDynamicImageResource
Construct.- Parameters:
format
-
-
-
Method Details
-
setImage
- Parameters:
image
- The image to set
-
getImageData
Description copied from class:DynamicImageResource
Get image data for our dynamic image resource. If the subclass regenerates the data, it should set theDynamicImageResource.setLastModifiedTime(Instant)
when it does so. This ensures that image caching works correctly.- Specified by:
getImageData
in classDynamicImageResource
- 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.
-