Class DefaultCachedImageHandler

    • Constructor Detail

      • DefaultCachedImageHandler

        public DefaultCachedImageHandler()
    • Method Detail

      • createElement

        public org.w3c.dom.Element createElement​(SVGGeneratorContext generatorContext)
        Creates an Element which can refer to an image. Note that no assumptions should be made by the caller about the corresponding SVG tag. By default, an <image> tag is used, but the CachedImageHandlerBase64Encoder, for example, overrides this method to use a different tag.
        Specified by:
        createElement in interface GenericImageHandler
      • handleImage

        public java.awt.geom.AffineTransform handleImage​(java.awt.Image image,
                                                         org.w3c.dom.Element imageElement,
                                                         int x,
                                                         int y,
                                                         int width,
                                                         int height,
                                                         SVGGeneratorContext generatorContext)
        The handler sets the xlink:href tag and returns a transform
        Specified by:
        handleImage in interface GenericImageHandler
        Parameters:
        image - the image under consideration
        imageElement - the DOM Element for this image
        x - x coordinate
        y - y coordinate
        width - width for rendering
        height - height for rendering
        generatorContext - the SVGGeneratorContext
        Returns:
        transform converting the image dimension to rendered dimension
      • handleImage

        public java.awt.geom.AffineTransform handleImage​(java.awt.image.RenderedImage image,
                                                         org.w3c.dom.Element imageElement,
                                                         int x,
                                                         int y,
                                                         int width,
                                                         int height,
                                                         SVGGeneratorContext generatorContext)
        The handler sets the xlink:href tag and returns a transform
        Specified by:
        handleImage in interface GenericImageHandler
        Parameters:
        image - the image under consideration
        imageElement - the DOM Element for this image
        x - x coordinate
        y - y coordinate
        width - width for rendering
        height - height for rendering
        generatorContext - the SVGGeneratorContext
        Returns:
        transform converting the image dimension to rendered dimension
      • handleImage

        public java.awt.geom.AffineTransform handleImage​(java.awt.image.renderable.RenderableImage image,
                                                         org.w3c.dom.Element imageElement,
                                                         double x,
                                                         double y,
                                                         double width,
                                                         double height,
                                                         SVGGeneratorContext generatorContext)
        The handler sets the xlink:href tag and returns a transform
        Specified by:
        handleImage in interface GenericImageHandler
        Parameters:
        image - the image under consideration
        imageElement - the DOM Element for this image
        x - x coordinate
        y - y coordinate
        width - width for rendering
        height - height for rendering
        generatorContext - the SVGGeneratorContext
        Returns:
        transform converting the image dimension to rendered dimension
      • handleTransform

        protected java.awt.geom.AffineTransform handleTransform​(org.w3c.dom.Element imageElement,
                                                                double x,
                                                                double y,
                                                                double srcWidth,
                                                                double srcHeight,
                                                                double dstWidth,
                                                                double dstHeight,
                                                                SVGGeneratorContext generatorContext)
        Determines the transformation needed to get the cached image to scale & position properly. Sets x and y attributes on the element accordingly.
      • handleEmptyImage

        protected void handleEmptyImage​(org.w3c.dom.Element imageElement)
      • buildBufferedImage

        public java.awt.image.BufferedImage buildBufferedImage​(java.awt.Dimension size)
        This method creates a BufferedImage of the right size and type for the derived class.
      • getRefPrefix

        public abstract java.lang.String getRefPrefix()
        Should return the prefix with wich the image reference should be pre-concatenated.
      • encodeImage

        public abstract void encodeImage​(java.awt.image.BufferedImage buf,
                                         java.io.OutputStream os)
                                  throws java.io.IOException
        Derived classes should implement this method and encode the input BufferedImage as needed
        Throws:
        java.io.IOException
      • getBufferedImageType

        public abstract int getBufferedImageType()
        This template method should be overridden by derived classes to declare the image type they need for saving to file.