Package com.mxgraph.layout
Class mxGraphLayout
- java.lang.Object
-
- com.mxgraph.layout.mxGraphLayout
-
- All Implemented Interfaces:
mxIGraphLayout
- Direct Known Subclasses:
mxCircleLayout
,mxCompactTreeLayout
,mxEdgeLabelLayout
,mxFastOrganicLayout
,mxHierarchicalLayout
,mxOrganicLayout
,mxOrthogonalLayout
,mxParallelEdgeLayout
,mxPartitionLayout
,mxStackLayout
public abstract class mxGraphLayout extends java.lang.Object implements mxIGraphLayout
Abstract bass class for layouts
-
-
Field Summary
Fields Modifier and Type Field Description protected mxGraph
graph
Holds the enclosing graph.protected java.lang.Object
parent
The parent cell of the layout, if anyprotected boolean
useBoundingBox
Boolean indicating if the bounding box of the label should be used if its available.
-
Constructor Summary
Constructors Constructor Description mxGraphLayout(mxGraph graph)
Constructs a new fast organic layout for the specified graph.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
arrangeGroups(java.lang.Object[] groups, int border)
Updates the bounds of the given groups to include all children.void
execute(java.lang.Object parent)
Executes the layout for the children of the specified parent.java.lang.Object
getConstraint(java.lang.Object key, java.lang.Object cell)
Returns the constraint for the given key and cell.java.lang.Object
getConstraint(java.lang.Object key, java.lang.Object cell, java.lang.Object edge, boolean source)
Returns the constraint for the given key and cell.mxGraph
getGraph()
Returns the associated graph.mxPoint
getParentOffset(java.lang.Object parent)
mxRectangle
getVertexBounds(java.lang.Object vertex)
Returns anthat defines the bounds of the given cell or the bounding box if is true. boolean
isEdgeIgnored(java.lang.Object edge)
Returns true if the given edge has no source or target terminal.boolean
isUseBoundingBox()
boolean
isVertexIgnored(java.lang.Object vertex)
Returns true if the given vertex has no connected edges.boolean
isVertexMovable(java.lang.Object vertex)
Returns true if the given vertex may be moved by the layout.void
moveCell(java.lang.Object cell, double x, double y)
Notified when a cell is being moved in a parent that has automatic layout to update the cell state (eg.void
setEdgePoints(java.lang.Object edge, java.util.List<mxPoint> points)
Sets the control points of the given edge to the given list of mxPoints.void
setEdgeStyleEnabled(java.lang.Object edge, boolean value)
Disables or enables the edge style of the given edge.void
setOrthogonalEdge(java.lang.Object edge, boolean value)
Disables or enables orthogonal end segments of the given edgevoid
setUseBoundingBox(boolean useBoundingBox)
mxRectangle
setVertexLocation(java.lang.Object vertex, double x, double y)
Sets the new position of the given cell taking into account the size of the bounding box ifis true.
-
-
-
Field Detail
-
graph
protected mxGraph graph
Holds the enclosing graph.
-
parent
protected java.lang.Object parent
The parent cell of the layout, if any
-
useBoundingBox
protected boolean useBoundingBox
Boolean indicating if the bounding box of the label should be used if its available. Default is true.
-
-
Constructor Detail
-
mxGraphLayout
public mxGraphLayout(mxGraph graph)
Constructs a new fast organic layout for the specified graph.
-
-
Method Detail
-
execute
public void execute(java.lang.Object parent)
Description copied from interface:mxIGraphLayout
Executes the layout for the children of the specified parent.- Specified by:
execute
in interfacemxIGraphLayout
- Parameters:
parent
- Parent cell that contains the children to be layed out.
-
moveCell
public void moveCell(java.lang.Object cell, double x, double y)
Description copied from interface:mxIGraphLayout
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.- Specified by:
moveCell
in interfacemxIGraphLayout
- Parameters:
cell
- Cell which is being moved.x
- X-coordinate of the new cell location.y
- Y-coordinate of the new cell location.
-
getGraph
public mxGraph getGraph()
Returns the associated graph.
-
getConstraint
public java.lang.Object getConstraint(java.lang.Object key, java.lang.Object cell)
Returns the constraint for the given key and cell. This implementation always returns the value for the given key in the style of the given cell.- Parameters:
key
- Key of the constraint to be returned.cell
- Cell whose constraint should be returned.
-
getConstraint
public java.lang.Object getConstraint(java.lang.Object key, java.lang.Object cell, java.lang.Object edge, boolean 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.- Parameters:
key
- Key of the constraint to be returned.cell
- Cell whose constraint should be returned.edge
- Optional cell 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 false.
-
isUseBoundingBox
public boolean isUseBoundingBox()
- Returns:
- the useBoundingBox
-
setUseBoundingBox
public void setUseBoundingBox(boolean useBoundingBox)
- Parameters:
useBoundingBox
- the useBoundingBox to set
-
isVertexMovable
public boolean isVertexMovable(java.lang.Object vertex)
Returns true if the given vertex may be moved by the layout.- Parameters:
vertex
- Object that represents the vertex to be tested.- Returns:
- Returns true if the vertex can be moved.
-
isVertexIgnored
public boolean isVertexIgnored(java.lang.Object vertex)
Returns true if the given vertex has no connected edges.- Parameters:
vertex
- Object that represents the vertex to be tested.- Returns:
- Returns true if the vertex should be ignored.
-
isEdgeIgnored
public boolean isEdgeIgnored(java.lang.Object edge)
Returns true if the given edge has no source or target terminal.- Parameters:
edge
- Object that represents the edge to be tested.- Returns:
- Returns true if the edge should be ignored.
-
setEdgeStyleEnabled
public void setEdgeStyleEnabled(java.lang.Object edge, boolean value)
Disables or enables the edge style of the given edge.
-
setOrthogonalEdge
public void setOrthogonalEdge(java.lang.Object edge, boolean value)
Disables or enables orthogonal end segments of the given edge
-
getParentOffset
public mxPoint getParentOffset(java.lang.Object parent)
-
setEdgePoints
public void setEdgePoints(java.lang.Object edge, java.util.List<mxPoint> points)
Sets the control points of the given edge to the given list of mxPoints. Set the points to null to remove all existing points for an edge.
-
getVertexBounds
public mxRectangle getVertexBounds(java.lang.Object vertex)
Returns anthat defines the bounds of the given cell or the bounding box if is true.
-
setVertexLocation
public mxRectangle setVertexLocation(java.lang.Object vertex, double x, double y)
Sets the new position of the given cell taking into account the size of the bounding box ifis 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). Parameters: cell - 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.
-
arrangeGroups
public void arrangeGroups(java.lang.Object[] groups, int border)
Updates the bounds of the given groups to include all children. Call this with the groups in parent to child order, top-most group first, eg. arrangeGroups(graph, mxUtils.sortCells(Arrays.asList( new Object[] { v1, v3 }), true).toArray(), 10);- Parameters:
groups
- the groups to adjustborder
- the border applied to the adjusted groups
-
-