Package com.mxgraph.model
Class mxCell
- java.lang.Object
-
- com.mxgraph.model.mxCell
-
- All Implemented Interfaces:
mxICell,java.io.Serializable,java.lang.Cloneable
public class mxCell extends java.lang.Object implements mxICell, java.lang.Cloneable, java.io.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
Fields Modifier and Type Field Description protected java.util.List<java.lang.Object>childrenHolds the child cells and connected edges.protected booleancollapsedSpecifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed.protected booleanconnectableSpecifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed.protected booleanedgeSpecifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed.protected java.util.List<java.lang.Object>edgesHolds the child cells and connected edges.protected mxGeometrygeometryHolds the geometry.protected java.lang.StringidHolds the Id.protected mxICellparentReference to the parent cell and source and target terminals for edges.protected mxICellsourceReference to the parent cell and source and target terminals for edges.protected java.lang.StringstyleHolds the style as a string of the form stylename[;key=value].protected mxICelltargetReference to the parent cell and source and target terminals for edges.protected java.lang.ObjectvalueHolds the user object.protected booleanvertexSpecifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed.protected booleanvisibleSpecifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed.
-
Constructor Summary
Constructors Constructor Description mxCell()Constructs a new cell with an empty user object.mxCell(java.lang.Object value)Constructs a new cell for the given user object.mxCell(java.lang.Object value, mxGeometry geometry, java.lang.String style)Constructs a new cell for the given parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()Returns a clone of the cell.protected java.lang.ObjectcloneValue()Returns a clone of the user object.java.lang.StringgetAttribute(java.lang.String name)Returns the specified attribute from the user object if it is an XML node.java.lang.StringgetAttribute(java.lang.String name, java.lang.String defaultValue)Returns the specified attribute from the user object if it is an XML node.mxICellgetChildAt(int index)Returns the child at the specified index.intgetChildCount()Returns the number of child cells.mxICellgetEdgeAt(int index)Returns the edge at the specified index in the edge array.intgetEdgeCount()Returns the number of edges in the edge array.intgetEdgeIndex(mxICell edge)Returns the index of the specified edge in the edge array.mxGeometrygetGeometry()Returns the object that describes the geometry.java.lang.StringgetId()Returns the Id of the cell as a string.intgetIndex(mxICell child)Returns the index of the specified child in the child array.mxICellgetParent()Returns the cell's parent.mxICellgetSource()Returns the source terminal.java.lang.StringgetStyle()Returns the string that describes the style.mxICellgetTarget()Returns the target terminal.mxICellgetTerminal(boolean source)Returns the source or target terminal.java.lang.ObjectgetValue()Returns the user object of the cell.mxICellinsert(mxICell child)Appends the specified child into the child array and updates the parent reference of the child.mxICellinsert(mxICell child, int index)Inserts the specified child into the child array at the specified index and updates the parent reference of the child.mxICellinsertEdge(mxICell edge, boolean isOutgoing)Inserts the specified edge into the edge array and returns the edge.booleanisCollapsed()Returns true if the cell is collapsed.booleanisConnectable()Returns true if the cell is connectable.booleanisEdge()Returns true if the cell is an edge.booleanisVertex()Returns true if the cell is a vertex.booleanisVisible()Returns true if the cell is visibile.mxICellremove(int index)Removes the child at the specified index from the child array and returns the child that was removed.mxICellremove(mxICell child)Removes the given child from the child array and returns it.mxICellremoveEdge(mxICell edge, boolean isOutgoing)Removes the specified edge from the edge array and returns the edge.voidremoveFromParent()Removes the cell from its parent.voidremoveFromTerminal(boolean isSource)Removes the edge from its source or target terminal.voidsetAttribute(java.lang.String name, java.lang.String value)Sets the specified attribute on the user object if it is an XML node.voidsetCollapsed(boolean collapsed)Sets the collapsed state.voidsetConnectable(boolean connectable)voidsetEdge(boolean edge)voidsetGeometry(mxGeometry geometry)Sets the object to be used as the geometry.voidsetId(java.lang.String id)Sets the Id of the cell to the given string.voidsetParent(mxICell parent)Sets the parent cell.voidsetSource(mxICell source)Sets the source terminal.voidsetStyle(java.lang.String style)Sets the string to be used as the style.voidsetTarget(mxICell target)Sets the target terminal.mxICellsetTerminal(mxICell terminal, boolean isSource)Sets the source or target terminal and returns the new terminal.voidsetValue(java.lang.Object value)Sets the user object of the cell.voidsetVertex(boolean vertex)voidsetVisible(boolean visible)Specifies if the cell is visible.java.lang.StringtoString()
-
-
-
Field Detail
-
id
protected java.lang.String id
Holds the Id. Default is null.
-
value
protected java.lang.Object value
Holds the user object. Default is null.
-
geometry
protected mxGeometry geometry
Holds the geometry. Default is null.
-
style
protected java.lang.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 java.util.List<java.lang.Object> children
Holds the child cells and connected edges.
-
edges
protected java.util.List<java.lang.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(java.lang.Object value)
Constructs a new cell for the given user object.- Parameters:
value- Object that represents the value of the cell.
-
mxCell
public mxCell(java.lang.Object value, mxGeometry geometry, java.lang.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 java.lang.String getId()
Description copied from interface:mxICellReturns the Id of the cell as a string.
-
setId
public void setId(java.lang.String id)
Description copied from interface:mxICellSets the Id of the cell to the given string.
-
getValue
public java.lang.Object getValue()
Description copied from interface:mxICellReturns the user object of the cell.
-
setValue
public void setValue(java.lang.Object value)
Description copied from interface:mxICellSets the user object of the cell.
-
getGeometry
public mxGeometry getGeometry()
Description copied from interface:mxICellReturns the object that describes the geometry.- Specified by:
getGeometryin interfacemxICell- Returns:
- Returns the cell geometry.
-
setGeometry
public void setGeometry(mxGeometry geometry)
Description copied from interface:mxICellSets the object to be used as the geometry.- Specified by:
setGeometryin interfacemxICell
-
getStyle
public java.lang.String getStyle()
Description copied from interface:mxICellReturns the string that describes the style.
-
setStyle
public void setStyle(java.lang.String style)
Description copied from interface:mxICellSets the string to be used as the style.
-
isVertex
public boolean isVertex()
Description copied from interface:mxICellReturns true if the cell is a vertex.
-
setVertex
public void setVertex(boolean vertex)
-
isEdge
public boolean isEdge()
Description copied from interface:mxICellReturns true if the cell is an edge.
-
setEdge
public void setEdge(boolean edge)
-
isConnectable
public boolean isConnectable()
Description copied from interface:mxICellReturns true if the cell is connectable.- Specified by:
isConnectablein interfacemxICell- Returns:
- Returns the connectable state.
-
setConnectable
public void setConnectable(boolean connectable)
-
isVisible
public boolean isVisible()
Description copied from interface:mxICellReturns true if the cell is visibile.
-
setVisible
public void setVisible(boolean visible)
Description copied from interface:mxICellSpecifies if the cell is visible.- Specified by:
setVisiblein interfacemxICell- Parameters:
visible- Boolean that specifies the new visible state.
-
isCollapsed
public boolean isCollapsed()
Description copied from interface:mxICellReturns true if the cell is collapsed.- Specified by:
isCollapsedin interfacemxICell- Returns:
- Returns the collapsed state.
-
setCollapsed
public void setCollapsed(boolean collapsed)
Description copied from interface:mxICellSets the collapsed state.- Specified by:
setCollapsedin interfacemxICell- Parameters:
collapsed- Boolean that specifies the new collapsed state.
-
getParent
public mxICell getParent()
Description copied from interface:mxICellReturns the cell's parent.
-
setParent
public void setParent(mxICell parent)
Description copied from interface:mxICellSets the parent cell.
-
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:mxICellReturns the source or target terminal.- Specified by:
getTerminalin interfacemxICell- 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:mxICellSets the source or target terminal and returns the new terminal.- Specified by:
setTerminalin interfacemxICell- 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:mxICellReturns the number of child cells.- Specified by:
getChildCountin interfacemxICell- Returns:
- Returns the number of children.
-
getIndex
public int getIndex(mxICell child)
Description copied from interface:mxICellReturns the index of the specified child in the child array.
-
getChildAt
public mxICell getChildAt(int index)
Description copied from interface:mxICellReturns the child at the specified index.- Specified by:
getChildAtin interfacemxICell- 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:mxICellAppends the specified child into the child array and updates the parent reference of the child. Returns the appended child.
-
insert
public mxICell insert(mxICell child, int index)
Description copied from interface:mxICellInserts the specified child into the child array at the specified index and updates the parent reference of the child. Returns the inserted child.
-
remove
public mxICell remove(int index)
Description copied from interface:mxICellRemoves 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.
-
remove
public mxICell remove(mxICell child)
Description copied from interface:mxICellRemoves the given child from the child array and returns it. Will remove the parent reference of the child.
-
removeFromParent
public void removeFromParent()
Description copied from interface:mxICellRemoves the cell from its parent.- Specified by:
removeFromParentin interfacemxICell
-
getEdgeCount
public int getEdgeCount()
Description copied from interface:mxICellReturns the number of edges in the edge array.- Specified by:
getEdgeCountin interfacemxICell- Returns:
- Returns the number of edges.
-
getEdgeIndex
public int getEdgeIndex(mxICell edge)
Description copied from interface:mxICellReturns the index of the specified edge in the edge array.- Specified by:
getEdgeIndexin interfacemxICell- 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:mxICellReturns the edge at the specified index in the edge array.
-
insertEdge
public mxICell insertEdge(mxICell edge, boolean isOutgoing)
Description copied from interface:mxICellInserts the specified edge into the edge array and returns the edge. Will update the respective terminal reference of the edge.- Specified by:
insertEdgein interfacemxICell- 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:mxICellRemoves the specified edge from the edge array and returns the edge. Will remove the respective terminal reference from the edge.- Specified by:
removeEdgein interfacemxICell- 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:mxICellRemoves the edge from its source or target terminal.- Specified by:
removeFromTerminalin interfacemxICell- Parameters:
isSource- Boolean that specifies if the edge should be removed from its source or target terminal.
-
getAttribute
public java.lang.String getAttribute(java.lang.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 java.lang.String getAttribute(java.lang.String name, java.lang.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(java.lang.String name, java.lang.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 java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionReturns a clone of the cell.
-
cloneValue
protected java.lang.Object cloneValue()
Returns a clone of the user object. This implementation clones any XML nodes or otherwise returns the same user object instance.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-