- I
- I
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.
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.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.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.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
| Name | Default | Description |
|---|---|---|
| alignmentPolicy | AlignmentStageAlignmentPolicy.SNAP_XY | Nodes are aligned horizontally and vertically. |
| coreLayout | null | |
| gridSpacing | 0.0 | Nodes are aligned on an irregular grid. |
| minimumNodeDistance | 15.0 | |
| nodeLabelPlacement | BasicNodeLabelPlacement.CONSIDER | Node labels are considered for resolving overlaps when determining the alignment of the nodes. |
| separateStripes | false | Rows and Columns are not strictly separated and may overlap. |
| snapDistance | 50.0 |
See Also
Developer's Guide
Members
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.
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.
Property Value
Throws
- Exception ({ name: 'ArgumentError' })
- if an unknown alignment policy is given
Default Value
Sample Graphs
See Also
Developer's Guide
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.enabled0.0, the nodes are aligned on an irregular grid.Property Value
Throws
- Exception ({ name: 'ArgumentError' })
- if a negative value is specified
Default Value
See Also
Developer's Guide
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.
Property Value
Throws
- Exception ({ name: 'ArgumentError' })
- if the given value is negative
Default Value
Sample Graphs
Gets or sets whether node labels are taken into account for snapping nodes on common lines.
Property Value
Default Value
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
Sample Graphs
falseSee Also
Developer's Guide
API
- minimumNodeDistance
Property Value
Throws
- Exception ({ name: 'ArgumentError' })
- if the given value is negative
Default Value
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.applyLayoutAligns the nodes of the graph into a grid-like structure.
createLayoutData
(graph: LayoutGraph): AlignmentStageData<LayoutNode, LayoutEdge, LayoutNodeLabel, LayoutEdgeLabel>Returns an instance of LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> that can be used to perform item-specific configurations for the AlignmentStage.
createLayoutData
(graph: LayoutGraph): AlignmentStageData<LayoutNode, LayoutEdge, LayoutNodeLabel, LayoutEdgeLabel>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.
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