documentationfor yFiles for HTML 2.6

PortConstraint

A PortConstraint represents a constraint for the source or target port of an edge path.

Inheritance Hierarchy
PortConstraint

Remarks

It determines the location at which an edge path can be connected to its source and/or target node. There exist two different types of PortConstraints:

  • Weak PortConstraints specify the side where an edge should enter/leave a node.
  • Strong PortConstraints specify the exact coordinates of the point where an edge should enter/leave a node. Therefore, for edges with strong port constraints, layout algorithms supporting such constraints use the current source/target point coordinates as returned by method getSourcePointRel and getTargetPointRel respectively.

Sample output of weak port constraints. For both edges, source port constraints are associated with side EAST while target port constraints are associated with side WEST. Red rectangles indicate that edges can be connected to any point of these sides. Black rectangles represent the selected ports. Sample output of strong port constraints. For both edges, source port constraints are associated with side EAST while target port constraints are associated with side WEST. Black rectangles indicate the exact points on the corresponding sides of the nodes to which edges can be connected.

Information about PortConstraints is held by IDataProviders that are registered with the graph using keys SOURCE_PORT_CONSTRAINT_DP_KEY (to specify PortConstraints for an edge on its source node) and TARGET_PORT_CONSTRAINT_DP_KEY (to specify PortConstraints for an edge on its target node).

Not all layout and routing algorithms are able to handle PortConstraints. Major layout algorithms that obey them are HierarchicLayout, TreeLayout, EdgeRouter, ChannelEdgeRouter and BusRouter.

Type Details

yfiles module
layout-core
yfiles-umd modules
All layout modules, view-layout-bridge
Legacy UMD name
yfiles.layout.PortConstraint

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.
For edges incident to group nodes, the HierarchicLayout only considers weak PortConstraints.

Properties

Methods

Static Methods