documentationfor yFiles for HTML 2.6

PortCandidate

This class represents a candidate port on which edges can be connected to their source and/or target node.

Inheritance Hierarchy
PortCandidate

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.

Example of using edge port candidates. Edge port candidates are colored uniquely based on the edge with which they are associated.

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

PortPlacementStage can be appended to any layout algorithm that cannot handle port constraints in order to assign edges to the ports specified by PortConstraints or PortCandidates after calling the core layout algorithm.
In case that both PortConstraints and PortCandidates (on edges and/or nodes) are defined for a graph, the layout or the routing algorithm will try to match both of them in order to find an appropriate port. The matching process depends on the actual algorithm.

Properties

Methods

Constants

Static Methods