Class ThumbnailImageResource
- java.lang.Object
-
- org.apache.wicket.request.resource.AbstractResource
-
- org.apache.wicket.request.resource.DynamicImageResource
-
- org.apache.wicket.extensions.markup.html.image.resource.ThumbnailImageResource
-
- All Implemented Interfaces:
Serializable
,IResource
,IClusterable
public class ThumbnailImageResource extends DynamicImageResource
Image resource that dynamically scales the given original resource to a thumbnail. It is scaled either using the given maxSize as width or height, depending on its shape. If both the width and height are less than maxSize, no scaling is performed.- Author:
- Eelco Hillenius, Eugene Kamenev
- 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 ThumbnailImageResource(IResource unscaledImageResource, int maxSize)
Construct.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected byte[]
getImageData(IResource.Attributes attributes)
Get image data for our dynamic image resource.protected BufferedImage
getScaledImageInstance(IResource.Attributes attributes)
get resized image instance.-
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 Detail
-
ThumbnailImageResource
public ThumbnailImageResource(IResource unscaledImageResource, int maxSize)
Construct.- Parameters:
unscaledImageResource
- the unscaled, original image resource. Must be not nullmaxSize
- maximum size (width or height) for resize operation
-
-
Method Detail
-
getImageData
protected byte[] getImageData(IResource.Attributes attributes)
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
-
getScaledImageInstance
protected BufferedImage getScaledImageInstance(IResource.Attributes attributes)
get resized image instance.- Parameters:
attributes
-- Returns:
- BufferedImage
-
-