instrument/JTree API Documentation

org.pvv.bcd.instrument.JTree
Class DefaultNodeFactory

java.lang.Object
  |
  +--org.pvv.bcd.instrument.JTree.DefaultNodeFactory
All Implemented Interfaces:
NodeFactory, UserObjectFactory, XmlNodeFactory

public class DefaultNodeFactory
extends java.lang.Object
implements NodeFactory, XmlNodeFactory, UserObjectFactory

The default node factory will create DefaultMutableTreeNode type nodes with DefaultNodeInfo type user objects.

See Also:
DefaultNodeInfo, DefaultMutableTreeNode

Constructor Summary
DefaultNodeFactory()
          Default constructor, doesn't do anything.
 
Method Summary
 javax.swing.tree.TreeNode cloneNode(javax.swing.tree.TreeNode node)
          Will clone a node.
 javax.swing.tree.TreeNode createNode(java.lang.Object ob)
          Will create a new node with a given user object.
 javax.swing.tree.TreeNode createNode(java.lang.String title, java.lang.String contents)
          Will create a new node based on XML data.
 javax.swing.tree.TreeNode createNode(javax.swing.tree.TreeNode parent)
          Will create a default empty node.
 java.awt.datatransfer.Transferable createTransferable(java.lang.Object[] nodes, DndId dndId)
          Will create and return a suitable Transferable carrying data for multiple nodes.
 java.awt.datatransfer.Transferable createTransferable(java.lang.Object node, DndId dndId)
          Will create and return a suitable Transferable carrying data for one node.
 void setUserObjectTitle(java.lang.Object userobject, java.lang.String title)
          Sets the displayable title of a node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultNodeFactory

public DefaultNodeFactory()
Default constructor, doesn't do anything.
Method Detail

cloneNode

public javax.swing.tree.TreeNode cloneNode(javax.swing.tree.TreeNode node)
Will clone a node. This is not accomplished by calling clone() on the node. Rather, we use our own logic for achieving this. If the node to be cloned is of type DefaultMutableTreeNode, the new node will copy the user object also. If the user object is Copyable, a new object is created by calling its copy() method. If it is not, the new node will have the exact same user object as the original. Calls createNode() to achieve this.
Specified by:
cloneNode in interface NodeFactory
Parameters:
node - Node to clone
Returns:
Newly created node
See Also:
createNode(Object)

createNode

public javax.swing.tree.TreeNode createNode(javax.swing.tree.TreeNode parent)
Will create a default empty node. In the default implementaiton, this is a node with a default DefaultNodeInfo object as its user object.
Specified by:
createNode in interface NodeFactory
Parameters:
parent - Parent of the new node to create, not used in the default implementation
Returns:
Newly created node. The default implementation will return a DefaultMutableTreeNode
See Also:
createNode(Object), createNode(String, String)

createNode

public javax.swing.tree.TreeNode createNode(java.lang.Object ob)
Will create a new node with a given user object.
Specified by:
createNode in interface NodeFactory
Parameters:
ob - User object to insert into node
Returns:
Newly created node. The default implementation will return a DefaultMutableTreeNode
See Also:
createNode(String, String), createNode(TreeNode)

createNode

public javax.swing.tree.TreeNode createNode(java.lang.String title,
                                            java.lang.String contents)
Will create a new node based on XML data. Uses
Specified by:
createNode in interface NodeFactory
Parameters:
title - Title of new node
contents - Textual contents of new node
Returns:
Newly created node. The default implementation will return a DefaultMutableTreeNode
See Also:
createNode(Object), createNode(TreeNode)

setUserObjectTitle

public void setUserObjectTitle(java.lang.Object userobject,
                               java.lang.String title)
Sets the displayable title of a node. Typically called when the user changes the node title by use of a CellEditor or similar.
Specified by:
setUserObjectTitle in interface UserObjectFactory
Parameters:
userobject - Node to set title on. The default implementation expects this to be a DefaultNodeInfo type object.
title - New title to set on the node.

createTransferable

public java.awt.datatransfer.Transferable createTransferable(java.lang.Object node,
                                                             DndId dndId)
                                                      throws org.pvv.bcd.Util.FeatureNotSupportedException
Will create and return a suitable Transferable carrying data for one node.
Specified by:
createTransferable in interface NodeFactory
Parameters:
node - Node to create a Transferable for. The default implementation expects this to be a DefaultMutableTreeNode.
Unique - DND id associated with this transfer.
Returns:
A Transferable suitable for transferring the given node data. The default implementation will return a DefaultTransferable.
Throws:
org.pvv.bcd.Util.FeatureNotSupportedException - if data transfer is not supported by this node factory.
See Also:
createTransferable(Object[], DndId), DefaultTransferable

createTransferable

public java.awt.datatransfer.Transferable createTransferable(java.lang.Object[] nodes,
                                                             DndId dndId)
                                                      throws org.pvv.bcd.Util.FeatureNotSupportedException
Will create and return a suitable Transferable carrying data for multiple nodes.
Specified by:
createTransferable in interface NodeFactory
Parameters:
nodes - Nodes to create a Transferable for. The default implementation expects these to be DefaultMutableTreeNode.
Unique - DND id associated with this transfer.
Returns:
A Transferable suitable for transferring the given node data. The default implementation will return a DefaultTransferable.
Throws:
org.pvv.bcd.Util.FeatureNotSupportedException - if data transfer is not supported by this node factory.
See Also:
createTransferable(Object, DndId), DefaultTransferable

instrument/JTree API Documentation