## org.apache.batik.svggen
Class SVGGeneratorContext

    java.lang.Object
      org.apache.batik.svggen.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.

See Also:
  `SVGGraphics2D.SVGGraphics2D(SVGGeneratorContext,boolean)`

Nested Class Summary
`static class` `SVGGeneratorContext.GraphicContextDefaults` Class to describe the GraphicContext defaults to be used.

Field Summary
`protected java.text.DecimalFormat` `decimalFormat` Current double value formatter
`protected static java.text.DecimalFormat[]` `decimalFormats`
`protected static java.text.DecimalFormatSymbols` `dsf`

Fields inherited from interface org.apache.batik.svggen.ErrorConstants

`ERR_ACI, ERR_CANNOT_USE_IMAGE_DIR, ERR_CANVAS_SIZE_NULL, ERR_CLIP_NULL, ERR_CONTEXT_NULL, ERR_DOM_FACTORY_NULL, ERR_DOMTREEMANAGER_NULL, ERR_ERROR_HANDLER_NULL, ERR_EXTENSION_HANDLER_NULL, ERR_FONT_NULL, ERR_GC_NULL, ERR_HINT_NULL, ERR_ID_GENERATOR_NULL, ERR_ILLEGAL_BUFFERED_IMAGE_LOOKUP_OP, ERR_ILLEGAL_BUFFERED_IMAGE_RESCALE_OP, ERR_IMAGE_DIR_DOES_NOT_EXIST, ERR_IMAGE_DIR_NULL, ERR_IMAGE_HANDLER_NOT_SUPPORTED, ERR_IMAGE_HANDLER_NULL, ERR_IMAGE_NULL, ERR_MAP_NULL, ERR_MAXGCOVERRIDES_OUTOFRANGE, ERR_PROXY, ERR_READ, ERR_SCALE_FACTORS_AND_OFFSETS_MISMATCH, ERR_STROKE_NULL, ERR_STYLE_HANDLER_NULL, ERR_TOP_LEVEL_GROUP_NOT_G, ERR_TOP_LEVEL_GROUP_NULL, ERR_TRANS_NULL, ERR_UNEXPECTED, ERR_WRITE, ERR_XOR, INVALID_NODE`

Constructor Summary
`protected` `SVGGeneratorContext(org.w3c.dom.Document domFactory)` Builds an instance of `SVGGeneratorContext` with the given `domFactory` but let the user set later the other contextual information.

Method Summary
`static SVGGeneratorContext` `createDefault(org.w3c.dom.Document domFactory)` Creates an instance of `SVGGeneratorContext` with the given `domFactory` and with the default values for the other information.
`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.
`java.lang.String` `getComment()` Returns the comment to be generated in the SVG file.
`org.w3c.dom.Document` `getDOMFactory()` Returns the DOM Factory that has been set.
`ErrorHandler` `getErrorHandler()` Returns the `ErrorHandler` that has been set.
`ExtensionHandler` `getExtensionHandler()` Returns the `ExtensionHandler` that has been set.
`SVGGeneratorContext.GraphicContextDefaults` `getGraphicContextDefaults()` Returns the set of defaults which should be used for the GraphicContext.
`SVGIDGenerator` `getIDGenerator()` Returns the `SVGIDGenerator` that has been set.
`ImageHandler` `getImageHandler()` Returns the `ImageHandler` that has been set.
`int` `getPrecision()` Returns the current precision used by this context
`StyleHandler` `getStyleHandler()` Returns the `StyleHandler` that has been set.
`boolean` `isEmbeddedFontsOn()` Returns `true` if we should generate SVG Fonts for texts.
`void` `setComment(java.lang.String generatorComment)` Sets the comment to be used.
`void` `setDOMFactory(org.w3c.dom.Document domFactory)` Sets the DOM Factory to be used.
`void` `setEmbeddedFontsOn(boolean svgFont)` Sets if we should generate SVG Fonts for texts.
`void` `setErrorHandler(ErrorHandler errorHandler)` Sets the `ErrorHandler` to be used.
`void` `setExtensionHandler(ExtensionHandler extensionHandler)` Sets the `ExtensionHandler` to be used.
`void` `setGenericImageHandler(GenericImageHandler genericImageHandler)` Sets the `GenericImageHandler` to be used.
`void` `setGraphicContextDefaults(SVGGeneratorContext.GraphicContextDefaults gcDefaults)` Sets the default to be used for the graphic context.
`void` `setIDGenerator(SVGIDGenerator idGenerator)` Sets the `SVGIDGenerator` to be used.
`void` `setImageHandler(ImageHandler imageHandler)` Sets the `ImageHandler` to be used.
`void` `setPrecision(int precision)` Sets the precision used by this context.
`void` `setStyleHandler(StyleHandler styleHandler)` Sets the `StyleHandler` to be used.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### decimalFormat

    protected java.text.DecimalFormat decimalFormat

  Current double value formatter

### dsf

    protected static java.text.DecimalFormatSymbols dsf

### decimalFormats

    protected static java.text.DecimalFormat[] decimalFormats

Constructor Detail

### SVGGeneratorContext

    protected SVGGeneratorContext(org.w3c.dom.Document domFactory)

  Builds an instance of `SVGGeneratorContext` with the given `domFactory` but let the user set later the other contextual information. Please note that none of the parameter below should be `null`.

See Also:
  `setIDGenerator(org.apache.batik.svggen.SVGIDGenerator)`, `setExtensionHandler(org.apache.batik.svggen.ExtensionHandler)`, `setImageHandler(org.apache.batik.svggen.ImageHandler)`, `setStyleHandler(org.apache.batik.svggen.StyleHandler)`, `setErrorHandler(org.apache.batik.svggen.ErrorHandler)`

Method Detail

### createDefault

    public static SVGGeneratorContext createDefault(org.w3c.dom.Document domFactory)

  Creates an instance of `SVGGeneratorContext` with the given `domFactory` and with the default values for the other information.

  See Also:
    `SVGIDGenerator`, `DefaultExtensionHandler`, `ImageHandlerBase64Encoder`, `DefaultStyleHandler`, `DefaultErrorHandler`

### getGraphicContextDefaults

    public final SVGGeneratorContext.GraphicContextDefaults getGraphicContextDefaults()

  Returns the set of defaults which should be used for the GraphicContext.

### 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.

### getIDGenerator

    public final SVGIDGenerator getIDGenerator()

  Returns the `SVGIDGenerator` that has been set.

### 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`.

### getExtensionHandler

    public final ExtensionHandler getExtensionHandler()

  Returns the `ExtensionHandler` that has been set.

### setExtensionHandler

    public final void setExtensionHandler(ExtensionHandler extensionHandler)

  Sets the `ExtensionHandler` to be used. It should not be `null`.

### getImageHandler

    public final ImageHandler getImageHandler()

  Returns the `ImageHandler` that has been set.

### setImageHandler

    public final void setImageHandler(ImageHandler imageHandler)

  Sets the `ImageHandler` to be used. It should not be `null`.

### setGenericImageHandler

    public final void setGenericImageHandler(GenericImageHandler genericImageHandler)

  Sets the `GenericImageHandler` to be used.

### getStyleHandler

    public final StyleHandler getStyleHandler()

  Returns the `StyleHandler` that has been set.

### 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.

### getErrorHandler

    public final ErrorHandler getErrorHandler()

  Returns the `ErrorHandler` that has been set.

### 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.

Copyright © 2004 Apache Software Foundation. All Rights Reserved.