# Class PivotByAlgorithm

java.lang.Object
com.treemap.AbstractAlgorithm
com.treemap.PivotByAlgorithm

All Implemented Interfaces:
  `Algorithm`

public class PivotByAlgorithm extends AbstractAlgorithm
Implementation of the Pivot By algorithm. It is described described in:

Ben Shneiderman and Martin Wattenberg. Ordered treemap layouts. IEEE Symposium on Information Visualization, 0:73, 2001.

Complexity: O(n^2), where n is the number of nodes in the tree (depends on the pivot in use).

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `PivotByAlgorithm.Biggest`
  The pivot is taken to be the item with the largest area since the largest item is the most difficult to place.
  `static class`
  `PivotByAlgorithm.Middle`
  The pivot is taken to be the middle item of the list since this is more likely to create a balanced layout.
  `static class`
  `PivotByAlgorithm.SplitSize`
  Selects the pivot that will split L1 and L3 into approximately equal total areas.
  `static interface`
  `PivotByAlgorithm.Type`
  Strategy for determining the node to use as a pivot

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PivotByAlgorithm()`
  `PivotByAlgorithm(PivotByAlgorithm.Type type)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `breadthFirstLayout(com.macrofocus.geom.Shape shape, MutableTreeMapNode parent, MutableTreeMapNode[] children, double sumSizes, int horizontalVanishingPoint, int verticalVanishingPoint, TreeMapWorker worker)`
  Arrange the items in the given array to fill the given shape.
  `boolean`
  `isCompatible(com.macrofocus.geom.Shape shape)`
  Indicates whether the layout algorithm can handle the given geometry of its parent
  `String`
  `toString()`

  ### Methods inherited from class AbstractAlgorithm

  `depthFirstLayout, finishLayout, getProperties, isChildContained, isColorParent, isRenderingLeafLabelsSupported, isRenderingParentLabelSupported, isSpaceFilling, iterator, startLayout, sum`

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### PivotByAlgorithm

    public PivotByAlgorithm()

  - ### PivotByAlgorithm

    public PivotByAlgorithm(PivotByAlgorithm.Type type)

- ## Method Details

  - ### breadthFirstLayout

    public boolean breadthFirstLayout(com.macrofocus.geom.Shape shape, MutableTreeMapNode parent, MutableTreeMapNode[] children, double sumSizes, int horizontalVanishingPoint, int verticalVanishingPoint, TreeMapWorker worker)
    Arrange the items in the given array to fill the given shape. This is called during the first pass, while traversing the tree top down.
    Parameters:
      `shape` - the current rectangle being divided.
      `parent` - the parent node.
      `children` - the items to map.
      `sumSizes` - the size of the parent.
      `horizontalVanishingPoint` -
      `verticalVanishingPoint` -
      `worker` - the worker thread
    Returns:
      true if the layout has been cancelled, false otherwise

  - ### isCompatible

    public boolean isCompatible(com.macrofocus.geom.Shape shape)
    Description copied from interface: `Algorithm`
    Indicates whether the layout algorithm can handle the given geometry of its parent
    Parameters:
      `shape` - the geometry of its parent
    Returns:
      true if it can lay out the children using the specified geometrical shape

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`