using CSharpCodeAnalyst.Contracts; namespace CSharpCodeAnalyst.TreeMap.TreeMap { /// /// Per-node rectangle assignments produced by the tree-map layout. Kept as a side map /// (keyed by node reference) so the pure tree does not have /// to carry mutable rendering state. Produced by and /// consumed by the renderer and hit testing. /// public sealed class TreeMapLayout { private readonly Dictionary _rects = new(); /// Returns the node's layout, creating an empty one on first access. public RectangularLayoutInfo GetOrCreate(IHierarchicalData node) { if (!_rects.TryGetValue(node, out var info)) { info = new RectangularLayoutInfo(); _rects[node] = info; } return info; } /// Returns the node's layout, or null if it was never laid out. public RectangularLayoutInfo? Get(IHierarchicalData node) { return _rects.GetValueOrDefault(node); } } }