|
Xj3D 2.0 VRML/X3D Code API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.web3d.x3d.dom.swing.DOMTreeModel
public class DOMTreeModel
A complex implementation of the TreeModel that is used for dealing with DOM tree in combination with the cell renderer and DOMTreeNode classes.
This implementation is for generic DOM representations. It does not have any X3D specific handling. That is left to derived classes.
The model is specifically tailored to display DOM objects. The model is configured so that it should always ask if it allows children as some DOM nodes cannot have children. If the Document allows events then this will automatically add listeners and build the correct tree as the underlying DOM changes.
Each of the objects represented by this model will be the DOMTreeNode class. Building of these objects is lazy for memory consumption purposes. We do not build the child DOMTreeNode object until we have to.
The tree will also show attribute information as nodes in the tree. In order to maintain consistency, we will need to make sure that the indexes are always in the same order. To do this, we always put the attributes first and follow with child nodes.
To keep itself consistent, we only register a listener at the root of the document. This is for node add, remove and attribute modified. Because events bubble for these types, there is no need to register an event listener on every single node instance. We just listen at the document root for the events that bubble up to us.
| Constructor Summary | |
|---|---|
DOMTreeModel(org.w3c.dom.Node root)
Create a new tree model that represents the given document root. |
|
| Method Summary | |
|---|---|
void |
addTreeModelListener(javax.swing.event.TreeModelListener l)
Add a tree listener to this model. |
java.lang.Object |
getChild(java.lang.Object parent,
int index)
Get the child of the given parent at that index. |
int |
getChildCount(java.lang.Object parent)
Get the number of children the given parent contains. |
int |
getIndexOfChild(java.lang.Object parent,
java.lang.Object child)
Get the index of the given child in the parent node. |
java.lang.Object |
getRoot()
Get the object that represents the root of this tree model. |
void |
handleEvent(org.w3c.dom.events.Event evt)
Handle an incoming event. |
boolean |
isLeaf(java.lang.Object child)
Check to see if the given node is a leaf node. |
void |
removeTreeModelListener(javax.swing.event.TreeModelListener l)
Remove the tree listener from this model. |
void |
valueForPathChanged(javax.swing.tree.TreePath path,
java.lang.Object value)
Notification that the UI has changed the value to the destination object to the new value. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DOMTreeModel(org.w3c.dom.Node root)
root - The DOM node representing the root of the tree| Method Detail |
|---|
public java.lang.Object getChild(java.lang.Object parent,
int index)
getChild in interface javax.swing.tree.TreeModelparent - The parent node to askindex - The position to get the child for
public int getChildCount(java.lang.Object parent)
getChildCount in interface javax.swing.tree.TreeModelparent - The parent to quiz for the number of children
public int getIndexOfChild(java.lang.Object parent,
java.lang.Object child)
getIndexOfChild in interface javax.swing.tree.TreeModelparent - The parent node to check forchild - The child to find the index of
public java.lang.Object getRoot()
getRoot in interface javax.swing.tree.TreeModelpublic boolean isLeaf(java.lang.Object child)
isLeaf in interface javax.swing.tree.TreeModelchild - The child node to check
public void valueForPathChanged(javax.swing.tree.TreePath path,
java.lang.Object value)
valueForPathChanged in interface javax.swing.tree.TreeModelpath - The path to the object that changedvalue - The new value for the Nodepublic void addTreeModelListener(javax.swing.event.TreeModelListener l)
addTreeModelListener in interface javax.swing.tree.TreeModell - The listener to be addedpublic void removeTreeModelListener(javax.swing.event.TreeModelListener l)
removeTreeModelListener in interface javax.swing.tree.TreeModell - The listener to be removedpublic void handleEvent(org.w3c.dom.events.Event evt)
handleEvent in interface org.w3c.dom.events.EventListenerevt - The event to be processed
|
Xj3D 2.0 VRML/X3D Code API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||