selectedNodesBounds property
GraphRect?
get
selectedNodesBounds
Gets the bounding rectangle that encompasses all selected nodes in graph coordinates.
Returns null if no nodes are selected.
This is useful for operations like "fit selected nodes to view" or calculating the area occupied by the selection.
Returns a GraphRect containing all selected nodes, or null if nothing is selected.
Implementation
GraphRect? get selectedNodesBounds {
if (_selectedNodeIds.isEmpty) return null;
final selectedNodes = _selectedNodeIds
.map((id) => _nodes[id])
.where((node) => node != null)
.cast<Node<T>>();
return _calculateNodesBounds(selectedNodes);
}