Package com.mxgraph.model
Class mxCell
java.lang.Object
com.mxgraph.model.mxCell
- All Implemented Interfaces:
mxICell,Serializable,Cloneable
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionHolds the child cells and connected edges.protected booleanSpecifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed.protected booleanSpecifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed.protected booleanSpecifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed.Holds the child cells and connected edges.protected mxGeometryHolds the geometry.protected StringHolds the Id.protected mxICellReference to the parent cell and source and target terminals for edges.protected mxICellReference to the parent cell and source and target terminals for edges.protected StringHolds the style as a string of the form stylename[;key=value].protected mxICellReference to the parent cell and source and target terminals for edges.protected ObjectHolds the user object.protected booleanSpecifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed.protected booleanSpecifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()Returns a clone of the cell.protected ObjectReturns a clone of the user object.getAttribute(String name) Returns the specified attribute from the user object if it is an XML node.getAttribute(String name, String defaultValue) Returns the specified attribute from the user object if it is an XML node.getChildAt(int index) Returns the child at the specified index.intReturns the number of child cells.getEdgeAt(int index) Returns the edge at the specified index in the edge array.intReturns the number of edges in the edge array.intgetEdgeIndex(mxICell edge) Returns the index of the specified edge in the edge array.Returns the object that describes the geometry.getId()Returns the Id of the cell as a string.intReturns the index of the specified child in the child array.Returns the cell's parent.Returns the source terminal.getStyle()Returns the string that describes the style.Returns the target terminal.getTerminal(boolean source) Returns the source or target terminal.getValue()Returns the user object of the cell.Appends the specified child into the child array and updates the parent reference of the child.Inserts the specified child into the child array at the specified index and updates the parent reference of the child.insertEdge(mxICell edge, boolean isOutgoing) Inserts the specified edge into the edge array and returns the edge.booleanReturns true if the cell is collapsed.booleanReturns true if the cell is connectable.booleanisEdge()Returns true if the cell is an edge.booleanisVertex()Returns true if the cell is a vertex.booleanReturns true if the cell is visibile.remove(int index) Removes the child at the specified index from the child array and returns the child that was removed.Removes the given child from the child array and returns it.removeEdge(mxICell edge, boolean isOutgoing) Removes the specified edge from the edge array and returns the edge.voidRemoves the cell from its parent.voidremoveFromTerminal(boolean isSource) Removes the edge from its source or target terminal.voidsetAttribute(String name, 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.voidSets the Id of the cell to the given string.voidSets the parent cell.voidSets the source terminal.voidSets the string to be used as the style.voidSets the target terminal.setTerminal(mxICell terminal, boolean isSource) Sets the source or target terminal and returns the new terminal.voidSets the user object of the cell.voidsetVertex(boolean vertex) voidsetVisible(boolean visible) Specifies if the cell is visible.
-
Field Details
-
id
Holds the Id. Default is null. -
value
Holds the user object. Default is null. -
geometry
Holds the geometry. Default is null. -
style
Holds the style as a string of the form stylename[;key=value]. Default is null. -
vertex
protected boolean vertexSpecifies 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 edgeSpecifies 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 connectableSpecifies 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 visibleSpecifies 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 collapsedSpecifies 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
Reference to the parent cell and source and target terminals for edges. -
source
Reference to the parent cell and source and target terminals for edges. -
target
Reference to the parent cell and source and target terminals for edges. -
children
Holds the child cells and connected edges. -
edges
Holds the child cells and connected edges.
-
-
Constructor Details
-
mxCell
public mxCell()Constructs a new cell with an empty user object. -
mxCell
Constructs a new cell for the given user object.- Parameters:
value- Object that represents the value of the cell.
-
mxCell
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 Details
-
getId
Description copied from interface:mxICellReturns the Id of the cell as a string. -
setId
Description copied from interface:mxICellSets the Id of the cell to the given string. -
getValue
Description copied from interface:mxICellReturns the user object of the cell. -
setValue
Description copied from interface:mxICellSets the user object of the cell. -
getGeometry
Description copied from interface:mxICellReturns the object that describes the geometry.- Specified by:
getGeometryin interfacemxICell- Returns:
- Returns the cell geometry.
-
setGeometry
Description copied from interface:mxICellSets the object to be used as the geometry.- Specified by:
setGeometryin interfacemxICell
-
getStyle
Description copied from interface:mxICellReturns the string that describes the style. -
setStyle
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
Description copied from interface:mxICellReturns the cell's parent. -
setParent
Description copied from interface:mxICellSets the parent cell. -
getSource
Returns the source terminal. -
setSource
Sets the source terminal.- Parameters:
source- Cell that represents the new source terminal.
-
getTarget
Returns the target terminal. -
setTarget
Sets the target terminal.- Parameters:
target- Cell that represents the new target terminal.
-
getTerminal
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
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
Description copied from interface:mxICellReturns the index of the specified child in the child array. -
getChildAt
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
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
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
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
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
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
Description copied from interface:mxICellReturns the edge at the specified index in the edge array. -
insertEdge
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
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
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
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
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
Returns a clone of the cell.- Specified by:
clonein interfacemxICell- Overrides:
clonein classObject- Returns:
- Returns a clone of this cell.
- Throws:
CloneNotSupportedException
-
cloneValue
Returns a clone of the user object. This implementation clones any XML nodes or otherwise returns the same user object instance.
-