C

RecursiveGroupLayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>

Specifies custom data for the RecursiveGroupLayout.
Inheritance Hierarchy

Members

Show:

Constructors

Parameters

Properties

Gets or sets the mapping from group nodes to the ILayoutAlgorithm used for their child nodes.

The specified layout is applied to the content of the group node. To arrange the top level elements the coreLayout is used.

The core layout is also applied to group nodes if there are no groupNodeLayouts defined at all. Importantly, this must be distinguished from the case that the mapping is defined but null is mapped with a group. Then, RecursiveGroupLayout handles this group node non-recursively. The group node and its content is arranged using the ILayoutAlgorithm instance specified for the nearest ancestor of the group node which is associated with an ILayoutAlgorithm.

To leave the content of a group node unchanged, the group node can be associated with a layout algorithm which does not change the layout of the graph like FIX_CONTENT_LAYOUT.
conversionfinal

Examples

The layout algorithms for individual group nodes can be specified in various ways, depending on which option is the most convenient. The easiest way would be to set the same layout algorithm for all group nodes:

Using the same layout algorithm for all group nodes
layoutData.groupNodeLayouts = new OrthogonalLayout()

For scenarios where only some group nodes should have a specific layout algorithm the mapper is usually the best option. However, due to RecursiveGroupLayout's handling of individual group node layouts as described above, this can be a bit complicated to specify since the IMapper<K, V> by default returns null.

So when only the mapped group nodes should have a layout algorithm applied to their contents a new Mapper<K, V> would have to be created:

const mapper = new Mapper<INode, ILayoutAlgorithm>()
mapper.defaultValue = RecursiveGroupLayout.FIX_CONTENT_LAYOUT
mapper.set(groupNode1, new OrthogonalLayout())
mapper.set(groupNode2, new HierarchicalLayout())
layoutData.groupNodeLayouts = mapper

In cases where all group node's contents should be laid out, most of them with the coreLayout and only some customized, the predefined IMapper<K, V> can be used as is:

layoutData.groupNodeLayouts.mapper.set(groupNode1, new OrthogonalLayout())
layoutData.groupNodeLayouts.mapper.set(
  groupNode2,
  new HierarchicalLayout(),
)

If the desired layout algorithm for a group node can be readily inferred from the node itself, the mapperFunction is usually the easiest to use:

Specifying custom layout algorithms for group node contents with a delegate
// Determine the layout for the group node from a property in the tag object
layoutData.groupNodeLayouts = (groupNode: INode): ILayoutAlgorithm => {
  switch ((groupNode.tag as CustomData).layoutStyle) {
    case 'hierarchic':
      return new HierarchicalLayout()
    case 'organic':
      return new OrganicLayout()
    case 'orthogonal':
      return new OrthogonalLayout()
    case 'none':
    default:
      return RecursiveGroupLayout.FIX_CONTENT_LAYOUT
  }
}

See Also

API
GROUP_NODE_LAYOUT_DATA_KEY
Gets or sets the layout grid layout data.
Note that if you use LayoutExecutor's configureTableLayout feature this property should not be used as it overrides the LayoutGrid set by TableLayoutConfigurator.
All nodes handled by a specific core layout run (usually the direct children of a group node) have to be mapped to cells of the same layoutGrid. The content of independently handled group nodes may be assigned to cells of different grids (i.e., the group node represents the specific layout grid). In addition, the LayoutGrid is only considered if the applied layout algorithm supports such constraints.
final
Gets or sets the mapping from nodes to their margins.
Node margins allow to reserve space around nodes.
conversionfinal

Examples

The easiest option is to reserve the same space around all nodes, by setting a constant value:

Using constant space around all nodes
layoutData.nodeMargins = new Insets(20)

Handling only certain nodes differently can be done easily by using the mapper property:

Using a mapper to set margins for certain nodes
// node1 only reserves space above and below
layoutData.nodeMargins.mapper.set(node1, new Insets(20, 10, 0, 0))
// node2 has space all around
layoutData.nodeMargins.mapper.set(node2, new Insets(25))
// all other nodes don't get extra space

In cases where the nodeMargins for each node can be determined by looking at the node itself it's often easier to just set a mapperFunction instead of preparing a mapper:

Using a delegate to determine margins for all nodes
// Retrieve the space around the node from its tag property
layoutData.nodeMargins = (node: INode): Insets =>
  new Insets(parseFloat(node.tag))

See Also

API
NODE_MARGIN_DATA_KEY
Gets or sets the sub-data that provides a way of influencing the placement of the ports.

The port placement can be influenced by specifying EdgePortCandidates for the source and target of an edge, as well as by specifying NodePortCandidates at the nodes.

In addition, it is possible to specify that ports should be grouped at the source or target.

If and how the layout algorithm supports these port placement constraints depends on the specified coreLayout, the layout algorithms specified by groupNodeLayouts, and the router for the inter-edges.

final
Gets or sets a mapping from edges connecting to group nodes to source split IDs.
Edges will be aligned with edges that connect to the same group node and have the same split ID at their source (preferably) or target.
Marking edges with split IDs will only provide good results if HierarchicalLayout is used as the core layout algorithm. Also, the edges need to be routed directly from the content of a group to the group itself .
When a source split ID is assigned to an edge that crosses a group node's border, it will be split automatically for layout. In that case, the HierarchicalLayout's defaultEdgeDescriptor must have direct edge routing from the content of a group to the group itself enabled for good results.
In case a core layout algorithm is used that cannot handle groups, it will fail if it needs to layout a graph containing an edge with a split ID.
conversionfinal

See Also

API
SOURCE_SPLIT_ID_DATA_KEY
Gets or sets a mapping from edges connecting to group nodes to target split IDs.
Edges will be aligned with edges that connect to the same group node and have the same split ID at their source or target (preferably).
Marking edges with split IDs will only provide good results if HierarchicalLayout is used as core layout algorithm. Also, the edges need to be routed directly from the content of a group to the group itself .
In case a core layout algorithm is used that cannot handle groups, it will fail if it needs to layout a graph containing an edge with a split ID.
conversionfinal

See Also

API
TARGET_SPLIT_ID_DATA_KEY

Methods

Combines this instance with the given layout data.
This keeps the current instance unmodified and instead returns a new instance that dynamically combines the contents of all involved instances.
final

Parameters

data: LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>
The LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> to combine this instance with.

Return Value

LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>
The combined layout data.

See Also

Developer's Guide
API
CompositeLayoutData, GenericLayoutData