Interface ImageSessionContext
- All Known Implementing Classes:
AbstractImageSessionContext
,DefaultImageSessionContext
public interface ImageSessionContext
This interface is used to tell the cache which images are used by a session (in FOP that would
be a rendering run). Images access within a session get a hard reference so they cannot be
discarded. That could increase memory usage but helps with performance because the images
don't get unloaded between layout and rendering which would mean that they have to be reloaded.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the session-independent context object which provides configuration information.Returns a Source object for a URI.float
Returns the resolution (in dpi) of the source device used when painting images.float
Returns the resolution (in dpi) of the target device used when painting images.needSource
(String uri) Returns a Source object for a URI.Attempts to create a Source object from the given URI.void
returnSource
(String uri, Source src) Returns a Source object to a pool.
-
Method Details
-
getParentContext
ImageContext getParentContext()Returns the session-independent context object which provides configuration information.- Returns:
- the associated ImageContext instance
-
getTargetResolution
float getTargetResolution()Returns the resolution (in dpi) of the target device used when painting images.- Returns:
- the target resolution (in dpi)
-
getSourceResolution
float getSourceResolution()Returns the resolution (in dpi) of the source device used when painting images.- Returns:
- the source resolution (in dpi)
-
newSource
Attempts to create a Source object from the given URI. If possible this method returns an ImageSource instance which provides the best possible method to access the image.- Parameters:
uri
- URI to access- Returns:
- A
Source
object, or null if the URI cannot be resolved.
-
getSource
Returns a Source object for a URI. This method is not guaranteed to return an instance. Implementations normally return already created Sources from a pool (normally populated through thereturnSource(String, Source)
method).- Parameters:
uri
- the URI of the image- Returns:
- the Source object to load the image from, or null
-
needSource
Returns a Source object for a URI. This method is guaranteed to return a Source object. If the image cannot be found, aFileNotFoundException
is thrown.- Parameters:
uri
- the URI of the image- Returns:
- the Source object to load the image from
- Throws:
FileNotFoundException
- if the image cannot be found
-
returnSource
Returns a Source object to a pool. This is provided in order to reuse a Source object between the preloading and the final loading of an image. Note that not all Source objects can be reused! Non-reusable Sources are discarded.- Parameters:
uri
- the URI of the imagesrc
- the Source object belonging to the URI
-