documentationfor yFiles for HTML 3.0.0.2

ClearAreaLayout

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

Inheritance Hierarchy
ClearAreaLayout
Implemented Interfaces

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

areanullThere is no area to be cleared.
clearAreaStrategyPRESERVE_SHAPES
componentAssignmentStrategySINGLEEach node is a separate component.
considerEdgestrueEdges are not allowed to intersect the area.
edgeLabelPlacementCONSIDEREdge labels intersecting the clearing area are considered and rearranged.
edgeRoutingStyleAUTOMATICThe routing style is automatically determined.
fixPortstruePorts are fixed and not allowed to change when adjusting the edge paths.
gridSpacing0No grid is considered.
layoutOrientationNONEThe layout is considered to have no specific orientation.
nodeLabelPlacementCONSIDERNode labels are considered.
spacing10
stopDurationMAX_VALUE

Type Details

yFiles module
algorithms

See Also

The input graph should already have a rather good layout for this algorithm to produce sophisticated results. The reason is that it analyzes the existing layout to decide how to change it. Overlapping nodes, edges intersecting nodes and other suboptimal arrangements can cause that this algorithm generates unexpected results. Furthermore, it is not meant to repair things like that in the input layout.

Constructors

Properties

Methods

Constants