- I
- I
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
| Name | Default | Description |
|---|---|---|
| coreLayout | null | |
| routeCorrectionPolicy | RouteCorrectionPolicy.MOVE_PORTS_TO_BORDER | The ports are just moved. |
See Also
Developer's Guide
API
- LayoutPortCandidate, NodePortCandidates, routeCorrectionPolicy
Members
Constructors
Creates a new PortPlacementStage instance with an optional coreLayout.
Parameters
- coreLayout?: ILayoutAlgorithm
- The core layout algorithm.
Properties
Gets or sets the core ILayoutAlgorithm that is wrapped by this stage.
Property Value
Default Value
Defined in
LayoutStageBase.coreLayoutGets or sets a value that determines whether this stage should do anything but execute the coreLayout.
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.
Defined in
LayoutStageBase.enabledGets or sets how this ILayoutStage corrects the edge paths after moving the ports to the locations specified by the LayoutPortCandidates.
Default Value
Sample Graphs
See Also
Developer's Guide
Methods
Implementation of the ILayoutAlgorithm interface and main entry point for the layout calculation.
Parameters
- graph: LayoutGraph
- The graph to apply the layout to.
Defined in
LayoutStageBase.applyLayoutCorrects the ports of the edges considering LayoutPortCandidates, NodePortCandidates, and port groups.
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.
createLayoutData
(graph: LayoutGraph): BasicPortData<LayoutNode, LayoutEdge, LayoutNodeLabel, LayoutEdgeLabel>Parameters
- graph: LayoutGraph
- the graph that determines the generic type arguments of the created layout data
Return Value
- BasicPortData<LayoutNode, LayoutEdge, LayoutNodeLabel, LayoutEdgeLabel>
- an instance of layout data that can be used to perform item-specific configurations for the given PortPlacementStage.