org.apache.batik.svggen
Class ImageCacher

java.lang.Object
  extended by org.apache.batik.svggen.ImageCacher
All Implemented Interfaces:
ErrorConstants, SVGSyntax, CSSConstants, SVGConstants, XMLConstants
Direct Known Subclasses:
ImageCacher.Embedded, ImageCacher.External

public abstract class ImageCacher
extends java.lang.Object
implements SVGSyntax, ErrorConstants

This class implements caching functionality for raster images.


Nested Class Summary
static class ImageCacher.Embedded
          Cache implementation for images embedded in the SVG file.
static class ImageCacher.External
          Cache implementation for file-based images.
 
Field Summary
 
Fields inherited from interface org.apache.batik.svggen.SVGSyntax
CLOSE_PARENTHESIS, COMMA, DATA_PROTOCOL_PNG_PREFIX, ID_PREFIX_ALPHA_COMPOSITE_CLEAR, ID_PREFIX_ALPHA_COMPOSITE_DST_IN, ID_PREFIX_ALPHA_COMPOSITE_DST_OUT, ID_PREFIX_ALPHA_COMPOSITE_DST_OVER, ID_PREFIX_ALPHA_COMPOSITE_SRC, ID_PREFIX_ALPHA_COMPOSITE_SRC_IN, ID_PREFIX_ALPHA_COMPOSITE_SRC_OUT, ID_PREFIX_AMBIENT_LIGHT, ID_PREFIX_BUMP_MAP, ID_PREFIX_CLIP_PATH, ID_PREFIX_DEFS, ID_PREFIX_DIFFUSE_ADD, ID_PREFIX_DIFFUSE_LIGHTING_RESULT, ID_PREFIX_FE_COMPLEX_FILTER, ID_PREFIX_FE_COMPONENT_TRANSFER, ID_PREFIX_FE_COMPOSITE, ID_PREFIX_FE_CONVOLVE_MATRIX, ID_PREFIX_FE_DIFFUSE_LIGHTING, ID_PREFIX_FE_FLOOD, ID_PREFIX_FE_GAUSSIAN_BLUR, ID_PREFIX_FE_LIGHTING_FILTER, ID_PREFIX_FE_SPECULAR_LIGHTING, ID_PREFIX_FONT, ID_PREFIX_GENERIC_DEFS, ID_PREFIX_IMAGE, ID_PREFIX_IMAGE_DEFS, ID_PREFIX_LINEAR_GRADIENT, ID_PREFIX_MASK, ID_PREFIX_PATTERN, ID_PREFIX_RADIAL_GRADIENT, ID_PREFIX_SPECULAR_ADD, ID_PREFIX_SPECULAR_LIGHTING_RESULT, OPEN_PARENTHESIS, RGB_PREFIX, RGB_SUFFIX, SIGN_PERCENT, SIGN_POUND, SPACE, URL_PREFIX, URL_SUFFIX
 
Constructor Summary
ImageCacher()
          Creates an ImageCacher.
ImageCacher(DOMTreeManager domTreeManager)
          Creates an ImageCacher.
 
Constructor Detail

ImageCacher

public ImageCacher()
Creates an ImageCacher.


ImageCacher

public ImageCacher(DOMTreeManager domTreeManager)
Creates an ImageCacher.

Parameters:
domTreeManager - the DOMTreeManager for the tree this cacher works on
Method Detail

setDOMTreeManager

public void setDOMTreeManager(DOMTreeManager domTreeManager)
Sets the DOMTreeManager this cacher should work on.

Parameters:
domTreeManager - the DOMTreeManager for the tree this cacher works on

getDOMTreeManager

public DOMTreeManager getDOMTreeManager()

lookup

public java.lang.String lookup(java.io.ByteArrayOutputStream os,
                               int width,
                               int height,
                               SVGGeneratorContext ctx)
                        throws SVGGraphics2DIOException
Checks if the image is already in the cache, and adds it if not. Returns a unique id for the entry.

Parameters:
os - the image as a byte stream
width - the width of the image
height - the height of the image
ctx - the SVGGeneratorContext
Returns:
a URI for the image
Throws:
SVGGraphics2DIOException - if an error occurs during image file i/o