org.apache.batik.bridge

Class AbstractGraphicsNodeBridge

public abstract class AbstractGraphicsNodeBridge extends AnimatableSVGBridge implements SVGContext, BridgeUpdateHandler, GraphicsNodeBridge, ErrorConstants

The base bridge class for SVG graphics node. By default, the namespace URI is the SVG namespace. Override the getNamespaceURI if you want to add custom GraphicsNode with a custom namespace.

This class handles various attributes that are defined on most of the SVG graphic elements as described in the SVG specification.

Field Summary
protected Rectangle2Dbbox
protected SoftReferencebboxShape
protected booleanisSVG12
Whether the document is an SVG 1.2 document.
protected GraphicsNodenode
The graphics node constructed by this bridge.
protected ContextunitContext
The unit context for length conversions.
Constructor Summary
protected AbstractGraphicsNodeBridge()
Constructs a new abstract bridge.
Method Summary
protected voidassociateSVGContext(BridgeContext ctx, Element e, GraphicsNode node)
Associates the {@link SVGContext} with the element.
voidbuildGraphicsNode(BridgeContext ctx, Element e, GraphicsNode node)
Builds using the specified BridgeContext and element, the specified graphics node.
protected voidcheckBBoxChange()
Checks if the bounding box of the node has changed, and if so, fires a bboxchange event on the element.
protected AffineTransformcomputeTransform(SVGTransformable te, BridgeContext ctx)
Returns an {@link AffineTransform} that is the transformation to be applied to the node.
GraphicsNodecreateGraphicsNode(BridgeContext ctx, Element e)
Creates a GraphicsNode according to the specified parameters.
voiddispose()
Disposes this BridgeUpdateHandler and releases all resources.
protected voiddisposeTree(Node node)
Disposes all resources related to the specified node and its subtree.
protected voiddisposeTree(Node node, boolean removeContext)
Disposes all resources related to the specified node and its subtree, and optionally removes the nodes' {@link SVGContext}.
protected voidfireBBoxChangeEvent()
Fires an svg:bboxchange event on the element.
protected voidfireShapeChangeEvent()
Fires a ShapeChange event on the element this bridge is managing.
Rectangle2DgetBBox()
Returns the tight bounding box in current user space (i.e., after application of the transform attribute, if any) on the geometry of all contained graphics elements, exclusive of stroke-width and filter effects).
AffineTransformgetCTM()
Returns the transformation matrix from current user units (i.e., after application of the transform attribute, if any) to the viewport coordinate system for the nearestViewportElement.
booleangetDisplay(Element e)
Returns true if the graphics node has to be displayed, false otherwise.
floatgetFontSize()
Returns the font-size on the associated element.
AffineTransformgetGlobalTransform()
Returns the global transformation matrix from the current element to the root.
floatgetPixelToMM()
Returns the size of a px CSS unit in millimeters.
floatgetPixelUnitToMillimeter()
Returns the size of a px CSS unit in millimeters.
AffineTransformgetScreenTransform()
Returns the display transform.
floatgetViewportHeight()
Returns the height of the viewport which directly contains the given element.
floatgetViewportWidth()
Returns the width of the viewport which directly contains the given element.
voidhandleAnimatedAttributeChanged(AnimatedLiveAttributeValue alav)
Invoked when the animated value of an animatable attribute has changed.
voidhandleCSSEngineEvent(CSSEngineEvent evt)
Invoked when an CSSEngineEvent is fired.
protected voidhandleCSSPropertyChanged(int property)
Invoked for each CSS property that has changed.
voidhandleDOMAttrModifiedEvent(MutationEvent evt)
Invoked when an MutationEvent of type 'DOMAttrModified' is fired.
voidhandleDOMCharacterDataModified(MutationEvent evt)
Invoked when an MutationEvent of type 'DOMCharacterDataModified' is fired.
voidhandleDOMNodeInsertedEvent(MutationEvent evt)
Invoked when an MutationEvent of type 'DOMNodeInserted' is fired.
voidhandleDOMNodeRemovedEvent(MutationEvent evt)
Invoked when an MutationEvent of type 'DOMNodeRemoved' is fired.
protected voidhandleGeometryChanged()
Invoked when the geometry of a graphical element has changed.
voidhandleOtherAnimationChanged(String type)
Invoked when an 'other' animation value has changed.
protected voidinitializeDynamicSupport(BridgeContext ctx, Element e, GraphicsNode node)
This method is invoked during the build phase if the document is dynamic.
protected abstract GraphicsNodeinstantiateGraphicsNode()
Creates the GraphicsNode depending on the GraphicsNodeBridge implementation.
voidsetScreenTransform(AffineTransform at)
Sets the display transform.
protected voidsetTransform(GraphicsNode n, Element e, BridgeContext ctx)
Sets the graphics node's transform to the current animated transform value.

Field Detail

bbox

protected Rectangle2D bbox

bboxShape

protected SoftReference bboxShape

isSVG12

protected boolean isSVG12
Whether the document is an SVG 1.2 document.

node

protected GraphicsNode node
The graphics node constructed by this bridge.

unitContext

protected Context unitContext
The unit context for length conversions.

Constructor Detail

AbstractGraphicsNodeBridge

protected AbstractGraphicsNodeBridge()
Constructs a new abstract bridge.

Method Detail

associateSVGContext

protected void associateSVGContext(BridgeContext ctx, Element e, GraphicsNode node)
Associates the {@link SVGContext} with the element. This method should be called even for static documents, since some bridges will need to access animated attribute values even during the first build.

buildGraphicsNode

public void buildGraphicsNode(BridgeContext ctx, Element e, GraphicsNode node)
Builds using the specified BridgeContext and element, the specified graphics node.

Parameters: ctx the bridge context to use e the element that describes the graphics node to build node the graphics node to build

checkBBoxChange

protected void checkBBoxChange()
Checks if the bounding box of the node has changed, and if so, fires a bboxchange event on the element.

computeTransform

protected AffineTransform computeTransform(SVGTransformable te, BridgeContext ctx)
Returns an {@link AffineTransform} that is the transformation to be applied to the node.

createGraphicsNode

public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e)
Creates a GraphicsNode according to the specified parameters.

Parameters: ctx the bridge context to use e the element that describes the graphics node to build

Returns: a graphics node that represents the specified element

dispose

public void dispose()
Disposes this BridgeUpdateHandler and releases all resources.

disposeTree

protected void disposeTree(Node node)
Disposes all resources related to the specified node and its subtree.

disposeTree

protected void disposeTree(Node node, boolean removeContext)
Disposes all resources related to the specified node and its subtree, and optionally removes the nodes' {@link SVGContext}.

fireBBoxChangeEvent

protected void fireBBoxChangeEvent()
Fires an svg:bboxchange event on the element.

fireShapeChangeEvent

protected void fireShapeChangeEvent()
Fires a ShapeChange event on the element this bridge is managing.

getBBox

public Rectangle2D getBBox()
Returns the tight bounding box in current user space (i.e., after application of the transform attribute, if any) on the geometry of all contained graphics elements, exclusive of stroke-width and filter effects).

getCTM

public AffineTransform getCTM()
Returns the transformation matrix from current user units (i.e., after application of the transform attribute, if any) to the viewport coordinate system for the nearestViewportElement.

getDisplay

public boolean getDisplay(Element e)
Returns true if the graphics node has to be displayed, false otherwise.

getFontSize

public float getFontSize()
Returns the font-size on the associated element.

getGlobalTransform

public AffineTransform getGlobalTransform()
Returns the global transformation matrix from the current element to the root.

getPixelToMM

public float getPixelToMM()
Returns the size of a px CSS unit in millimeters. This will be removed after next release.

See Also: getPixelUnitToMillimeter

getPixelUnitToMillimeter

public float getPixelUnitToMillimeter()
Returns the size of a px CSS unit in millimeters.

getScreenTransform

public AffineTransform getScreenTransform()
Returns the display transform.

getViewportHeight

public float getViewportHeight()
Returns the height of the viewport which directly contains the given element.

getViewportWidth

public float getViewportWidth()
Returns the width of the viewport which directly contains the given element.

handleAnimatedAttributeChanged

public void handleAnimatedAttributeChanged(AnimatedLiveAttributeValue alav)
Invoked when the animated value of an animatable attribute has changed.

handleCSSEngineEvent

public void handleCSSEngineEvent(CSSEngineEvent evt)
Invoked when an CSSEngineEvent is fired.

handleCSSPropertyChanged

protected void handleCSSPropertyChanged(int property)
Invoked for each CSS property that has changed.

handleDOMAttrModifiedEvent

public void handleDOMAttrModifiedEvent(MutationEvent evt)
Invoked when an MutationEvent of type 'DOMAttrModified' is fired.

handleDOMCharacterDataModified

public void handleDOMCharacterDataModified(MutationEvent evt)
Invoked when an MutationEvent of type 'DOMCharacterDataModified' is fired.

handleDOMNodeInsertedEvent

public void handleDOMNodeInsertedEvent(MutationEvent evt)
Invoked when an MutationEvent of type 'DOMNodeInserted' is fired.

handleDOMNodeRemovedEvent

public void handleDOMNodeRemovedEvent(MutationEvent evt)
Invoked when an MutationEvent of type 'DOMNodeRemoved' is fired.

handleGeometryChanged

protected void handleGeometryChanged()
Invoked when the geometry of a graphical element has changed.

handleOtherAnimationChanged

public void handleOtherAnimationChanged(String type)
Invoked when an 'other' animation value has changed.

initializeDynamicSupport

protected void initializeDynamicSupport(BridgeContext ctx, Element e, GraphicsNode node)
This method is invoked during the build phase if the document is dynamic. The responsibility of this method is to ensure that any dynamic modifications of the element this bridge is dedicated to, happen on its associated GVT product.

instantiateGraphicsNode

protected abstract GraphicsNode instantiateGraphicsNode()
Creates the GraphicsNode depending on the GraphicsNodeBridge implementation.

setScreenTransform

public void setScreenTransform(AffineTransform at)
Sets the display transform.

setTransform

protected void setTransform(GraphicsNode n, Element e, BridgeContext ctx)
Sets the graphics node's transform to the current animated transform value.
Copyright B) 2007 Apache Software Foundation. All Rights Reserved.