The PortPlacementStage assigns edges to the ports specified by LayoutPortCandidates or NodePortCandidates after calling the coreLayout.
Remarks
It can be used for adjusting ports for layout algorithms that cannot handle such constraints.
If LayoutPortCandidates are assigned for edges and nodes, this stage tries to match them. An edge port candidate matches a node port candidate if
- their matchingIds are equal or one type is
null
, - they belong to a common side or one side is ANY, and
- if both candidates are fixed, they describe the same positions.
The position of a port candidate is defined by offset or the actual offset of the edge endpoint for fixed-from-sketch candidates. This stage determines an assignment of minimum total cost, where the cost of the port of an edge is given by the sum of the costs of the chosen candidate specified at the edge and the corresponding matching candidate specified at the node. All costs of ports exceeding 10,000 are considered to be equal, and negative costs are treated as 0. When there is no matching candidates for an edge, the LayoutPortCandidate with the lowest costs specified for the edge is chosen.
This stage also considers port groups (see sourcePortGroupIds and targetPortGroupIds). It assigns the same port to edges that are port-grouped at a common node. Importantly, port grouping is prioritized over other constraints, for example, if two port-grouped edges do not have at least one common LayoutPortCandidate, then the port of one of the edges will be chosen for both, violating the constraint of the other edge.
Furthermore, property routeCorrectionPolicy allows to specify how the edge path should be corrected after correcting a port.
It is recommended that the PortPlacementStage is prepended to the coreLayout in order to be able to process all the edges and especially, self-loops and parallel edges. Note that edges that might be hidden by other ILayoutStages cannot be handled by PortPlacementStage.
Default Values of Properties
routeCorrectionPolicy | MOVE_PORTS_TO_BORDER
| The ports are just moved. |
Type Details
- yFiles module
- algorithms
See Also
Constructors
Creates a new PortPlacementStage instance with an optional coreLayout.
Parameters
A map of options to pass to the method.
- coreLayout - ILayoutAlgorithm
- The core layout algorithm.
- routeCorrectionPolicy - RouteCorrectionPolicy
- How this ILayoutStage corrects the edge paths after moving the ports to the locations specified by the LayoutPortCandidates. This option sets the routeCorrectionPolicy property on the created object.
- enabled - boolean
Properties
Gets or sets the core ILayoutAlgorithm that is wrapped by this stage.
Default Value
null
.Property Value
See Also
Implements
Gets or sets a value that determines whether this stage should do anything but execute the coreLayout.
Remarks
By default, when constructed, stages should be enabled. Users may disable a stage's functionality by setting this property to false
.
Stages that can guarantee that the graph will not change can choose to not even execute the coreLayout when disabled.
See Also
Implements
Gets or sets how this ILayoutStage corrects the edge paths after moving the ports to the locations specified by the LayoutPortCandidates.
Remarks
Default Value
See Also
Sample Graphs
Methods
Implementation of the ILayoutAlgorithm interface and main entry point for the layout calculation.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- The graph to apply the layout to.
See Also
Implements
Corrects the ports of the edges considering LayoutPortCandidates, NodePortCandidates, and port groups.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
See Also
Implements
createLayoutData
(graph: LayoutGraph) : BasicPortData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>Returns an instance of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to perform item-specific configurations for the PortPlacementStage.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph that determines the generic type arguments of the created layout data
Returns
- ↪BasicPortData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>
- an instance of layout data that can be used to perform item-specific configurations for the given PortPlacementStage.