getPortCapsuleSide method

CapsuleFlatSide getPortCapsuleSide(
  1. String portId
)

Gets the capsule flat side orientation for a port.

Ports are rendered as capsule half shapes with one flat edge. This method determines which edge should be flat based on the port's position.

Throws ArgumentError if no port with the given portId is found.

Implementation

CapsuleFlatSide getPortCapsuleSide(String portId) {
  final port = findPort(portId);

  if (port == null) {
    throw ArgumentError('Port $portId not found');
  }

  switch (port.position) {
    case PortPosition.left:
      return CapsuleFlatSide.left;
    case PortPosition.right:
      return CapsuleFlatSide.right;
    case PortPosition.top:
      return CapsuleFlatSide.top;
    case PortPosition.bottom:
      return CapsuleFlatSide.bottom;
  }
}