This class represents a candidate port on which edges can be connected to their source and/or target node.
Remarks
LayoutPortCandidates can be associated with both edges and nodes. Moreover, more than one LayoutPortCandidate can be specified for an edge or a node.
Information about edge LayoutPortCandidates can be specified using EdgePortCandidates that allow to define specific sides or exact locations on which a given edge can be connected to its source or target node. It is recommended to set the EdgePortCandidates using the corresponding properties sourcePortCandidates and targetPortCandidates, respectively. Alternatively, the EdgePortCandidates can be given via IMapper<K,V>s that are registered with the graph using the keys SOURCE_PORT_CANDIDATES_DATA_KEY (to specify EdgePortCandidates on the source node) and TARGET_PORT_CANDIDATES_DATA_KEY (to specify EdgePortCandidates on the target node).
NodePortCandidates 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 EdgePortCandidates are specified too). To register and define node LayoutPortCandidates refer to NodePortCandidates.
A LayoutPortCandidate is described by the following attributes:
- type: FREE candidates specify that the port may be placed anywhere on the side. Fixed candidates with an offset specify that the location of the port relative to the center of the node is given by offset. Fixed-from-sketch candidates specify that the location of the port relative to the center of the node is the same as in the input.
- offset: The X-offset (Y-offset) determines the horizontal (vertical) distance of the candidate relative to the center of the node. It is only meaningful if the type is FIXED_OFFSET.
- side: Corresponds to the sides of the nodes at which the edges connect to their target or source nodes.
- cost: Represents the cost of usage of the candidate. During the processing of an edge by a layout or routing algorithm, candidates of lower cost will be preferred.
- matchingId: When matching candidates that belong to an edge to ones that belong to a node in a layout or routing algorithm, only candidates with the same ID can match. By default, the matching ID is
null
, which matches all matching IDs. - capacity: Represents the maximum number of edges that may connect to the candidate. The capacity is only relevant for candidates that belong to a node.
Not all layout and routing algorithms are able to handle port candidates. Major layout algorithms that consider them are HierarchicalLayout and EdgeRouter.
This class cannot be instantiated
Default Values of Properties
Type Details
- yFiles module
- algorithms
See Also
Properties
Gets the number of possible connections to this candidate.
Remarks
Default Value
1
.The port candidate can only be used by one edge
Property Value
Gets the penalty cost for using this candidate instance.
Remarks
Default Value
0
.the candidate has no cost
Property Value
Gets the matching ID of this candidate.
Remarks
null
, this candidate may match with all other candidates. Otherwise, it matches only with other candidates whose matching ID is equal or null
.Default Value
null
.the candidate may match with all other candidates
Property Value
Gets the offset of the candidate relative to the center of the corresponding node.
Remarks
Default Value
PointD.Origin
.the port is at the center of the node
Property Value
Gets the side of this candidate.
Remarks
Property Value
See Also
Gets the type of this candidate.
Remarks
- FREE candidates specify that the port may be placed anywhere on the side.
- Fixed candidates with an offset specify that the location of the port relative to the center of the node is given by offset.
- Fixed-from-sketch candidates specify that the location of the port relative to the center of the node is the same as in the input.
Property Value
Methods
Returns the side of this candidate where the sides relative to the flow are replaced by absolute sides.
Remarks
If the side is ANY, then the return value is ANY.
If flowDirection
is set to null
and the side does not include any absolute side, ANY is returned. If it includes absolute sides, the sides relative to the flow are ignored.
Parameters
A map of options to pass to the method.
- flowDirection - Direction
- The direction of the flow or
null
if there is no flow direction.
Returns
- ↪PortSides
- The side of this candidate where the sides relative to the flow are replaced by absolute sides.
Returns whether this candidate can be placed at any side.
Remarks
flowDirection
is set to null
and the side includes one of the sides that are relative to the flow, true
is returned.Parameters
A map of options to pass to the method.
- flowDirection - Direction
- The current direction of the flow or
null
if there is no flow direction
Returns
- ↪boolean
true
if this candidate can be placed at any side,false
otherwise
See Also
Returns whether this candidate lies on the given side.
Remarks
This method tests whether this candidate contains any of the given sides. It does not check if other sides are included. In particular, if side is ANY, true
is returned for all non-zero values of testSide
.
This method does not resolve the sides that are relative to the flow (if there is any).
Parameters
A map of options to pass to the method.
- testSide - PortSides
- one of the default side specifiers
Returns
- ↪boolean
true
if this candidate lies on the given side,false
otherwise
Returns whether this candidate lies on the given side after resolving the sides relative to the flow direction.
Remarks
This method tests whether this candidate contains any of the given sides. It does not check if other sides are included. In particular, if side is ANY, true
is returned for all non-zero values of testSide
.
Similarly, if testSide
is set to ANY, true
is returned for all non-zero values of side. To check whether the port can be placed on ANY side, use isOnAnySide instead.
If flowDirection
is set to null
and the side includes one of the sides that are relative to the flow direction, true
is returned.
Parameters
A map of options to pass to the method.
- testSide - PortSides
- one of the default side specifiers
- flowDirection - Direction
- the current direction of the flow or
null
if there is no flow direction
Returns
- ↪boolean
true
if this candidate lies on the given side,false
otherwise
See Also
Static Methods
createFixed
(side: PortSides, offset?: Point, cost?: number, capacity?: number, matchingId?: any) : LayoutPortCandidateFactory method that creates a fixed port candidate with the given side, offset, and cost of usage.
Remarks
It is rarely necessary to create LayoutPortCandidates directly. Typically, they are created as part of NodePortCandidates or EdgePortCandidates.
If the offset
is not specified, the offset values are determined from sketch during the execution time of the layout algorithm and correspond to the current port location of the associated edge (see sourcePortOffset and targetPortOffset).
Parameters
A map of options to pass to the method.
- side - PortSides
- any combination of the side specifiers
- offset - Point
- the offset relative to the center of the node
- cost - number
- the penalty cost for using this candidate
- capacity - number
- the capacity of this candidate
- matchingId - any
- the matching ID of this candidate
Returns
- ↪LayoutPortCandidate
- a fixed LayoutPortCandidate instance
See Also
createFree
(side: PortSides, cost?: number, capacity?: number, matchingId?: any) : LayoutPortCandidateFactory method that creates a free port candidate instance with the given side and cost of usage.
Remarks
Parameters
A map of options to pass to the method.
- side - PortSides
- any combination of the default side specifiers
- cost - number
- the penalty cost for using this candidate
- capacity - number
- the capacity of this LayoutPortCandidate
- matchingId - any
- the matching ID of this LayoutPortCandidate