Class DefaultGalleryProcessor
- java.lang.Object
-
- org.hippoecm.frontend.plugins.gallery.model.DefaultGalleryProcessor
-
- All Implemented Interfaces:
Serializable
,org.apache.wicket.util.io.IClusterable
,GalleryProcessor
- Direct Known Subclasses:
NullGalleryProcessor
public class DefaultGalleryProcessor extends Object implements GalleryProcessor
Gallery processor that puts a resized version of the image in the primary item and populates other resource child nodes with the original.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultGalleryProcessor.UnsupportedMimeTypeException
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_THUMBNAIL_SIZE
-
Fields inherited from interface org.hippoecm.frontend.plugins.gallery.model.GalleryProcessor
DEFAULT_GALLERY_PROCESSOR_ID, GALLERY_PROCESSOR_ID
-
-
Constructor Summary
Constructors Constructor Description DefaultGalleryProcessor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description InputStream
createThumbnail(InputStream imageData, int maxSize, String mimeType)
Creates a thumbnail version of an image.Dimension
getDesiredResourceDimension(Node node)
static GalleryProcessor
getGalleryProcessor(IPluginContext pluginContext, IPluginConfig pluginConfig)
Get the gallery processor service identified by the parameterGalleryProcessor.GALLERY_PROCESSOR_ID
in the plugin config.static GalleryProcessor
getGalleryProcessor(IPluginContext pluginContext, IPluginConfig pluginConfig, String defaultServiceId)
Get the gallery processor service specified by the parameterGalleryProcessor.GALLERY_PROCESSOR_ID
in the plugin config.BufferedImage
getScaledInstance(BufferedImage img, int targetWidth, int targetHeight, Object hint, boolean higherQuality)
Convenience method that returns a scaled instance of the providedBufferedImage
.Map<String,ScalingParameters>
getScalingParametersMap()
int
getThumbnailSize()
void
initGalleryResource(Node node, InputStream data, String mimeType, String fileName, Calendar lastModified)
boolean
isUpscalingEnabled(Node node)
void
makeImage(Node node, InputStream istream, String mimeType, String fileName)
protected void
makeRegularImage(Node node, String name, InputStream istream, String mimeType, Calendar lastModified)
protected void
makeThumbnailImage(Node node, InputStream resourceData, String mimeType)
void
setThumbnailSize(int thumbnailSize)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hippoecm.frontend.plugins.gallery.model.GalleryProcessor
getScalingParameters
-
-
-
-
Field Detail
-
DEFAULT_THUMBNAIL_SIZE
public static final int DEFAULT_THUMBNAIL_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
setThumbnailSize
public void setThumbnailSize(int thumbnailSize)
-
getThumbnailSize
public int getThumbnailSize()
-
createThumbnail
public InputStream createThumbnail(InputStream imageData, int maxSize, String mimeType) throws GalleryException
Creates a thumbnail version of an image. The maxsize parameter determines how the image is scaled: it is the maximum size of both the width and height. If the original height is greater than the original width, then the height of the scaled image will be equal to max size. The same goes for the original width: if it is greater than the original height, the width of the scaled image is equal to maxsize.- Parameters:
imageData
- the original image data; the input stream is closed by this method.maxSize
- the maximum height or width of the scaled imagemimeType
- the mime type of the image- Returns:
- the scaled image stream
- Throws:
GalleryException
-
getScaledInstance
public BufferedImage getScaledInstance(BufferedImage img, int targetWidth, int targetHeight, Object hint, boolean higherQuality)
Convenience method that returns a scaled instance of the providedBufferedImage
.- Parameters:
img
- the original image to be scaledtargetWidth
- the desired width of the scaled instance, in pixelstargetHeight
- the desired height of the scaled instance, in pixelshint
- one of the rendering hints that corresponds toRenderingHints.KEY_INTERPOLATION
(e.g.RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR
,RenderingHints.VALUE_INTERPOLATION_BILINEAR
,RenderingHints.VALUE_INTERPOLATION_BICUBIC
)higherQuality
- if true, this method will use a multi-step scaling technique that provides higher quality than the usual one-step technique (only useful in downscaling cases, wheretargetWidth
ortargetHeight
is smaller than the original dimensions, and generally only when theBILINEAR
hint is specified)- Returns:
- a scaled version of the original
BufferedImage
-
getDesiredResourceDimension
public Dimension getDesiredResourceDimension(Node node) throws RepositoryException
- Specified by:
getDesiredResourceDimension
in interfaceGalleryProcessor
- Throws:
RepositoryException
-
makeImage
public void makeImage(Node node, InputStream istream, String mimeType, String fileName) throws GalleryException, RepositoryException
- Specified by:
makeImage
in interfaceGalleryProcessor
- Throws:
GalleryException
RepositoryException
-
makeRegularImage
protected void makeRegularImage(Node node, String name, InputStream istream, String mimeType, Calendar lastModified) throws RepositoryException
- Throws:
RepositoryException
-
makeThumbnailImage
protected void makeThumbnailImage(Node node, InputStream resourceData, String mimeType) throws RepositoryException, GalleryException
- Throws:
RepositoryException
GalleryException
-
initGalleryResource
public void initGalleryResource(Node node, InputStream data, String mimeType, String fileName, Calendar lastModified) throws GalleryException, RepositoryException
- Specified by:
initGalleryResource
in interfaceGalleryProcessor
- Throws:
GalleryException
RepositoryException
-
isUpscalingEnabled
public boolean isUpscalingEnabled(Node node) throws GalleryException, RepositoryException
- Specified by:
isUpscalingEnabled
in interfaceGalleryProcessor
- Throws:
GalleryException
RepositoryException
-
getScalingParametersMap
public Map<String,ScalingParameters> getScalingParametersMap()
- Specified by:
getScalingParametersMap
in interfaceGalleryProcessor
-
getGalleryProcessor
public static GalleryProcessor getGalleryProcessor(IPluginContext pluginContext, IPluginConfig pluginConfig)
Get the gallery processor service identified by the parameterGalleryProcessor.GALLERY_PROCESSOR_ID
in the plugin config. If no service id configuration is found, the service with idGalleryProcessor.DEFAULT_GALLERY_PROCESSOR_ID
is used.
-
getGalleryProcessor
public static GalleryProcessor getGalleryProcessor(IPluginContext pluginContext, IPluginConfig pluginConfig, String defaultServiceId)
Get the gallery processor service specified by the parameterGalleryProcessor.GALLERY_PROCESSOR_ID
in the plugin config. If no service id configuration is found, the service with iddefaultServiceId
is used. If the service with this default id is not found, a new instance of theDefaultGalleryProcessor
is returned.
-
-