Package adams.gui.core
Class BaseTreeNode
- java.lang.Object
-
- javax.swing.tree.DefaultMutableTreeNode
-
- adams.gui.core.BaseTreeNode
-
- All Implemented Interfaces:
Transferable
,Serializable
,Cloneable
,MutableTreeNode
,TreeNode
- Direct Known Subclasses:
AbstractInfoNode
,DOMNode
,DotNotationNode
,JsonNode
,LazyExpansionTreeNode
,Node
public class BaseTreeNode extends DefaultMutableTreeNode implements Transferable
TreeNode used by the BasicTree component. Implements the "Transferable" interface for simple drag'n'drop support of strings.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
-
-
Constructor Summary
Constructors Constructor Description BaseTreeNode()
Creates a tree node that has no parent and no children, but which allows children.BaseTreeNode(Object userObject)
Creates a tree node with no parent, no children, but which allows children, and initializes it with the specified user object.BaseTreeNode(Object userObject, boolean allowsChildren)
Creates a tree node with no parent, no children, initialized with the specified user object, and that allows children only if specified.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<BaseTreeNode>
getChildren()
Returns the children as list.Object
getTransferData(DataFlavor flavor)
Returns an object which represents the data to be transferred.DataFlavor[]
getTransferDataFlavors()
Returns an array of DataFlavor objects indicating the flavors the data can be provided in.boolean
isDataFlavorSupported(DataFlavor flavor)
Returns whether or not the specified data flavor is supported for this object.String
toPlainText()
Returns the plain text representation of this node.Transferable
toTransferable()
Turns the node/userObject into a transferable string.-
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject, toString
-
-
-
-
Constructor Detail
-
BaseTreeNode
public BaseTreeNode()
Creates a tree node that has no parent and no children, but which allows children.
-
BaseTreeNode
public BaseTreeNode(Object userObject)
Creates a tree node with no parent, no children, but which allows children, and initializes it with the specified user object.- Parameters:
userObject
- an Object provided by the user that constitutes the node's data
-
BaseTreeNode
public BaseTreeNode(Object userObject, boolean allowsChildren)
Creates a tree node with no parent, no children, initialized with the specified user object, and that allows children only if specified.- Parameters:
userObject
- an Object provided by the user that constitutes the node's dataallowsChildren
- if true, the node is allowed to have child nodes -- otherwise, it is always a leaf node
-
-
Method Detail
-
toTransferable
public Transferable toTransferable()
Turns the node/userObject into a transferable string.- Returns:
- the generated string
-
getTransferDataFlavors
public DataFlavor[] getTransferDataFlavors()
Returns an array of DataFlavor objects indicating the flavors the data can be provided in. The array should be ordered according to preference for providing the data (from most richly descriptive to least descriptive).- Specified by:
getTransferDataFlavors
in interfaceTransferable
- Returns:
- an array of data flavors in which this data can be transferred
-
isDataFlavorSupported
public boolean isDataFlavorSupported(DataFlavor flavor)
Returns whether or not the specified data flavor is supported for this object.- Specified by:
isDataFlavorSupported
in interfaceTransferable
- Parameters:
flavor
- the requested flavor for the data- Returns:
- boolean indicating whether or not the data flavor is supported
-
getTransferData
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException
Returns an object which represents the data to be transferred. The class of the object returned is defined by the representation class of the flavor.- Specified by:
getTransferData
in interfaceTransferable
- Parameters:
flavor
- the requested flavor for the data- Returns:
- the transferable data
- Throws:
IOException
- if the data is no longer available in the requested flavor.UnsupportedFlavorException
- if the requested data flavor is not supported.- See Also:
DataFlavor.getRepresentationClass()
-
toPlainText
public String toPlainText()
Returns the plain text representation of this node.
Default implementation simply returnsDefaultMutableTreeNode.toString()
.- Returns:
- the string representation
-
getChildren
public List<BaseTreeNode> getChildren()
Returns the children as list.- Returns:
- the children as list
-
-