Base class for all layout algorithms in mxGraph. Main public functions are <move> for handling a moved cell within a layouted parent, and execute for running the layout on a given parent cell.
mxCircleLayout, mxCompactTreeLayout, mxCompositeLayout, mxFastOrganicLayout, mxParallelEdgeLayout, mxPartitionLayout, mxStackLayout
mxGraphLayout | Base class for all layout algorithms in mxGraph. |
Functions | |
mxGraphLayout | Constructs a new layout using the given layouts. |
Variables | |
graph | Reference to the enclosing mxGraph. |
useBoundingBox | Boolean indicating if the bounding box of the label should be used if its available. |
parent | The parent cell of the layout, if any |
Functions | |
moveCell | Notified when a cell is being moved in a parent that has automatic layout to update the cell state (eg. |
execute | Executes the layout algorithm for the children of the given parent. |
getGraph | Returns the graph that this layout operates on. |
getConstraint | Returns the constraint for the given key and cell. |
traverse | Traverses the (directed) graph invoking the given function for each visited vertex and edge. |
isVertexMovable | Returns a boolean indicating if the given mxCell is movable or bendable by the algorithm. |
isVertexIgnored | Returns a boolean indicating if the given mxCell should be ignored by the algorithm. |
isEdgeIgnored | Returns a boolean indicating if the given mxCell should be ignored by the algorithm. |
setEdgeStyleEnabled | Disables or enables the edge style of the given edge. |
setOrthogonalEdge | Disables or enables orthogonal end segments of the given edge. |
getParentOffset | Determines the offset of the given parent to the parent of the layout |
setEdgePoints | Replaces the array of mxPoints in the geometry of the given edge with the given array of mxPoints. |
setVertexLocation | Sets the new position of the given cell taking into account the size of the bounding box if useBoundingBox is true. |
getCellBounds | Returns an mxRectangle that defines the bounds of the given cell or the bounding box if useBoundingBox is true. |
getCellBounds | Updates the bounds of the given groups to include all children. |
mxGraphLayout.prototype.graph
Reference to the enclosing mxGraph.
mxGraphLayout.prototype.moveCell = function( cell, x, y )
Notified when a cell is being moved in a parent that has automatic layout to update the cell state (eg. index) so that the outcome of the layout will position the vertex as close to the point (x, y) as possible.
Empty implementation.
cell | mxCell which has been moved. |
x | X-coordinate of the new cell location. |
y | Y-coordinate of the new cell location. |
mxGraphLayout.prototype.execute = function( parent )
Executes the layout algorithm for the children of the given parent.
parent | mxCell whose children should be layed out. |
mxGraphLayout.prototype.getConstraint = function( key, cell, edge, source )
Returns the constraint for the given key and cell. The optional edge and source arguments are used to return inbound and outgoing routing- constraints for the given edge and vertex. This implementation always returns the value for the given key in the style of the given cell.
key | Key of the constraint to be returned. |
cell | mxCell whose constraint should be returned. |
edge | Optional mxCell that represents the connection whose constraint should be returned. Default is null. |
source | Optional boolean that specifies if the connection is incoming or outgoing. Default is null. |
mxGraphLayout.traverse = function( vertex, directed, func, edge, visited )
Traverses the (directed) graph invoking the given function for each visited vertex and edge. The function is invoked with the current vertex and the incoming edge as a parameter. This implementation makes sure each vertex is only visited once. The function may return false if the traversal should stop at the given vertex.
mxLog.show(); var cell = graph.getSelectionCell(); graph.traverse(cell, false, function(vertex, edge) { mxLog.debug(graph.getLabel(vertex)); });
vertex | mxCell that represents the vertex where the traversal starts. |
directed | Optional boolean indicating if edges should only be traversed from source to target. Default is true. |
func | Visitor function that takes the current vertex and the incoming edge as arguments. The traversal stops if the function returns false. |
edge | Optional mxCell that represents the incoming edge. This is null for the first step of the traversal. |
visited | Optional array of cell paths for the visited cells. |
mxGraphLayout.prototype.setVertexLocation = function( cell, x, y )
Sets the new position of the given cell taking into account the size of the bounding box if useBoundingBox is true. The change is only carried out if the new location is not equal to the existing location, otherwise the geometry is not replaced with an updated instance. The new or old bounds are returned (including overlapping labels).
cell | mxCell whose geometry is to be set. |
x | Integer that defines the x-coordinate of the new location. |
y | Integer that defines the y-coordinate of the new location. |
Returns an mxRectangle that defines the bounds of the given cell or the bounding box if useBoundingBox is true.
Constructs a new layout using the given layouts.
function mxGraphLayout( graph )
Reference to the enclosing mxGraph.
mxGraphLayout.prototype.graph
Boolean indicating if the bounding box of the label should be used if its available.
mxGraphLayout.prototype.useBoundingBox
The parent cell of the layout, if any
mxGraphLayout.prototype.parent
Notified when a cell is being moved in a parent that has automatic layout to update the cell state (eg.
mxGraphLayout.prototype.moveCell = function( cell, x, y )
Executes the layout algorithm for the children of the given parent.
mxGraphLayout.prototype.execute = function( parent )
Returns the graph that this layout operates on.
mxGraphLayout.prototype.getGraph = function()
Returns the constraint for the given key and cell.
mxGraphLayout.prototype.getConstraint = function( key, cell, edge, source )
Traverses the (directed) graph invoking the given function for each visited vertex and edge.
mxGraphLayout.traverse = function( vertex, directed, func, edge, visited )
Returns a boolean indicating if the given mxCell is movable or bendable by the algorithm.
mxGraphLayout.prototype.isVertexMovable = function( cell )
Returns a boolean indicating if the given mxCell should be ignored by the algorithm.
mxGraphLayout.prototype.isVertexIgnored = function( vertex )
Returns a boolean indicating if the given mxCell should be ignored by the algorithm.
mxGraphLayout.prototype.isEdgeIgnored = function( edge )
Disables or enables the edge style of the given edge.
mxGraphLayout.prototype.setEdgeStyleEnabled = function( edge, value )
Disables or enables orthogonal end segments of the given edge.
mxGraphLayout.prototype.setOrthogonalEdge = function( edge, value )
Determines the offset of the given parent to the parent of the layout
mxGraphLayout.prototype.getParentOffset = function( parent )
Replaces the array of mxPoints in the geometry of the given edge with the given array of mxPoints.
mxGraphLayout.prototype.setEdgePoints = function( edge, points )
Sets the new position of the given cell taking into account the size of the bounding box if useBoundingBox is true.
mxGraphLayout.prototype.setVertexLocation = function( cell, x, y )