Class SVGGeneratorContext
java.lang.Object
org.apache.batik.svggen.SVGGeneratorContext
- All Implemented Interfaces:
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$
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClass to describe the GraphicContext defaults to be used. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DecimalFormatCurrent double value formatterprotected static DecimalFormat[](package private) DocumentFactory used by this Graphics2D to create Elements that make the SVG DOM Treeprotected static DecimalFormatSymbols(package private) ErrorHandlerThe error handler.(package private) ExtensionHandlerTo deal with Java 2D extension (custom java.awt.Paint for example).(package private) SVGGeneratorContext.GraphicContextDefaultsGraphicContextDefaults(package private) StringThe comment to insert at generation time.(package private) GenericImageHandlerGeneric image handler.(package private) SVGIDGeneratorTo generate consitent ids.(package private) ImageHandlerHandler that defines how images are referenced in the generated SVG fragment.(package private) intNumber of decimal places to use in output values.(package private) StyleHandlerTo set style.(package private) booleanDo we accept SVG Fonts generation?Fields inherited from interface 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
ConstructorsModifierConstructorDescriptionprotectedSVGGeneratorContext(Document domFactory) Builds an instance ofSVGGeneratorContextwith the givendomFactorybut let the user set later the other contextual information. -
Method Summary
Modifier and TypeMethodDescriptionstatic SVGGeneratorContextcreateDefault(Document domFactory) Creates an instance ofSVGGeneratorContextwith the givendomFactoryand with the default values for the other information.final StringdoubleString(double value) Converts the input double value to a string with a number of decimal places controlled by the precision attribute.final StringReturns the comment to be generated in the SVG file.final DocumentReturns the DOM Factory that has been set.final ErrorHandlerReturns theErrorHandlerthat has been set.final ExtensionHandlerReturns theExtensionHandlerthat has been set.Returns the set of defaults which should be used for the GraphicContext.final SVGIDGeneratorReturns theSVGIDGeneratorthat has been set.final ImageHandlerReturns theImageHandlerthat has been set.final intReturns the current precision used by this contextfinal StyleHandlerReturns theStyleHandlerthat has been set.final booleanReturnstrueif we should generate SVG Fonts for texts.final voidsetComment(String generatorComment) Sets the comment to be used.final voidsetDOMFactory(Document domFactory) Sets the DOM Factory to be used.final voidsetEmbeddedFontsOn(boolean svgFont) Sets if we should generate SVG Fonts for texts.final voidsetErrorHandler(ErrorHandler errorHandler) Sets theErrorHandlerto be used.final voidsetExtensionHandler(ExtensionHandler extensionHandler) Sets theExtensionHandlerto be used.final voidsetGenericImageHandler(GenericImageHandler genericImageHandler) Sets theGenericImageHandlerto be used.final voidSets the default to be used for the graphic context.final voidsetIDGenerator(SVGIDGenerator idGenerator) Sets theSVGIDGeneratorto be used.final voidsetImageHandler(ImageHandler imageHandler) Sets theImageHandlerto be used.final voidsetPrecision(int precision) Sets the precision used by this context.final voidsetStyleHandler(StyleHandler styleHandler) Sets theStyleHandlerto be used.
-
Field Details
-
domFactory
Document domFactoryFactory used by this Graphics2D to create Elements that make the SVG DOM Tree -
imageHandler
ImageHandler imageHandlerHandler that defines how images are referenced in the generated SVG fragment. This allows different strategies to be used to handle images.- See Also:
-
genericImageHandler
GenericImageHandler genericImageHandlerGeneric image handler. This allows more sophisticated image handling strategies than theImageHandlerinterfaces. -
extensionHandler
ExtensionHandler extensionHandlerTo deal with Java 2D extension (custom java.awt.Paint for example). -
idGenerator
SVGIDGenerator idGeneratorTo generate consitent ids. -
styleHandler
StyleHandler styleHandlerTo set style. -
generatorComment
String generatorCommentThe comment to insert at generation time. -
errorHandler
ErrorHandler errorHandlerThe error handler. -
svgFont
boolean svgFontDo we accept SVG Fonts generation? -
gcDefaults
SVGGeneratorContext.GraphicContextDefaults gcDefaultsGraphicContextDefaults -
precision
int precisionNumber of decimal places to use in output values. 3 decimal places are used by default. -
decimalFormat
Current double value formatter -
dsf
-
decimalFormats
-
-
Constructor Details
-
SVGGeneratorContext
Builds an instance ofSVGGeneratorContextwith the givendomFactorybut let the user set later the other contextual information. Please note that none of the parameter below should benull.- See Also:
-
-
Method Details
-
createDefault
Creates an instance ofSVGGeneratorContextwith the givendomFactoryand with the default values for the other information.- See Also:
-
getGraphicContextDefaults
Returns the set of defaults which should be used for the GraphicContext. -
setGraphicContextDefaults
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
Returns theSVGIDGeneratorthat has been set. -
setIDGenerator
Sets theSVGIDGeneratorto be used. It should not benull. -
getDOMFactory
Returns the DOM Factory that has been set. -
setDOMFactory
Sets the DOM Factory to be used. It should not benull. -
getExtensionHandler
Returns theExtensionHandlerthat has been set. -
setExtensionHandler
Sets theExtensionHandlerto be used. It should not benull. -
getImageHandler
Returns theImageHandlerthat has been set. -
setImageHandler
Sets theImageHandlerto be used. It should not benull. -
setGenericImageHandler
Sets theGenericImageHandlerto be used. -
getStyleHandler
Returns theStyleHandlerthat has been set. -
setStyleHandler
Sets theStyleHandlerto be used. It should not benull. -
getComment
Returns the comment to be generated in the SVG file. -
setComment
Sets the comment to be used. It can benullif you want to disable it. -
getErrorHandler
Returns theErrorHandlerthat has been set. -
setErrorHandler
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
Converts the input double value to a string with a number of decimal places controlled by the precision attribute.
-