TreeLayoutResult

class TreeLayoutResult<T>(positions: Map<T, Point>, maxDepth: Int)(source)

The result of a tree layout computation, providing access to node positions, layout metadata, and transformation utilities.

Type Parameters

T

The node type of the external tree.

Constructors

Link copied to clipboard
constructor(positions: Map<T, Point>, maxDepth: Int)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun centered(width: Float, height: Float): TreeLayoutResult<T>

Returns a new result centered within a viewport of width×height. The layout is first scaled to fit (preserving aspect ratio), then offset so that the bounding box is centered in the viewport.

Link copied to clipboard

Returns the axis-aligned bounding box of all node positions.

Link copied to clipboard

Returns the maximum depth of the tree.

Link copied to clipboard
fun getPosition(node: T): Point

Returns the position assigned to node.

Link copied to clipboard

Returns all node-to-position mappings.

Link copied to clipboard
fun mapped(transform: (Point) -> Point): TreeLayoutResult<T>

Returns a new result with all positions transformed by transform.

Link copied to clipboard

Returns a new result with all positions shifted so the minimum corner is at the origin.

Link copied to clipboard
fun scaledTo(width: Float, height: Float): TreeLayoutResult<T>

Returns a new result uniformly scaled to fit within width×height, preserving aspect ratio. Positions are normalized to origin before scaling.

Link copied to clipboard
fun <T> TreeLayoutResult<T>.toJson(nodeToKey: (T) -> String): String

Serializes a TreeLayoutResult to a JSON string.

Link copied to clipboard

Returns a new result with all positions shifted by dx and dy.