Class SVGGeneratorContext

  • All Implemented Interfaces:
    ErrorConstants

    public class SVGGeneratorContext
    extends java.lang.Object
    implements ErrorConstants
    This class contains all non graphical contextual information that are needed by the SVGGraphics2D to generate SVG from Java 2D primitives. You can subclass it to change the defaults.
    Version:
    $Id: SVGGeneratorContext.java 1733416 2016-03-03 07:07:13Z gadams $
    See Also:
    SVGGraphics2D(SVGGeneratorContext,boolean)
    • Field Detail

      • domFactory

        org.w3c.dom.Document domFactory
        Factory used by this Graphics2D to create Elements that make the SVG DOM Tree
      • genericImageHandler

        GenericImageHandler genericImageHandler
        Generic image handler. This allows more sophisticated image handling strategies than the ImageHandler interfaces.
      • extensionHandler

        ExtensionHandler extensionHandler
        To deal with Java 2D extension (custom java.awt.Paint for example).
      • generatorComment

        java.lang.String generatorComment
        The comment to insert at generation time.
      • svgFont

        boolean svgFont
        Do we accept SVG Fonts generation?
      • precision

        int precision
        Number of decimal places to use in output values. 3 decimal places are used by default.
      • decimalFormat

        protected java.text.DecimalFormat decimalFormat
        Current double value formatter
      • dsf

        protected static java.text.DecimalFormatSymbols dsf
      • decimalFormats

        protected static java.text.DecimalFormat[] decimalFormats
    • Method Detail

      • setGraphicContextDefaults

        public final void setGraphicContextDefaults​(SVGGeneratorContext.GraphicContextDefaults gcDefaults)
        Sets the default to be used for the graphic context. Note that gcDefaults may be null and that any of its attributes may be null.
      • setIDGenerator

        public final void setIDGenerator​(SVGIDGenerator idGenerator)
        Sets the SVGIDGenerator to be used. It should not be null.
      • getDOMFactory

        public final org.w3c.dom.Document getDOMFactory()
        Returns the DOM Factory that has been set.
      • setDOMFactory

        public final void setDOMFactory​(org.w3c.dom.Document domFactory)
        Sets the DOM Factory to be used. It should not be null.
      • setExtensionHandler

        public final void setExtensionHandler​(ExtensionHandler extensionHandler)
        Sets the ExtensionHandler to be used. It should not be null.
      • setImageHandler

        public final void setImageHandler​(ImageHandler imageHandler)
        Sets the ImageHandler to be used. It should not be null.
      • setStyleHandler

        public final void setStyleHandler​(StyleHandler styleHandler)
        Sets the StyleHandler to be used. It should not be null.
      • getComment

        public final java.lang.String getComment()
        Returns the comment to be generated in the SVG file.
      • setComment

        public final void setComment​(java.lang.String generatorComment)
        Sets the comment to be used. It can be null if you want to disable it.
      • setErrorHandler

        public final void setErrorHandler​(ErrorHandler errorHandler)
        Sets the ErrorHandler to be used. It should not be null.
      • isEmbeddedFontsOn

        public final boolean isEmbeddedFontsOn()
        Returns true if we should generate SVG Fonts for texts.
      • setEmbeddedFontsOn

        public final void setEmbeddedFontsOn​(boolean svgFont)
        Sets if we should generate SVG Fonts for texts. Default value is false.
      • getPrecision

        public final int getPrecision()
        Returns the current precision used by this context
      • setPrecision

        public final void setPrecision​(int precision)
        Sets the precision used by this context. The precision controls the number of decimal places used in floating point values output by the SVGGraphics2D generator. Note that the precision is clipped to the [0,12] range.
      • doubleString

        public final java.lang.String doubleString​(double value)
        Converts the input double value to a string with a number of decimal places controlled by the precision attribute.