C

ClearAreaLayout

This layout algorithm clears a specified area by moving intersecting elements, while trying to minimize the changes in the given layout.
ImplementsInheritance Hierarchy

Remarks

Layout Style

The algorithm can be applied if it is necessary to make space within a specific region/area in an existing graph layout. It tries to keep the given layout style as much as possible. Ideally, only local changes in and around the marked area are made, such that the mental map for the user is preserved.

An example application is the use case where new nodes or a whole graph component were added to the graph and should be placed in a specific region of an existing graph layout. The region can then first be cleared using this algorithm such that afterwards the nodes or the component could be inserted without overlaps with other elements. This specific case can conveniently be implemented by defining a set of so-called area nodes, via areaNodes. Another, more general use case would be nodes that grow in size, including the case that a folder node is expanded and converted to a larger group node. This case is easily realized by specifying the expanded node via expandedNode.

An input sample - the area that must be cleared is visualized as a gray rectangle.

The result after clearing the area with this algorithm.

Concept

The area, which can be defined as a rectangle or an outline, defines a region in the given input graph which must be cleared. Clearing the area means no graph elements are allowed to intersect with it. This includes nodes and, depending on settings also edges, node labels and edge labels.

In order to clear the area, the graph elements must be moved. Moving an element often induces the necessity to move further elements along with them. Thus, depending on where the area is located in the input drawing, many elements may be moved to make the necessary space. How elements are selected and how they are moved highly depends on the chosen clearing strategy.

Features

For grouped graphs, the group nodes are also correctly handled by this algorithm. However, it is important to note that there is always one so-called area group node. It is the group node inside which the free space should be created and which may in consequence need to grow, see areaGroupNode for more details. When defining the free space via area nodes (see above), this group is automatically determined, otherwise it must explicitly be specified. If not specified, the free space is created in the top-level hierarchy.

The algorithm is able to consider a specified LayoutGrid as long as there are no group nodes that span multiple grid cells. Note that the cleared area is always allocated to a single cell of the grid, i.e., it is not possible that the area spans multiple cells. For this feature to work properly it is required that the values of the properties position, position, width and height are correctly specified. This is usually automatically the case when executing the ClearAreaLayout as a standalone algorithm via layout execution convenience methods (e.g. the values are taken from the table visualization of the grid). However, if the ClearAreaLayout is applied as part of a more complex layout pipeline it may be necessary to specify the values manually. For example, if another algorithm previously computed the grid position values and stored them in the respective 'computed' properties (e.g. position), and afterwards ClearAreaLayout should be applied, then the 'computed' values of the first algorithm should be written to the 'original' values prior to the run of the ClearAreaLayout.

The algorithm considers port placements constraints only during the rerouting of edges using the specified edgeRouter. The applied routing algorithm must support port placement constraints to have an effect.

Layout Stages

This class provides a configurable pipeline that contains various ILayoutStages. Each ILayoutStage can incorporate preprocessing or postprocessing steps into the layout calculation to streamline the input graph and enhance the resulting layout. Additionally, custom ILayoutStages can be added and executed either before or after the predefined ones.

The following default ILayoutStages are included:

With these layoutStages the layout algorithm is configured well, so they usually don't need to be changed.

Default Values of Properties

NameDefaultDescription
areanull
There is no area to be cleared.
clearAreaStrategyClearAreaStrategy.PRESERVE_SHAPES
componentAssignmentStrategyComponentAssignmentStrategy.SINGLE
Each node is a separate component.
considerEdgestrue
Edges are not allowed to intersect the area.
edgeLabelPlacementClearAreaLayoutEdgeLabelPlacement.CONSIDER
Edge labels intersecting the clearing area are considered and rearranged.
edgeRoutingStylePartialLayoutRoutingStyle.AUTOMATIC
The routing style is automatically determined.
fixPortstrue
Ports are fixed and not allowed to change when adjusting the edge paths.
gridSpacing0
No grid is considered.
layoutOrientationPartialLayoutOrientation.NONE
The layout is considered to have no specific orientation.
nodeLabelPlacementNodeLabelPlacement.CONSIDER
Node labels are considered.
spacing10
stopDurationTimeSpan.MAX_VALUE

See Also

Developer's Guide

Members

Show:

Constructors

Creates a new instance of ClearAreaLayout with default settings.

Parameters

Properties

Gets or sets the rectangular area that must be cleared.
All elements (nodes, edges, and labels) that currently intersect the area will be moved such that the area is cleared after the layout run.
The specified area is ignored in case that the area is derived from a custom set of areaNodes or from the size of an expandedNode.
conversionfinal

Property Value

the rectangular area that must be cleared

Default Value

The default value is: null
There is no area to be cleared.

See Also

Developer's Guide
Gets or sets the strategy applied for clearing the desired area.
This property controls the main approach followed to clear the area of graph elements.
conversionfinal

Property Value

one of the predefined strategies to clear the area

Default Value

The default value is: ClearAreaStrategy.PRESERVE_SHAPES

See Also

Developer's Guide
Gets or sets the strategy that assigns nodes to components whose elements should preferably not be separated.

To define custom components instead of using the predefined strategies, use componentIds. In this case, the value of componentAssignmentStrategy will be ignored.

While the algorithm may move a whole component, it tries to not move only a subset of its elements, thus, all elements of a component are not moved at all or moved by the same offset.

  • CONNECTED components are defined by the connected components of the graph.
  • CLUSTERING: components are defined by edge betweenness clustering.
  • SINGLE: each node is a separate component which basically means that there are no components that should explicitly be kept together.
Borders of groups and layout grid cells always split up the components, i.e., two nodes assigned to different groups or layout grid cells are always assigned to different subgraph components.
This feature is only supported by clearing strategies PRESERVE_SHAPES, PRESERVE_SHAPES_UNIFORM and GLOBAL.
conversionfinal

Property Value

one of the predefined assignment strategies

Default Value

The default value is: ComponentAssignmentStrategy.SINGLE
Each node is a separate component.

See Also

API
componentIds
Gets or sets whether or not edges are considered when clearing the area such that no segments intersecting the area are allowed.

If enabled, edges that must be rerouted are not allowed to intersect the area that is cleared. Furthermore, edges whose source and target node are not moved but where segments intersect the area in the input graph are rerouted in order to remove that intersection.

If disabled, edges are allowed to intersect the area that is cleared. This has the effect that the area is cleared of nodes only.

With edge routing styles STRAIGHT_LINE and ORGANIC, intersections with the area are not resolved. Use strategies ORTHOGONAL or OCTILINEAR if preventing them is an important requirement.
final

Property Value

true if edges are considered and edge intersections with the area are removed, false otherwise

Default Value

The default value is: true
Edges are not allowed to intersect the area.

Sample Graphs

ShownSetting: Input example where the gray area must be cleared.
Gets or sets how the layout handles the position of edge labels.
conversionfinal

Property Value

CONSIDER if the layout algorithm rearranges the edge labels intersecting the area, IGNORE if the positions should be ignored, and GENERIC if the edge labels are placed by an independent labeling algorithm subsequently.

Default Value

Edge labels intersecting the clearing area are considered and rearranged.
Gets or sets the custom edge router instance that is applied to reroute edges.

Several types of edges can be routed by this algorithm:

  1. Edges where one or both endpoints were displaced in order to clear the area. It depends on the strategy if such edges are actually handled by the routing algorithm or if they are implicitly moved. For example, strategy PRESERVE_SHAPES tries to keep the shapes and can avoid rerouting in many cases.
  2. So-called inter-edges resulting from the areaNodes component. If such a component exists, the inter-edges are the edges connecting area nodes with non-area nodes. They are always handled by this routing algorithm, independent of the strategy.
  3. Edges connecting to a specifically marked expandedNode and to the descendants of the expanded node in case it is a group node.

Changing the value of property edgeRoutingStyle automatically sets a new edge router instance according to the specified routing style, thus, overwriting any previously set instances. The following routing algorithms are set:

final

Property Value

the custom edge router instance that is applied to reroute edges

Default Value

The default value is: null
There is no custom router and the routing style is automatically determined.

See Also

API
edgeRoutingStyle
Gets or sets the routing style that is preserved while clearing the area and applied when rerouting edges.

The algorithm assumes that the existing edges have paths according to the specified style and takes this into account when moving nodes and edges in order to clear the area. If the AUTOMATIC style is set, then no assumptions are made but the given paths are analyzed to derive the best fitting routing style. Note that in this case, the algorithm may use different routing styles for the edges.

This routing style is also relevant when edges need to be rerouted, as it determines the routing algorithm used for rerouting, see edgeRouter for more details.

Changing the value of this property overwrites a previously set customized edge router, see edgeRouter.
It is strongly discouraged to specify a routing style different from the actual routing style of the input drawing.
conversionfinal

Property Value

one of the predefined edge routing styles

Default Value

The routing style is automatically determined.

See Also

API
edgeRouter
Gets or sets whether the ports of the input graph must be fixed or if they can be changed.

This property is relevant for edges that are rerouted in order to clear the area, i.e., edges where one or both endpoints are displaced or edges that intersect the area in the input graph (depending on property considerEdges) and that are consequently handled by the specified edgeRouter. Inter-edges resulting from the areaNodes component are not affected by this property (edges connecting area nodes with non-area nodes). For such edges, the behavior is the same as if this property would be disabled, see the following description. The same applies for edges incident to the expandedNode or the descendants of the expanded node (if one endpoint is not the expanded node or a descendant).

If the ports are fixed, then the port side and location are not changed, except for group nodes that grow due to the area inside them. Edges at these groups keep the port side, but the absolute location is not fixed.

If disabled, the algorithm considers specified LayoutPortCandidates when rerouting edges. If there are no such constraints for an edge, then the ports of that edge can be freely placed. This can often produce better edge routes in the resulting drawing, however, the overall shape of the edge may then not be preserved.

final

Property Value

true if ports of the input are fixed, false otherwise

Default Value

The default value is: true
Ports are fixed and not allowed to change when adjusting the edge paths.
Gets the GenericLabeling helper class from the layoutStages of this instance.
If you need to replace the instance, modify the layoutStages stack using replace. If you want to remove a stage, consider disabling it instead.
readonlyfinal

Throws

Exception ({ name: 'InvalidOperationError' })
If there is no instance of the respective type in the layoutStages
Gets or sets the current grid spacing.

Elements are moved by multiples of this value, thus, keeping their offset to the grid. That way, components or parts of them that were placed on a grid before, will stay on their original grid.

The grid spacing needs to be a non-negative value. If it is set to 0, no grid is considered.

For edges that need to be rerouted, it is not guaranteed that the bends are placed on grid points.
final

Property Value

the grid spacing

Throws

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

Default Value

The default value is: 0
No grid is considered.
Gets or sets the layout orientation that is considered during the clearing of the area.

The orientation affects the direction that the algorithm prefers when moving elements. For the vertical orientations TOP_TO_BOTTOM and BOTTOM_TO_TOP, moving elements horizontally (i.e. to the left and to the right) is preferred. For the horizontal orientations LEFT_TO_RIGHT and RIGHT_TO_LEFT, the vertical moving direction is preferred. This is mainly useful for layouts that have a clear direction and nodes are divided into layers with respect to this direction, like e.g., hierarchical layouts.

If this behavior is undesired, the orientation can be ignored by specifying NONE. No specific moving direction will be preferred in that case. The orientation can also be automatically detected based on the flow direction of the edges when choosing AUTO_DETECT.

conversionfinal

Property Value

one of the predefined layout orientations

Default Value

The default value is: PartialLayoutOrientation.NONE
The layout is considered to have no specific orientation.
Gets or sets how the layout handles the position of node labels.
conversionfinal

Property Value

CONSIDER if the layout algorithm takes the position and sizes of the node labels into account, IGNORE if the node labels are ignored by the layout algorithm, and GENERIC if the node labels are placed by an independent labeling algorithm subsequently.

Default Value

The default value is: NodeLabelPlacement.CONSIDER
Node labels are considered.
Gets or sets the spacing that is considered between elements when they are moved to clear the area.

This spacing only affects the moving of elements out of the area. Elements keep the specified distance to other elements. Carefully observe that if the distance between two elements is already smaller, then they may not be moved apart.

Strategies PRESERVE_SHAPES, PRESERVE_SHAPES_UNIFORM and GLOBAL consider the spacing for all graph elements, including nodes, edges, node labels and edge labels when they are encountered during the movement process. On the other hand, strategies LOCAL and LOCAL_UNIFORM consider the spacing only with respect to nodes.

For edges that are rerouted with the edgeRouter, this spacing is not considered. Instead, the respective distance/spacing values of the router instance apply. To configure custom distance/spacing values for the routing, one may specify a manually configured router instance.
final

Property Value

the non-negative spacing between elements

Throws

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

Default Value

The default value is: 10

Sample Graphs

ShownSetting: Spacing set to 10. The gray area was cleared of elements.
Gets or sets the time limit for the layout algorithm.
Values have to be greater than or equal to ZERO.
Restricting the stop duration may result in a lower layout quality. Furthermore, the real runtime may exceed the stop duration since the layout algorithm still has to find a valid solution. For strategies LOCAL and LOCAL_UNIFORM a restricted time can highly affect the quality of the edge routes and, on the other hand, significantly improve the performance.
conversionfinal

Throws

Exception ({ name: 'ArgumentError' })
if the stop duration is negative

Default Value

The default value is: TimeSpan.MAX_VALUE

Methods

Clears the specified rectangular area, the area defined via areaNodes or expandedNode by moving all other graph elements currently intersecting with it.
In contrast to applyLayoutCore, graph and layouter are prepared for an independent layout run.
The given graph will not be copied during the layout process and the layout will be immediately applied to the given graph.

Parameters

graph: LayoutGraph
the input graph
Clears the specified rectangular area, the area defined via areaNodes or expandedNode by moving all other graph elements currently intersecting with it.
protectedfinal

Parameters

graph: LayoutGraph
the input graph
Creates and sets the value of the property areaOutline of the layout determined from the items.
This method saves the user from having to create the BorderLines of the areaOutline property himself.
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

items: IEnumerable<IModelItem>
The IModelItems from which the BorderLines are determined.
spacing: number
The spacing that is considered between the area and the elements.
closed?: boolean
Whether the area is closed or can be traversed by other elements (without overlaps).
Returns an instance of LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> that can be used to perform item-specific configurations for the ClearAreaLayout.
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

ClearAreaLayoutData<LayoutNode, LayoutEdge, LayoutNodeLabel, LayoutEdgeLabel>
an instance of layout data that can be used to perform item-specific configurations for the given ClearAreaLayout.
Returns an instance of LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> that can be used to perform item-specific configurations for the ClearAreaLayout.
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

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

See Also

Developer's Guide
Moves the areaOutline by the given delta.
This method prevents users from having to modify the BorderLines of the areaOutline property themselves.
final

Parameters

delta: IPoint
the delta to move the areaOutline

Constants

All constants are filtered. Go to Filters.