This class associates PortCandidates with the nodes of a graph.
Remarks
PortCandidates defined on nodes specify sides or even exact locations at which edges can be connected. This means that an edge can be connected to any of the available node ports (unless edge PortCandidates are specified too). Each node PortCandidate has a capacity, i.e., a maximum number of edges allowed to connect to it.
Information about PortCandidates on nodes is held by a IDataProvider that stores a PortCandidateSet for each node and is registered with the graph using key NODE_PORT_CANDIDATE_SET_DP_KEY.
The PortCandidates are retrieved from the PortCandidateSet through a IPortCandidateSetEntry that holds the information about the actual PortCandidate. This object is also used for retrieving the best candidate from a PortCandidateSet based on the cost (lower costs are considered first) and the available capacity of each candidate. Custom searching for the best PortCandidate can be achieved by implementing IPortCandidateMatcher interface.
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.PortCandidateSet
See Also
Constructors
Creates a new empty PortCandidateSet instance.
Remarks
Properties
Gets the total number of connections allowed by the PortCandidates described by this PortCandidateSet or 0x7FFFFFFF
if the number is unbounded.
Gets an IEnumerator<T> over the list of candidate entries of this PortCandidateSet.
Methods
Adds a PortCandidate with the given capacity to this PortCandidateSet.
Remarks
The capacity value defines the maximum number of edges allowed to connect to the candidate. If no limitation for this number exists, 0x7FFFFFFF
can be used.
The capacity must be greater than zero.
Parameters
A map of options to pass to the method.
- p - PortCandidate
- the PortCandidate to add
- connections - number
- the capacity of the given port
Throws
- Exception({ name: 'ArgumentError' })
- if the given capacity is less than or equal to zero
Creates a IPortCandidateMatcher that retrieves entries from this PortCandidateSet.
Remarks
Each next best matching candidate is determined based on its cost, its current available capacity and based on whether or not its direction is consistent with the desired one.
This method may be overridden to support custom implementations of IPortCandidateMatcher.
Returns
- ↪IPortCandidateMatcher
- a new IPortCandidateMatcher instance
getCost
(entry: IPortCandidateSetEntry, edge: Edge, source: boolean, xOffset: number, yOffset: number) : numberCalculates the penalty cost for the usage of the given entry and the given parameters.
Remarks
The cost is equal to the cost of usage of the associated port candidate.
This method may be overridden to customize the calculation of the cost of usage of an entry.
Parameters
A map of options to pass to the method.
- entry - IPortCandidateSetEntry
- the entry for which the cost is computed
- edge - Edge
- the edge that will connect to the PortCandidate associated with the entry
- source - boolean
true
if the given edge connects to its source node,false
otherwise- xOffset - number
- the preferred X-offset of the port relative to the center of the node
- yOffset - number
- the preferred Y-offset of the port relative to the center of the node
Returns
- ↪number
- the penalty cost for the usage of the given IPortCandidateSetEntry
Calculates the priority of the given entry.
Remarks
Higher priority means that the entry will be considered earlier by a IPortCandidateMatcher.
This method may be overridden to customize the calculation of the priority of entries.
Parameters
A map of options to pass to the method.
- entry - IPortCandidateSetEntry
- the entry for which the cost is computed
- edge - Edge
- the edge that will connect to the PortCandidate associated with the entry
- source - boolean
true
if the given edge connects to its source node,false
otherwise
Returns
- ↪number
- the priority of the given IPortCandidateSetEntry
Removes the given entry from the list of candidate entries.
Parameters
A map of options to pass to the method.
- entry - IPortCandidateSetEntry
- the entry to remove
Constants
A data provider key for specifying a port candidate set for each node.
Domain | YNode | |
Values | PortCandidateSet | a set of possible null if no such set is specified |