com.jgoodies.skeleton.model.node
Class AbstractTreeNode

java.lang.Object
  extended by com.jgoodies.skeleton.model.node.AbstractTreeNode
All Implemented Interfaces:
NavigationNode, TreeNode
Direct Known Subclasses:
DescriptionNode, FlangeNode, RootNode, SegmentNode, ShaftNode

public abstract class AbstractTreeNode
extends Object
implements NavigationNode

The abstract superclass for all tree node classes in Skeleton (Pro).

Version:
$Revision: 1.5 $
Author:
Karsten Lentzsch

Constructor Summary
AbstractTreeNode(NavigationNode parent, Object model)
          Constructs a tree node for the given parent and model.
 
Method Summary
 void add(NavigationNode child)
          Adds the given child to the list of this node's children.
 Enumeration children()
          Returns the children of the receiver as an Enumeration.
 boolean getAllowsChildren()
          Returns true if the receiver allows children.
 TreeNode getChildAt(int childIndex)
          Returns the child TreeNode at index childIndex.
 int getChildCount()
          Returns the number of children TreeNodes the receiver contains.
 Icon getIcon(boolean selected)
          Returns this node's icon for the given selection state.
 int getIndex(TreeNode node)
          Returns the index of node in the receivers children.
 Object getModel()
          Returns this node's model.
abstract  String getName()
          Returns this node's name.
 TreeNode getParent()
          Returns the parent TreeNode of the receiver.
 boolean isLeaf()
          Returns true if the receiver is a leaf.
 String toString()
          Returns a string representation for this node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractTreeNode

public AbstractTreeNode(NavigationNode parent,
                        Object model)
Constructs a tree node for the given parent and model.

Parameters:
parent - this node's parent
model - the domain object associated with this node
Method Detail

getAllowsChildren

public boolean getAllowsChildren()
Returns true if the receiver allows children.

Specified by:
getAllowsChildren in interface TreeNode
Returns:
true if the receiver allows children

getChildAt

public TreeNode getChildAt(int childIndex)
Returns the child TreeNode at index childIndex.

Specified by:
getChildAt in interface TreeNode
Returns:
the child at the specified index

getChildCount

public int getChildCount()
Returns the number of children TreeNodes the receiver contains.

Specified by:
getChildCount in interface TreeNode
Returns:
the number of children

children

public Enumeration children()
Returns the children of the receiver as an Enumeration.

Specified by:
children in interface TreeNode
Returns:
the children of the receiver as an Enumeration.

getIndex

public int getIndex(TreeNode node)
Returns the index of node in the receivers children. If the receiver does not contain node, -1 will be returned.

Specified by:
getIndex in interface TreeNode
Returns:
the index of the given node, or -1 if it is not a child

getParent

public TreeNode getParent()
Returns the parent TreeNode of the receiver.

Specified by:
getParent in interface TreeNode
Returns:
the parent TreeNode of the receiver.

isLeaf

public boolean isLeaf()
Returns true if the receiver is a leaf.

Specified by:
isLeaf in interface TreeNode
Returns:
true if the receiver is a leaf.

getName

public abstract String getName()
Returns this node's name. Subclasses typically implement this method by returning the model's name or identifier.

Specified by:
getName in interface NavigationNode
Returns:
this node's name

getIcon

public Icon getIcon(boolean selected)
Returns this node's icon for the given selection state.

Specified by:
getIcon in interface NavigationNode
Parameters:
selected - true for selected node, false for deselected
Returns:
this node's icon for the given selection state

getModel

public Object getModel()
Returns this node's model. Subclasses may provide a type-safe method with a more specific return type that is the model's class. For example, the FlangeNode may implement getFlange.

Specified by:
getModel in interface NavigationNode
Returns:
this node's model

add

public void add(NavigationNode child)
Adds the given child to the list of this node's children.

Parameters:
child - the node to add as this node's child

toString

public String toString()
Returns a string representation for this node. Currently it prints the class info and node name.

Overrides:
toString in class Object
Returns:
a string representation for this node


Copyright © 2002-2008 JGoodies Karsten Lentzsch. All Rights Reserved.