eu.beesoft.gantt.treetable
Class GanttNode

java.lang.Object
  extended by javax.swing.tree.DefaultMutableTreeNode
      extended by eu.beesoft.gaia.swing.ExplorableTreeNode
          extended by eu.beesoft.gaia.swing.TreeTableNode
              extended by eu.beesoft.gantt.treetable.GanttNode
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.tree.MutableTreeNode, javax.swing.tree.TreeNode, javax.swing.undo.StateEditable

public final class GanttNode
extends TreeTableNode
implements javax.swing.undo.StateEditable, java.beans.PropertyChangeListener

A GanttNode is a general-purpose node in a gantt tree data structure.

A TimelineObject is used as an user object in tree node. Each user object must implement this interface.

Instances of GanttNode are exploited by ChartComponent and Layer instances for painting. These methods are designated for this purpose:

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, EMPTY_ENUMERATION, children, parent, userObject
 
Fields inherited from interface javax.swing.undo.StateEditable
RCSID
 
Constructor Summary
GanttNode(GanttModel model, TimelineObject userObject)
          Creates new instance of GanttNode.
 
Method Summary
 void add(javax.swing.tree.MutableTreeNode child)
          Adds given child to node children.
protected  void exploreImpl()
          Implementation of method exploreImpl() from TreeTableNode.
 java.awt.Rectangle getBounds()
          Returns bounds of this node in ChartComponent coordinates.
 GanttModel getModel()
          Returns instance of GanttModel to which this node belongs.
 TimelineObject getTimelineObject()
          Returns user object from this node.
 java.lang.Object getValueAt(int column)
          Returns value for given column.
 void insert(javax.swing.tree.MutableTreeNode child, int index)
          Inserts given child into a node children.
 boolean isVisible()
          Returns visibility state of this node.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Implementation of PropertyChangeListener interface.
 void remove(int childIndex)
          Removes the child at the specified index from this node's children and sets that node's parent to null.
 void remove(javax.swing.tree.MutableTreeNode aChild)
          Removes aChild from this node's child array, giving it a null parent.
 void removeAllChildren()
          Removes all of this node's children, setting their parents to null.
 void restoreState(java.util.Hashtable<?,?> state)
          Extracts any relevant state out of state.
 void setTimelineObject(TimelineObject object)
          Sets user object for this node.
 void setUserObject(java.lang.Object object)
          Sets user object for this node.
 void setVisible(boolean isVisible)
          Sets value for the isVisible property.
 void storeState(java.util.Hashtable<java.lang.Object,java.lang.Object> state)
          Places any relevant state into a state.
 
Methods inherited from class eu.beesoft.gaia.swing.TreeTableNode
setValueAt, toString
 
Methods inherited from class eu.beesoft.gaia.swing.ExplorableTreeNode
explore, getAllowsChildren, isExplorable, isExplored, isLeaf, setExplorable
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
breadthFirstEnumeration, clone, depthFirstEnumeration, getDepth, getFirstChild, getFirstLeaf, getChildAfter, getChildAt, getChildBefore, getChildCount, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, children, isNodeAncestor, isNodeDescendant, isNodeChild, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, removeFromParent, setAllowsChildren, setParent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GanttNode

public GanttNode(GanttModel model,
                 TimelineObject userObject)
Creates new instance of GanttNode.

Parameters:
model - Model to which this node belongs
userObject -
Method Detail

getModel

public GanttModel getModel()
Returns instance of GanttModel to which this node belongs.

Returns:
model to which belongs this node

setUserObject

public void setUserObject(java.lang.Object object)
Sets user object for this node. As user object you can use an instance of TimelineObject only.

Specified by:
setUserObject in interface javax.swing.tree.MutableTreeNode
Overrides:
setUserObject in class javax.swing.tree.DefaultMutableTreeNode
Parameters:
object - new user object for node

getTimelineObject

public TimelineObject getTimelineObject()
Returns user object from this node.

Returns:
user object of this node

setTimelineObject

public void setTimelineObject(TimelineObject object)
Sets user object for this node.

Parameters:
object - new user object for node

add

public void add(javax.swing.tree.MutableTreeNode child)
Adds given child to node children. Simply calls super.add() and then updates ChartComponent.

Overrides:
add in class javax.swing.tree.DefaultMutableTreeNode
Parameters:
child - Node to add. This node can be instance of GanttNode only.

insert

public void insert(javax.swing.tree.MutableTreeNode child,
                   int index)
Inserts given child into a node children. Simply calls super.insert() and then updates ChartComponent.

Specified by:
insert in interface javax.swing.tree.MutableTreeNode
Overrides:
insert in class javax.swing.tree.DefaultMutableTreeNode
Parameters:
child - Node to insert. This node can be instance of GanttNode only.
index - the index in this node's child array where this node is to be inserted

remove

public void remove(int childIndex)
Removes the child at the specified index from this node's children and sets that node's parent to null. Calls super.remove() and then updates ChartComponent.

Specified by:
remove in interface javax.swing.tree.MutableTreeNode
Overrides:
remove in class javax.swing.tree.DefaultMutableTreeNode
Parameters:
childIndex - the index in this node's child array of the child to remove

remove

public void remove(javax.swing.tree.MutableTreeNode aChild)
Removes aChild from this node's child array, giving it a null parent. Calls super.remove() and then updates ChartComponent.

Specified by:
remove in interface javax.swing.tree.MutableTreeNode
Overrides:
remove in class javax.swing.tree.DefaultMutableTreeNode
Parameters:
aChild - a child of this node to remove

removeAllChildren

public void removeAllChildren()
Removes all of this node's children, setting their parents to null. If this node has no children, this method does nothing. Calls super.removeAllChildren() and then updates ChartComponent.

Overrides:
removeAllChildren in class javax.swing.tree.DefaultMutableTreeNode

getValueAt

public java.lang.Object getValueAt(int column)
Returns value for given column. Implementation of method getValueAt() from TreeTableNode. Redirects to method getValueAt() in GanttModel.

Specified by:
getValueAt in class TreeTableNode
Parameters:
column - the column whose value is to be queried
Returns:
the value for specified column

exploreImpl

protected void exploreImpl()
Implementation of method exploreImpl() from TreeTableNode. Redirects to method explore() in GanttModel.

Specified by:
exploreImpl in class ExplorableTreeNode

getBounds

public java.awt.Rectangle getBounds()
Returns bounds of this node in ChartComponent coordinates. This method should be called from Layer instances only.

Returns:
bounds of this node for ChartComponent

isVisible

public boolean isVisible()
Returns visibility state of this node. Node is visible, if its parent is expanded.

Returns:
value of isVisible property

setVisible

public void setVisible(boolean isVisible)
Sets value for the isVisible property. Don't call this method directly, it is called from ChartComponent only.

Parameters:
isVisible - new value for the isVisible property

restoreState

public void restoreState(java.util.Hashtable<?,?> state)
Extracts any relevant state out of state. Implementation of StateEditable interface for undo / redo functionality.

Specified by:
restoreState in interface javax.swing.undo.StateEditable
Parameters:
state - Hashtable with values for restore

storeState

public void storeState(java.util.Hashtable<java.lang.Object,java.lang.Object> state)
Places any relevant state into a state. Implementation of StateEditable interface for undo / redo functionality.

Specified by:
storeState in interface javax.swing.undo.StateEditable
Parameters:
state - Hashtable to store valuess

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Implementation of PropertyChangeListener interface. Notifies GanttModel about change in user object.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener