# PivotByAlgorithm

class PivotByAlgorithm(type: PivotByAlgorithm.Type = SplitSize()) : AbstractAlgorithm

Implementation of the Pivot By algorithm. It is 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).

## Constructors

PivotByAlgorithm
Link copied to clipboard
constructor(type: PivotByAlgorithm.Type = SplitSize())

## Types

Biggest
Link copied to clipboard
class Biggest : PivotByAlgorithm.Type

The pivot is taken to be the item with the largest area since the largest item is the most difficult to place.

Middle
Link copied to clipboard
class Middle : PivotByAlgorithm.Type

The pivot is taken to be the middle item of the list since this is more likely to create a balanced layout.

SplitSize
Link copied to clipboard
class SplitSize : PivotByAlgorithm.Type

Selects the pivot that will split L1 and L3 into approximately equal total areas.

Type
Link copied to clipboard
interface Type

Strategy for determining the node to use as a pivot

## Properties

isChildContained
Link copied to clipboard
open override val isChildContained: Boolean
isColorParent
Link copied to clipboard
open override val isColorParent: Boolean
isRenderingLeafLabelsSupported
Link copied to clipboard
open override val isRenderingLeafLabelsSupported: Boolean
isRenderingParentLabelSupported
Link copied to clipboard
open override val isRenderingParentLabelSupported: Boolean
isSpaceFilling
Link copied to clipboard
open override val isSpaceFilling: Boolean
properties
Link copied to clipboard
open override val properties: MutableProperties<String?>?

Properties for storing layout algorithm specific options.

## Functions

breadthFirstLayout
Link copied to clipboard
open override fun <N, Row, Column> breadthFirstLayout(shape: Shape, parent: N, children: Array<N>, sumSizes: Double, horizontalVanishingPoint: Int, verticalVanishingPoint: Int, accessor: TreeMapAccessor<N>, worker: TreeMapWorker?): Boolean

{@inheritDoc}

computeAverageAspectRatio
Link copied to clipboard
fun computeAverageAspectRatio(rectangles: Array<Rectangle2D?>): Double
depthFirstLayout
Link copied to clipboard
open override fun <N, Row, Column> depthFirstLayout(shape: Shape?, parent: N, children: Array<N>, sumSizes: Double, horizontalVanishingPoint: Int, verticalVanishingPoint: Int, accessor: TreeMapAccessor<N>, worker: TreeMapWorker?): Boolean

Arrange the items in the given array to fill the given shape. This is called during the first pass, while traversing the tree from the bottom up.

finishLayout
Link copied to clipboard
open override fun <N, Row, Column> finishLayout(bounds: Rectangle2D?, model: TreeMapModel<N, Row, Column>?, root: N)

Do nothing by default.

getName
Link copied to clipboard
fun getName(): String
isCompatible
Link copied to clipboard
open override fun isCompatible(shape: Shape?): Boolean

Indicates whether the layout algorithm can handle the given geometry of its parent

iterator
Link copied to clipboard
open override fun <N, Row, Column> iterator(model: TreeMapModel<N, Row, Column>, root: N): Iterable<N>

Breadth first traversal by default.

layout
Link copied to clipboard
fun <N, Row, Column> layout(children: Array<N>, bounds: Rectangle2D?, accessor: TreeMapAccessor<N>): Array<Rectangle2D?>

Divide the items in the list, other than P, into three lists, L1, L2, and L3, such that L1 consist of items whose index is less than P and L2 have items having index less than those in L3, and the aspect ratio of RP is as close to 1 as possible.

startLayout
Link copied to clipboard
open override fun <N, Row, Column> startLayout(bounds: Rectangle2D?, model: TreeMapModel<N, Row, Column>, root: N, worker: TreeMapWorker?)

Do nothing by default.

toString
Link copied to clipboard
open override fun toString(): String
tryAlternativeLayouts
Link copied to clipboard
fun <N> tryAlternativeLayouts(children: Array<N>, bounds: Rectangle2D, rectangles: Array<Rectangle2D?>, accessor: TreeMapAccessor<N>): Array<Rectangle2D?>

If number of items is <= 5, lay them either in a pivot, quad, or snake layout. Pick the best layout whose average aspect ratio is closest to 1.