C

AlignmentStage

AlignmentStage places the nodes of the given layout on automatically determined horizontal and/or vertical lines.

Remarks

The AlignmentStage arranges the nodes on vertical and horizontal lines that are derived from the given layout. It can be used to automatically snap nodes to the same x- or y-coordinate to obtain a grid-like structure. When rearranging the layout, the stage moves the nodes as little as possible.

Input graph. The nodes have been horizontally and vertically aligned.

Concept

The nodes are aligned on heuristically determined lines in two phases.

In the first phase, the nodes are assigned to lines such that the following criteria are taken into account:

  • The nodes maintain their order along the x- and y-axis, if possible.
  • Nodes that are assigned to the same grid line have similar coordinates in the initial layout.
  • The number of lines is minimized.

In the second phase, the positions of these lines and consequently their assigned nodes are determined. The positions are chosen such that the overall movement of the nodes is minimized.

Features

Alignment policy

AlignmentStage supports the alignment of the nodes in horizontal direction, vertical direction or in both directions. The mode is determined by the alignmentPolicy. If a single direction, i.e., SNAP_X or SNAP_Y is selected, the nodes do not move in the orthogonal direction. The nodes have been aligned horizontally, but not vertically.

Snap Distance

The snapDistance can be used to balance the trade-off between maintaining the initial graph layout and the grid-like structure produced by the stage. More specifically, the snap distance describes the maximum distance between two nodes that may still be snapped to the same grid line. Therefore, large snap distances produce a more emphasized grid structure, while giving up more of the initial layout compared to smaller snap distances.

Minimum Node Distance

The minimumNodeDistance determines the compactness of the result. The distance is enforced in the same direction as the nodes are snapped to (horizontal, vertical, both). It prevents any two nodes on different grid lines from being placed closer to one another. The minimum node distance is set to 15px. The minimum node distance is set to 80px.

Stripe Separation

If stripe separation is enabled, the nodes of two consecutive grid lines are strictly separated by a line L that has the same orientation as the two grid lines, i.e., the nodes of the two grid lines lie on opposite sides of L. For example, when aligning nodes horizontally with stripe separation, the nodes of two consecutive grid lines are separated by a horizontal line H such that the nodes of one grid line lie above H and the others lie below H. Further, if stripe separation is enabled, the minimumNodeDistance is enforced such that any two nodes of different grid lines are separated by at least the given distance. The nodes have been aligned horizontally and vertically using alignment separation.

Node Margins and Node Labels

The automatic AlignmentStage supports node margins as well as considering node labels when calculating the distances between nodes.

Node Overlaps

In case that nodes mutually overlap, applying the stage will resolve these overlaps resulting in a layout without overlaps. However, no guarantees are given how the nodes are rearranged such that it may lead to undesired artifacts. Generally, it is recommended that the initial layout should be free of node overlaps and adhere to the specified minimumNodeDistance as much as possible. To that end, an overlap removal stage can be applied to the layout before this stage.

Layout Grid

The automatic AlignmentStage supports the use of a layout grid. It is required that the nodes do not span multiple cells. In particular, it is required that the child nodes of a group node are assigned to the same cell as the group node. In case that the AlignmentStage is applied only to one dimension, the layout grid is only changed in that dimension, while the other dimension remains unchanged.

Default Values of Properties

NameDefaultDescription
alignmentPolicyAlignmentStageAlignmentPolicy.SNAP_XY
Nodes are aligned horizontally and vertically.
coreLayoutnull
gridSpacing0.0
Nodes are aligned on an irregular grid.
minimumNodeDistance15.0
nodeLabelPlacementBasicNodeLabelPlacement.CONSIDER
Node labels are considered for resolving overlaps when determining the alignment of the nodes.
separateStripesfalse
Rows and Columns are not strictly separated and may overlap.
snapDistance50.0

See Also

Developer's Guide

Members

Show:

Constructors

Creates a new AlignmentStage with the given algorithm as coreLayout or null if no core layout should be applied prior to the alignment stage.

Parameters

coreLayout?: ILayoutAlgorithm
the core layout algorithm

Properties

Gets or sets the axis, parallel to which the nodes are aligned by the algorithm.
There are three supported modes:
  • SNAP_Y: nodes are aligned horizontally.
  • SNAP_X: nodes are aligned vertically.
  • SNAP_XY: nodes are aligned both horizontally and vertically.
conversionfinal

Property Value

the axis, parallel to which the nodes are aligned by the algorithm

Throws

Exception ({ name: 'ArgumentError' })
if an unknown alignment policy is given

Default Value

Nodes are aligned horizontally and vertically.

Sample Graphs

ShownSetting: Nodes are not aligned.

See Also

Developer's Guide
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 the distance between two adjacent grid lines to which the nodes can be snapped, or zero if nodes are aligned on an irregular grid.
The axis distance between any two node centers is a multiple of the grid spacing.
If this property is set to 0.0, the nodes are aligned on an irregular grid.
final

Property Value

the distance between two adjacent grid lines to which the nodes can be snapped, or zero if nodes are aligned on an irregular grid

Throws

Exception ({ name: 'ArgumentError' })
if a negative value is specified

Default Value

The default value is: 0.0
Nodes are aligned on an irregular grid.

See Also

Developer's Guide
Gets or sets the minimum horizontal and vertical distance between two nodes.

The horizontal distance is enforced if using the SNAP_Y or the SNAP_XY alignment policy. The vertical distance is enforced if using the SNAP_Y or the SNAP_XY alignment policy.

If alignment separation is enabled, the vertical and horizontal distances are enforced such that any two nodes of different grid lines are separated by at least the given distance in horizontal and vertical direction, respectively.

final

Property Value

the minimum horizontal and vertical distance between two nodes.

Throws

Exception ({ name: 'ArgumentError' })
if the given value is negative

Default Value

The default value is: 15.0

Sample Graphs

ShownSetting: Nodes are not aligned
Gets or sets whether node labels are taken into account for snapping nodes on common lines.
The nodes are snapped to common lines such that neither nodes nor labels overlap.
conversionfinal

Property Value

CONSIDER if node labels are considered for resolving overlaps when determining the alignment of the nodes, IGNORE if the labels should be ignored.

Default Value

The default value is: BasicNodeLabelPlacement.CONSIDER
Node labels are considered for resolving overlaps when determining the alignment of the nodes.
Gets or sets whether nodes are placed in strictly separated rows and strictly separated columns.
final

Property Value

true if nodes are placed in strictly separated rows and columns, false if overlaps between rows as well as overlaps between columns are allowed.

Default Value

The default value is: false
Rows and Columns are not strictly separated and may overlap.

Sample Graphs

ShownSetting: false

See Also

Developer's Guide
API
minimumNodeDistance
Gets or sets the maximum distance between two nodes that can be aligned on the same line.
The distance is measured between the centers of the nodes in the input layout. Further, for vertical alignment it refers to the horizontal distance between the nodes and for horizontal alignment it refers to the vertical distance between the nodes.
final

Property Value

the maximum distance between two nodes that can be aligned on the same line.

Throws

Exception ({ name: 'ArgumentError' })
if the given value is negative

Default Value

The default value is: 50.0

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.
Aligns the nodes of the graph into a grid-like structure.
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 AlignmentStage.
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

AlignmentStageData<LayoutNode, LayoutEdge, LayoutNodeLabel, LayoutEdgeLabel>
an instance of layout data that can be used to perform item-specific configurations for the given AlignmentStage.
Returns an instance of LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> that can be used to perform item-specific configurations for the AlignmentStage.
The generic type arguments of the created layout data are compatible with instances of IGraph, 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.
This method is not available unless the module view-layout-bridge is loaded. Either load the module 'view-layout-bridge' explicitly or ensure that the LayoutExecutor type is available at runtime.

Parameters

graph?: IGraph
the graph that determines the generic type arguments of the created layout data

Return Value

AlignmentStageData<INode, IEdge, ILabel, ILabel>
an instance of layout data that can be used to perform item-specific configurations for the given AlignmentStage.

See Also

Developer's Guide

Constants

All constants are filtered. Go to Filters.