mxGraph 1.10.2.0


com.mxgraph.model
Class mxCell

java.lang.Object
  extended by com.mxgraph.model.mxCell
All Implemented Interfaces:
mxICell, Serializable, Cloneable

public class mxCell
extends Object
implements mxICell, Cloneable, Serializable

Cells are the elements of the graph model. They represent the state of the groups, vertices and edges in a graph.

Edge Labels

Using the x- and y-coordinates of a cell's geometry it is possible to position the label on edges on a specific location on the actual edge shape as it appears on the screen. The x-coordinate of an edge's geometry is used to describe the distance from the center of the edge from -1 to 1 with 0 being the center of the edge and the default value. The y-coordinate of an edge's geometry is used to describe the absolute, orthogonal distance in pixels from that point. In addition, the mxGeometry.offset is used as a absolute offset vector from the resulting point. The width and height of an edge geometry are ignored. To add more than one edge label, add a child vertex with a relative geometry. The x- and y-coordinates of that geometry will have the same semantiv as the above for edge labels.

See Also:
Serialized Form

Field Summary
protected  List<Object> children
          Holds the child cells and connected edges.
protected  boolean collapsed
          Specifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed.
protected  boolean connectable
          Specifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed.
protected  boolean edge
          Specifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed.
protected  List<Object> edges
          Holds the child cells and connected edges.
protected  mxGeometry geometry
          Holds the geometry.
protected  String id
          Holds the Id.
protected  mxICell parent
          Reference to the parent cell and source and target terminals for edges.
protected  mxICell source
          Reference to the parent cell and source and target terminals for edges.
protected  String style
          Holds the style as a string of the form stylename[;key=value].
protected  mxICell target
          Reference to the parent cell and source and target terminals for edges.
protected  Object value
          Holds the user object.
protected  boolean vertex
          Specifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed.
protected  boolean visible
          Specifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed.
 
Constructor Summary
mxCell()
          Constructs a new cell with an empty user object.
mxCell(Object value)
          Constructs a new cell for the given user object.
mxCell(Object value, mxGeometry geometry, String style)
          Constructs a new cell for the given parameters.
 
Method Summary
 Object clone()
          Returns a clone of the cell.
protected  Object cloneValue()
          Returns a clone of the user object.
 String getAttribute(String name)
          Returns the specified attribute from the user object if it is an XML node.
 String getAttribute(String name, String defaultValue)
          Returns the specified attribute from the user object if it is an XML node.
 mxICell getChildAt(int index)
          Returns the child at the specified index.
 int getChildCount()
          Returns the number of child cells.
 mxICell getEdgeAt(int index)
          Returns the edge at the specified index in the edge array.
 int getEdgeCount()
          Returns the number of edges in the edge array.
 int getEdgeIndex(mxICell edge)
          Returns the index of the specified edge in the edge array.
 mxGeometry getGeometry()
          Returns the object that describes the geometry.
 String getId()
          Returns the Id of the cell as a string.
 int getIndex(mxICell child)
          Returns the index of the specified child in the child array.
 mxICell getParent()
          Returns the cell's parent.
 mxICell getSource()
          Returns the source terminal.
 String getStyle()
          Returns the string that describes the style.
 mxICell getTarget()
          Returns the target terminal.
 mxICell getTerminal(boolean source)
          Returns the source or target terminal.
 Object getValue()
          Returns the user object of the cell.
 mxICell insert(mxICell child)
          Appends the specified child into the child array and updates the parent reference of the child.
 mxICell insert(mxICell child, int index)
          Inserts the specified child into the child array at the specified index and updates the parent reference of the child.
 mxICell insertEdge(mxICell edge, boolean isOutgoing)
          Inserts the specified edge into the edge array and returns the edge.
 boolean isCollapsed()
          Returns true if the cell is collapsed.
 boolean isConnectable()
          Returns true if the cell is connectable.
 boolean isEdge()
          Returns true if the cell is an edge.
 boolean isVertex()
          Returns true if the cell is a vertex.
 boolean isVisible()
          Returns true if the cell is visibile.
 mxICell remove(int index)
          Removes the child at the specified index from the child array and returns the child that was removed.
 mxICell remove(mxICell child)
          Removes the given child from the child array and returns it.
 mxICell removeEdge(mxICell edge, boolean isOutgoing)
          Removes the specified edge from the edge array and returns the edge.
 void removeFromParent()
          Removes the cell from its parent.
 void removeFromTerminal(boolean isSource)
          Removes the edge from its source or target terminal.
 void setAttribute(String name, String value)
          Sets the specified attribute on the user object if it is an XML node.
 void setCollapsed(boolean collapsed)
          Sets the collapsed state.
 void setConnectable(boolean connectable)
           
 void setEdge(boolean edge)
           
 void setGeometry(mxGeometry geometry)
          Sets the object to be used as the geometry.
 void setId(String id)
          Sets the Id of the cell to the given string.
 void setParent(mxICell parent)
          Sets the parent cell.
 void setSource(mxICell source)
          Sets the source terminal.
 void setStyle(String style)
          Sets the string to be used as the style.
 void setTarget(mxICell target)
          Sets the target terminal.
 mxICell setTerminal(mxICell terminal, boolean isSource)
          Sets the source or target terminal and returns the new terminal.
 void setValue(Object value)
          Sets the user object of the cell.
 void setVertex(boolean vertex)
           
 void setVisible(boolean visible)
          Specifies if the cell is visible.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

protected String id
Holds the Id. Default is null.


value

protected Object value
Holds the user object. Default is null.


geometry

protected mxGeometry geometry
Holds the geometry. Default is null.


style

protected String style
Holds the style as a string of the form stylename[;key=value]. Default is null.


vertex

protected boolean vertex
Specifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed. Default values are false, false, true, true and false respectively.


edge

protected boolean edge
Specifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed. Default values are false, false, true, true and false respectively.


connectable

protected boolean connectable
Specifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed. Default values are false, false, true, true and false respectively.


visible

protected boolean visible
Specifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed. Default values are false, false, true, true and false respectively.


collapsed

protected boolean collapsed
Specifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed. Default values are false, false, true, true and false respectively.


parent

protected mxICell parent
Reference to the parent cell and source and target terminals for edges.


source

protected mxICell source
Reference to the parent cell and source and target terminals for edges.


target

protected mxICell target
Reference to the parent cell and source and target terminals for edges.


children

protected List<Object> children
Holds the child cells and connected edges.


edges

protected List<Object> edges
Holds the child cells and connected edges.

Constructor Detail

mxCell

public mxCell()
Constructs a new cell with an empty user object.


mxCell

public mxCell(Object value)
Constructs a new cell for the given user object.

Parameters:
value - Object that represents the value of the cell.

mxCell

public mxCell(Object value,
              mxGeometry geometry,
              String style)
Constructs a new cell for the given parameters.

Parameters:
value - Object that represents the value of the cell.
geometry - Specifies the geometry of the cell.
style - Specifies the style as a formatted string.
Method Detail

getId

public String getId()
Description copied from interface: mxICell
Returns the Id of the cell as a string.

Specified by:
getId in interface mxICell
Returns:
Returns the Id.

setId

public void setId(String id)
Description copied from interface: mxICell
Sets the Id of the cell to the given string.

Specified by:
setId in interface mxICell
Parameters:
id - String that represents the new Id.

getValue

public Object getValue()
Description copied from interface: mxICell
Returns the user object of the cell.

Specified by:
getValue in interface mxICell
Returns:
Returns the user object.

setValue

public void setValue(Object value)
Description copied from interface: mxICell
Sets the user object of the cell.

Specified by:
setValue in interface mxICell
Parameters:
value - Object that represents the new value.

getGeometry

public mxGeometry getGeometry()
Description copied from interface: mxICell
Returns the object that describes the geometry.

Specified by:
getGeometry in interface mxICell
Returns:
Returns the cell geometry.

setGeometry

public void setGeometry(mxGeometry geometry)
Description copied from interface: mxICell
Sets the object to be used as the geometry.

Specified by:
setGeometry in interface mxICell

getStyle

public String getStyle()
Description copied from interface: mxICell
Returns the string that describes the style.

Specified by:
getStyle in interface mxICell
Returns:
Returns the cell style.

setStyle

public void setStyle(String style)
Description copied from interface: mxICell
Sets the string to be used as the style.

Specified by:
setStyle in interface mxICell

isVertex

public boolean isVertex()
Description copied from interface: mxICell
Returns true if the cell is a vertex.

Specified by:
isVertex in interface mxICell
Returns:
Returns true if the cell is a vertex.

setVertex

public void setVertex(boolean vertex)

isEdge

public boolean isEdge()
Description copied from interface: mxICell
Returns true if the cell is an edge.

Specified by:
isEdge in interface mxICell
Returns:
Returns true if the cell is an edge.

setEdge

public void setEdge(boolean edge)

isConnectable

public boolean isConnectable()
Description copied from interface: mxICell
Returns true if the cell is connectable.

Specified by:
isConnectable in interface mxICell
Returns:
Returns the connectable state.

setConnectable

public void setConnectable(boolean connectable)

isVisible

public boolean isVisible()
Description copied from interface: mxICell
Returns true if the cell is visibile.

Specified by:
isVisible in interface mxICell
Returns:
Returns the visible state.

setVisible

public void setVisible(boolean visible)
Description copied from interface: mxICell
Specifies if the cell is visible.

Specified by:
setVisible in interface mxICell
Parameters:
visible - Boolean that specifies the new visible state.

isCollapsed

public boolean isCollapsed()
Description copied from interface: mxICell
Returns true if the cell is collapsed.

Specified by:
isCollapsed in interface mxICell
Returns:
Returns the collapsed state.

setCollapsed

public void setCollapsed(boolean collapsed)
Description copied from interface: mxICell
Sets the collapsed state.

Specified by:
setCollapsed in interface mxICell
Parameters:
collapsed - Boolean that specifies the new collapsed state.

getParent

public mxICell getParent()
Description copied from interface: mxICell
Returns the cell's parent.

Specified by:
getParent in interface mxICell
Returns:
Returns the parent cell.

setParent

public void setParent(mxICell parent)
Description copied from interface: mxICell
Sets the parent cell.

Specified by:
setParent in interface mxICell
Parameters:
parent - Cell that represents the new parent.

getSource

public mxICell getSource()
Returns the source terminal.


setSource

public void setSource(mxICell source)
Sets the source terminal.

Parameters:
source - Cell that represents the new source terminal.

getTarget

public mxICell getTarget()
Returns the target terminal.


setTarget

public void setTarget(mxICell target)
Sets the target terminal.

Parameters:
target - Cell that represents the new target terminal.

getTerminal

public mxICell getTerminal(boolean source)
Description copied from interface: mxICell
Returns the source or target terminal.

Specified by:
getTerminal in interface mxICell
Parameters:
source - Boolean that specifies if the source terminal should be returned.
Returns:
Returns the source or target terminal.

setTerminal

public mxICell setTerminal(mxICell terminal,
                           boolean isSource)
Description copied from interface: mxICell
Sets the source or target terminal and returns the new terminal.

Specified by:
setTerminal in interface mxICell
Parameters:
terminal - Cell that represents the new source or target terminal.
isSource - Boolean that specifies if the source or target terminal should be set.
Returns:
Returns the new terminal.

getChildCount

public int getChildCount()
Description copied from interface: mxICell
Returns the number of child cells.

Specified by:
getChildCount in interface mxICell
Returns:
Returns the number of children.

getIndex

public int getIndex(mxICell child)
Description copied from interface: mxICell
Returns the index of the specified child in the child array.

Specified by:
getIndex in interface mxICell
Parameters:
child - Child whose index should be returned.
Returns:
Returns the index of the given child.

getChildAt

public mxICell getChildAt(int index)
Description copied from interface: mxICell
Returns the child at the specified index.

Specified by:
getChildAt in interface mxICell
Parameters:
index - Integer that specifies the child to be returned.
Returns:
Returns the child at the given index.

insert

public mxICell insert(mxICell child)
Description copied from interface: mxICell
Appends the specified child into the child array and updates the parent reference of the child. Returns the appended child.

Specified by:
insert in interface mxICell
Parameters:
child - Cell to be appended to the child array.
Returns:
Returns the new child.

insert

public mxICell insert(mxICell child,
                      int index)
Description copied from interface: mxICell
Inserts the specified child into the child array at the specified index and updates the parent reference of the child. Returns the inserted child.

Specified by:
insert in interface mxICell
Parameters:
child - Cell to be inserted into the child array.
index - Integer that specifies the index at which the child should be inserted into the child array.
Returns:
Returns the new child.

remove

public mxICell remove(int index)
Description copied from interface: mxICell
Removes the child at the specified index from the child array and returns the child that was removed. Will remove the parent reference of the child.

Specified by:
remove in interface mxICell
Parameters:
index - Integer that specifies the index of the child to be removed.
Returns:
Returns the child that was removed.

remove

public mxICell remove(mxICell child)
Description copied from interface: mxICell
Removes the given child from the child array and returns it. Will remove the parent reference of the child.

Specified by:
remove in interface mxICell
Parameters:
child - Cell that represents the child to be removed.
Returns:
Returns the child that was removed.

removeFromParent

public void removeFromParent()
Description copied from interface: mxICell
Removes the cell from its parent.

Specified by:
removeFromParent in interface mxICell

getEdgeCount

public int getEdgeCount()
Description copied from interface: mxICell
Returns the number of edges in the edge array.

Specified by:
getEdgeCount in interface mxICell
Returns:
Returns the number of edges.

getEdgeIndex

public int getEdgeIndex(mxICell edge)
Description copied from interface: mxICell
Returns the index of the specified edge in the edge array.

Specified by:
getEdgeIndex in interface mxICell
Parameters:
edge - Cell whose index should be returned.
Returns:
Returns the index of the given edge.

getEdgeAt

public mxICell getEdgeAt(int index)
Description copied from interface: mxICell
Returns the edge at the specified index in the edge array.

Specified by:
getEdgeAt in interface mxICell
Parameters:
index - Integer that specifies the index of the edge to be returned.
Returns:
Returns the edge at the given index.

insertEdge

public mxICell insertEdge(mxICell edge,
                          boolean isOutgoing)
Description copied from interface: mxICell
Inserts the specified edge into the edge array and returns the edge. Will update the respective terminal reference of the edge.

Specified by:
insertEdge in interface mxICell
Parameters:
edge - Cell to be inserted into the edge array.
isOutgoing - Boolean that specifies if the edge is outgoing.
Returns:
Returns the new edge.

removeEdge

public mxICell removeEdge(mxICell edge,
                          boolean isOutgoing)
Description copied from interface: mxICell
Removes the specified edge from the edge array and returns the edge. Will remove the respective terminal reference from the edge.

Specified by:
removeEdge in interface mxICell
Parameters:
edge - Cell to be removed from the edge array.
isOutgoing - Boolean that specifies if the edge is outgoing.
Returns:
Returns the edge that was removed.

removeFromTerminal

public void removeFromTerminal(boolean isSource)
Description copied from interface: mxICell
Removes the edge from its source or target terminal.

Specified by:
removeFromTerminal in interface mxICell
Parameters:
isSource - Boolean that specifies if the edge should be removed from its source or target terminal.

getAttribute

public String getAttribute(String name)
Returns the specified attribute from the user object if it is an XML node.

Parameters:
name - Name of the attribute whose value should be returned.
Returns:
Returns the value of the given attribute or null.

getAttribute

public String getAttribute(String name,
                           String defaultValue)
Returns the specified attribute from the user object if it is an XML node.

Parameters:
name - Name of the attribute whose value should be returned.
defaultValue - Default value to use if the attribute has no value.
Returns:
Returns the value of the given attribute or defaultValue.

setAttribute

public void setAttribute(String name,
                         String value)
Sets the specified attribute on the user object if it is an XML node.

Parameters:
name - Name of the attribute whose value should be set.
value - New value of the attribute.

clone

public Object clone()
             throws CloneNotSupportedException
Returns a clone of the cell.

Specified by:
clone in interface mxICell
Overrides:
clone in class Object
Returns:
Returns a clone of this cell.
Throws:
CloneNotSupportedException

cloneValue

protected Object cloneValue()
Returns a clone of the user object. This implementation clones any XML nodes or otherwise returns the same user object instance.


mxGraph 1.10.2.0


Copyright (c) 2010 Gaudenz Alder, David Benson. All rights reserved.