Package com.treemap

# Class SliceAndDiceAlgorithm

java.lang.Object
com.treemap.AbstractAlgorithm
com.treemap.SliceAndDiceAlgorithm

All Implemented Interfaces:
  `Algorithm`

public class SliceAndDiceAlgorithm extends AbstractAlgorithm
Implementation of the Slice-and-dice algorithm described in the original treemap paper. It is described in:

Ben Shneiderman. 'Tree Visualization with Tree-Maps: 2-d Space-filling Approach." ACM Transactions on Graphics, 11(1), pp. 92-99, 1992.

It uses parallel lines to divide a rectangle representing an item into smaller rectangles representing its children. At each level of hierarchy the orientation of the lines - vertical or horizontal - is switched (Alternate), computed according to the aspect ratio (Best), or fixed (Vertical, Horizontal).

Complexity: O(n), where n is the number of nodes in the tree.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `SliceAndDiceAlgorithm.AlternateOrientationStrategy`
  Switched between vertical and horizontal at each hierarchy level
  `static class`
  `SliceAndDiceAlgorithm.BestOrientationStrategy`
  Computed according to the aspect ratio
  `static class`
  `SliceAndDiceAlgorithm.HoritzonalOrientationStrategy`
  Always horizontal
  `static interface`
  `SliceAndDiceAlgorithm.OrientationStragegy`
  Types of orientation of the rectangle divisions
  `static class`
  `SliceAndDiceAlgorithm.VerticalOrientationStrategy`
  Always vertical

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SliceAndDiceAlgorithm()`
  Creates an instance of the slice-and-dice algorithm with the orientation of the layout switched between vertical and horizontal at each hierarchy level.
  `SliceAndDiceAlgorithm(SliceAndDiceAlgorithm.OrientationStragegy orientationStrategy)`
  Creates an instance of the slide-and-dice algorithm with the given orientation strategy.

- ## 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 com.treemap.AbstractAlgorithm

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

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

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

- ## Constructor Details

  - ### SliceAndDiceAlgorithm

    public SliceAndDiceAlgorithm()
    Creates an instance of the slice-and-dice algorithm with the orientation of the layout switched between vertical and horizontal at each hierarchy level.

  - ### SliceAndDiceAlgorithm

    public SliceAndDiceAlgorithm(SliceAndDiceAlgorithm.OrientationStragegy orientationStrategy)
    Creates an instance of the slide-and-dice algorithm with the given orientation strategy.
    Parameters:
      `orientationStrategy` - the orientation strategy to use

- ## 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`