JGraph
v5.1


org.jgraph.graph
Class DefaultGraphCell

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

public class DefaultGraphCell
extends DefaultMutableTreeNode
implements GraphCell, Cloneable

The default implementation for the GraphCell interface.

See Also:
Serialized Form

Field Summary
protected  AttributeMap attributes
          Hashtable for properties.
static Rectangle defaultBounds
           
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
DefaultGraphCell()
          Creates an empty cell.
DefaultGraphCell(Object userObject)
          Creates a graph cell and initializes it with the specified user object.
DefaultGraphCell(Object userObject, boolean allowsChildren)
          Creates a graph cell and initializes it with the specified user object.
DefaultGraphCell(Object userObject, MutableTreeNode[] children)
          Constructs a cell that holds a reference to the specified user object and contains the specified array of children and sets default values for the bounds attribute.
 
Method Summary
 Map changeAttributes(Map change)
          Apply change to the cell and sync userObject.
 Object clone()
          Create a clone of the cell.
 AttributeMap getAttributes()
          Returns the properies of the cell.
 List getChildren()
          Provides access to the children list to change ordering.
 void setAttributes(AttributeMap attributes)
          Sets the attributes.
 void setUserObject(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

defaultBounds

public static final Rectangle defaultBounds

attributes

protected AttributeMap attributes
Hashtable for properties. Initially empty

Constructor Detail

DefaultGraphCell

public DefaultGraphCell()
Creates an empty cell.


DefaultGraphCell

public DefaultGraphCell(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(Object userObject,
                        MutableTreeNode[] children)
Constructs a cell that holds a reference to the specified user object and contains the specified array of children and sets default values for the bounds attribute.

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

DefaultGraphCell

public DefaultGraphCell(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(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 MutableTreeNode
Overrides:
setUserObject in class DefaultMutableTreeNode

getChildren

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


getAttributes

public AttributeMap getAttributes()
Returns the properies of the cell.

Specified by:
getAttributes in interface GraphCell

changeAttributes

public Map changeAttributes(Map change)
Apply change to the cell and sync userObject.

Specified by:
changeAttributes in interface GraphCell

setAttributes

public void setAttributes(AttributeMap attributes)
Sets the attributes.

Specified by:
setAttributes in interface GraphCell
Parameters:
attributes - The attributes to set

clone

public Object clone()
Create a clone of the cell. This method uses the superclass implementation (which does not clone the children), then uses clone on the attribute map, and overrides the clone's user object with the value in the cloned attribute map.

Overrides:
clone in class DefaultMutableTreeNode
Returns:
Object a clone of this object.

JGraph
v5.1


Copyright (C) 2001-2004 Gaudenz Alder. All rights reserved.