Class SVGImageTranscoder

java.lang.Object
org.apache.batik.transcoder.TranscoderSupport
org.apache.batik.transcoder.AbstractTranscoder
org.apache.batik.transcoder.XMLAbstractTranscoder
org.apache.batik.transcoder.SVGAbstractTranscoder
org.apache.batik.transcoder.image.ImageTranscoder
de.edgesoft.edgeutils.javafx.SVGImageTranscoder
All Implemented Interfaces:
org.apache.batik.transcoder.Transcoder

public class SVGImageTranscoder
extends org.apache.batik.transcoder.image.ImageTranscoder
BufferedImageTranscoder for transcoding SVG to BufferedImage or Image.

Code inspired by https://gist.github.com/ComFreek/b0684ac324c815232556

Legal stuff

Copyright 2010-2020 Ekkart Kleinod ekleinod@edgesoft.de

This file is part of edgeutils.

edgeutils is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

edgeutils is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with edgeutils. If not, see http://www.gnu.org/licenses/.

Since:
0.12.0
Author:
Ekkart Kleinod
  • Field Summary

    Fields inherited from class org.apache.batik.transcoder.image.ImageTranscoder

    KEY_BACKGROUND_COLOR, KEY_FORCE_TRANSPARENT_WHITE

    Fields inherited from class org.apache.batik.transcoder.SVGAbstractTranscoder

    DEFAULT_ALLOWED_SCRIPT_TYPES, DEFAULT_DEFAULT_FONT_FAMILY, KEY_ALLOWED_SCRIPT_TYPES, KEY_ALTERNATE_STYLESHEET, KEY_AOI, KEY_CONSTRAIN_SCRIPT_ORIGIN, KEY_DEFAULT_FONT_FAMILY, KEY_EXECUTE_ONLOAD, KEY_HEIGHT, KEY_LANGUAGE, KEY_MAX_HEIGHT, KEY_MAX_WIDTH, KEY_MEDIA, KEY_PIXEL_TO_MM, KEY_PIXEL_UNIT_TO_MILLIMETER, KEY_SNAPSHOT_TIME, KEY_USER_STYLESHEET_URI, KEY_WIDTH

    Fields inherited from class org.apache.batik.transcoder.XMLAbstractTranscoder

    KEY_DOCUMENT_ELEMENT, KEY_DOCUMENT_ELEMENT_NAMESPACE_URI, KEY_DOM_IMPLEMENTATION, KEY_XML_PARSER_CLASSNAME, KEY_XML_PARSER_VALIDATING
  • Constructor Summary

    Constructors 
    Constructor Description
    SVGImageTranscoder()  
  • Method Summary

    Modifier and Type Method Description
    java.awt.image.BufferedImage createImage​(int theWidth, int theHeight)  
    static SVGImageTranscoder createSVGImageTranscoder​(int theWidth, int theHeight)
    Creates new SVGImageTranscoder with given width and height.
    java.awt.image.BufferedImage getBufferedImage()
    Returns buffered image.
    javafx.scene.image.Image getFXImage()
    Returns fx image.
    void setHeight​(int theHeight)
    Sets image height.
    void setWidth​(int theWidth)
    Sets image width.
    void writeImage​(java.awt.image.BufferedImage img, org.apache.batik.transcoder.TranscoderOutput to)  

    Methods inherited from class org.apache.batik.transcoder.SVGAbstractTranscoder

    transcode

    Methods inherited from class org.apache.batik.transcoder.TranscoderSupport

    addTranscodingHint, getErrorHandler, getTranscodingHints, removeTranscodingHint, setErrorHandler, setTranscodingHints, setTranscodingHints

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.batik.transcoder.Transcoder

    addTranscodingHint, getErrorHandler, getTranscodingHints, removeTranscodingHint, setErrorHandler, setTranscodingHints, setTranscodingHints
  • Constructor Details

  • Method Details

    • setWidth

      public void setWidth​(int theWidth)
      Sets image width.
      Parameters:
      theWidth - image width (-1 no width specified)
    • setHeight

      public void setHeight​(int theHeight)
      Sets image height.
      Parameters:
      theHeight - image height (-1 no height specified)
    • createSVGImageTranscoder

      public static SVGImageTranscoder createSVGImageTranscoder​(int theWidth, int theHeight)
      Creates new SVGImageTranscoder with given width and height.
      Parameters:
      theWidth - image width (-1 no width specified)
      theHeight - image height (-1 no height specified)
      Returns:
      new transcoder
    • createImage

      public java.awt.image.BufferedImage createImage​(int theWidth, int theHeight)
      Specified by:
      createImage in class org.apache.batik.transcoder.image.ImageTranscoder
    • writeImage

      public void writeImage​(java.awt.image.BufferedImage img, org.apache.batik.transcoder.TranscoderOutput to) throws org.apache.batik.transcoder.TranscoderException
      Specified by:
      writeImage in class org.apache.batik.transcoder.image.ImageTranscoder
      Throws:
      org.apache.batik.transcoder.TranscoderException
    • getBufferedImage

      public java.awt.image.BufferedImage getBufferedImage()
      Returns buffered image.
      Returns:
      buffered image
    • getFXImage

      public javafx.scene.image.Image getFXImage()
      Returns fx image.
      Returns:
      fx image