Package org.apache.batik.bridge.svg12
Class DefaultXBLManager
- java.lang.Object
-
- org.apache.batik.bridge.svg12.DefaultXBLManager
-
- All Implemented Interfaces:
XBLManager,XBLConstants
public class DefaultXBLManager extends java.lang.Object implements XBLManager, XBLConstants
A full featured sXBL manager.- Version:
- $Id: DefaultXBLManager.java 1851346 2019-01-15 13:41:00Z ssteiner $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classDefaultXBLManager.DefAttrListenerDOM attribute mutation listener for definition elements.protected static classDefaultXBLManager.DefinitionRecordRecord class for storing information about an XBL definition.protected classDefaultXBLManager.DefNodeInsertedListenerDOM node inserted listener for definition elements.protected classDefaultXBLManager.DefNodeRemovedListenerDOM node removed listener for definition elements.protected classDefaultXBLManager.DocInsertedListenerDOM node inserted listener for the document.protected classDefaultXBLManager.DocRemovedListenerDOM node removed listener for the document.protected classDefaultXBLManager.DocSubtreeListenerDOM subtree mutation listener for the document.protected classDefaultXBLManager.ImportAttrListenerDOM attribute mutation listener for import elements.protected classDefaultXBLManager.ImportInsertedListenerDOM node inserted listener for imported XBL trees.protected classDefaultXBLManager.ImportRecordRecord class for storing information about an XBL import.protected static classDefaultXBLManager.ImportRemovedListenerDOM node removed listener for imported XBL trees.protected classDefaultXBLManager.ImportSubtreeListenerDOM subtree listener for imported XBL trees.protected classDefaultXBLManager.RefAttrListenerDOM attribute mutation listener for referencing definition elements.protected classDefaultXBLManager.TemplateMutationListenerDOM mutation listener for template elements.protected classDefaultXBLManager.XblChildNodesTo iterate over the XBL child nodes.protected classDefaultXBLManager.XBLRecordXBL record.protected classDefaultXBLManager.XblScopedChildNodesTo iterate over the scoped XBL child nodes.
-
Field Summary
Fields Modifier and Type Field Description protected javax.swing.event.EventListenerListbindingListenerListGlobal event listener list for XBL binding related events.protected java.util.MapcontentManagersMap of shadow trees to content managers.protected javax.swing.event.EventListenerListcontentSelectionChangedListenerListGlobal event listener list for ContentSelectionChanged events.protected BridgeContextctxThe BridgeContext.protected DoublyIndexedTabledefinitionListsMap of namespace URI/local name pairs to ordered sets of definition records.protected DoublyIndexedTabledefinitionsMap of definition element/import element pairs to definition records.protected DefaultXBLManager.DocInsertedListenerdocInsertedListenerDOM node inserted listener for the document.protected DefaultXBLManager.DocRemovedListenerdocRemovedListenerDOM node removed listener for the document.protected DefaultXBLManager.DocSubtreeListenerdocSubtreeListenerDOM subtree mutation listener for the document.protected org.w3c.dom.DocumentdocumentThe document.protected DefaultXBLManager.ImportAttrListenerimportAttrListenerDOM attribute listener for import elements.protected java.util.MapimportsMap of import elements to import records.protected booleanisProcessingWhether XBL processing is currently taking place.protected DefaultXBLManager.RefAttrListenerrefAttrListenerDOM attribute listener for referencing definition elements.-
Fields inherited from interface org.apache.batik.util.XBLConstants
XBL_BINDINGS_ATTRIBUTE, XBL_BOUND_EVENT_TYPE, XBL_CONTENT_TAG, XBL_DEFINITION_TAG, XBL_ELEMENT_ATTRIBUTE, XBL_HANDLER_GROUP_TAG, XBL_IMPORT_TAG, XBL_INCLUDES_ATTRIBUTE, XBL_NAMESPACE_URI, XBL_ONBOUND_ATTRIBUTE, XBL_ONPREBIND_ATTRIBUTE, XBL_ONUNBINDING_ATTRIBUTE, XBL_PREBIND_EVENT_TYPE, XBL_REF_ATTRIBUTE, XBL_SHADOW_TREE_TAG, XBL_TEMPLATE_TAG, XBL_UNBINDING_EVENT_TYPE, XBL_XBL_TAG
-
-
Constructor Summary
Constructors Constructor Description DefaultXBLManager(org.w3c.dom.Document doc, BridgeContext ctx)Creates a new DefaultXBLManager for the given document.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBindingListener(BindingListener l)Adds the specified BindingListener to the global listener list.voidaddContentSelectionChangedListener(ContentSelectionChangedListener l)Adds the specified ContentSelectionChangedListener to the global listener list.protected voidaddDefinition(java.lang.String namespaceURI, java.lang.String localName, XBLOMDefinitionElement def, org.w3c.dom.Element imp)Adds an xbl:definition element to the list of definitions that could possibly affect elements with the specified QName.protected voidaddDefinitionElementListeners(XBLOMDefinitionElement def, DefaultXBLManager.ImportRecord ir)Adds DOM mutation listeners to the given definition element.protected voidaddDefinitionRef(org.w3c.dom.Element defRef)Adds a definition through its referring definition element (one with a 'ref' attribute).protected voidaddImport(org.w3c.dom.Element imp)Imports bindings from another document.protected voidaddImportedDefinitions(org.w3c.dom.Element imp, org.w3c.dom.Node n)Adds the definitions in the given imported subtree.protected voidaddTemplateElementListeners(XBLOMTemplateElement template, DefaultXBLManager.ImportRecord ir)Adds DOM mutation listeners to the given template element.protected voidbind(org.w3c.dom.Element e)Binds each bindable element in the given element's subtree.protected XBLOMShadowTreeElementcloneTemplate(XBLOMTemplateElement template)Clones a template element for use as a shadow tree.static intcomputeBubbleLimit(org.w3c.dom.Node from, org.w3c.dom.Node to)Determines the number of nodes events should bubble if the mouse pointer has moved from one element to another.protected voiddispatchBindingChangedEvent(org.w3c.dom.Element bindableElement, org.w3c.dom.Element shadowTree)Dispatches a BindingEvent the registered listeners.protected voidfireShadowTreeEvent(BindableElement elt, java.lang.String type, XBLShadowTreeElement e)Fires a ShadowTreeEvent of the given type on this element.protected DefaultXBLManager.DefinitionRecordgetActiveDefinition(java.lang.String namespaceURI, java.lang.String localName)Returns the definition record of the active definition for namespace URI/local name pair.ContentManagergetContentManager(org.w3c.dom.Node n)Returns the ContentManager that handles the shadow tree the given node resides in.protected java.lang.Object[]getContentSelectionChangedListeners()Returns an array of the gloabl ContentSelectionChangedListeners.protected DefaultXBLManager.XBLRecordgetRecord(org.w3c.dom.Node n)Returns the XBL record for the given node.org.w3c.dom.ElementgetXblBoundElement(org.w3c.dom.Node n)Get the bound element whose shadow tree a node resides in.org.w3c.dom.NodeListgetXblChildNodes(org.w3c.dom.Node n)Get the list of child nodes of a node in the fully flattened tree.XBLOMContentElementgetXblContentElement(org.w3c.dom.Node n)Returns the content element that caused the given node to be present in the flattened tree.org.w3c.dom.NodeListgetXblDefinitions(org.w3c.dom.Node n)Get the xbl:definition elements currently binding an element.org.w3c.dom.NodegetXblFirstChild(org.w3c.dom.Node n)Get the first child node of a node in the fully flattened tree.org.w3c.dom.ElementgetXblFirstElementChild(org.w3c.dom.Node n)Get the first element child of a node in the fully flattened tree.org.w3c.dom.NodegetXblLastChild(org.w3c.dom.Node n)Get the last child node of a node in the fully flattened tree.org.w3c.dom.ElementgetXblLastElementChild(org.w3c.dom.Node n)Get the last element child of a node in the fully flattened tree.org.w3c.dom.ElementgetXblNextElementSibling(org.w3c.dom.Node n)Get the first element that follows a node in the xblParentNode's xblChildNodes list.org.w3c.dom.NodegetXblNextSibling(org.w3c.dom.Node n)Get the node which directly follows a node in the xblParentNode's xblChildNodes list.org.w3c.dom.NodegetXblParentNode(org.w3c.dom.Node n)Get the parent of a node in the fully flattened tree.org.w3c.dom.ElementgetXblPreviousElementSibling(org.w3c.dom.Node n)Get the first element that precedes the a node in the xblParentNode's xblChildNodes list.org.w3c.dom.NodegetXblPreviousSibling(org.w3c.dom.Node n)Get the node which directly precedes a node in the xblParentNode's xblChildNodes list.org.w3c.dom.NodeListgetXblScopedChildNodes(org.w3c.dom.Node n)Get the list of child nodes of a node in the fully flattened tree that are within the same shadow scope.org.w3c.dom.ElementgetXblShadowTree(org.w3c.dom.Node n)Get the shadow tree of a node.voidinvalidateChildNodes(org.w3c.dom.Node n)Mark the xblChildNodes and xblScopedChildNodes variables as invalid.protected booleanisActiveDefinition(XBLOMDefinitionElement def, org.w3c.dom.Element imp)Returns whether the given definition element is the active one for its element name.booleanisProcessing()Returns whether XBL processing is currently enabled.protected voidrebind(java.lang.String namespaceURI, java.lang.String localName, org.w3c.dom.Element e)Rebinds each bindable element of the given name in the given element's subtree.voidremoveBindingListener(BindingListener l)Removes the specified BindingListener from the global listener list.voidremoveContentSelectionChangedListener(ContentSelectionChangedListener l)Removes the specified ContentSelectionChangedListener from the global listener list.protected voidremoveDefinition(DefaultXBLManager.DefinitionRecord defRec)Removes an xbl:definition element from the list of definitions that could possibly affect elements with the specified QName.protected voidremoveDefinitionElementListeners(XBLOMDefinitionElement def, DefaultXBLManager.ImportRecord ir)Removes DOM mutation listeners from the given definition element.protected voidremoveDefinitionRef(org.w3c.dom.Element defRef)Removes a definition through its referring definition element (one with a 'ref' attribute).protected voidremoveImport(org.w3c.dom.Element imp)Removes an import.protected voidremoveTemplateElementListeners(XBLOMTemplateElement template, DefaultXBLManager.ImportRecord ir)Removes DOM mutation listeners from the given template element.protected voidsetActiveDefinition(BindableElement elt, DefaultXBLManager.DefinitionRecord defRec)Sets the given definition as the active one for a particular bindable element.(package private) voidsetContentManager(org.w3c.dom.Element shadow, ContentManager cm)Records the ContentManager that handles the given shadow tree.protected voidsetXblShadowTree(BindableElement elt, XBLOMShadowTreeElement newShadow)Sets the shadow tree for the given bindable element.(package private) voidshadowTreeSelectedContentChanged(java.util.Set deselected, java.util.Set selected)Called by the ContentManager of a shadow tree to indicate some selected nodes have changed.voidstartProcessing()Starts XBL processing on the document.voidstopProcessing()Stops XBL processing on the document.protected voidunbind(org.w3c.dom.Element e)Unbinds each bindable element in the given element's subtree.protected voidupdateLinks(org.w3c.dom.Node n)Updates the xblPreviousSibling and xblNextSibling properties of the given XBL node.
-
-
-
Field Detail
-
isProcessing
protected boolean isProcessing
Whether XBL processing is currently taking place.
-
document
protected org.w3c.dom.Document document
The document.
-
ctx
protected BridgeContext ctx
The BridgeContext.
-
definitionLists
protected DoublyIndexedTable definitionLists
Map of namespace URI/local name pairs to ordered sets of definition records.
-
definitions
protected DoublyIndexedTable definitions
Map of definition element/import element pairs to definition records.
-
contentManagers
protected java.util.Map contentManagers
Map of shadow trees to content managers.
-
imports
protected java.util.Map imports
Map of import elements to import records.
-
docInsertedListener
protected DefaultXBLManager.DocInsertedListener docInsertedListener
DOM node inserted listener for the document.
-
docRemovedListener
protected DefaultXBLManager.DocRemovedListener docRemovedListener
DOM node removed listener for the document.
-
docSubtreeListener
protected DefaultXBLManager.DocSubtreeListener docSubtreeListener
DOM subtree mutation listener for the document.
-
importAttrListener
protected DefaultXBLManager.ImportAttrListener importAttrListener
DOM attribute listener for import elements.
-
refAttrListener
protected DefaultXBLManager.RefAttrListener refAttrListener
DOM attribute listener for referencing definition elements.
-
bindingListenerList
protected javax.swing.event.EventListenerList bindingListenerList
Global event listener list for XBL binding related events.
-
contentSelectionChangedListenerList
protected javax.swing.event.EventListenerList contentSelectionChangedListenerList
Global event listener list for ContentSelectionChanged events.
-
-
Constructor Detail
-
DefaultXBLManager
public DefaultXBLManager(org.w3c.dom.Document doc, BridgeContext ctx)Creates a new DefaultXBLManager for the given document.
-
-
Method Detail
-
startProcessing
public void startProcessing()
Starts XBL processing on the document.- Specified by:
startProcessingin interfaceXBLManager
-
stopProcessing
public void stopProcessing()
Stops XBL processing on the document.- Specified by:
stopProcessingin interfaceXBLManager
-
isProcessing
public boolean isProcessing()
Returns whether XBL processing is currently enabled.- Specified by:
isProcessingin interfaceXBLManager
-
addDefinitionRef
protected void addDefinitionRef(org.w3c.dom.Element defRef)
Adds a definition through its referring definition element (one with a 'ref' attribute).
-
removeDefinitionRef
protected void removeDefinitionRef(org.w3c.dom.Element defRef)
Removes a definition through its referring definition element (one with a 'ref' attribute).
-
addImport
protected void addImport(org.w3c.dom.Element imp)
Imports bindings from another document.
-
addImportedDefinitions
protected void addImportedDefinitions(org.w3c.dom.Element imp, org.w3c.dom.Node n)Adds the definitions in the given imported subtree.
-
removeImport
protected void removeImport(org.w3c.dom.Element imp)
Removes an import.
-
addDefinition
protected void addDefinition(java.lang.String namespaceURI, java.lang.String localName, XBLOMDefinitionElement def, org.w3c.dom.Element imp)Adds an xbl:definition element to the list of definitions that could possibly affect elements with the specified QName. This may or may not actually cause a new binding to come in to effect, as this new definition element may be added earlier in the document than another already in effect.- Parameters:
namespaceURI- the namespace URI of the bound elementslocalName- the local name of the bound elementsdef- the xbl:definition elementimp- the xbl:import or xbl;definition element through which this definition is being added, or null if the binding is in the original document
-
addDefinitionElementListeners
protected void addDefinitionElementListeners(XBLOMDefinitionElement def, DefaultXBLManager.ImportRecord ir)
Adds DOM mutation listeners to the given definition element.
-
addTemplateElementListeners
protected void addTemplateElementListeners(XBLOMTemplateElement template, DefaultXBLManager.ImportRecord ir)
Adds DOM mutation listeners to the given template element.
-
removeDefinition
protected void removeDefinition(DefaultXBLManager.DefinitionRecord defRec)
Removes an xbl:definition element from the list of definitions that could possibly affect elements with the specified QName. This will only cause a new binding to come in to effect if it is currently active.
-
removeDefinitionElementListeners
protected void removeDefinitionElementListeners(XBLOMDefinitionElement def, DefaultXBLManager.ImportRecord ir)
Removes DOM mutation listeners from the given definition element.
-
removeTemplateElementListeners
protected void removeTemplateElementListeners(XBLOMTemplateElement template, DefaultXBLManager.ImportRecord ir)
Removes DOM mutation listeners from the given template element.
-
getActiveDefinition
protected DefaultXBLManager.DefinitionRecord getActiveDefinition(java.lang.String namespaceURI, java.lang.String localName)
Returns the definition record of the active definition for namespace URI/local name pair.
-
unbind
protected void unbind(org.w3c.dom.Element e)
Unbinds each bindable element in the given element's subtree.
-
bind
protected void bind(org.w3c.dom.Element e)
Binds each bindable element in the given element's subtree.
-
rebind
protected void rebind(java.lang.String namespaceURI, java.lang.String localName, org.w3c.dom.Element e)Rebinds each bindable element of the given name in the given element's subtree.
-
setActiveDefinition
protected void setActiveDefinition(BindableElement elt, DefaultXBLManager.DefinitionRecord defRec)
Sets the given definition as the active one for a particular bindable element.
-
setXblShadowTree
protected void setXblShadowTree(BindableElement elt, XBLOMShadowTreeElement newShadow)
Sets the shadow tree for the given bindable element.
-
fireShadowTreeEvent
protected void fireShadowTreeEvent(BindableElement elt, java.lang.String type, XBLShadowTreeElement e)
Fires a ShadowTreeEvent of the given type on this element.
-
cloneTemplate
protected XBLOMShadowTreeElement cloneTemplate(XBLOMTemplateElement template)
Clones a template element for use as a shadow tree.
-
getXblParentNode
public org.w3c.dom.Node getXblParentNode(org.w3c.dom.Node n)
Get the parent of a node in the fully flattened tree.- Specified by:
getXblParentNodein interfaceXBLManager
-
getXblChildNodes
public org.w3c.dom.NodeList getXblChildNodes(org.w3c.dom.Node n)
Get the list of child nodes of a node in the fully flattened tree.- Specified by:
getXblChildNodesin interfaceXBLManager
-
getXblScopedChildNodes
public org.w3c.dom.NodeList getXblScopedChildNodes(org.w3c.dom.Node n)
Get the list of child nodes of a node in the fully flattened tree that are within the same shadow scope.- Specified by:
getXblScopedChildNodesin interfaceXBLManager
-
getXblFirstChild
public org.w3c.dom.Node getXblFirstChild(org.w3c.dom.Node n)
Get the first child node of a node in the fully flattened tree.- Specified by:
getXblFirstChildin interfaceXBLManager
-
getXblLastChild
public org.w3c.dom.Node getXblLastChild(org.w3c.dom.Node n)
Get the last child node of a node in the fully flattened tree.- Specified by:
getXblLastChildin interfaceXBLManager
-
getXblPreviousSibling
public org.w3c.dom.Node getXblPreviousSibling(org.w3c.dom.Node n)
Get the node which directly precedes a node in the xblParentNode's xblChildNodes list.- Specified by:
getXblPreviousSiblingin interfaceXBLManager
-
getXblNextSibling
public org.w3c.dom.Node getXblNextSibling(org.w3c.dom.Node n)
Get the node which directly follows a node in the xblParentNode's xblChildNodes list.- Specified by:
getXblNextSiblingin interfaceXBLManager
-
getXblFirstElementChild
public org.w3c.dom.Element getXblFirstElementChild(org.w3c.dom.Node n)
Get the first element child of a node in the fully flattened tree.- Specified by:
getXblFirstElementChildin interfaceXBLManager
-
getXblLastElementChild
public org.w3c.dom.Element getXblLastElementChild(org.w3c.dom.Node n)
Get the last element child of a node in the fully flattened tree.- Specified by:
getXblLastElementChildin interfaceXBLManager
-
getXblPreviousElementSibling
public org.w3c.dom.Element getXblPreviousElementSibling(org.w3c.dom.Node n)
Get the first element that precedes the a node in the xblParentNode's xblChildNodes list.- Specified by:
getXblPreviousElementSiblingin interfaceXBLManager
-
getXblNextElementSibling
public org.w3c.dom.Element getXblNextElementSibling(org.w3c.dom.Node n)
Get the first element that follows a node in the xblParentNode's xblChildNodes list.- Specified by:
getXblNextElementSiblingin interfaceXBLManager
-
getXblBoundElement
public org.w3c.dom.Element getXblBoundElement(org.w3c.dom.Node n)
Get the bound element whose shadow tree a node resides in.- Specified by:
getXblBoundElementin interfaceXBLManager
-
getXblShadowTree
public org.w3c.dom.Element getXblShadowTree(org.w3c.dom.Node n)
Get the shadow tree of a node.- Specified by:
getXblShadowTreein interfaceXBLManager
-
getXblDefinitions
public org.w3c.dom.NodeList getXblDefinitions(org.w3c.dom.Node n)
Get the xbl:definition elements currently binding an element.- Specified by:
getXblDefinitionsin interfaceXBLManager
-
getRecord
protected DefaultXBLManager.XBLRecord getRecord(org.w3c.dom.Node n)
Returns the XBL record for the given node.
-
updateLinks
protected void updateLinks(org.w3c.dom.Node n)
Updates the xblPreviousSibling and xblNextSibling properties of the given XBL node.
-
getXblContentElement
public XBLOMContentElement getXblContentElement(org.w3c.dom.Node n)
Returns the content element that caused the given node to be present in the flattened tree.
-
computeBubbleLimit
public static int computeBubbleLimit(org.w3c.dom.Node from, org.w3c.dom.Node to)Determines the number of nodes events should bubble if the mouse pointer has moved from one element to another.- Parameters:
from- the element from which the mouse pointer movedto- the element to which the mouse pointer moved
-
getContentManager
public ContentManager getContentManager(org.w3c.dom.Node n)
Returns the ContentManager that handles the shadow tree the given node resides in.
-
setContentManager
void setContentManager(org.w3c.dom.Element shadow, ContentManager cm)Records the ContentManager that handles the given shadow tree.
-
invalidateChildNodes
public void invalidateChildNodes(org.w3c.dom.Node n)
Mark the xblChildNodes and xblScopedChildNodes variables as invalid.
-
addContentSelectionChangedListener
public void addContentSelectionChangedListener(ContentSelectionChangedListener l)
Adds the specified ContentSelectionChangedListener to the global listener list.
-
removeContentSelectionChangedListener
public void removeContentSelectionChangedListener(ContentSelectionChangedListener l)
Removes the specified ContentSelectionChangedListener from the global listener list.
-
getContentSelectionChangedListeners
protected java.lang.Object[] getContentSelectionChangedListeners()
Returns an array of the gloabl ContentSelectionChangedListeners.
-
shadowTreeSelectedContentChanged
void shadowTreeSelectedContentChanged(java.util.Set deselected, java.util.Set selected)Called by the ContentManager of a shadow tree to indicate some selected nodes have changed.
-
addBindingListener
public void addBindingListener(BindingListener l)
Adds the specified BindingListener to the global listener list.
-
removeBindingListener
public void removeBindingListener(BindingListener l)
Removes the specified BindingListener from the global listener list.
-
dispatchBindingChangedEvent
protected void dispatchBindingChangedEvent(org.w3c.dom.Element bindableElement, org.w3c.dom.Element shadowTree)Dispatches a BindingEvent the registered listeners.- Parameters:
bindableElement- the bindable element whose binding has changedshadowTree- the new shadow tree of the bindable element
-
isActiveDefinition
protected boolean isActiveDefinition(XBLOMDefinitionElement def, org.w3c.dom.Element imp)
Returns whether the given definition element is the active one for its element name.
-
-