documentationfor yFiles for HTML 2.6

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 that 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 AREA_NODES_DP_KEY. 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 EXPANDED_NODE_DP_KEY.

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 considerEdges, considerNodeLabels and considerEdgeLabels 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 AREA_GROUP_NODE_DP_KEY 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 PartitionGrid 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 originalPosition, originalPosition originalWidth and originalHeight 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. computedPosition), 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.

Default Values of Properties

areanullThere is no area to be cleared.
clearAreaStrategyPRESERVE_SHAPES
componentAssignmentStrategyCUSTOMIZEDComponents can be user-defined and if none are defined, each node is a separate component.
considerEdgeLabelstrueEdge labels are considered.
considerEdgestrueEdges are not allowed to intersect the area.
considerNodeLabelstrueNode labels are considered.
edgeRoutingStrategyAUTOMATICThe routing strategy 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.
maximumDuration<code>0x7FFFFFFF</code>
spacing10

Type Details

yfiles module
layout-area
yfiles-umd modules
layout-area, layout
Legacy UMD name
yfiles.partial.ClearAreaLayout

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