Package org.apache.batik.bridge
Class BridgeContext
- java.lang.Object
-
- org.apache.batik.bridge.BridgeContext
-
- All Implemented Interfaces:
ErrorConstants,CSSContext
- Direct Known Subclasses:
SVG12BridgeContext
public class BridgeContext extends java.lang.Object implements ErrorConstants, CSSContext
This class represents a context used by the various bridges and the builder. A bridge context is associated to a particular document and cannot be reused. The context encapsulates the dynamic bindings between DOM elements and GVT nodes, graphic contexts such as aGraphicsNodeRenderContext, and the different objects required by the GVT builder to interpret a SVG DOM tree such as the current viewport or the user agent.- Version:
- $Id: BridgeContext.java 1851346 2019-01-15 13:41:00Z ssteiner $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classBridgeContext.AnimatedAttrListenerA listener class for changes to animated attributes in the document.static classBridgeContext.CSSEngineUserAgentWrapperprotected classBridgeContext.CSSPropertiesChangedListenerThe CSSEngineListener invoked when CSS properties are modified on a particular element.protected classBridgeContext.DOMAttrModifiedEventListenerThe DOM EventListener invoked when an attribute is modified.protected classBridgeContext.DOMCharacterDataModifiedEventListenerThe DOM EventListener invoked when a character data is changed.protected classBridgeContext.DOMMouseOutEventListenerThe DOM EventListener invoked when the mouse exits an elementprotected classBridgeContext.DOMMouseOverEventListenerThe DOM EventListener invoked when the mouse mouves over a new element.protected classBridgeContext.DOMNodeInsertedEventListenerThe DOM EventListener invoked when a node is added.protected classBridgeContext.DOMNodeRemovedEventListenerThe DOM EventListener invoked when a node is removed.protected static classBridgeContext.EventListenerMememtoA class used to store an EventListener added to the DOM.static classBridgeContext.SoftReferenceMememto
-
Field Summary
Fields Modifier and Type Field Description protected AnimatedAttributeListeneranimatedAttributeListenerThe listener to receive notification of animated attribute changes.protected SVGAnimationEngineanimationEngineThe animation engine for the document.protected floatanimationLimitingAmountThe amount of animation limiting.protected intanimationLimitingModeThe animation limiting mode.protected java.util.HashSetchildContextsSet of WeakReferences to child BridgeContexts.protected CSSEngineListenercssPropertiesChangedListenerThe CSSEngine listener to receive CSSEngineEvent.protected CursorManagercursorManagerManages cursors and performs caching when appropriateprotected BridgedefaultBridgeDefault bridge.protected org.w3c.dom.DocumentdocumentThe document is bridge context is dedicated to.protected DocumentLoaderdocumentLoaderThe document loader used to load/create Document.protected java.awt.geom.Dimension2DdocumentSizeThe size of the document.protected org.w3c.dom.events.EventListenerdomAttrModifiedEventListenerThe DOM EventListener to receive 'DOMAttrModified' event.protected org.w3c.dom.events.EventListenerdomCharacterDataModifiedEventListenerThe DOM EventListener to receive 'DOMCharacterDataModified' event.protected org.w3c.dom.events.EventListenerdomNodeInsertedEventListenerThe DOM EventListener to receive 'DOMNodeInserted' event.protected org.w3c.dom.events.EventListenerdomNodeRemovedEventListenerThe DOM EventListener to receive 'DOMNodeRemoved' event.static intDYNAMICIndicates that all DOM listeners should be registered.protected intdynamicStatusWhether the bridge should support dynamic, or interactive features.protected java.util.MapelementDataMapElement Data Map: This is a general location for elements to 'cache' data.protected java.util.MapelementNodeMapBinding Map: key is an SVG Element - value is a GraphicsNodeprotected java.util.SeteventListenerSetThe list of all EventListener attached by bridges that need to be removed on a dispose() call.protected java.util.Listextensionsprotected FocusManagerfocusManagerThe EventListener that is responsible of managing DOM focus event.private java.util.MapfontFamilyMapA Map of all the font families already matched.protected static java.util.ListglobalExtensionsReturns the extensions supported by this bridge context.protected GVTBuildergvtBuilderThe GVT builder that might be used to create a GVT subtree.static intINTERACTIVEIndicates that DOM listeners should be registered to support, 'interactivity' this includes anchors and cursors, but does not include support for DOM modifications.protected java.util.MapinterpreterMapThe interpreter cache per document.protected InterpreterPoolinterpreterPoolThe interpreter pool used to handle scripts.protected booleanisSVG12Whether the document is an SVG 1.2 document.protected java.util.MapnamespaceURIMapBridge Map: Keys are namespace URI - values are HashMap (with keys are local name and values are a Bridge instance).protected java.util.MapnodeElementMapBinding Map: key is GraphicsNode - value is a SVG Element.protected BridgeContextprimaryContextThe bridge context for the primary document, if this is a bridge context for a resource document.protected java.util.SetreservedNamespaceSetDefault bridge reserved namespaces set.private static InterpreterPoolsharedPoolBy default we share a unique instance of InterpreterPool.static intSTATICIndicates that no DOM listeners should be registered.protected TextPaintertextPainterThe text painter to use.protected UpdateManagerupdateManagerThe update manager.protected UserAgentuserAgentThe user agent.protected java.util.MapviewportMapThe viewports.protected java.util.ListviewportStackThe viewport stack.protected XBLManagerxblManagerThe XBL manager.-
Fields inherited from interface org.apache.batik.bridge.ErrorConstants
ERR_ATTRIBUTE_MISSING, ERR_ATTRIBUTE_VALUE_MALFORMED, ERR_CSS_LENGTH_NEGATIVE, ERR_CSS_URI_BAD_TARGET, ERR_LENGTH_NEGATIVE, ERR_URI_BAD_TARGET, ERR_URI_IMAGE_BROKEN, ERR_URI_IMAGE_INVALID, ERR_URI_IO, ERR_URI_MALFORMED, ERR_URI_REFERENCE_A_DOCUMENT, ERR_URI_UNSECURE, ERR_XLINK_HREF_CIRCULAR_DEPENDENCIES, URI_IMAGE_ERROR
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBridgeContext()Constructs a new empty bridge context.BridgeContext(UserAgent userAgent)Constructs a new bridge context.BridgeContext(UserAgent userAgent, DocumentLoader loader)Constructs a new bridge context.BridgeContext(UserAgent userAgent, InterpreterPool interpreterPool, DocumentLoader documentLoader)Constructs a new bridge context.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDOMListeners()Adds EventListeners to the DOM and CSSEngineListener to the CSSEngine to handle any modifications on the DOM tree or style properties and update the GVT tree in response.voidaddGVTListener(org.w3c.dom.Document doc)Adds the GVT listener for AWT event support.voidaddUIEventListeners(org.w3c.dom.Document doc)Adds EventListeners to the input document to handle the cursor property.voidbind(org.w3c.dom.Node node, GraphicsNode gn)Binds the specified GraphicsNode to the specified Node.booleancheckInteractiveElement(org.w3c.dom.Element e)used by isInteractiveDocument to check if document contains any 'interactive' elements.booleancheckInteractiveElement(org.w3c.dom.svg.SVGDocument doc, org.w3c.dom.Element e)used by isInteractiveDocument to check if document contains any 'interactive' elements.voidcheckLoadExternalResource(ParsedURL resourceURL, ParsedURL docURL)This method throws a SecurityException if the resource found at url and referenced from docURL should not be loaded.protected voidclearChildContexts()Clears the list of child BridgeContexts and disposes them if there are no more references to them.voidcloseViewport(org.w3c.dom.Element e)Closes the viewport associated to the specified element.BridgeContextcreateBridgeContext(SVGOMDocument doc)This function creates a new BridgeContext, it mostly exists so subclasses can provide an instance of themselves when a sub BridgeContext is needed.BridgeContextcreateSubBridgeContext(SVGOMDocument newDoc)This function creates a new 'sub' BridgeContext to associated with 'newDoc' if one currently doesn't exist, otherwise it returns the BridgeContext currently associated with the document.URIResolvercreateURIResolver(org.w3c.dom.svg.SVGDocument doc, DocumentLoader dl)Returns a new URIResolver object.voiddispose()Disposes this BridgeContext.protected voidfinalize()Calls dispose on this BridgeContext, if it is a child context.SVGAnimationEnginegetAnimationEngine()Returns the AnimationEngine for the document.floatgetBlockHeight(org.w3c.dom.Element elt)Returns the height of the block which directly contains the given element.floatgetBlockWidth(org.w3c.dom.Element elt)Returns the width of the block which directly contains the given element.floatgetBolderFontWeight(float f)Returns a bolder font-weight.BridgegetBridge(java.lang.String namespaceURI, java.lang.String localName)Returns the bridge associated with the element typeBridgegetBridge(org.w3c.dom.Element element)Returns the bridge associated with the specified element.java.util.ListgetBridgeExtensions(org.w3c.dom.Document doc)protected static BridgeUpdateHandlergetBridgeUpdateHandler(org.w3c.dom.Node node)Returns the BridgeUpdateHandler associated to the specified Node or null if there is none.BridgeContext[]getChildContexts()Returns an array of the child contexts.CSSEnginegetCSSEngineForElement(org.w3c.dom.Element e)Returns the CSS engine associated with given element.CursorManagergetCursorManager()Returns the cursor managerValuegetDefaultFontFamily()Returns the value corresponding to the default font.org.w3c.dom.DocumentgetDocument()Returns the document this bridge context is dedicated to.DocumentBridgegetDocumentBridge()Returns the bridge for the document node.DocumentLoadergetDocumentLoader()Returns the document loader used to load external documents.java.awt.geom.Dimension2DgetDocumentSize()Returns the actual size of the document or null if the document has not been built yet.org.w3c.dom.ElementgetElement(GraphicsNode gn)Returns the Node associated to the specified GraphicsNode or null if any.java.lang.ObjectgetElementData(org.w3c.dom.Node n)Retrieves a data object associated with the given node.FocusManagergetFocusManager()Returns the focus manager.java.util.MapgetFontFamilyMap()Returns the map of font familiesFontFamilyResolvergetFontFamilyResolver()static java.util.ListgetGlobalBridgeExtensions()GraphicsNodegetGraphicsNode(org.w3c.dom.Node node)Returns the GraphicsNode associated to the specified Node or null if any.GVTBuildergetGVTBuilder()Returns the GVT builder that is currently used to build the GVT tree.InterpretergetInterpreter(java.lang.String language)Returns a Interpreter for the specified language.InterpreterPoolgetInterpreterPool()Returns the interpreter pool used to handle scripts.floatgetLighterFontWeight(float f)Returns a lighter font-weight.floatgetMediumFontSize()Returns the medium font size.floatgetPixelToMillimeter()Returns the size of a px CSS unit in millimeters.floatgetPixelUnitToMillimeter()Returns the size of a px CSS unit in millimeters.BridgeContextgetPrimaryBridgeContext()Returns the primary bridge context.org.w3c.dom.ElementgetReferencedElement(org.w3c.dom.Element e, java.lang.String uri)Returns the element referenced by the specified element by the specified uri.org.w3c.dom.NodegetReferencedNode(org.w3c.dom.Element e, java.lang.String uri)Returns the node referenced by the specified element by the specified uri.protected static SVGContextgetSVGContext(org.w3c.dom.Node node)Returns the SVGContext associated to the specified Node or null if there is none.ValuegetSystemColor(java.lang.String ident)Returns the Value corresponding to the given system color.TextPaintergetTextPainter()Returns the text painter that will be used be text nodes.UpdateManagergetUpdateManager()Returns the update manager, if the bridge supports dynamic features.UserAgentgetUserAgent()Returns the user agent of this bridge context.ViewportgetViewport(org.w3c.dom.Element e)Returns the viewport of the specified element.booleanhasGraphicsNodeBridge(org.w3c.dom.Element element)Returns true if the specified element has a GraphicsNodeBridge associated to it, false otherwise.protected voidinitializeDocument(org.w3c.dom.Document document)Initializes the given document.booleanisDynamic()Returns true if the document is dynamic, false otherwise.booleanisDynamicDocument(org.w3c.dom.Document doc)Tells whether the given SVG document is dynamic.booleanisInteractive()Returns true if the document is interactive, false otherwise.booleanisInteractiveDocument(org.w3c.dom.Document doc)Tells whether the given SVG document is Interactive.booleanisSVG12()Returns whether the managed document is an SVG 1.2 document.voidopenViewport(org.w3c.dom.Element e, Viewport viewport)Starts a new viewport from the specified element.voidputBridge(java.lang.String namespaceURI, java.lang.String localName, Bridge bridge)Associates the specifiedBridgeobject with the specified namespace URI and local name.voidputBridge(Bridge bridge)Associates the specifiedBridgeobject with it's namespace URI and local name.voidputReservedNamespaceURI(java.lang.String namespaceURI)Adds a namespace URI to avoid when creating default bridges.voidregisterSVGBridges()Registers the bridges to handle SVG 1.0 elements.voidremoveBridge(java.lang.String namespaceURI, java.lang.String localName)Removes theBridgeobject associated to the specified namespace URI and local name.protected voidremoveDOMListeners()Removes event listeners from the DOM and CSS engine.voidremoveReservedNamespaceURI(java.lang.String namespaceURI)Removes a namespace URI to avoid when creating default bridges.voidremoveUIEventListeners(org.w3c.dom.Document doc)voidremoveViewport(org.w3c.dom.Element e)voidsetAnimationLimitingCPU(float pc)Sets the animation limiting mode to a percentage of CPU.voidsetAnimationLimitingFPS(float fps)Sets the animation limiting mode to a number of frames per second.protected voidsetAnimationLimitingMode()Set the animationg limiting mode on the animation engine.voidsetAnimationLimitingNone()Sets the animation limiting mode to "none".voidsetDefaultBridge(Bridge bridge)Sets theBridgeobject to be used for foreign namespace elements.protected voidsetDocument(org.w3c.dom.Document document)Sets the document this bridge context is dedicated to, to the specified document.protected voidsetDocumentLoader(DocumentLoader newDocumentLoader)Sets the document loader used to load external documents.protected voidsetDocumentSize(java.awt.geom.Dimension2D d)Sets the size of the document to the specified dimension.voidsetDynamic(boolean dynamic)Sets the document as DYNAMIC ifdynamicis true STATIC otherwise.voidsetDynamicState(int status)Sets the document as a STATIC, INTERACTIVE or DYNAMIC document.voidsetElementData(org.w3c.dom.Node n, java.lang.Object data)Associates a data object with a node so it can be retrieved later.protected voidsetFontFamilyMap(java.util.Map fontFamilyMap)Sets the map of font families to the specified value.protected voidsetGVTBuilder(GVTBuilder gvtBuilder)Sets the GVT builder that uses this context.voidsetInteractive(boolean interactive)Sets the document as INTERACTIVE ifinteractiveis true STATIC otherwise.protected voidsetInterpreterPool(InterpreterPool interpreterPool)Sets the interpreter pool used to handle scripts to the specified interpreter pool.voidsetTextPainter(TextPainter textPainter)Sets the text painter that will be used by text nodes.protected voidsetUpdateManager(BridgeContext ctx, UpdateManager um)Sets the update manager on the given BridgeContext.protected voidsetUpdateManager(UpdateManager um)Sets the update manager.protected voidsetUserAgent(UserAgent userAgent)Sets the user agent to the specified user agent.protected voidsetXBLManager(BridgeContext ctx, XBLManager xm)Sets the xblManager variable of the given BridgeContext.protected voidstoreEventListener(org.w3c.dom.events.EventTarget t, java.lang.String s, org.w3c.dom.events.EventListener l, boolean b)Adds to the eventListenerSet the specified event listener registration.protected voidstoreEventListenerNS(org.w3c.dom.events.EventTarget t, java.lang.String n, java.lang.String s, org.w3c.dom.events.EventListener l, boolean b)Adds to the eventListenerSet the specified event listener registration.voidunbind(org.w3c.dom.Node node)Removes the binding of the specified Node.
-
-
-
Field Detail
-
document
protected org.w3c.dom.Document document
The document is bridge context is dedicated to.
-
isSVG12
protected boolean isSVG12
Whether the document is an SVG 1.2 document.
-
gvtBuilder
protected GVTBuilder gvtBuilder
The GVT builder that might be used to create a GVT subtree.
-
interpreterMap
protected java.util.Map interpreterMap
The interpreter cache per document. key is the language - value is a Interpreter
-
fontFamilyMap
private java.util.Map fontFamilyMap
A Map of all the font families already matched. This is to reduce the number of instances of GVTFontFamilies and to hopefully reduce the time taken to search for a matching SVG font.
-
viewportMap
protected java.util.Map viewportMap
The viewports. key is an Element - value is a Viewport
-
viewportStack
protected java.util.List viewportStack
The viewport stack. Used in building time.
-
userAgent
protected UserAgent userAgent
The user agent.
-
elementNodeMap
protected java.util.Map elementNodeMap
Binding Map: key is an SVG Element - value is a GraphicsNode
-
nodeElementMap
protected java.util.Map nodeElementMap
Binding Map: key is GraphicsNode - value is a SVG Element.
-
namespaceURIMap
protected java.util.Map namespaceURIMap
Bridge Map: Keys are namespace URI - values are HashMap (with keys are local name and values are a Bridge instance).
-
defaultBridge
protected Bridge defaultBridge
Default bridge. When a bridge is requested for an element type that does not have a bridge, and there is no other bridge for elements in the same namespace, the default bridge is returned. This is used for custom elements, which all use the same bridge type.
-
reservedNamespaceSet
protected java.util.Set reservedNamespaceSet
Default bridge reserved namespaces set. Default bridges will not be created for elements that have a namespace URI present in this set.
-
elementDataMap
protected java.util.Map elementDataMap
Element Data Map: This is a general location for elements to 'cache' data. Such as the graphics tree for a pattern or the Gradient arrays. This is a weak hash map and the data is referenced by SoftReference so both must be referenced elsewhere to stay live.
-
interpreterPool
protected InterpreterPool interpreterPool
The interpreter pool used to handle scripts.
-
documentLoader
protected DocumentLoader documentLoader
The document loader used to load/create Document.
-
documentSize
protected java.awt.geom.Dimension2D documentSize
The size of the document.
-
textPainter
protected TextPainter textPainter
The text painter to use. Typically, you can specify the text painter that will be used be text nodes.
-
STATIC
public static final int STATIC
Indicates that no DOM listeners should be registered. In this case the generated GVT tree should be totally independent of the DOM tree (in practice text holds references to the source text elements for font resolution).- See Also:
- Constant Field Values
-
INTERACTIVE
public static final int INTERACTIVE
Indicates that DOM listeners should be registered to support, 'interactivity' this includes anchors and cursors, but does not include support for DOM modifications.- See Also:
- Constant Field Values
-
DYNAMIC
public static final int DYNAMIC
Indicates that all DOM listeners should be registered. This supports 'interactivity' (anchors and cursors), as well as DOM modifications listeners to update the GVT rendering tree.- See Also:
- Constant Field Values
-
dynamicStatus
protected int dynamicStatus
Whether the bridge should support dynamic, or interactive features.
-
updateManager
protected UpdateManager updateManager
The update manager.
-
xblManager
protected XBLManager xblManager
The XBL manager.
-
primaryContext
protected BridgeContext primaryContext
The bridge context for the primary document, if this is a bridge context for a resource document.
-
childContexts
protected java.util.HashSet childContexts
Set of WeakReferences to child BridgeContexts.
-
animationEngine
protected SVGAnimationEngine animationEngine
The animation engine for the document.
-
animationLimitingMode
protected int animationLimitingMode
The animation limiting mode.
-
animationLimitingAmount
protected float animationLimitingAmount
The amount of animation limiting.
-
sharedPool
private static InterpreterPool sharedPool
By default we share a unique instance of InterpreterPool.
-
eventListenerSet
protected java.util.Set eventListenerSet
The list of all EventListener attached by bridges that need to be removed on a dispose() call.
-
domCharacterDataModifiedEventListener
protected org.w3c.dom.events.EventListener domCharacterDataModifiedEventListener
The DOM EventListener to receive 'DOMCharacterDataModified' event.
-
domAttrModifiedEventListener
protected org.w3c.dom.events.EventListener domAttrModifiedEventListener
The DOM EventListener to receive 'DOMAttrModified' event.
-
domNodeInsertedEventListener
protected org.w3c.dom.events.EventListener domNodeInsertedEventListener
The DOM EventListener to receive 'DOMNodeInserted' event.
-
domNodeRemovedEventListener
protected org.w3c.dom.events.EventListener domNodeRemovedEventListener
The DOM EventListener to receive 'DOMNodeRemoved' event.
-
cssPropertiesChangedListener
protected CSSEngineListener cssPropertiesChangedListener
The CSSEngine listener to receive CSSEngineEvent.
-
animatedAttributeListener
protected AnimatedAttributeListener animatedAttributeListener
The listener to receive notification of animated attribute changes.
-
focusManager
protected FocusManager focusManager
The EventListener that is responsible of managing DOM focus event.
-
cursorManager
protected CursorManager cursorManager
Manages cursors and performs caching when appropriate
-
extensions
protected java.util.List extensions
-
globalExtensions
protected static java.util.List globalExtensions
Returns the extensions supported by this bridge context.
-
-
Constructor Detail
-
BridgeContext
protected BridgeContext()
Constructs a new empty bridge context.
-
BridgeContext
public BridgeContext(UserAgent userAgent)
Constructs a new bridge context.- Parameters:
userAgent- the user agent
-
BridgeContext
public BridgeContext(UserAgent userAgent, DocumentLoader loader)
Constructs a new bridge context.- Parameters:
userAgent- the user agentloader- document loader
-
BridgeContext
public BridgeContext(UserAgent userAgent, InterpreterPool interpreterPool, DocumentLoader documentLoader)
Constructs a new bridge context.- Parameters:
userAgent- the user agentinterpreterPool- the interpreter pooldocumentLoader- document loader
-
-
Method Detail
-
getFontFamilyResolver
public final FontFamilyResolver getFontFamilyResolver()
-
finalize
protected void finalize()
Calls dispose on this BridgeContext, if it is a child context.- Overrides:
finalizein classjava.lang.Object
-
createSubBridgeContext
public BridgeContext createSubBridgeContext(SVGOMDocument newDoc)
This function creates a new 'sub' BridgeContext to associated with 'newDoc' if one currently doesn't exist, otherwise it returns the BridgeContext currently associated with the document.- Parameters:
newDoc- The document to get/create a BridgeContext for.
-
createBridgeContext
public BridgeContext createBridgeContext(SVGOMDocument doc)
This function creates a new BridgeContext, it mostly exists so subclasses can provide an instance of themselves when a sub BridgeContext is needed.
-
initializeDocument
protected void initializeDocument(org.w3c.dom.Document document)
Initializes the given document.
-
getCSSEngineForElement
public CSSEngine getCSSEngineForElement(org.w3c.dom.Element e)
Returns the CSS engine associated with given element.- Specified by:
getCSSEngineForElementin interfaceCSSContext
-
setTextPainter
public void setTextPainter(TextPainter textPainter)
Sets the text painter that will be used by text nodes. This attributes might be used by bridges (especially SVGTextElementBridge) to set the text painter of each TextNode.- Parameters:
textPainter- the text painter for text nodes
-
getTextPainter
public TextPainter getTextPainter()
Returns the text painter that will be used be text nodes.
-
getDocument
public org.w3c.dom.Document getDocument()
Returns the document this bridge context is dedicated to.
-
setDocument
protected void setDocument(org.w3c.dom.Document document)
Sets the document this bridge context is dedicated to, to the specified document.- Parameters:
document- the document
-
getFontFamilyMap
public java.util.Map getFontFamilyMap()
Returns the map of font families
-
setFontFamilyMap
protected void setFontFamilyMap(java.util.Map fontFamilyMap)
Sets the map of font families to the specified value.- Parameters:
fontFamilyMap- the map of font families
-
setElementData
public void setElementData(org.w3c.dom.Node n, java.lang.Object data)Associates a data object with a node so it can be retrieved later. This is primarily used for caching the graphics node generated from a 'pattern' element. A soft reference to the data object is used.
-
getElementData
public java.lang.Object getElementData(org.w3c.dom.Node n)
Retrieves a data object associated with the given node.
-
getUserAgent
public UserAgent getUserAgent()
Returns the user agent of this bridge context.
-
setUserAgent
protected void setUserAgent(UserAgent userAgent)
Sets the user agent to the specified user agent.- Parameters:
userAgent- the user agent
-
getGVTBuilder
public GVTBuilder getGVTBuilder()
Returns the GVT builder that is currently used to build the GVT tree.
-
setGVTBuilder
protected void setGVTBuilder(GVTBuilder gvtBuilder)
Sets the GVT builder that uses this context.
-
getInterpreterPool
public InterpreterPool getInterpreterPool()
Returns the interpreter pool used to handle scripts.
-
getFocusManager
public FocusManager getFocusManager()
Returns the focus manager.
-
getCursorManager
public CursorManager getCursorManager()
Returns the cursor manager
-
setInterpreterPool
protected void setInterpreterPool(InterpreterPool interpreterPool)
Sets the interpreter pool used to handle scripts to the specified interpreter pool.- Parameters:
interpreterPool- the interpreter pool
-
getInterpreter
public Interpreter getInterpreter(java.lang.String language)
Returns a Interpreter for the specified language.- Parameters:
language- the scripting language
-
getDocumentLoader
public DocumentLoader getDocumentLoader()
Returns the document loader used to load external documents.
-
setDocumentLoader
protected void setDocumentLoader(DocumentLoader newDocumentLoader)
Sets the document loader used to load external documents.- Parameters:
newDocumentLoader- the new document loader
-
getDocumentSize
public java.awt.geom.Dimension2D getDocumentSize()
Returns the actual size of the document or null if the document has not been built yet.
-
setDocumentSize
protected void setDocumentSize(java.awt.geom.Dimension2D d)
Sets the size of the document to the specified dimension.- Parameters:
d- the actual size of the SVG document
-
isDynamic
public boolean isDynamic()
Returns true if the document is dynamic, false otherwise.- Specified by:
isDynamicin interfaceCSSContext
-
isInteractive
public boolean isInteractive()
Returns true if the document is interactive, false otherwise.- Specified by:
isInteractivein interfaceCSSContext
-
setDynamicState
public void setDynamicState(int status)
Sets the document as a STATIC, INTERACTIVE or DYNAMIC document. Call this method before the build phase (ie. beforegvtBuilder.build(...)) otherwise, that will have no effect.- Parameters:
status- the document dynamicStatus
-
setDynamic
public void setDynamic(boolean dynamic)
Sets the document as DYNAMIC ifdynamicis true STATIC otherwise.
-
setInteractive
public void setInteractive(boolean interactive)
Sets the document as INTERACTIVE ifinteractiveis true STATIC otherwise.
-
getUpdateManager
public UpdateManager getUpdateManager()
Returns the update manager, if the bridge supports dynamic features.
-
setUpdateManager
protected void setUpdateManager(UpdateManager um)
Sets the update manager.
-
setUpdateManager
protected void setUpdateManager(BridgeContext ctx, UpdateManager um)
Sets the update manager on the given BridgeContext.
-
setXBLManager
protected void setXBLManager(BridgeContext ctx, XBLManager xm)
Sets the xblManager variable of the given BridgeContext.
-
isSVG12
public boolean isSVG12()
Returns whether the managed document is an SVG 1.2 document.
-
getPrimaryBridgeContext
public BridgeContext getPrimaryBridgeContext()
Returns the primary bridge context.
-
getChildContexts
public BridgeContext[] getChildContexts()
Returns an array of the child contexts.
-
getAnimationEngine
public SVGAnimationEngine getAnimationEngine()
Returns the AnimationEngine for the document. Creates one if it doesn't exist.
-
createURIResolver
public URIResolver createURIResolver(org.w3c.dom.svg.SVGDocument doc, DocumentLoader dl)
Returns a new URIResolver object.
-
getReferencedNode
public org.w3c.dom.Node getReferencedNode(org.w3c.dom.Element e, java.lang.String uri)Returns the node referenced by the specified element by the specified uri. The referenced node can be either an element given by a fragment ID, or the document node.- Parameters:
e- the element referencinguri- the uri of the referenced node
-
getReferencedElement
public org.w3c.dom.Element getReferencedElement(org.w3c.dom.Element e, java.lang.String uri)Returns the element referenced by the specified element by the specified uri. The referenced element can not be a Document.- Parameters:
e- the element referencinguri- the uri of the referenced element
-
getViewport
public Viewport getViewport(org.w3c.dom.Element e)
Returns the viewport of the specified element.- Parameters:
e- the element interested in its viewport
-
openViewport
public void openViewport(org.w3c.dom.Element e, Viewport viewport)Starts a new viewport from the specified element.- Parameters:
e- the element that defines a new viewportviewport- the viewport of the element
-
removeViewport
public void removeViewport(org.w3c.dom.Element e)
-
closeViewport
public void closeViewport(org.w3c.dom.Element e)
Closes the viewport associated to the specified element.- Parameters:
e- the element that closes its viewport
-
bind
public void bind(org.w3c.dom.Node node, GraphicsNode gn)Binds the specified GraphicsNode to the specified Node. This method automatically bind the graphics node to the element and the element to the graphics node.- Parameters:
node- the DOM Node to bind to the specified graphics nodegn- the graphics node to bind to the specified element
-
unbind
public void unbind(org.w3c.dom.Node node)
Removes the binding of the specified Node.- Parameters:
node- the DOM Node to unbind
-
getGraphicsNode
public GraphicsNode getGraphicsNode(org.w3c.dom.Node node)
Returns the GraphicsNode associated to the specified Node or null if any.- Parameters:
node- the DOM Node associated to the graphics node to return
-
getElement
public org.w3c.dom.Element getElement(GraphicsNode gn)
Returns the Node associated to the specified GraphicsNode or null if any.- Parameters:
gn- the graphics node associated to the element to return
-
hasGraphicsNodeBridge
public boolean hasGraphicsNodeBridge(org.w3c.dom.Element element)
Returns true if the specified element has a GraphicsNodeBridge associated to it, false otherwise.- Parameters:
element- the element
-
getDocumentBridge
public DocumentBridge getDocumentBridge()
Returns the bridge for the document node.
-
getBridge
public Bridge getBridge(org.w3c.dom.Element element)
Returns the bridge associated with the specified element.- Parameters:
element- the element
-
getBridge
public Bridge getBridge(java.lang.String namespaceURI, java.lang.String localName)
Returns the bridge associated with the element type- Parameters:
namespaceURI- namespace of the requested elementlocalName- element's local name
-
putBridge
public void putBridge(java.lang.String namespaceURI, java.lang.String localName, Bridge bridge)Associates the specifiedBridgeobject with the specified namespace URI and local name.- Parameters:
namespaceURI- the namespace URIlocalName- the local namebridge- the bridge that manages the element
-
putBridge
public void putBridge(Bridge bridge)
Associates the specifiedBridgeobject with it's namespace URI and local name.- Parameters:
bridge- the bridge that manages the element
-
removeBridge
public void removeBridge(java.lang.String namespaceURI, java.lang.String localName)Removes theBridgeobject associated to the specified namespace URI and local name.- Parameters:
namespaceURI- the namespace URIlocalName- the local name
-
setDefaultBridge
public void setDefaultBridge(Bridge bridge)
Sets theBridgeobject to be used for foreign namespace elements.- Parameters:
bridge- the bridge that manages the element
-
putReservedNamespaceURI
public void putReservedNamespaceURI(java.lang.String namespaceURI)
Adds a namespace URI to avoid when creating default bridges.
-
removeReservedNamespaceURI
public void removeReservedNamespaceURI(java.lang.String namespaceURI)
Removes a namespace URI to avoid when creating default bridges.
-
addUIEventListeners
public void addUIEventListeners(org.w3c.dom.Document doc)
Adds EventListeners to the input document to handle the cursor property. This is not done in the addDOMListeners method because addDOMListeners is only used for dynamic content whereas cursor support is provided for all content. Also note that it is very important that the listeners be registered for the capture phase as the 'default' behavior for cursors is handled by the BridgeContext during the capture phase and the 'custom' behavior (handling of 'auto' on anchors, for example), is handled during the bubbling phase.
-
removeUIEventListeners
public void removeUIEventListeners(org.w3c.dom.Document doc)
-
addDOMListeners
public void addDOMListeners()
Adds EventListeners to the DOM and CSSEngineListener to the CSSEngine to handle any modifications on the DOM tree or style properties and update the GVT tree in response.
-
removeDOMListeners
protected void removeDOMListeners()
Removes event listeners from the DOM and CSS engine.
-
storeEventListener
protected void storeEventListener(org.w3c.dom.events.EventTarget t, java.lang.String s, org.w3c.dom.events.EventListener l, boolean b)Adds to the eventListenerSet the specified event listener registration.
-
storeEventListenerNS
protected void storeEventListenerNS(org.w3c.dom.events.EventTarget t, java.lang.String n, java.lang.String s, org.w3c.dom.events.EventListener l, boolean b)Adds to the eventListenerSet the specified event listener registration.
-
addGVTListener
public void addGVTListener(org.w3c.dom.Document doc)
Adds the GVT listener for AWT event support.
-
clearChildContexts
protected void clearChildContexts()
Clears the list of child BridgeContexts and disposes them if there are no more references to them.
-
dispose
public void dispose()
Disposes this BridgeContext.
-
getSVGContext
protected static SVGContext getSVGContext(org.w3c.dom.Node node)
Returns the SVGContext associated to the specified Node or null if there is none.
-
getBridgeUpdateHandler
protected static BridgeUpdateHandler getBridgeUpdateHandler(org.w3c.dom.Node node)
Returns the BridgeUpdateHandler associated to the specified Node or null if there is none.
-
getSystemColor
public Value getSystemColor(java.lang.String ident)
Returns the Value corresponding to the given system color.- Specified by:
getSystemColorin interfaceCSSContext
-
getDefaultFontFamily
public Value getDefaultFontFamily()
Returns the value corresponding to the default font.- Specified by:
getDefaultFontFamilyin interfaceCSSContext
-
getLighterFontWeight
public float getLighterFontWeight(float f)
Returns a lighter font-weight.- Specified by:
getLighterFontWeightin interfaceCSSContext
-
getBolderFontWeight
public float getBolderFontWeight(float f)
Returns a bolder font-weight.- Specified by:
getBolderFontWeightin interfaceCSSContext
-
getPixelUnitToMillimeter
public float getPixelUnitToMillimeter()
Returns the size of a px CSS unit in millimeters.- Specified by:
getPixelUnitToMillimeterin interfaceCSSContext
-
getPixelToMillimeter
public float getPixelToMillimeter()
Returns the size of a px CSS unit in millimeters. This will be removed after next release.- Specified by:
getPixelToMillimeterin interfaceCSSContext- See Also:
getPixelUnitToMillimeter()
-
getMediumFontSize
public float getMediumFontSize()
Returns the medium font size.- Specified by:
getMediumFontSizein interfaceCSSContext
-
getBlockWidth
public float getBlockWidth(org.w3c.dom.Element elt)
Returns the width of the block which directly contains the given element.- Specified by:
getBlockWidthin interfaceCSSContext
-
getBlockHeight
public float getBlockHeight(org.w3c.dom.Element elt)
Returns the height of the block which directly contains the given element.- Specified by:
getBlockHeightin interfaceCSSContext
-
checkLoadExternalResource
public void checkLoadExternalResource(ParsedURL resourceURL, ParsedURL docURL) throws java.lang.SecurityException
This method throws a SecurityException if the resource found at url and referenced from docURL should not be loaded. This is a convenience method to call checkLoadExternalResource on the ExternalResourceSecurity strategy returned by getExternalResourceSecurity.- Specified by:
checkLoadExternalResourcein interfaceCSSContext- Parameters:
resourceURL- url for the script, as defined in the resource's xlink:href attribute. If that attribute was empty, then this parameter should be nulldocURL- url for the document into which the resource was found.- Throws:
java.lang.SecurityException
-
isDynamicDocument
public boolean isDynamicDocument(org.w3c.dom.Document doc)
Tells whether the given SVG document is dynamic.
-
isInteractiveDocument
public boolean isInteractiveDocument(org.w3c.dom.Document doc)
Tells whether the given SVG document is Interactive. We say it is, if it has any <title>, <desc>, or <a> elements, of if the 'cursor' property is anything but Auto on any element.
-
checkInteractiveElement
public boolean checkInteractiveElement(org.w3c.dom.Element e)
used by isInteractiveDocument to check if document contains any 'interactive' elements.
-
checkInteractiveElement
public boolean checkInteractiveElement(org.w3c.dom.svg.SVGDocument doc, org.w3c.dom.Element e)used by isInteractiveDocument to check if document contains any 'interactive' elements.
-
setAnimationLimitingNone
public void setAnimationLimitingNone()
Sets the animation limiting mode to "none".
-
setAnimationLimitingCPU
public void setAnimationLimitingCPU(float pc)
Sets the animation limiting mode to a percentage of CPU.- Parameters:
pc- the maximum percentage of CPU to use (0 < pc ≤ 1)
-
setAnimationLimitingFPS
public void setAnimationLimitingFPS(float fps)
Sets the animation limiting mode to a number of frames per second.- Parameters:
fps- the maximum number of frames per second (fps > 0)
-
setAnimationLimitingMode
protected void setAnimationLimitingMode()
Set the animationg limiting mode on the animation engine.
-
registerSVGBridges
public void registerSVGBridges()
Registers the bridges to handle SVG 1.0 elements.
-
getBridgeExtensions
public java.util.List getBridgeExtensions(org.w3c.dom.Document doc)
-
getGlobalBridgeExtensions
public static java.util.List getGlobalBridgeExtensions()
-
-