Specifies the layout data for the GenericLayoutGridStage.
Inheritance Hierarchy
Members
Show:
Constructors
Properties
Gets or sets the layoutGridData that allows to configure the LayoutGrid for the layout stage.
Gets or sets the layoutGridData that allows to configure the LayoutGrid for the layout stage.
final
Examples
The following sample shows how to assign nodes to layout grid cells simply via cell indices:
// Create four nodes and place them in grid cells in the following way
// +---+---+---+
// | 1 | 2 | 3 |
// +---+---+---+
// | 4 |
// +---+
const gridData = layoutData.layoutGridData
const node1 = graph.createNode()
const node2 = graph.createNode()
const node3 = graph.createNode()
const node4 = graph.createNode()
// Assign the nodes to their rows and columns.
// Note that you don't have to create or use LayoutGrid directly in this case.
// Setting the indices is enough.
gridData.rowIndices.mapper.set(node1, 0)
gridData.rowIndices.mapper.set(node2, 0)
gridData.rowIndices.mapper.set(node3, 0)
gridData.rowIndices.mapper.set(node4, 1)
gridData.columnIndices.mapper.set(node1, 0)
gridData.columnIndices.mapper.set(node2, 1)
gridData.columnIndices.mapper.set(node3, 2)
gridData.columnIndices.mapper.set(node4, 1)
graph.applyLayout(
new GenericLayoutGridStage(coreLayout),
coreLayoutData.combineWith(layoutData),
)If used this way there is no need to create a LayoutGrid instance or work with it directly. For more flexibility, e.g. to use cells that span multiple columns or rows, the LayoutGrid can be used as well:
// Create three nodes and place them in grid cells in the following way
// +---+---+
// | 1 | 2 |
// +---+---+
// | 3 |
// +---+---+
const gridData = layoutData.layoutGridData
const node1 = graph.createNode(new Rect(0, 0, 50, 50))
const node2 = graph.createNode(new Rect(0, 0, 50, 50))
const node3 = graph.createNode(new Rect(0, 0, 125, 50))
// Create a new LayoutGrid with two rows and two columns
const grid = new LayoutGrid(2, 2)
// Assign the nodes to their cells
const gridCells = new Mapper<INode, LayoutGridCellDescriptor>()
gridCells.set(node1, grid.createCellDescriptor(0, 0))
gridCells.set(node2, grid.createCellDescriptor(0, 1))
gridCells.set(node3, grid.createRowSpanDescriptor(1))
gridData.layoutGridCellDescriptors = gridCells
graph.applyLayout(
new GenericLayoutGridStage(coreLayout),
coreLayoutData.combineWith(layoutData),
)Gets or sets the collection of edges that should not be considered when calculating the sub-components.
Gets or sets the collection of edges that should not be considered when calculating the sub-components.
This property is only considered if property splitMultiCellComponents is disabled. The split-edges are temporarily removed during the calculation of the sub-components and, finally, routed with the specified interEdgeRouter. This allows to control how the graph is split into smaller graph components. Recall that with this setting a component may contain nodes of different layout grid cells.
conversionfinal
Examples
If only a few edges should be removed during the calculation of the sub-components, the easiest way is often to add them one by one via the items collection:
layoutData.splitEdges.items.add(edge1)
layoutData.splitEdges.items.add(edge2)If you already have a collection or IEnumerable<T> for those edges, the source property is usually easier:
// Consider selected edges
layoutData.splitEdges = graphComponent.selection.edgesIf it can be inferred directly from the edge itself whether it should be routed that way, a delegate is often most convenient:
layoutData.splitEdges = (edge) => edge.tag.isSplitEdgeMethods
combineWith
(data: LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>): LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>Combines this instance with the given layout data.
combineWith
(data: LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>): LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>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