com.jgraph.graph
Class DefaultGraphCell

java.lang.Object
  extended byjavax.swing.tree.DefaultMutableTreeNode
      extended bycom.jgraph.graph.DefaultGraphCell
All Implemented Interfaces:
java.lang.Cloneable, GraphCell, javax.swing.tree.MutableTreeNode, java.io.Serializable, javax.swing.tree.TreeNode
Direct Known Subclasses:
DefaultEdge, DefaultPort

public class DefaultGraphCell
extends javax.swing.tree.DefaultMutableTreeNode
implements GraphCell, java.lang.Cloneable

The default implementation for the GraphCell interface.

See Also:
Serialized Form

Nested Class Summary
static interface DefaultGraphCell.ValueChangeHandler
           
 
Field Summary
protected  java.util.Map attributes
          Hashtable for properties.
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
DefaultGraphCell()
          Creates an empty cell.
DefaultGraphCell(java.lang.Object userObject)
          Creates a graph cell and initializes it with the specified user object.
DefaultGraphCell(java.lang.Object userObject, boolean allowsChildren)
          Creates a graph cell and initializes it with the specified user object.
DefaultGraphCell(java.lang.Object userObject, javax.swing.tree.MutableTreeNode[] children)
          Constructs a cell that holds a reference to the specified user object and contains the specified array of children.
 
Method Summary
 java.lang.Object clone()
          Create a clone of the cell.
protected  java.lang.Object cloneUserObject()
          Create a clone of the user object.
 java.util.Map getAttributes()
          Returns the properies of the cell.
 java.util.List getChildren()
          Provides access to the children list to change ordering.
 void setAttributes(java.util.Map change)
          Apply change to the cell and sync userObject.
 void setUserObject(java.lang.Object obj)
          Override parent method to synchronize value property and userObject.
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, 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, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

attributes

protected java.util.Map attributes
Hashtable for properties. Initially empty

Constructor Detail

DefaultGraphCell

public DefaultGraphCell()
Creates an empty cell.


DefaultGraphCell

public DefaultGraphCell(java.lang.Object userObject)
Creates a graph cell and initializes it with the specified user object.

Parameters:
userObject - an Object provided by the user that constitutes the cell's data

DefaultGraphCell

public DefaultGraphCell(java.lang.Object userObject,
                        javax.swing.tree.MutableTreeNode[] children)
Constructs a cell that holds a reference to the specified user object and contains the specified array of children.

Parameters:
userObject - reference to the user object
children - array of children

DefaultGraphCell

public DefaultGraphCell(java.lang.Object userObject,
                        boolean allowsChildren)
Creates a graph cell and initializes it with the specified user object. The GraphCell allows children only if specified.

Parameters:
userObject - an Object provided by the user that constitutes the cell's data
Method Detail

setUserObject

public void setUserObject(java.lang.Object obj)
Override parent method to synchronize value property and userObject. The following holds for each GraphCell c:

GraphConstants.getValue(c.getAttributes()) == c.getUserObject()

Note: A cell's userObject can be set using GraphModel.edit() with a propertyMap that carries a value entry for that cell.

Specified by:
setUserObject in interface javax.swing.tree.MutableTreeNode

getChildren

public java.util.List getChildren()
Provides access to the children list to change ordering. This method returns a Collections.EMPTY_LIST if the list of children points to null.


getAttributes

public java.util.Map getAttributes()
Returns the properies of the cell.

Specified by:
getAttributes in interface GraphCell

setAttributes

public void setAttributes(java.util.Map change)
Apply change to the cell and sync userObject.

Specified by:
setAttributes in interface GraphCell

clone

public java.lang.Object clone()
Create a clone of the cell. The cloning of the user object is deferred to the cloneUserObject() method.

Returns:
Object a clone of this object.

cloneUserObject

protected java.lang.Object cloneUserObject()
Create a clone of the user object. This is provided for subclassers who need special cloning. This implementation simply returns a reference to the original user object.

Returns:
Object a clone of this cells user object.