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 boolean
Specifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed.protected boolean
Specifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed.protected boolean
Specifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed.Holds the child cells and connected edges.protected mxGeometry
Holds the geometry.protected String
Holds the Id.protected mxICell
Reference to the parent cell and source and target terminals for edges.protected mxICell
Reference to the parent cell and source and target terminals for edges.protected String
Holds the style as a string of the form stylename[;key=value].protected mxICell
Reference to the parent cell and source and target terminals for edges.protected Object
Holds the user object.protected boolean
Specifies whether the cell is a vertex or edge and whether it is connectable, visible and collapsed.protected boolean
Specifies 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 Object
Returns 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.int
Returns the number of child cells.getEdgeAt
(int index) Returns the edge at the specified index in the edge array.int
Returns the number of edges in the edge array.int
getEdgeIndex
(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.int
Returns 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.boolean
Returns true if the cell is collapsed.boolean
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
Returns 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.void
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
Sets the Id of the cell to the given string.void
Sets the parent cell.void
Sets the source terminal.void
Sets the string to be used as the style.void
Sets the target terminal.setTerminal
(mxICell terminal, boolean isSource) Sets the source or target terminal and returns the new terminal.void
Sets the user object of the cell.void
setVertex
(boolean vertex) void
setVisible
(boolean visible) Specifies if the cell is visible.toString()
-
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:mxICell
Returns the Id of the cell as a string. -
setId
Description copied from interface:mxICell
Sets the Id of the cell to the given string. -
getValue
Description copied from interface:mxICell
Returns the user object of the cell. -
setValue
Description copied from interface:mxICell
Sets the user object of the cell. -
getGeometry
Description copied from interface:mxICell
Returns the object that describes the geometry.- Specified by:
getGeometry
in interfacemxICell
- Returns:
- Returns the cell geometry.
-
setGeometry
Description copied from interface:mxICell
Sets the object to be used as the geometry.- Specified by:
setGeometry
in interfacemxICell
-
getStyle
Description copied from interface:mxICell
Returns the string that describes the style. -
setStyle
Description copied from interface:mxICell
Sets the string to be used as the style. -
isVertex
public boolean isVertex()Description copied from interface:mxICell
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. -
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 interfacemxICell
- 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. -
setVisible
public void setVisible(boolean visible) Description copied from interface:mxICell
Specifies if the cell is visible.- Specified by:
setVisible
in interfacemxICell
- 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 interfacemxICell
- Returns:
- Returns the collapsed state.
-
setCollapsed
public void setCollapsed(boolean collapsed) Description copied from interface:mxICell
Sets the collapsed state.- Specified by:
setCollapsed
in interfacemxICell
- Parameters:
collapsed
- Boolean that specifies the new collapsed state.
-
getParent
Description copied from interface:mxICell
Returns the cell's parent. -
setParent
Description copied from interface:mxICell
Sets 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:mxICell
Returns the source or target terminal.- Specified by:
getTerminal
in 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:mxICell
Sets the source or target terminal and returns the new terminal.- Specified by:
setTerminal
in 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:mxICell
Returns the number of child cells.- Specified by:
getChildCount
in interfacemxICell
- Returns:
- Returns the number of children.
-
getIndex
Description copied from interface:mxICell
Returns the index of the specified child in the child array. -
getChildAt
Description copied from interface:mxICell
Returns the child at the specified index.- Specified by:
getChildAt
in interfacemxICell
- Parameters:
index
- Integer that specifies the child to be returned.- Returns:
- Returns the child at the given index.
-
insert
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. -
insert
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. -
remove
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. -
remove
Description copied from interface:mxICell
Removes 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:mxICell
Removes the cell from its parent.- Specified by:
removeFromParent
in interfacemxICell
-
getEdgeCount
public int getEdgeCount()Description copied from interface:mxICell
Returns the number of edges in the edge array.- Specified by:
getEdgeCount
in interfacemxICell
- Returns:
- Returns the number of edges.
-
getEdgeIndex
Description copied from interface:mxICell
Returns the index of the specified edge in the edge array.- Specified by:
getEdgeIndex
in interfacemxICell
- Parameters:
edge
- Cell whose index should be returned.- Returns:
- Returns the index of the given edge.
-
getEdgeAt
Description copied from interface:mxICell
Returns the edge at the specified index in the edge array. -
insertEdge
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 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: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 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:mxICell
Removes the edge from its source or target terminal.- Specified by:
removeFromTerminal
in 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:
clone
in interfacemxICell
- Overrides:
clone
in 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. -
toString
-