This class represents a layout grid that partitions the drawing area into rectangular layout grid cells.
Remarks
Such a structure allows, for example, to model vertical/horizontal swimlanes which are often used in flow diagrams to separate logical units.
The grid consists of rows and columns that are created using the corresponding constructors of this class or methods addRow and addColumn. The LayoutGrid can be defined by using property grid or layoutGridCellDescriptors.
Each node can have a LayoutGridCellDescriptor assigned which represents a set of layout grid cells. The mapping has to be registered with the graph using layoutGridCellDescriptors. Simple layout grid cell descriptors which represent a single layout grid cell, i.e., a row/column pair, can be created using method createCellDescriptor or createCellDescriptor.
Nodes can also be mapped to a layout grid cell descriptor that represents a multi-cell, i.e., a cell spanning multiple columns and rows. Please note, however, that multi-cells are not allowed to overlap each other. This means that the user has to ensure that each grid cell (row/column pair) is associated with at most one cell descriptor. The multi-cell descriptor can be created using methods createCellSpanDescriptor, createCellSpanDescriptor, createCellSpanDescriptor , createColumnSpanDescriptor, and createRowSpanDescriptor.
Default Values of Properties
Type Details
- yFiles module
- algorithms
Constructors
LayoutGrid
(rowCount?: number, columnCount?: number, rowPadding?: number, columnPadding?: number, minRowSize?: number, minColumnSize?: number)Creates an instance of LayoutGrid and optionally creates the given number of rows and columns with given padding and minimum sizes.
Parameters
A map of options to pass to the method.
- rowCount - number
- The number of rows. The default value is 0.
- columnCount - number
- The number of columns. The default value is 0.
- rowPadding - number
- The top and bottom padding of the rows. The default value is 0.
- columnPadding - number
- The left and right padding of the columns. The default value is 0.
- minRowSize - number
- The minimum row height. The default value is 0.
- minColumnSize - number
- The minimum column width. The default value is 0.
- optimizeColumnOrder - boolean
- Whether or not the order of the columns should be chosen automatically to minimize edge lengths. This option sets the optimizeColumnOrder property on the created object.
- optimizeRowOrder - boolean
- Whether or not the order of the rows should be chosen automatically to minimize edge lengths. This option sets the optimizeRowOrder property on the created object.
Properties
Gets the columns of the LayoutGrid.
Gets or sets whether or not the order of the columns should be chosen automatically to minimize edge lengths.
Remarks
true
, the relative ordering given by the indices is preserved. The remaining columns may be sorted again so that the overall edge lengths are minimized.Default Value
true
.Property Value
true
if the order is chosen automatically, false
otherwiseSample Graphs
Gets or sets whether or not the order of the rows should be chosen automatically to minimize edge lengths.
Remarks
true
, the relative ordering given by the indices is preserved. The remaining rows may be sorted again so that the overall edge lengths are minimized.Default Value
true
.Property Value
true
if the order is chosen automatically, false
otherwiseSample Graphs
Gets the rows of the LayoutGrid.
Methods
Adds a new column to the LayoutGrid instance.
Remarks
Parameters
A map of options to pass to the method.
- padding - number
- The left and right padding of the added column. The default value is 0.
- minimumWidth - number
- The minimum width of the added column. The default value is 0.
Returns
- ↪LayoutGridColumn
- a new LayoutGridColumn instance
Adds a new column to the LayoutGrid instance.
Remarks
Parameters
A map of options to pass to the method.
- leftPadding - number
- The left padding of the added column.
- rightPadding - number
- The right padding of the added column.
- minimumWidth - number
- The minimum width of the added column.
Returns
- ↪LayoutGridColumn
- a new LayoutGridColumn instance
Adds a new row to the LayoutGrid instance.
Remarks
Parameters
A map of options to pass to the method.
- padding - number
- The top and bottom padding of the added row. The default value is 0.
- minimumHeight - number
- The minimum height of the added row. The default value is 0.
Returns
- ↪LayoutGridRow
- a new LayoutGridRow instance
Adds a new row to the LayoutGrid instance.
Remarks
Parameters
A map of options to pass to the method.
- topPadding - number
- The top padding of the added row.
- bottomPadding - number
- The bottom padding of the added row.
- minimumHeight - number
- The minimum height of the added row.
Returns
- ↪LayoutGridRow
- a new LayoutGridRow instance
Creates a LayoutGridCellDescriptor defined by the given column and row.
Parameters
A map of options to pass to the method.
- row - LayoutGridRow
- the row defining the cell
- column - LayoutGridColumn
- the column defining the cell
Returns
- ↪LayoutGridCellDescriptor
- a LayoutGridCellDescriptor instance
Throws
- Exception({ name: 'ArgumentError' })
- if the given column/row is
null
Creates a LayoutGridCellDescriptor defined by the given column and row index.
Parameters
A map of options to pass to the method.
- rowIndex - number
- the row index of the row defining the cell
- columnIndex - number
- the column index of the column defining the cell
Returns
- ↪LayoutGridCellDescriptor
- a LayoutGridCellDescriptor instance
Throws
- Exception({ name: 'ArgumentError' })
- if the given column/row index is not valid
createCellSpanDescriptor
(fromRowIndex: number, fromColIndex: number, toRowIndex: number, toColIndex: number) : LayoutGridCellDescriptorCreates a LayoutGridCellDescriptor that spans multiple columns and rows.
Remarks
The layout grid cell descriptor represents all cells defined by a row with index between fromRowIndex
and toRowIndex
(both inclusive) and a column with index between fromColIndex
and toColIndex
(both inclusive).
A group node mapped to such a layout grid cell descriptor represents the multi-cell, i.e., its boundary corresponds to the smallest rectangle containing all layout grid cells specified by the layout grid cell descriptor. The boundary does not depend on the layout grid cells associated with the group's descendants. Hence, each non-group descendant has to be manually assigned to one of the layout grid cells. Furthermore, edges incident to such a group node are not considered during the layout.
Parameters
A map of options to pass to the method.
- fromRowIndex - number
- the row index of the topmost row defining the cell
- fromColIndex - number
- the column index of the leftmost column defining the cell
- toRowIndex - number
- the row index of the bottommost row defining the cell
- toColIndex - number
- the column index of the rightmost column defining the cell
Returns
- ↪LayoutGridCellDescriptor
- a LayoutGridCellDescriptor instance
createCellSpanDescriptor
(rowList: IEnumerable<LayoutGridRow>, columnList: IEnumerable<LayoutGridColumn>) : LayoutGridCellDescriptorCreates a LayoutGridCellDescriptor that spans multiple columns and rows.
Remarks
The layout grid cell descriptor represents all cells spanned by the columns of columnList
and rows of rowList
.
A group node mapped to such a layout grid cell represents the multi-cell, i.e., its boundary corresponds to the smallest rectangle containing all layout grid cells specified by the layout grid cell descriptor. The boundary does not depend on the layout grid cells associated with the group's descendants. Hence, each non-group descendant has to be manually assigned to one of the layout grid cells. Furthermore, edges incident to such a group node are not considered during the layout.
Parameters
A map of options to pass to the method.
- rowList - IEnumerable<LayoutGridRow>
- the rows defining the cell
- columnList - IEnumerable<LayoutGridColumn>
- the columns defining the cell
Returns
- ↪LayoutGridCellDescriptor
- a LayoutGridCellDescriptor instance
createCellSpanDescriptor
(fromRow: LayoutGridRow, fromCol: LayoutGridColumn, toRow: LayoutGridRow, toCol: LayoutGridColumn) : LayoutGridCellDescriptorCreates a LayoutGridCellDescriptor spanning multiple columns and rows.
Remarks
The layout grid cell descriptor represents all cells defined by a row between fromRow
and toRow
(both including) and a column between fromCol
and toCol
(both including).
A group node mapped to such a layout grid cell represents the multi-cell, i.e., its boundary corresponds to the smallest rectangle containing all layout grid cells specified by the layout grid cell descriptor. The boundary does not depend on the layout grid cells associated with the group's descendants. Hence, each non-group descendant has to be manually assigned to one of the layout grid cells. Furthermore, edges incident to such a group node are not considered during the layout.
Parameters
A map of options to pass to the method.
- fromRow - LayoutGridRow
- the topmost row defining the cell
- fromCol - LayoutGridColumn
- the leftmost column defining the cell
- toRow - LayoutGridRow
- the bottommost row defining the cell
- toCol - LayoutGridColumn
- the rightmost column defining the cell
Returns
- ↪LayoutGridCellDescriptor
- a LayoutGridCellDescriptor instance
Creates a LayoutGridCellDescriptor that spans a whole column.
Remarks
Parameters
A map of options to pass to the method.
- columnIndex - number
- the column index of the column defining the cell
Returns
- ↪LayoutGridCellDescriptor
- a LayoutGridCellDescriptor instance
Creates a dynamic LayoutGridCellDescriptor.
Remarks
Returns
- ↪LayoutGridCellDescriptor
- a LayoutGridCellDescriptor instance
Creates a LayoutGridCellDescriptor spanning a whole row.
Remarks
Parameters
A map of options to pass to the method.
- rowIndex - number
- the row index of the row defining the cell
Returns
- ↪LayoutGridCellDescriptor
- a LayoutGridCellDescriptor instance
Returns the column with the given index.
Parameters
A map of options to pass to the method.
- index - number
- the index of the column to be returned
Returns
- ↪LayoutGridColumn?
- the column with the given index or
null
if no such column exists
Returns the row with the given index.
Parameters
A map of options to pass to the method.
- index - number
- the index of the row to be returned
Returns
- ↪LayoutGridRow?
- the row with the given index or
null
if no such row exists
Constants
A data key for storing a set of layout grid cells for each node.
Remarks
Each node is placed inside the columns/rows defined by the corresponding LayoutGridCellDescriptor. Instances can be shared among multiple nodes, but don't have to be shared.
Assign a set of layout grid cells for each node or null
if no such set is specified.
See Also
Static Methods
Returns the LayoutGrid instance of the first node of the given graph having LayoutGridCellDescriptor associated.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the given graph
Returns
- ↪LayoutGrid?
- the LayoutGrid of the first node of the graph or
null
if no node of the graph has a LayoutGridCellDescriptor associated.