public class PartitionGrid extends Object
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 PartitionGrid
object has to be registered with the graph using the IDataProvider
key PARTITION_GRID_DPKEY
.
Each node can be assigned to a PartitionCellId
which represents a set of partition cells. The mapping has to be
registered with the graph using IDataProvider
key PARTITION_CELL_ID_DPKEY
. Simple partition cell
identifiers which represent a single partition cell, i.e., a row/column pair, can be created using method createCellId(RowDescriptor, ColumnDescriptor)
or createCellId(int, int)
.
Nodes can also be mapped to a partition cell identifier 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 partition cell (row/column pair) is associated with at most one partition cell identifier. The
multi-cell identifier can be created using methods
createCellSpanId(RowDescriptor, ColumnDescriptor, RowDescriptor, ColumnDescriptor)
,
createCellSpanId(int, int, int, int)
, createCellSpanId(Collection, Collection)
,
createColumnSpanId(int)
, and createRowSpanId(int)
.
Sample output of a layout algorithm with a partition grid
Furthermore, edges incident to such a group node are not considered during the layout. Mapping a group node to a simple partition cell identifier has no effect.
ColumnOrderOptimizationEnabled
or RowOrderOptimizationEnabled
has no effect.Modifier and Type | Field and Description |
---|---|
static NodeDpKey<PartitionCellId> |
PARTITION_CELL_ID_DPKEY
A
DataProvider key for storing a set of partition cells for each node
Each node is placed inside the columns/rows defined by the corresponding PartitionCellId identifier. |
static GraphDpKey<PartitionGrid> |
PARTITION_GRID_DPKEY
A
DataProvider key for storing the partition grid structure
If the IDataProvider contains a partition grid structure, this structure will be considered during layout
(provided that the layout algorithm supports such constraints). |
Constructor and Description |
---|
PartitionGrid()
Creates a new empty instance of
PartitionGrid . |
PartitionGrid(int rowCount,
int columnCount)
Creates an instance of
PartitionGrid with the given number of rows and columns. |
PartitionGrid(int rowCount,
int columnCount,
double rowInsets,
double columnInsets,
double minRowSize,
double minColumnSize)
Creates an instance of
PartitionGrid with the given number of rows and columns as well as with given insets and
minimum sizes. |
Modifier and Type | Method and Description |
---|---|
ColumnDescriptor |
addColumn()
Adds a new
column to the PartitionGrid instance. |
RowDescriptor |
addRow()
Adds a new
row to the PartitionGrid instance. |
PartitionCellId |
createCellId(int rowIndex,
int columnIndex)
Creates a
partition cell identifier that represents the cell defined by the given column and row
index. |
PartitionCellId |
createCellId(RowDescriptor rd,
ColumnDescriptor cd)
|
PartitionCellId |
createCellSpanId(Collection<Object> rowList,
Collection<Object> columnList)
Creates a
partition cell identifier that represents a multi-cell spanning multiple columns and
rows. |
PartitionCellId |
createCellSpanId(int fromRowIndex,
int fromColIndex,
int toRowIndex,
int toColIndex)
Creates a
partition cell identifier that represents a multi-cell spanning multiple columns and
rows. |
PartitionCellId |
createCellSpanId(RowDescriptor fromRow,
ColumnDescriptor fromCol,
RowDescriptor toRow,
ColumnDescriptor toCol)
Creates a
partition cell identifier that represents a multi-cell spanning multiple columns and
rows. |
PartitionCellId |
createColumnSpanId(int columnIndex)
Creates a
partition cell identifier that represents a cell spanning a whole column. |
PartitionCellId |
createRowSpanId(int rowIndex)
Creates a
partition cell identifier that represents a cell spanning a whole row. |
void |
finalizeOrientationChange(OrientationLayout orientationLayouter)
Finalizes the orientation changes and is called at the end of the
OrientationLayout stage. |
ColumnDescriptor |
getColumn(int index)
Returns the
column with the given index. |
YList |
getColumns()
Gets the columns of the
partition grid . |
static PartitionGrid |
getPartitionGrid(Graph graph)
Returns the
PartitionGrid instance associated with the given graph. |
RowDescriptor |
getRow(int index)
Returns the
row with the given index. |
YList |
getRows()
Gets the list of rows of the
partition grid . |
static boolean |
hasAtLeastTwoNonEmptyRows(Graph graph)
Checks whether or not the nodes of the graph are assigned to at least two different partition rows.
|
boolean |
isColumnOrderOptimizationEnabled()
Gets whether or not the order of the columns should be chosen automatically to minimize edge lengths.
|
boolean |
isRowOrderOptimizationEnabled()
Gets whether or not the order of the rows should be chosen automatically to minimize edge lengths.
|
void |
prepareOrientationChange(OrientationLayout orientationLayouter)
Prepares for the orientation changes and is called at the beginning of the
OrientationLayout stage. |
void |
setColumnOrderOptimizationEnabled(boolean value)
Sets whether or not the order of the columns should be chosen automatically to minimize edge lengths.
|
void |
setRowOrderOptimizationEnabled(boolean value)
Sets whether or not the order of the rows should be chosen automatically to minimize edge lengths.
|
public static final NodeDpKey<PartitionCellId> PARTITION_CELL_ID_DPKEY
DataProvider
key for storing a set of partition cells for each node
Each node is placed inside the columns/rows defined by the corresponding PartitionCellId
identifier. Instances
can be shared among multiple nodes, but don't have to be shared.
PartitionCellId
public static final GraphDpKey<PartitionGrid> PARTITION_GRID_DPKEY
DataProvider
key for storing the partition grid structure
If the IDataProvider
contains a partition grid structure, this structure will be considered during layout
(provided that the layout algorithm supports such constraints).
public PartitionGrid()
PartitionGrid
.public PartitionGrid(int rowCount, int columnCount)
PartitionGrid
with the given number of rows and columns.rowCount
- the number of rowscolumnCount
- the number of columnspublic PartitionGrid(int rowCount, int columnCount, double rowInsets, double columnInsets, double minRowSize, double minColumnSize)
PartitionGrid
with the given number of rows and columns as well as with given insets and
minimum sizes.rowCount
- the number of rowscolumnCount
- the number of columnsrowInsets
- the top and bottom insets of the rowscolumnInsets
- the left and right insets of the columnsminRowSize
- the minimum row heightminColumnSize
- the minimum column widthpublic ColumnDescriptor addColumn()
column
to the PartitionGrid
instance.
The index of the column (as returned by Index
) is equal to the size of the list
returned by Columns
.
ColumnDescriptor
instancepublic RowDescriptor addRow()
row
to the PartitionGrid
instance.
The index of the row (as returned by Index
) is equal to the size of the list returned
by Rows
.
RowDescriptor
instancepublic PartitionCellId createCellId(int rowIndex, int columnIndex)
partition cell
identifier that represents the cell defined by the given column and row
index.IllegalArgumentException
- if the given column/row index is not validrowIndex
- the row index of the row defining the cellcolumnIndex
- the column index of the column defining the cellPartitionCellId
instancepublic PartitionCellId createCellId(RowDescriptor rd, ColumnDescriptor cd)
IllegalArgumentException
- if the given column/row is null
rd
- the row defining the cellcd
- the column defining the cellPartitionCellId
instancepublic PartitionCellId createCellSpanId(Collection<Object> rowList, Collection<Object> columnList)
partition cell
identifier that represents a multi-cell spanning multiple columns and
rows.
The partition cell identifier represents all cells spanned by the columns of columnList
and rows of
rowList
.
A group node mapped to such a partition cell identifier represents the multi-cell, i.e., its boundary corresponds to the smallest rectangle containing all partition cells specified by the partition cell identifier. The boundary does not depend on the partition cells associated with the group's descendants. Hence, each non-group descendant has to be manually assigned to one of the partition cells. Furthermore, edges incident to such a group node are not considered during the layout.
rowList
- the rows
defining the cellcolumnList
- the columns
defining the cellPartitionCellId
instancepublic PartitionCellId createCellSpanId(int fromRowIndex, int fromColIndex, int toRowIndex, int toColIndex)
partition cell
identifier that represents a multi-cell spanning multiple columns and
rows.
The partition cell identifier represents all cells defined by a row with index between fromRowIndex
and toRowIndex
(both including) and a column with index between fromColIndex
and toColIndex
(both including).
A group node mapped to such a partition cell identifier represents the multi-cell, i.e., its boundary corresponds to the smallest rectangle containing all partition cells specified by the partition cell identifier. The boundary does not depend on the partition cells associated with the group's descendants. Hence, each non-group descendant has to be manually assigned to one of the partition cells. Furthermore, edges incident to such a group node are not considered during the layout.
fromRowIndex
- the row index of the topmost row defining the cellfromColIndex
- the column index of the leftmost column defining the celltoRowIndex
- the row index of the bottommost row defining the celltoColIndex
- the column index of the rightmost column defining the cellPartitionCellId
instancepublic PartitionCellId createCellSpanId(RowDescriptor fromRow, ColumnDescriptor fromCol, RowDescriptor toRow, ColumnDescriptor toCol)
partition cell
identifier that represents a multi-cell spanning multiple columns and
rows.
The partition cell identifier represents all cells defined by a row between fromRow
and toRow
(both
including) and a column between fromRow
and toCol
(both including).
A group node mapped to such a partition cell identifier represents the multi-cell, i.e., its boundary corresponds to the smallest rectangle containing all partition cells specified by the partition cell identifier. The boundary does not depend on the partition cells associated with the group's descendants. Hence, each non-group descendant has to be manually assigned to one of the partition cells. Furthermore, edges incident to such a group node are not considered during the layout.
fromRow
- the topmost row defining the cellfromCol
- the leftmost column defining the celltoRow
- the bottommost row defining the celltoCol
- the rightmost column defining the cellPartitionCellId
instancepublic PartitionCellId createColumnSpanId(int columnIndex)
partition cell
identifier that represents a cell spanning a whole column.
A group node mapped to such a partition cell identifier represents the column, i.e., its enclosing boundary corresponds to that of the column. The boundary does not depend on the partition cells associated with the group's descendants. Hence, each non-group descendant has to be manually assigned to one of the partition cells. Furthermore, edges incident to such a group node are not considered during the layout.
columnIndex
- the column index of the column defining the cellPartitionCellId
instancepublic PartitionCellId createRowSpanId(int rowIndex)
partition cell
identifier that represents a cell spanning a whole row.
A group node mapped to such a partition cell identifier represents the row, i.e., its enclosing boundary corresponds to that of the row. The boundary does not depend on the partition cells associated with the group's descendants. Hence, each non-group descendant has to be manually assigned to one of the partition cells. Furthermore, edges incident to such a group node are not considered during the layout.
rowIndex
- the row index of the row defining the cellPartitionCellId
instancepublic void finalizeOrientationChange(OrientationLayout orientationLayouter)
OrientationLayout
stage.
Points are transferred to their final positions through OrientationLayout.completeTransform(YPoint)
.
orientationLayouter
- an OrientationLayout
instanceOrientationLayout
public ColumnDescriptor getColumn(int index)
column
with the given index.index
- the index of the column to be returnedcolumn
with the given index or null
if no such column existspublic YList getColumns()
partition grid
.columns
of this PartitionGrid
public static final PartitionGrid getPartitionGrid(Graph graph)
PartitionGrid
instance associated with the given graph.graph
- the given graphPartitionGrid
of the graph or null
if the graph has no associated partition gridpublic RowDescriptor getRow(int index)
row
with the given index.index
- the index of the row to be returnedrow
with the given index or null
if no such row existspublic YList getRows()
partition grid
.rows
of this PartitionGrid
public static final boolean hasAtLeastTwoNonEmptyRows(Graph graph)
graph
- the input graphtrue
if the nodes of the graph are assigned to at least two different partition rows, false
otherwisepublic boolean isColumnOrderOptimizationEnabled()
For all columns where IndexFixed
is set to
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.
true
. true
if the order is chosen automatically, false
otherwisesetColumnOrderOptimizationEnabled(boolean)
public boolean isRowOrderOptimizationEnabled()
For all rows where IndexFixed
is set to
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.
true
. true
if the order is chosen automatically, false
otherwisesetRowOrderOptimizationEnabled(boolean)
public void prepareOrientationChange(OrientationLayout orientationLayouter)
OrientationLayout
stage.
Original points are transferred to their temporary positions through
OrientationLayout.prepareTransform(YPoint)
.
orientationLayouter
- an OrientationLayout
instanceOrientationLayout
public void setColumnOrderOptimizationEnabled(boolean value)
For all columns where IndexFixed
is set to
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.
true
. value
- true
if the order is chosen automatically, false
otherwiseisColumnOrderOptimizationEnabled()
public void setRowOrderOptimizationEnabled(boolean value)
For all rows where IndexFixed
is set to
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.
true
. value
- true
if the order is chosen automatically, false
otherwiseisRowOrderOptimizationEnabled()