Package org.web3d.x3d.dom.swing
Class DOMTreeNode
java.lang.Object
org.web3d.x3d.dom.swing.DOMTreeNode
- All Implemented Interfaces:
MutableTreeNode
,TreeNode
An implementation of the MutableTreeNode that represents a single DOM node
within a JTree.
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. This class does not add event listeners as it assumes that the TreeModel it is a part of will do that for us.
Our basic assumption is that this tree node is dumb. It only looks after its tree node children. If the DOM node it represents changes underneath it then someone needs to tell it that.
- Version:
- $Revision: 1.3 $
- Author:
- Justin Couch
-
Constructor Summary
ConstructorsConstructorDescriptionDOMTreeNode
(Node node, DOMTreeNode parent) Create an instance of the tree node that represents the given DOM Node. -
Method Summary
Modifier and TypeMethodDescriptionchildren()
Get the list of children of this node as an enumeration.boolean
Check to see if this node allows children.getChildAt
(int index) Get the child at the given index position.int
Get the number of children of this node.int
Get the index of the given tree node.getNode()
Get the DOM node that this tree node represents.Get the parent node of this node.Get the user data stored in this object.void
insert
(MutableTreeNode child, int index) Insert the child at the given position.boolean
isLeaf()
Check to see if this instance is a leaf nodevoid
remove
(int index) Remove the child at the given index position.void
remove
(MutableTreeNode child) Remove the given tree node from the list of children of this node.void
Remove this node from it's parent.void
setParent
(MutableTreeNode parent) Set the parent node of this node to the new value.void
setUserObject
(Object obj) Add some user data to this object.
-
Constructor Details
-
DOMTreeNode
Create an instance of the tree node that represents the given DOM Node. If the node allows events, then this will register itself as a listener.- Parameters:
node
- The DOM node this tree node representsparent
-
-
-
Method Details
-
insert
Insert the child at the given position.- Specified by:
insert
in interfaceMutableTreeNode
- Parameters:
child
- The new child to insertindex
- The position to insert the child into
-
remove
public void remove(int index) Remove the child at the given index position. If there is no child there it will do nothing.- Specified by:
remove
in interfaceMutableTreeNode
- Parameters:
index
-
-
remove
Remove the given tree node from the list of children of this node.- Specified by:
remove
in interfaceMutableTreeNode
- Parameters:
child
- The node to remove
-
removeFromParent
public void removeFromParent()Remove this node from it's parent. If this is the root node then this will ignore the request.- Specified by:
removeFromParent
in interfaceMutableTreeNode
-
setParent
Set the parent node of this node to the new value.- Specified by:
setParent
in interfaceMutableTreeNode
- Parameters:
parent
- The new node to use as a parent
-
setUserObject
Add some user data to this object.- Specified by:
setUserObject
in interfaceMutableTreeNode
- Parameters:
obj
- The data to be stored
-
children
Get the list of children of this node as an enumeration. If the node could have children, but does not at the moment, it will return an empty enumeration. -
getAllowsChildren
public boolean getAllowsChildren()Check to see if this node allows children. For the purposes of the DOM view of the world, a leaf and allowing children are the same thing. We do not consider whether the node is an X3D node type or not.- Specified by:
getAllowsChildren
in interfaceTreeNode
- Returns:
- true if this node allows children
-
getChildAt
Get the child at the given index position. If there is no child there it will return null.- Specified by:
getChildAt
in interfaceTreeNode
- Parameters:
index
- The position to check- Returns:
- The tree node at the index
-
getChildCount
public int getChildCount()Get the number of children of this node. The children count is of the tree node children, not the DOM children. Tree children includes the attributes as well- Specified by:
getChildCount
in interfaceTreeNode
- Returns:
- The number of children of this child
-
getIndex
-
getParent
-
isLeaf
-
getNode
Get the DOM node that this tree node represents. Used by the renderer to build custom information about the node type.- Returns:
- The DOM node
-
getUserData
Get the user data stored in this object.- Returns:
- The currently set user data
-