C

PortPlacementStage

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

NameDefaultDescription
coreLayoutnull
routeCorrectionPolicyRouteCorrectionPolicy.MOVE_PORTS_TO_BORDER
The ports are just moved.

See Also

Developer's Guide

API

LayoutPortCandidate, NodePortCandidates, routeCorrectionPolicy

Members

Show:

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.
final

Property Value

the core layout routine

Default Value

The default value is: null
Gets 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.

final
Gets or sets how this ILayoutStage corrects the edge paths after moving the ports to the locations specified by the LayoutPortCandidates.
If the path correction policy is set to LOCAL_ORTHOGONAL, the edges will be rerouted within a specific area around their source and target nodes. Outside this area, they will keep the routes that were calculated by the coreLayout. If the path correction policy is set to MOVE_PORTS, only the ports will be moved, which may be more suitable for initially straight edges.
The path correction policy LOCAL_ORTHOGONAL uses a simple orthogonal routing strategy that is fast but may produce overlapping edge segments as well as edge-node intersections.
conversionfinal

Default Value

The ports are just moved.

Sample Graphs

ShownSetting: MOVE_PORTS

See Also

Developer's Guide

Methods

Implementation of the ILayoutAlgorithm interface and main entry point for the layout calculation.
This implementation checks the enabled state and when it's not enabled, will delegate to the coreLayout, directly. When the stage is enabled, all the work will be delegated to applyLayoutImpl, instead.
final

Parameters

graph: LayoutGraph
The graph to apply the layout to.
Corrects the ports of the edges considering LayoutPortCandidates, NodePortCandidates, and port groups.
protected

Parameters

graph: LayoutGraph
the input graph
Returns an instance of LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> that can be used to perform item-specific configurations for the PortPlacementStage.
The generic type arguments of the created layout data are compatible with instances of LayoutGraph, but the layout data is not bound to a specific graph instance. Therefore, the created layout data still has to be passed as an argument of applyLayout in order to be applied.

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.