Positioner
Positioner<T>
Places the ports depending on the type of Positioner. Each component assigns its own Positioner.
Template Parameters
T extends Port
– *Description needed*
Constructor
public Positioner
new Positioner(dir, scale, length, shortenEdges)
Intializes a Positioner with the following parameters.
Parameters
dir: "left" | "right" | "bottom" | "top"
– Direction of the ports relative to the parent component.scale: number
– Factor to increase the spacing of the ports by (defaults to 1).length: number
– Length of the ports (defaults to IO_PORT_LENGTH ).shortenEdges: false | true
– If true the first port and last port will be moved innerward by one space in the spacing calculation (defaults to true).
Properties
public DIRS: Record
Maps directions to their corresponding vectors.
private dir: Vector
Direction of the ports relative to the parent component.
private scale: number
Factor to increase the spacing of the ports by.
private length: number
Length of the ports.
private shortenEdges: false | true
If true the first port and last port will be moved innerward by one space in the spacing calculation.
Methods
protected calcSpacingPos
calcSpacingPos(i, numPorts, size) => number
Calculates the amount of space between ports.
Parameters
i: number
– Index of port.numPorts: number
– The number of ports.size: number
– Factor to increase the spacing between ports (the spacing is multiplied by size/2).
Returns
-
number
– Value representing the spacing between ports.
protected calcOriginPos
calcOriginPos(sX, sY, w, h) => Vector
Calculates the position of where the port attaches to the parent component relative to the parent component.
Parameters
sX: number
– Position of the port on X axis.sY: number
– Position of the port on Y axis.w: number
– Width of the port.h: number
– Height of the port.
Returns
-
Vector
– A vector representing the position where the port attaches to the parent component.
protected calcTargetPos
calcTargetPos(sX, sY, w, h) => Vector
Calculates the position of where the port is on the canvas relative to the parent component.
Parameters
sX: number
– Position of the port on X axis.sY: number
– Position of the port on Y axis.w: number
– Width of the port.h: number
– Height of the port.
Returns
-
Vector
– A vector representing the position of the port relative to the parent component.
public updatePortPositions
updatePortPositions(ports) => void
Default behavior for port positioning to be evenly spaced along the left side of this component.
Parameters
-
ports: T[]
– The array of ports (either in or out ports).
Static Methods
No static methods for Positioner