org.jgraph.graph

Class DefaultGraphCell

public class DefaultGraphCell extends DefaultMutableTreeNode implements GraphCell, Cloneable

The default implementation for the GraphCell interface.
Field Summary
protected AttributeMapattributes
Hashtable for properties.
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, AttributeMap storageMap)
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.
DefaultGraphCell(Object userObject, AttributeMap storageMap, MutableTreeNode[] children)
Creates a graph cell and initializes it with the specified user object.
Method Summary
ObjectaddPort()
Utility method to create a port for this cell.
ObjectaddPort(Point2D offset)
Utility method to create a port for this cell.
ObjectaddPort(Point2D offset, Object userObject)
Utility method to create a port for this cell.
MapchangeAttributes(Map change)
Changes the attributes of the cell.
Objectclone()
Create a clone of the cell.
AttributeMapgetAttributes()
Returns the properies of the cell.
ListgetChildren()
Provides access to the children list to change ordering.
voidsetAttributes(AttributeMap attributes)
Sets the attributes.

Field Detail

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, AttributeMap storageMap)
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 storageMap the storage attribute map for this cell

DefaultGraphCell

public DefaultGraphCell(Object userObject, AttributeMap storageMap, MutableTreeNode[] children)
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 storageMap the storage attribute map for this cell children array of children

Method Detail

addPort

public Object addPort()
Utility method to create a port for this cell. This method adds a floating port.

Returns: the port created

addPort

public Object addPort(Point2D offset)
Utility method to create a port for this cell. The method adds a port at a fixed relative offset within the cell. If the offset is null then a floating port is added.

Parameters: offset the offset of the port within the cell

Returns: the port created

addPort

public Object addPort(Point2D offset, Object userObject)
Utility method to create a port for this cell. The method adds a port at a fixed relative offset within the cell. If the offset is null then a floating port is added.

Parameters: offset the offset of the port within the cell userObject the user object of the port cell

Returns: the port created

changeAttributes

public Map changeAttributes(Map change)

Deprecated: Use getAttributes().applyMap

Changes the attributes of the cell.

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. This method does not clone the user object. You should override the cloneUserObject in the graph model to implement cloning of custom user objects.

Returns: Object a clone of this object.

getAttributes

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

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.

setAttributes

public void setAttributes(AttributeMap attributes)
Sets the attributes.

Parameters: attributes The attributes to set

Copyright (C) 2001-2009 JGraph Ltd. All rights reserved.