org.apache.batik.svggen

Class AbstractImageHandlerEncoder

public abstract class AbstractImageHandlerEncoder extends DefaultImageHandler

This abstract implementation of the ImageHandler interface is intended to be the base class for ImageHandlers that generate image files for all the images they handle. This class stores images in an configurable directory. The xlink:href value the class generates is made of a configurable url root and the name of the file created by this handler.

See Also: SVGGraphics2D ImageHandlerJPEGEncoder ImageHandlerPNGEncoder

Constructor Summary
AbstractImageHandlerEncoder(String imageDir, String urlRoot)
Method Summary
abstract BufferedImagebuildBufferedImage(Dimension size)
This method creates a BufferedImage of the right size and type for the derived class.
abstract voidencodeImage(BufferedImage buf, File imageFile)
Derived classes should implement this method and encode the input BufferedImage as needed
abstract StringgetPrefix()
abstract StringgetSuffix()
protected voidhandleHREF(Image image, Element imageElement, SVGGeneratorContext generatorContext)
This template method should set the xlink:href attribute on the input Element parameter
protected voidhandleHREF(RenderedImage image, Element imageElement, SVGGeneratorContext generatorContext)
This template method should set the xlink:href attribute on the input Element parameter
protected voidhandleHREF(RenderableImage image, Element imageElement, SVGGeneratorContext generatorContext)
This template method should set the xlink:href attribute on the input Element parameter

Constructor Detail

AbstractImageHandlerEncoder

public AbstractImageHandlerEncoder(String imageDir, String urlRoot)

Parameters: imageDir directory where this handler should generate images. If null, an SVGGraphics2DRuntimeException is thrown. urlRoot root for the urls that point to images created by this image handler. If null, then the url corresponding to imageDir is used.

Method Detail

buildBufferedImage

public abstract BufferedImage buildBufferedImage(Dimension size)
This method creates a BufferedImage of the right size and type for the derived class.

encodeImage

public abstract void encodeImage(BufferedImage buf, File imageFile)
Derived classes should implement this method and encode the input BufferedImage as needed

getPrefix

public abstract String getPrefix()

Returns: the prefix used by this encoder. E.g., "jpegImage" for ImageHandlerJPEGEncoder

getSuffix

public abstract String getSuffix()

Returns: the suffix used by this encoder. E.g., ".jpg" for ImageHandlerJPEGEncoder

handleHREF

protected void handleHREF(Image image, Element imageElement, SVGGeneratorContext generatorContext)
This template method should set the xlink:href attribute on the input Element parameter

handleHREF

protected void handleHREF(RenderedImage image, Element imageElement, SVGGeneratorContext generatorContext)
This template method should set the xlink:href attribute on the input Element parameter

handleHREF

protected void handleHREF(RenderableImage image, Element imageElement, SVGGeneratorContext generatorContext)
This template method should set the xlink:href attribute on the input Element parameter
Copyright B) 2008 Apache Software Foundation. All Rights Reserved.