Class ImageProviderPipeline
java.lang.Object
org.apache.xmlgraphics.image.loader.pipeline.ImageProviderPipeline
Represents a pipeline of ImageConverters with an ImageLoader at the beginning of the
pipeline.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final org.apache.commons.logging.Log
logger -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor without caching and without an ImageLoader (or the ImageLoader may be set later).ImageProviderPipeline
(ImageCache cache, ImageLoader loader) Main constructor.ImageProviderPipeline
(ImageLoader loader) Constructor for operation without caching. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConverter
(ImageConverter converter) Adds an additional ImageConverter to the end of the pipeline.execute
(ImageInfo info, Map hints, ImageSessionContext context) Executes the image converter pipeline.execute
(ImageInfo info, Image originalImage, Map hints, ImageSessionContext context) Executes the image converter pipeline.protected Image
forceCaching
(Image img) In some cases the provided Image is not cacheable, nor is any of the intermediate Image instances (for example, when loading a raw JPEG file).int
Returns the overall conversion penalty for the pipeline.getConversionPenalty
(ImageImplRegistry registry) Returns the overall conversion penalty for the pipeline.Returns the target flavor generated by this pipeline.void
setImageLoader
(ImageLoader imageLoader) Sets the ImageLoader that is used at the beginning of the pipeline if the image is not loaded, yet.toString()
-
Field Details
-
log
protected static final org.apache.commons.logging.Log loglogger
-
-
Constructor Details
-
ImageProviderPipeline
Main constructor.- Parameters:
cache
- the image cache (may be null if no caching is desired)loader
- the image loader to drive the pipeline with
-
ImageProviderPipeline
Constructor for operation without caching.- Parameters:
loader
- the image loader to drive the pipeline with
-
ImageProviderPipeline
public ImageProviderPipeline()Default constructor without caching and without an ImageLoader (or the ImageLoader may be set later).
-
-
Method Details
-
execute
public Image execute(ImageInfo info, Map hints, ImageSessionContext context) throws ImageException, IOException Executes the image converter pipeline. First, the image indicated by the ImageInfo instance is loaded through an ImageLoader and then optionally converted by a series of ImageConverters. At the end of the pipeline, the fully loaded and converted image is returned.- Parameters:
info
- the image info object indicating the image to loadhints
- a Map of image conversion hintscontext
- the session context- Returns:
- the requested image
- Throws:
ImageException
- if an error occurs while loader or converting the imageIOException
- if an I/O error occurs
-
execute
public Image execute(ImageInfo info, Image originalImage, Map hints, ImageSessionContext context) throws ImageException, IOException Executes the image converter pipeline. First, the image indicated by the ImageInfo instance is loaded through an ImageLoader and then optionally converted by a series of ImageConverters. At the end of the pipeline, the fully loaded and converted image is returned.- Parameters:
info
- the image info object indicating the image to loadoriginalImage
- the original image to start the pipeline off or null if an ImageLoader is usedhints
- a Map of image conversion hintscontext
- the session context- Returns:
- the requested image
- Throws:
ImageException
- if an error occurs while loader or converting the imageIOException
- if an I/O error occurs
-
forceCaching
In some cases the provided Image is not cacheable, nor is any of the intermediate Image instances (for example, when loading a raw JPEG file). If the image is loaded over a potentially slow network, it is preferrable to download the whole file and cache it in memory or in a temporary file. It's not always possible to convert an Image into a cacheable variant.- Parameters:
img
- the Image to investigate- Returns:
- the converted, cacheable Image or null if the Image cannot be converted
- Throws:
IOException
- if an I/O error occurs
-
setImageLoader
Sets the ImageLoader that is used at the beginning of the pipeline if the image is not loaded, yet.- Parameters:
imageLoader
- the image loader implementation
-
addConverter
Adds an additional ImageConverter to the end of the pipeline.- Parameters:
converter
- the ImageConverter instance
-
toString
-
getConversionPenalty
public int getConversionPenalty()Returns the overall conversion penalty for the pipeline. This can be used to choose among different possible pipelines.- Returns:
- the overall penalty (a non-negative integer)
-
getConversionPenalty
Returns the overall conversion penalty for the pipeline. This can be used to choose among different possible pipelines.- Parameters:
registry
- the image implementation registry- Returns:
- the overall penalty (a non-negative integer)
-
getTargetFlavor
Returns the target flavor generated by this pipeline.- Returns:
- the target flavor
-