Package com.treemap.swing.voronoi
Class VoronoiAlgorithm<N,Row,Column,Color,Font>
java.lang.Object
com.treemap.AbstractAlgorithm<N,Row,Column,Color,Font>
com.treemap.swing.voronoi.VoronoiAlgorithm<N,Row,Column,Color,Font>
- All Implemented Interfaces:
Algorithm<N,
Row, Column, Color, Font>
public class VoronoiAlgorithm<N,Row,Column,Color,Font>
extends AbstractAlgorithm<N,Row,Column,Color,Font>
Implementation of the Voronoi algorithm. It is described in:
Michael Balzer, Oliver Deussen "Voronoi Treemaps". In: Proceedings of the 2005 IEEE Symposium on Information
Visualization (INFOVIS'05), p. 49-56.
Rectangular algorithms, cause problems with the aspect ratio of the rectangles as well as with identifying the
visualized hierarchical structure. The approach of Voronoi Treemaps eliminates these problems through enabling
subdivisions of and in polygons. Additionally, this allows for creating Treemap visualizations within areas of
arbitrary shape, such as triangles and circles, thereby enabling a more flexible adaptation of Treemaps for a wider
range of applications.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionVoronoiAlgorithm
(double epsilon, double delta, int minIterations, int maxIterations, int seed, int maxRestarts, VoronoiAlgorithm.WeightType weightType) Creates a new object that can produce voronoi treemap layouts. -
Method Summary
Modifier and TypeMethodDescriptionboolean
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.static double
calculatePolygonArea
(com.macrofocus.geom.Polygon polygon) Calculates the area of a polygon.boolean
isCompatible
(com.macrofocus.geom.Shape shape) Indicates whether the layout algorithm can handle the given geometry of its parentboolean
run
(com.macrofocus.geom.Shape unscaledDomain, VoronoiCell[] cells, TreeMapWorker worker, MutableTreeMapNode parent) Calculates a pixel raster Voronoi based on the "Algorithm 1" discribed Balzer et al.void
startLayout
(com.macrofocus.geom.Rectangle2D bounds, TreeMapModel<N, Row, Column, Color, Font> model, N root, TreeMapWorker worker) Do nothing by default.toString()
Methods inherited from class com.treemap.AbstractAlgorithm
depthFirstLayout, finishLayout, getProperties, isChildContained, isColorParent, isRenderingLeafLabelsSupported, isRenderingParentLabelSupported, iterator, sum
-
Field Details
-
delta
protected double delta
-
-
Constructor Details
-
VoronoiAlgorithm
public VoronoiAlgorithm() -
VoronoiAlgorithm
public VoronoiAlgorithm(double epsilon, double delta, int minIterations, int maxIterations, int seed, int maxRestarts, VoronoiAlgorithm.WeightType weightType) Creates a new object that can produce voronoi treemap layouts.- Parameters:
epsilon
- absolute of the maximal allowed error in area (as proportion of the diagram area)delta
- minimum value of weights, must be small but must not be zero, eg. 1e-5minIterations
- minimal number of iterationsmaxIterations
- maximal number of iterationsseed
- seed parameter for the random start positions of the cellsmaxRestarts
- maximal number of layout restarts with reduced deltaweightType
- additively or power weigthed voronoi diagram type
-
-
Method Details
-
startLayout
public void startLayout(com.macrofocus.geom.Rectangle2D bounds, TreeMapModel<N, Row, Column, Color, Font> model, N root, TreeMapWorker worker) Do nothing by default.- Specified by:
startLayout
in interfaceAlgorithm<N,
Row, Column, Color, Font> - Overrides:
startLayout
in classAbstractAlgorithm<N,
Row, Column, Color, Font> - Parameters:
bounds
- the bounds of the viewmodel
- the modelroot
- the root node
-
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.worker
- the worker thread- Returns:
- true if the layout has been cancelled, false otherwise
-
run
public VoronoiOutputRaster run(com.macrofocus.geom.Shape unscaledDomain, VoronoiCell[] cells, TreeMapWorker worker, MutableTreeMapNode parent) Calculates a pixel raster Voronoi based on the "Algorithm 1" discribed Balzer et al. 2005 paper, enhanced with scaling and restart-when-failed functionality.- Parameters:
unscaledDomain
- domain inside which the layout is calculatedcells
- array of VoronoiCells containing initialized with their desired areasworker
- the worker threadparent
- the parent node (as debug information)- Returns:
- the calculated voronoi diagram as pixel raster. null if calculation was not successful
-
calculatePolygonArea
public static double calculatePolygonArea(com.macrofocus.geom.Polygon polygon) Calculates the area of a polygon.- Parameters:
polygon
- the polygon- Returns:
- the calculated area of the polygon
-
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
-
isSpaceFilling
public boolean isSpaceFilling()- Specified by:
isSpaceFilling
in interfaceAlgorithm<N,
Row, Column, Color, Font> - Overrides:
isSpaceFilling
in classAbstractAlgorithm<N,
Row, Column, Color, Font>
-
toString
-