This class represents a candidate port on which edges can be connected to their source and/or target node.
Remarks
The notion of PortCandidates extends the one of PortConstraints. In contrast to PortConstraints, they can be associated with both edges and nodes. Moreover, more than one PortCandidate can be specified for an edge or a node.
Edge PortCandidates can be introduced to define specific sides or exact locations on which a given edge can be connected to its source or target node.
Information about edge PortCandidates is held by IDataProviders that are registered with the graph using keys SOURCE_PORT_CANDIDATE_COLLECTION_DP_KEY (to specify PortCandidates for an edge on the source node) and TARGET_PORT_CANDIDATE_COLLECTION_DP_KEY (to specify PortCandidates for an edge on the target node). The IDataProviders hold a collection of PortCandidates for each edge.
Node PortCandidates determine available ports on the nodes to which edges can be connected. This means that an edge of the graph can be connected to any of these node ports (unless edge PortCandidates are specified too).
To register and define node PortCandidates refer to PortCandidateSet.
A PortCandidate is described by the following attributes:
- Offsets: The X-offset (Y-offset) determines the horizontal (vertical) distance of the PortCandidate relative to the center of the node.
- Fixed or free: Fixed PortCandidates are defined using exact coordinates, whereas coordinates of free candidates are selected arbitrarily.
- Direction: Corresponds to the incoming or outgoing directions of the edges when connecting to a target or source node, respectively.
- Penalty cost: Represents the cost of usage of a PortCandidate. During the processing of an edge by a layout or routing algorithm, candidates of lower cost will be considered first.
If candidates are defined for nodes as well as for edges and if they should be properly matched by layout algorithms (i.e. detected as the same candidate), then it is important that the same PortCandidate instance is registered. It does not suffice to register candidates with the same parameter values.
Not all layout and routing algorithms are able to handle PortCandidates. Major layout algorithms that obey them are HierarchicLayout, EdgeRouter, ChannelEdgeRouter and BusRouter.
Type Details
- yfiles module
- layout-core
- yfiles-umd modules
- All layout modules, view-layout-bridge
- Legacy UMD name
- yfiles.layout.PortCandidate
See Also
Properties
Gets the penalty cost for using this PortCandidate instance.
Gets the direction of this PortCandidate.
Remarks
See Also
Gets whether or not this PortCandidate is fixed.
Remarks
Gets the X-offset of the PortCandidate with respect to the center of the corresponding node.
Remarks
Gets the Y-offset of the PortCandidate with respect to the center of the corresponding node.
Remarks
Methods
Returns whether or not this PortCandidate is equal to another PortCandidate based on their internal attributes.
Parameters
A map of options to pass to the method.
- other - Object
- the reference PortCandidate object with which to compare
Returns
- ↪boolean
Returns the direction of this PortCandidate instance with respect to the given layout orientation.
Remarks
Returns
- ↪PortDirections
- the direction of this PortCandidate with respect to the given layout orientation
See Also
getXOffsetForLayoutOrientation
(layoutOrientation: LayoutOrientation, mirrorMask: MirrorModes) : numberReturns the X-offset of the PortCandidate with respect to the center of the corresponding node for the given layout orientation and mirror mask.
Remarks
Parameters
A map of options to pass to the method.
- layoutOrientation - LayoutOrientation
- the layout orientation
- mirrorMask - MirrorModes
- the mirror mask
Returns
- ↪number
- the X-offset of the port with respect to the given orientation and mirror mask
Returns the X-offset of the PortCandidate with respect to the center of the corresponding node for the given layout orientation.
Remarks
Parameters
A map of options to pass to the method.
- layoutOrientation - LayoutOrientation
- the layout orientation
Returns
- ↪number
- the X-offset of the PortCandidate with respect to the given layout orientation
getYOffsetForLayoutOrientation
(layoutOrientation: LayoutOrientation, mirrorMask: MirrorModes) : numberReturns the Y-offset of the PortCandidate with respect to the center of the corresponding node for the given layout orientation and mirror mask.
Remarks
Parameters
A map of options to pass to the method.
- layoutOrientation - LayoutOrientation
- the layout orientation
- mirrorMask - MirrorModes
- the mirror mask
Returns
- ↪number
- the Y-offset of the PortCandidate with respect to the given orientation and mirror mask
Returns the Y-offset of the PortCandidate with respect to the center of the corresponding node for the given layout orientation.
Remarks
Parameters
A map of options to pass to the method.
- layoutOrientation - LayoutOrientation
- the layout orientation
Returns
- ↪number
- the Y-offset of the PortCandidate with respect to the given layout orientation
Returns a hash code value for this PortCandidate instance based on the internal attributes.
Returns
- ↪number
- a hash code value
Returns whether or not this PortCandidate lies in the given direction.
Parameters
A map of options to pass to the method.
- directionMask - PortDirections
- one of the default direction specifiers
Returns
- ↪boolean
A utility method that converts the current PortCandidate instance to a PortConstraint.
Remarks
The side of the created PortConstraint matches the direction of this PortCandidate.
If this PortCandidate is fixed, the resulting PortConstraint will be strong.
Returns
- ↪PortConstraint
- a PortConstraint that matches this PortCandidate
A utility method that converts the current PortCandidate instance to a PortConstraint with respect to the given layout orientation.
Remarks
The side of the created PortConstraint is the direction of this PortCandidate interpreted for the given orientation.
If this PortCandidate is fixed, the resulting PortConstraint will be strong.
Returns
- ↪PortConstraint
- a PortConstraint that matches this PortCandidate with respect to the given orientation
Returns a string representation of this PortCandidate instance.
Returns
- ↪string
- a string representation of the PortCandidate
Constants
A data provider key for specifying source port candidates for each edge.
Domain | Edge | |
Values | ICollection<T> | a collection of null if no source |
See Also
A data provider key for specifying target port candidates for each edge.
Domain | Edge | |
Values | ICollection<T> | a collection of null if no target |
See Also
Static Methods
Factory method that creates a free PortCandidate instance with the given direction and cost of usage.
Parameters
A map of options to pass to the method.
- directionMask - PortDirections
- any combination of the default direction specifiers
- cost - number
- the penalty cost for using this PortCandidate
Returns
- ↪PortCandidate
- a new PortCandidate instance
createCandidate
(xOffset: number, yOffset: number, directionMask: PortDirections, cost?: number) : PortCandidateFactory method that creates a fixed PortCandidate instance with the given cost of usage, direction and offset values.
Parameters
A map of options to pass to the method.
- xOffset - number
- the X-offset relative to the center of the node
- yOffset - number
- the Y-offset relative to the center of the node
- directionMask - PortDirections
- any combination of the default direction specifiers
- cost - number
- the penalty cost for using this PortCandidate instance
Returns
- ↪PortCandidate
- a new PortCandidate instance
Factory method that returns a free PortCandidate instance with zero cost of usage and the direction specified by the side of the given PortConstraint.
Parameters
A map of options to pass to the method.
- fromPortConstraint - PortConstraint
- the PortConstraint whose side should be used as direction
Returns
- ↪PortCandidate
- a new PortCandidate instance