Package 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 theSVGGraphics2Dto 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)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSVGGeneratorContext.GraphicContextDefaultsClass to describe the GraphicContext defaults to be used.
-
Field Summary
Fields Modifier and Type Field Description protected java.text.DecimalFormatdecimalFormatCurrent double value formatterprotected static java.text.DecimalFormat[]decimalFormats(package private) org.w3c.dom.DocumentdomFactoryFactory used by this Graphics2D to create Elements that make the SVG DOM Treeprotected static java.text.DecimalFormatSymbolsdsf(package private) ErrorHandlererrorHandlerThe error handler.(package private) ExtensionHandlerextensionHandlerTo deal with Java 2D extension (custom java.awt.Paint for example).(package private) SVGGeneratorContext.GraphicContextDefaultsgcDefaultsGraphicContextDefaults(package private) java.lang.StringgeneratorCommentThe comment to insert at generation time.(package private) GenericImageHandlergenericImageHandlerGeneric image handler.(package private) SVGIDGeneratoridGeneratorTo generate consitent ids.(package private) ImageHandlerimageHandlerHandler that defines how images are referenced in the generated SVG fragment.(package private) intprecisionNumber of decimal places to use in output values.(package private) StyleHandlerstyleHandlerTo set style.(package private) booleansvgFontDo we accept SVG Fonts generation?-
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
Constructors Modifier Constructor Description protectedSVGGeneratorContext(org.w3c.dom.Document domFactory)Builds an instance ofSVGGeneratorContextwith the givendomFactorybut let the user set later the other contextual information.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SVGGeneratorContextcreateDefault(org.w3c.dom.Document domFactory)Creates an instance ofSVGGeneratorContextwith the givendomFactoryand with the default values for the other information.java.lang.StringdoubleString(double value)Converts the input double value to a string with a number of decimal places controlled by the precision attribute.java.lang.StringgetComment()Returns the comment to be generated in the SVG file.org.w3c.dom.DocumentgetDOMFactory()Returns the DOM Factory that has been set.ErrorHandlergetErrorHandler()Returns theErrorHandlerthat has been set.ExtensionHandlergetExtensionHandler()Returns theExtensionHandlerthat has been set.SVGGeneratorContext.GraphicContextDefaultsgetGraphicContextDefaults()Returns the set of defaults which should be used for the GraphicContext.SVGIDGeneratorgetIDGenerator()Returns theSVGIDGeneratorthat has been set.ImageHandlergetImageHandler()Returns theImageHandlerthat has been set.intgetPrecision()Returns the current precision used by this contextStyleHandlergetStyleHandler()Returns theStyleHandlerthat has been set.booleanisEmbeddedFontsOn()Returnstrueif we should generate SVG Fonts for texts.voidsetComment(java.lang.String generatorComment)Sets the comment to be used.voidsetDOMFactory(org.w3c.dom.Document domFactory)Sets the DOM Factory to be used.voidsetEmbeddedFontsOn(boolean svgFont)Sets if we should generate SVG Fonts for texts.voidsetErrorHandler(ErrorHandler errorHandler)Sets theErrorHandlerto be used.voidsetExtensionHandler(ExtensionHandler extensionHandler)Sets theExtensionHandlerto be used.voidsetGenericImageHandler(GenericImageHandler genericImageHandler)Sets theGenericImageHandlerto be used.voidsetGraphicContextDefaults(SVGGeneratorContext.GraphicContextDefaults gcDefaults)Sets the default to be used for the graphic context.voidsetIDGenerator(SVGIDGenerator idGenerator)Sets theSVGIDGeneratorto be used.voidsetImageHandler(ImageHandler imageHandler)Sets theImageHandlerto be used.voidsetPrecision(int precision)Sets the precision used by this context.voidsetStyleHandler(StyleHandler styleHandler)Sets theStyleHandlerto be used.
-
-
-
Field Detail
-
domFactory
org.w3c.dom.Document domFactory
Factory used by this Graphics2D to create Elements that make the SVG DOM Tree
-
imageHandler
ImageHandler imageHandler
Handler that defines how images are referenced in the generated SVG fragment. This allows different strategies to be used to handle images.
-
genericImageHandler
GenericImageHandler genericImageHandler
Generic image handler. This allows more sophisticated image handling strategies than theImageHandlerinterfaces.
-
extensionHandler
ExtensionHandler extensionHandler
To deal with Java 2D extension (custom java.awt.Paint for example).
-
idGenerator
SVGIDGenerator idGenerator
To generate consitent ids.
-
styleHandler
StyleHandler styleHandler
To set style.
-
generatorComment
java.lang.String generatorComment
The comment to insert at generation time.
-
errorHandler
ErrorHandler errorHandler
The error handler.
-
svgFont
boolean svgFont
Do we accept SVG Fonts generation?
-
gcDefaults
SVGGeneratorContext.GraphicContextDefaults gcDefaults
GraphicContextDefaults
-
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
-
createDefault
public static SVGGeneratorContext createDefault(org.w3c.dom.Document domFactory)
Creates an instance ofSVGGeneratorContextwith the givendomFactoryand with the default values for the other information.
-
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 theSVGIDGeneratorthat has been set.
-
setIDGenerator
public final void setIDGenerator(SVGIDGenerator idGenerator)
Sets theSVGIDGeneratorto be used. It should not benull.
-
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 benull.
-
getExtensionHandler
public final ExtensionHandler getExtensionHandler()
Returns theExtensionHandlerthat has been set.
-
setExtensionHandler
public final void setExtensionHandler(ExtensionHandler extensionHandler)
Sets theExtensionHandlerto be used. It should not benull.
-
getImageHandler
public final ImageHandler getImageHandler()
Returns theImageHandlerthat has been set.
-
setImageHandler
public final void setImageHandler(ImageHandler imageHandler)
Sets theImageHandlerto be used. It should not benull.
-
setGenericImageHandler
public final void setGenericImageHandler(GenericImageHandler genericImageHandler)
Sets theGenericImageHandlerto be used.
-
getStyleHandler
public final StyleHandler getStyleHandler()
Returns theStyleHandlerthat has been set.
-
setStyleHandler
public final void setStyleHandler(StyleHandler styleHandler)
Sets theStyleHandlerto be used. It should not benull.
-
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 benullif you want to disable it.
-
getErrorHandler
public final ErrorHandler getErrorHandler()
Returns theErrorHandlerthat has been set.
-
setErrorHandler
public final void setErrorHandler(ErrorHandler errorHandler)
Sets theErrorHandlerto be used. It should not benull.
-
isEmbeddedFontsOn
public final boolean isEmbeddedFontsOn()
Returnstrueif 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 isfalse.
-
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.
-
-