- I
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.
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:
- GenericLabeling: Efficiently places node and edge labels. The property fillEmptyScope is set to
falseand stopDuration is set to ZERO.
With these layoutStages the layout algorithm is configured well, so they usually don't need to be changed.
Default Values of Properties
| Name | Default | Description |
|---|---|---|
| area | null | There is no area to be cleared. |
| clearAreaStrategy | ClearAreaStrategy.PRESERVE_SHAPES | |
| componentAssignmentStrategy | ComponentAssignmentStrategy.SINGLE | Each node is a separate component. |
| considerEdges | true | Edges are not allowed to intersect the area. |
| edgeLabelPlacement | ClearAreaLayoutEdgeLabelPlacement.CONSIDER | Edge labels intersecting the clearing area are considered and rearranged. |
| edgeRoutingStyle | PartialLayoutRoutingStyle.AUTOMATIC | The routing style is automatically determined. |
| fixPorts | true | Ports are fixed and not allowed to change when adjusting the edge paths. |
| gridSpacing | 0 | No grid is considered. |
| layoutOrientation | PartialLayoutOrientation.NONE | The layout is considered to have no specific orientation. |
| nodeLabelPlacement | NodeLabelPlacement.CONSIDER | Node labels are considered. |
| spacing | 10 | |
| stopDuration | TimeSpan.MAX_VALUE |
See Also
Developer's Guide
Members
Constructors
Creates a new instance of ClearAreaLayout with default settings.
Parameters
Properties
Gets or sets the rectangular area that must be cleared.
Property Value
Default Value
See Also
Developer's Guide
Gets or sets the strategy applied for clearing the desired area.
Property Value
Default Value
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.
Property Value
Default Value
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.
Property Value
true if edges are considered and edge intersections with the area are removed, false otherwiseDefault Value
Sample Graphs
Gets or sets how the layout handles the position of edge labels.
Property Value
Default Value
Gets or sets the custom edge router instance that is applied to reroute edges.
Several types of edges can be routed by this algorithm:
- 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.
- 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.
- 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:
- EdgeRouter for strategies ORTHOGONAL and OCTILINEAR.
- OrganicEdgeRouter for style ORGANIC.
- StraightLineEdgeRouter for style STRAIGHT_LINE.
Property Value
Default Value
See Also
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.
Property Value
Default Value
See Also
API
- edgeRouter
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.
Property Value
true if ports of the input are fixed, false otherwiseDefault Value
Gets the GenericLabeling helper class from the layoutStages of this instance.
Throws
- Exception ({ name: 'InvalidOperationError' })
- If there is no instance of the respective type in the layoutStages
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.
Property Value
Throws
- Exception ({ name: 'ArgumentError' })
- if the given spacing is negative
Default Value
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.
Property Value
Default Value
Gets or sets how the layout handles the position of node labels.
Property Value
Default Value
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.
Property Value
Throws
- Exception ({ name: 'ArgumentError' })
- if the given spacing is negative
Default Value
Sample Graphs
Gets or sets the time limit for the layout algorithm.
Throws
- Exception ({ name: 'ArgumentError' })
- if the stop duration is negative
Default Value
Methods
Clears the specified rectangular area, the area defined via areaNodes or expandedNode by moving all other graph elements currently intersecting with it.
Parameters
- graph: LayoutGraph
- the input graph
Implements
ILayoutAlgorithm.applyLayoutClears the specified rectangular area, the area defined via areaNodes or expandedNode by moving all other graph elements currently intersecting with it.
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).
createLayoutData
(graph: LayoutGraph): ClearAreaLayoutData<LayoutNode, LayoutEdge, LayoutNodeLabel, LayoutEdgeLabel>Returns an instance of LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> that can be used to perform item-specific configurations for the ClearAreaLayout.
createLayoutData
(graph: LayoutGraph): ClearAreaLayoutData<LayoutNode, LayoutEdge, LayoutNodeLabel, LayoutEdgeLabel>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.
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.
delta.Parameters
- delta: IPoint
- the delta to move the areaOutline