Package org.apache.batik.transcoder
Class SVGAbstractTranscoder
java.lang.Object
org.apache.batik.transcoder.TranscoderSupport
org.apache.batik.transcoder.AbstractTranscoder
org.apache.batik.transcoder.XMLAbstractTranscoder
org.apache.batik.transcoder.SVGAbstractTranscoder
- All Implemented Interfaces:
Transcoder
- Direct Known Subclasses:
ImageTranscoder
,PrintTranscoder
This class may be the base class of all transcoders which take an
SVG document as input and which need to build a DOM tree. The
SVGAbstractTranscoder
uses several different hints that
guide it's behaviour:KEY_WIDTH, KEY_HEIGHT
can be used to specify how to scale the SVG image
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
A user agent implementation forPrintTranscoder
. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected GVTBuilder
Current gvt builderprotected BridgeContext
Current bridge contextprotected Rectangle2D
Current area of interest.protected AffineTransform
Transform needed to render the current area of intereststatic final String
Default value for the KEY_ALLOWED_SCRIPT_TYPES keystatic final String
Value used as a default for the default font-family hintprotected float
Image's width and height (init to 400x400).static final TranscodingHints.Key
static final TranscodingHints.Key
The set of supported script languages (i.e., the set of possible values for the <script> tag's type attribute).static final TranscodingHints.Key
The alternate stylesheet key.static final TranscodingHints.Key
The area of interest key.static final TranscodingHints.Key
Controls whether or not scripts can only be loaded from the same location as the document which references them.static final TranscodingHints.Key
The default font-family key.static final TranscodingHints.Key
The 'onload' execution key.static final TranscodingHints.Key
The image height key.static final TranscodingHints.Key
The language key.static final TranscodingHints.Key
The maximux height of the image key.static final TranscodingHints.Key
The maximum width of the image key.static final TranscodingHints.Key
The media key.static final TranscodingHints.Key
Deprecated.As of Batik Version 1.5b3static final TranscodingHints.Key
The number of millimeters in each pixel key.static final TranscodingHints.Key
The snapshot time key.static final TranscodingHints.Key
The user stylesheet URI key.static final TranscodingHints.Key
The image width key.protected GraphicsNode
Current GVT Tree, i.e., the GVT tree representing the page being printed currently.protected UserAgent
The user agent dedicated to an SVG Transcoder.protected float
Image's width and height (init to 400x400).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
Fields inherited from class org.apache.batik.transcoder.TranscoderSupport
handler, hints
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected BridgeContext
Creates the default SVG 1.0/1.1 BridgeContext.protected BridgeContext
createBridgeContext
(String svgVersion) Creates the BridgeContext.protected BridgeContext
Factory method for constructing an configuring a BridgeContext so subclasses can insert new/modified bridges in the context.protected DocumentFactory
createDocumentFactory
(DOMImplementation domImpl, String parserClassname) Creates aDocumentFactory
that is used to create an SVG DOM tree.protected UserAgent
protected CanvasGraphicsNode
protected void
setImageSize
(float docWidth, float docHeight) Sets document size according to the hints.void
transcode
(TranscoderInput input, TranscoderOutput output) Transcodes the specified XML input in the specified output.protected void
transcode
(Document document, String uri, TranscoderOutput output) Transcodes the specified Document as an image in the specified output.Methods inherited from class org.apache.batik.transcoder.TranscoderSupport
addTranscodingHint, getErrorHandler, getTranscodingHints, removeTranscodingHint, setErrorHandler, setTranscodingHints, setTranscodingHints
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.batik.transcoder.Transcoder
addTranscodingHint, getErrorHandler, getTranscodingHints, removeTranscodingHint, setErrorHandler, setTranscodingHints, setTranscodingHints
-
Field Details
-
DEFAULT_DEFAULT_FONT_FAMILY
Value used as a default for the default font-family hint- See Also:
-
curAOI
Current area of interest. -
curTxf
Transform needed to render the current area of interest -
root
Current GVT Tree, i.e., the GVT tree representing the page being printed currently. -
ctx
Current bridge context -
builder
Current gvt builder -
width
protected float widthImage's width and height (init to 400x400). -
height
protected float heightImage's width and height (init to 400x400). -
userAgent
The user agent dedicated to an SVG Transcoder. -
KEY_WIDTH
The image width key.Key: KEY_WIDTH Value: float Default: The width of the topmost svg element Required: No Description: Specify the width of the image to create. -
KEY_HEIGHT
The image height key.Key: KEY_HEIGHT Value: Float Default: The height of the topmost svg element Required: No Description: Specify the height of the image to create. -
KEY_MAX_WIDTH
The maximum width of the image key.Key: KEY_MAX_WIDTH Value: Float Default: The width of the topmost svg element Required: No Description: Specify the maximum width of the image to create. The value will set the maximum width of the image even when a bigger width is specified in a document or set with KEY_WIDTH. -
KEY_MAX_HEIGHT
The maximux height of the image key.Key: KEY_MAX_HEIGHT Value: Float Default: The height of the topmost svg element Required: No Description: Specify the maximum height of the image to create. The value will set the maximum height of the image even when bigger height is specified in a document or set with KEY_HEIGHT. -
KEY_AOI
The area of interest key.Key: KEY_AOI Value: Rectangle2D Default: The document's size Required: No Description: Specify the area of interest to render. The rectangle coordinates must be specified in pixels and in the document coordinates system. -
KEY_LANGUAGE
The language key.Key: KEY_LANGUAGE Value: String Default: "en" Required: No Description: Specify the preferred language of the document. -
KEY_MEDIA
The media key.Key: KEY_MEDIA Value: String Default: "screen" Required: No Description: Specify the media to use with CSS. -
KEY_DEFAULT_FONT_FAMILY
The default font-family key.Key: KEY_DEFAULT_FONT_FAMILY Value: String Default: "Arial, Helvetica, sans-serif" Required: No Description: Controls the default value used by the CSS engine for the font-family property when that property is unspecified. -
KEY_ALTERNATE_STYLESHEET
The alternate stylesheet key.Key: KEY_ALTERNATE_STYLESHEET Value: String Default: null Required: No Description: Specify the alternate style sheet title. -
KEY_USER_STYLESHEET_URI
The user stylesheet URI key.Key: KEY_USER_STYLESHEET_URI Value: String Default: null Required: No Description: Specify the user style sheet. -
KEY_PIXEL_UNIT_TO_MILLIMETER
The number of millimeters in each pixel key.Key: KEY_PIXEL_UNIT_TO_MILLIMETER Value: Float Default: 0.264583 Required: No Description: Specify the size of a px CSS unit in millimeters. -
KEY_PIXEL_TO_MM
Deprecated.As of Batik Version 1.5b3The pixel to millimeter conversion factor key.- See Also:
-
KEY_EXECUTE_ONLOAD
The 'onload' execution key.Key: KEY_EXECUTE_ONLOAD Value: Boolean Default: false Required: No Description: Specify if scripts added on the 'onload' event attribute must be invoked. -
KEY_SNAPSHOT_TIME
The snapshot time key.Key: KEY_SNAPSHOT_TIME Value: Float Default: 0 Required: No Description: Specifies the document time to seek to before rasterization. Only applies if KEY_EXECUTE_ONLOAD
is set totrue
. -
KEY_ALLOWED_SCRIPT_TYPES
The set of supported script languages (i.e., the set of possible values for the <script> tag's type attribute).Key: KEY_ALLOWED_SCRIPT_TYPES Value: String (Comma separated values) Default: text/ecmascript, application/java-archive Required: No Description: Specifies the allowed values for the type attribute in the <script> element. This is a comma separated list. The special value '*' means that all script types are allowed. -
DEFAULT_ALLOWED_SCRIPT_TYPES
Default value for the KEY_ALLOWED_SCRIPT_TYPES key- See Also:
-
KEY_CONSTRAIN_SCRIPT_ORIGIN
Controls whether or not scripts can only be loaded from the same location as the document which references them.Key: KEY_CONSTRAIN_SCRIPT_ORIGIN Value: Boolean Default: true Required: No Description: When set to true, script elements referencing files from a different origin (server) than the document containing the script element will not be loaded. When set to true, script elements may reference script files from any origin. -
KEY_ALLOW_EXTERNAL_RESOURCES
-
-
Constructor Details
-
SVGAbstractTranscoder
protected SVGAbstractTranscoder()
-
-
Method Details
-
createUserAgent
-
createDocumentFactory
Creates aDocumentFactory
that is used to create an SVG DOM tree. The specified DOM Implementation is ignored and the Batik SVG DOM Implementation is automatically used.- Overrides:
createDocumentFactory
in classXMLAbstractTranscoder
- Parameters:
domImpl
- the DOM Implementation (not used)parserClassname
- the XML parser classname
-
transcode
Description copied from class:XMLAbstractTranscoder
Transcodes the specified XML input in the specified output. AllTranscoderException
exceptions not catched previously are tagged as fatal errors (ie. call thefatalError
method of theErrorHandler
).- Specified by:
transcode
in interfaceTranscoder
- Overrides:
transcode
in classXMLAbstractTranscoder
- Parameters:
input
- the XML input to transcodeoutput
- the ouput where to transcode- Throws:
TranscoderException
- if an error occured while transcoding
-
transcode
protected void transcode(Document document, String uri, TranscoderOutput output) throws TranscoderException Transcodes the specified Document as an image in the specified output.- Specified by:
transcode
in classXMLAbstractTranscoder
- Parameters:
document
- the document to transcodeuri
- the uri of the document or null if anyoutput
- the ouput where to transcode- Throws:
TranscoderException
- if an error occured while transcoding
-
getCanvasGraphicsNode
-
createBridgeContext
Factory method for constructing an configuring a BridgeContext so subclasses can insert new/modified bridges in the context.- Parameters:
doc
- the SVG document to create the BridgeContext for- Returns:
- the newly instantiated BridgeContext
-
createBridgeContext
Creates the default SVG 1.0/1.1 BridgeContext. Subclass this method to provide customized bridges. This method is provided for historical reasons. New applications should usecreateBridgeContext(String)
instead.- Returns:
- the newly instantiated BridgeContext
- See Also:
-
createBridgeContext
Creates the BridgeContext. Subclass this method to provide customized bridges. For example, Apache FOP uses this method to register special bridges for optimized text painting.- Parameters:
svgVersion
- the SVG version in use (ex. "1.0", "1.x" or "1.2")- Returns:
- the newly instantiated BridgeContext
-
setImageSize
protected void setImageSize(float docWidth, float docHeight) Sets document size according to the hints. Global variables width and height are modified.- Parameters:
docWidth
- Width of the document.docHeight
- Height of the document.
-