updateConnection method

void updateConnection(
  1. Connection connection,
  2. List<Rect> segmentBounds
)

Updates a connection in the spatial index with segment bounds.

Connections use multiple segments for accurate curved path hit testing.

Implementation

void updateConnection(Connection connection, List<Rect> segmentBounds) {
  _connections[connection.id] = connection;
  _removeConnectionSegments(connectionId: connection.id, notify: false);

  if (segmentBounds.isEmpty) {
    _notifyChanged();
    return;
  }

  final segmentIds = <String>[];
  for (int i = 0; i < segmentBounds.length; i++) {
    final item = ConnectionSegmentItem(
      connectionId: connection.id,
      segmentIndex: i,
      bounds: segmentBounds[i],
    );
    _grid.addOrUpdate(item);
    segmentIds.add(item.id);
  }
  _connectionSegmentIds[connection.id] = segmentIds;
  _autoFlush();
  _notifyChanged();
}