org.norvelle.textcite.gui.outlook_bar
Class AuthorPubTreeNode

java.lang.Object
  extended by org.norvelle.textcite.gui.outlook_bar.AuthorPubTreeNode
All Implemented Interfaces:
javax.swing.tree.TreeNode

public class AuthorPubTreeNode
extends java.lang.Object
implements javax.swing.tree.TreeNode

AuthorPubTreeNode: A TreeNode implementation that is intelligent about representing Authors and their Publications in tree form.

Author:
Erik Norvelle

Field Summary
protected  java.util.Vector<AuthorPubTreeNode> children
           
protected  CiteBook citebook
           
protected  boolean isRoot
           
protected  AuthorPubTreeModel model
           
protected  AuthorPubTreeNode parent
           
protected  java.lang.Object userData
           
 
Constructor Summary
AuthorPubTreeNode(Author author, AuthorPubTreeNode parent, AuthorPubTreeModel model)
          Calling with an Author produces a node that represents an Author in the tree
AuthorPubTreeNode(AuthorPubTreeModel model)
          Calling with the empty constructor creates a root node
AuthorPubTreeNode(Book book, AuthorPubTreeNode parent, AuthorPubTreeModel model)
          Calling with an Author produces a node that represents an Author in the tree
 
Method Summary
 void addChild(AuthorPubTreeNode child)
          Add a new child to the AuthorPubTreeNode
 java.util.Enumeration<AuthorPubTreeNode> children()
          Return a enumeration of the children
 void destroy()
          Destructor... notify the TreeModel that this node is being eliminated, if necessary.
 boolean getAllowsChildren()
          The root node and Author nodes allow children, but not Books
 javax.swing.tree.TreeNode getChildAt(int pos)
          Return the node at the given position among the children
 int getChildCount()
           
 AuthorPubTreeNode getChildWithUserData(java.lang.Object data)
          Given a particular object of user data, find the child that hosts that data
 int getIndex(javax.swing.tree.TreeNode node)
           
 javax.swing.tree.TreeNode getParent()
           
 java.lang.Object getUserObject()
           
 boolean isAuthor()
           
 boolean isBook()
           
 boolean isLeaf()
           
 boolean isRoot()
           
 void removeChild(AuthorPubTreeNode node)
          Remove a child from the list of children
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

protected AuthorPubTreeNode parent

model

protected AuthorPubTreeModel model

isRoot

protected boolean isRoot

userData

protected java.lang.Object userData

children

protected java.util.Vector<AuthorPubTreeNode> children

citebook

protected CiteBook citebook
Constructor Detail

AuthorPubTreeNode

public AuthorPubTreeNode(AuthorPubTreeModel model)
Calling with the empty constructor creates a root node


AuthorPubTreeNode

public AuthorPubTreeNode(Author author,
                         AuthorPubTreeNode parent,
                         AuthorPubTreeModel model)
Calling with an Author produces a node that represents an Author in the tree


AuthorPubTreeNode

public AuthorPubTreeNode(Book book,
                         AuthorPubTreeNode parent,
                         AuthorPubTreeModel model)
Calling with an Author produces a node that represents an Author in the tree

Method Detail

destroy

public void destroy()
Destructor... notify the TreeModel that this node is being eliminated, if necessary.


removeChild

public void removeChild(AuthorPubTreeNode node)
Remove a child from the list of children

Parameters:
node - The child node to be removed.

addChild

public void addChild(AuthorPubTreeNode child)
Add a new child to the AuthorPubTreeNode


getChildAt

public javax.swing.tree.TreeNode getChildAt(int pos)
Return the node at the given position among the children

Specified by:
getChildAt in interface javax.swing.tree.TreeNode

getChildCount

public int getChildCount()
Specified by:
getChildCount in interface javax.swing.tree.TreeNode
Returns:
The number of children that this AuthorPubTreeNode has

getParent

public javax.swing.tree.TreeNode getParent()
Specified by:
getParent in interface javax.swing.tree.TreeNode
Returns:
The parent of this TreeNode

getIndex

public int getIndex(javax.swing.tree.TreeNode node)
Specified by:
getIndex in interface javax.swing.tree.TreeNode
Returns:
the index of node in the receivers children. If the receiver does not contain node, -1 will be returned.

getAllowsChildren

public boolean getAllowsChildren()
The root node and Author nodes allow children, but not Books

Specified by:
getAllowsChildren in interface javax.swing.tree.TreeNode

isLeaf

public boolean isLeaf()
Specified by:
isLeaf in interface javax.swing.tree.TreeNode
Returns:
true if the node represents a Book, false otherwise

children

public java.util.Enumeration<AuthorPubTreeNode> children()
Return a enumeration of the children

Specified by:
children in interface javax.swing.tree.TreeNode

isRoot

public boolean isRoot()
Returns:
Returns whether this TreeNode is the root of the tree

isAuthor

public boolean isAuthor()

isBook

public boolean isBook()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
The title of the Book or Author contained, or else "Authors" if this is root.

getUserObject

public java.lang.Object getUserObject()

getChildWithUserData

public AuthorPubTreeNode getChildWithUserData(java.lang.Object data)
Given a particular object of user data, find the child that hosts that data

Parameters:
data - A user data object (i.e. an Author or a Book)
Returns:
the AuthorPubTreeNode child that hosts the user data object