com.mxgraph.layout

## Class mxCompactTreeLayout

- java.lang.Object
- - com.mxgraph.layout.mxGraphLayout
  - - com.mxgraph.layout.mxCompactTreeLayout

- All Implemented Interfaces:
    mxIGraphLayout

      public class mxCompactTreeLayout
      extends mxGraphLayout

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static class` | `mxCompactTreeLayout.Polygon`
    `protected static class` | `mxCompactTreeLayout.Polyline`
    `protected static class` | `mxCompactTreeLayout.TreeNode`
    `protected class` | `mxCompactTreeLayout.WeightedCellSorter` A utility class used to track cells whilst sorting occurs on the weighted sum of their connected edges.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `channelBuffer` The size of the vertical buffer in the center of inter-rank channels where edge control points should not be placed
    `protected boolean` | `edgeRouting` Whether or not to apply the internal tree edge routing
    `protected int` | `groupPadding` Padding added to resized parents
    `protected boolean` | `horizontal` Specifies the orientation of the layout.
    `protected boolean` | `invert` Specifies if edge directions should be inverted.
    `protected int` | `levelDistance` Holds the levelDistance.
    `protected int` | `minEdgeJetty` The minimum distance for an edge jetty from a vertex
    `protected boolean` | `moveTree` Specifies if the tree should be moved to the top, left corner if it is inside a top-level layer.
    `protected int` | `nodeDistance` Holds the nodeDistance.
    `protected java.util.Set<java.lang.Object>` | `parentsChanged` A set of the parents that need updating based on children process as part of the layout
    `protected int` | `prefHozEdgeSep` The preferred horizontal distance between edges exiting a vertex
    `protected int` | `prefVertEdgeOff` The preferred vertical offset between edges exiting a vertex
    `protected boolean` | `resetEdges` Specifies if all edge points of traversed edges should be removed.
    `protected boolean` | `resizeParent` If the parents should be resized to match the width/height of the children.

    - ### Fields inherited from class com.mxgraph.layout.mxGraphLayout

      `graph, parent, useBoundingBox`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `mxCompactTreeLayout(mxGraph graph)`
    `mxCompactTreeLayout(mxGraph graph, boolean horizontal)`
    `mxCompactTreeLayout(mxGraph graph, boolean horizontal, boolean invert)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `adjustParents()` Adjust parent cells whose child geometries have changed.
    `protected mxRectangle` | `apply(mxCompactTreeLayout.TreeNode node, mxRectangle bounds)`
    `protected void` | `attachParent(mxCompactTreeLayout.TreeNode node, double height)`
    `protected mxCompactTreeLayout.Polyline` | `bridge(mxCompactTreeLayout.Polyline line1, double x1, double y1, mxCompactTreeLayout.Polyline line2, double x2, double y2)`
    `protected mxCompactTreeLayout.Polyline` | `createLine(double dx, double dy, mxCompactTreeLayout.Polyline next)`
    `protected mxCompactTreeLayout.TreeNode` | `createNode(java.lang.Object cell)`
    `protected mxCompactTreeLayout.TreeNode` | `dfs(java.lang.Object cell, java.lang.Object parent, java.util.Set<java.lang.Object> visited)` Does a depth first search starting at the specified cell.
    `void` | `execute(java.lang.Object parent)` Executes the layout for the children of the specified parent.
    `void` | `execute(java.lang.Object parent, java.lang.Object root)` Implements .
    `java.util.List<java.lang.Object>` | `findTreeRoots(java.lang.Object parent, boolean invert)` Returns all visible children in the given parent which do not have incoming edges.
    `double` | `getGroupPadding()`
    `int` | `getLevelDistance()`
    `int` | `getNodeDistance()`
    `protected mxRectangle` | `horizontalLayout(mxCompactTreeLayout.TreeNode node, double x0, double y0, mxRectangle bounds)`
    `boolean` | `isEdgeRouting()`
    `boolean` | `isHorizontal()`
    `boolean` | `isInvert()`
    `boolean` | `isMoveTree()`
    `boolean` | `isResetEdges()`
    `boolean` | `isResizeParent()`
    `boolean` | `isVertexIgnored(java.lang.Object vertex)` Returns a boolean indicating if the given should be ignored as a vertex.
    `protected double` | `join(mxCompactTreeLayout.TreeNode node)`
    `protected void` | `layout(mxCompactTreeLayout.TreeNode node)` Starts the actual compact tree layout algorithm at the given node.
    `protected void` | `layoutLeaf(mxCompactTreeLayout.TreeNode node)`
    `protected void` | `localEdgeProcessing(mxCompactTreeLayout.TreeNode node)` Moves the specified node and all of its children by the given amount.
    `protected double` | `merge(mxCompactTreeLayout.Polygon p1, mxCompactTreeLayout.Polygon p2)`
    `protected void` | `moveNode(mxCompactTreeLayout.TreeNode node, double dx, double dy)` Moves the specified node and all of its children by the given amount.
    `protected double` | `offset(double p1, double p2, double a1, double a2, double b1, double b2)`
    `protected void` | `processNodeOutgoing(mxCompactTreeLayout.TreeNode node)` Separates the x position of edges as they connect to vertices
    `void` | `setEdgeRouting(boolean edgeRouting)`
    `void` | `setGroupPadding(int groupPadding)`
    `void` | `setHorizontal(boolean horizontal)`
    `void` | `setInvert(boolean invert)`
    `void` | `setLevelDistance(int levelDistance)`
    `void` | `setMoveTree(boolean moveTree)`
    `void` | `setNodeDistance(int nodeDistance)`
    `void` | `setResetEdges(boolean resetEdges)`
    `void` | `setResizeParent(boolean resizeParent)`
    `protected mxRectangle` | `verticalLayout(mxCompactTreeLayout.TreeNode node, java.lang.Object parent, double x0, double y0, mxRectangle bounds)`

    - ### Methods inherited from class com.mxgraph.layout.mxGraphLayout

      `arrangeGroups, getConstraint, getConstraint, getGraph, getParentOffset, getVertexBounds, isEdgeIgnored, isUseBoundingBox, isVertexMovable, moveCell, setEdgePoints, setEdgeStyleEnabled, setOrthogonalEdge, setUseBoundingBox, setVertexLocation`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### horizontal

          protected boolean horizontal

      Specifies the orientation of the layout. Default is true.

    - #### invert

          protected boolean invert

      Specifies if edge directions should be inverted. Default is false.

    - #### resizeParent

          protected boolean resizeParent

      If the parents should be resized to match the width/height of the children. Default is true.

    - #### groupPadding

          protected int groupPadding

      Padding added to resized parents

    - #### parentsChanged

          protected java.util.Set<java.lang.Object> parentsChanged

      A set of the parents that need updating based on children process as part of the layout

    - #### moveTree

          protected boolean moveTree

      Specifies if the tree should be moved to the top, left corner if it is inside a top-level layer. Default is false.

    - #### resetEdges

          protected boolean resetEdges

      Specifies if all edge points of traversed edges should be removed. Default is true.

    - #### levelDistance

          protected int levelDistance

      Holds the levelDistance. Default is 10.

    - #### nodeDistance

          protected int nodeDistance

      Holds the nodeDistance. Default is 20.

    - #### prefHozEdgeSep

          protected int prefHozEdgeSep

      The preferred horizontal distance between edges exiting a vertex

    - #### prefVertEdgeOff

          protected int prefVertEdgeOff

      The preferred vertical offset between edges exiting a vertex

    - #### minEdgeJetty

          protected int minEdgeJetty

      The minimum distance for an edge jetty from a vertex

    - #### channelBuffer

          protected int channelBuffer

      The size of the vertical buffer in the center of inter-rank channels where edge control points should not be placed

    - #### edgeRouting

          protected boolean edgeRouting

      Whether or not to apply the internal tree edge routing

  - ### Constructor Detail

    - #### mxCompactTreeLayout

          public mxCompactTreeLayout(mxGraph graph)

      Parameters:
        `graph` -

    - #### mxCompactTreeLayout

          public mxCompactTreeLayout(mxGraph graph,
                             boolean horizontal)

      Parameters:
        `graph` -
        `horizontal` -

    - #### mxCompactTreeLayout

          public mxCompactTreeLayout(mxGraph graph,
                             boolean horizontal,
                             boolean invert)

      Parameters:
        `graph` -
        `horizontal` -
        `invert` -

  - ### Method Detail

    - #### isVertexIgnored

          public boolean isVertexIgnored(java.lang.Object vertex)

      Returns a boolean indicating if the given should be ignored as a vertex. This returns true if the cell has no connections.
      Overrides:
        `isVertexIgnored` in class `mxGraphLayout`
      Parameters:
        `vertex` - Object that represents the vertex to be tested.
      Returns:
        Returns true if the vertex should be ignored.

    - #### isHorizontal

          public boolean isHorizontal()

      Returns:
        the horizontal

    - #### setHorizontal

          public void setHorizontal(boolean horizontal)

      Parameters:
        `horizontal` - the horizontal to set

    - #### isInvert

          public boolean isInvert()

      Returns:
        the invert

    - #### setInvert

          public void setInvert(boolean invert)

      Parameters:
        `invert` - the invert to set

    - #### isResizeParent

          public boolean isResizeParent()

      Returns:
        the resizeParent

    - #### setResizeParent

          public void setResizeParent(boolean resizeParent)

      Parameters:
        `resizeParent` - the resizeParent to set

    - #### isMoveTree

          public boolean isMoveTree()

      Returns:
        the moveTree

    - #### setMoveTree

          public void setMoveTree(boolean moveTree)

      Parameters:
        `moveTree` - the moveTree to set

    - #### isResetEdges

          public boolean isResetEdges()

      Returns:
        the resetEdges

    - #### setResetEdges

          public void setResetEdges(boolean resetEdges)

      Parameters:
        `resetEdges` - the resetEdges to set

    - #### isEdgeRouting

          public boolean isEdgeRouting()

    - #### setEdgeRouting

          public void setEdgeRouting(boolean edgeRouting)

    - #### getLevelDistance

          public int getLevelDistance()

      Returns:
        the levelDistance

    - #### setLevelDistance

          public void setLevelDistance(int levelDistance)

      Parameters:
        `levelDistance` - the levelDistance to set

    - #### getNodeDistance

          public int getNodeDistance()

      Returns:
        the nodeDistance

    - #### setNodeDistance

          public void setNodeDistance(int nodeDistance)

      Parameters:
        `nodeDistance` - the nodeDistance to set

    - #### getGroupPadding

          public double getGroupPadding()

    - #### setGroupPadding

          public void setGroupPadding(int groupPadding)

    - #### 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 interface `mxIGraphLayout`
      Overrides:
        `execute` in class `mxGraphLayout`
      Parameters:
        `parent` - Parent cell that contains the children to be layed out.

    - #### execute

          public void execute(java.lang.Object parent,
                     java.lang.Object root)

      Implements . If the parent has any connected edges, then it is used as the root of the tree. Else, will be used to find a suitable root node within the set of children of the given parent.

    - #### findTreeRoots

          public java.util.List<java.lang.Object> findTreeRoots(java.lang.Object parent,
                                                       boolean invert)

      Returns all visible children in the given parent which do not have incoming edges. If the result is empty then the children with the maximum difference between incoming and outgoing edges are returned. This takes into account edges that are being promoted to the given root due to invisible children or collapsed cells.
      Parameters:
        `parent` - Cell whose children should be checked.
        `invert` - Specifies if outgoing or incoming edges should be counted for a tree root. If false then outgoing edges will be counted.
      Returns:
        List of tree roots in parent.

    - #### moveNode

          protected void moveNode(mxCompactTreeLayout.TreeNode node,
                      double dx,
                      double dy)

      Moves the specified node and all of its children by the given amount.

    - #### dfs

          protected mxCompactTreeLayout.TreeNode dfs(java.lang.Object cell,
                                         java.lang.Object parent,
                                         java.util.Set<java.lang.Object> visited)

      Does a depth first search starting at the specified cell. Makes sure the specified parent is never left by the algorithm.

    - #### layout

          protected void layout(mxCompactTreeLayout.TreeNode node)

      Starts the actual compact tree layout algorithm at the given node.

    - #### horizontalLayout

          protected mxRectangle horizontalLayout(mxCompactTreeLayout.TreeNode node,
                                     double x0,
                                     double y0,
                                     mxRectangle bounds)

    - #### verticalLayout

          protected mxRectangle verticalLayout(mxCompactTreeLayout.TreeNode node,
                                   java.lang.Object parent,
                                   double x0,
                                   double y0,
                                   mxRectangle bounds)

    - #### attachParent

          protected void attachParent(mxCompactTreeLayout.TreeNode node,
                          double height)

    - #### layoutLeaf

          protected void layoutLeaf(mxCompactTreeLayout.TreeNode node)

    - #### join

          protected double join(mxCompactTreeLayout.TreeNode node)

    - #### merge

          protected double merge(mxCompactTreeLayout.Polygon p1,
                     mxCompactTreeLayout.Polygon p2)

    - #### offset

          protected double offset(double p1,
                      double p2,
                      double a1,
                      double a2,
                      double b1,
                      double b2)

    - #### bridge

          protected mxCompactTreeLayout.Polyline bridge(mxCompactTreeLayout.Polyline line1,
                                            double x1,
                                            double y1,
                                            mxCompactTreeLayout.Polyline line2,
                                            double x2,
                                            double y2)

    - #### createNode

          protected mxCompactTreeLayout.TreeNode createNode(java.lang.Object cell)

    - #### apply

          protected mxRectangle apply(mxCompactTreeLayout.TreeNode node,
                          mxRectangle bounds)

      Parameters:
        `node` -
        `bounds` -
      Returns:

    - #### createLine

          protected mxCompactTreeLayout.Polyline createLine(double dx,
                                                double dy,
                                                mxCompactTreeLayout.Polyline next)

    - #### adjustParents

          protected void adjustParents()

      Adjust parent cells whose child geometries have changed. The default implementation adjusts the group to just fit around the children with a padding.

    - #### localEdgeProcessing

          protected void localEdgeProcessing(mxCompactTreeLayout.TreeNode node)

      Moves the specified node and all of its children by the given amount.

    - #### processNodeOutgoing

          protected void processNodeOutgoing(mxCompactTreeLayout.TreeNode node)

      Separates the x position of edges as they connect to vertices
      Parameters:
        `node` - the root node of the tree

Copyright (c) 2010 Gaudenz Alder. All rights reserved.