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 Object implements mxIGraphLayout
Abstract bass class for layouts
  • Field Details

    • graph

      protected mxGraph graph
      Holds the enclosing graph.
    • parent

      protected 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 Details

    • mxGraphLayout

      public mxGraphLayout(mxGraph graph)
      Constructs a new fast organic layout for the specified graph.
  • Method Details

    • execute

      public void execute(Object parent)
      Description copied from interface: mxIGraphLayout
      Executes the layout for the children of the specified parent.
      Specified by:
      execute in interface mxIGraphLayout
      Parameters:
      parent - Parent cell that contains the children to be layed out.
    • moveCell

      public void moveCell(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 interface mxIGraphLayout
      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 Object getConstraint(Object key, 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 Object getConstraint(Object key, Object cell, 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(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(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(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(Object edge, boolean value)
      Disables or enables the edge style of the given edge.
    • setOrthogonalEdge

      public void setOrthogonalEdge(Object edge, boolean value)
      Disables or enables orthogonal end segments of the given edge
    • getParentOffset

      public mxPoint getParentOffset(Object parent)
    • setEdgePoints

      public void setEdgePoints(Object edge, 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(Object vertex)
      Returns an that defines the bounds of the given cell or the bounding box if is true.
    • setVertexLocation

      public mxRectangle setVertexLocation(Object vertex, double x, double y)
      Sets the new position of the given cell taking into account the size of the bounding box if 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). 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(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 adjust
      border - the border applied to the adjusted groups