Search this API

y.layout.hierarchic.incremental
Class PartitionGrid

java.lang.Object
  extended by y.layout.hierarchic.incremental.PartitionGrid

public class PartitionGrid
extends Object

Class for creating a partition grid, i.e., a grid that partitions the drawing area into rectangular partition cells. The grid consists of rows and columns that are created using the corresponding constructors of this class or method #addColumn or #addRow. The PartitionGrid object has to be registered to the graph using DataProvider PARTITION_DPKEY;

Each node element can be assigned to a partition cell which consists of a row and a column. Therefore the user can create partition cell identifiers using method createCellId(RowDescriptor, ColumnDescriptor) or createCellId(int, int). These cell identifiers have to be assigned to nodes using DataProvider PARTITION_CELL_DPKEY.

Group nodes can also be mapped to a partition cell identifier that represents a multi-cell, i.e., a cell spanning multiple columns and rows. These identifiers can be created using methods createCellSpanId(RowDescriptor, ColumnDescriptor, RowDescriptor, ColumnDescriptor), createCellSpanId(int, int, int, int), createCellSpanId(java.util.Collection, java.util.Collection), createColumnSpanId(int), and createRowSpanId(int). A group node mapped to such a identifier represents the corresponding multi-cell, i.e., its boundary corresponds to the smallest rectangle containing all partition cells specified by the multi-cell.


Field Summary
static Object PARTITION_CELL_DPKEY
          DataProvider key used to store PartitionCellId instances for nodes of the graph.
static Object PARTITION_GRID_DPKEY
          DataProvider key used to store the PartitionGrid structure.
 
Constructor Summary
PartitionGrid()
          Constructs an empty partition grid.
PartitionGrid(int rowCount, int columnCount)
          Constructs a partition grid with rowCount rows and columnCount columns.
PartitionGrid(int rowCount, int columnCount, double rowInsets, double columnInsets, double minRowSize, double minColumnSize)
          Constructs a partition grid with rowCount rows and columnCount columns as well as the given insets and min sizes.
 
Method Summary
 ColumnDescriptor addColumn()
          Adds a new column to the partition grid.
 RowDescriptor addRow()
          Adds a new row to the partition grid.
 PartitionCellId createCellId(int rowIndex, int columnIndex)
          Creates a partition cell identifier that represents the cell defined by the given column and row.
 PartitionCellId createCellId(RowDescriptor rd, ColumnDescriptor cd)
          Creates a partition cell identifier that represents the cell defined by the given column and row.
 PartitionCellId createCellSpanId(Collection rowList, Collection 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(OrientationLayouter orientationLayouter, OrientationLayouter.Transformer transformer)
          A method that is called at the end of the OrientationLayouter stage.
 ColumnDescriptor getColumn(int index)
          Returns the column with the given index.
 YList getColumns()
          Returns the columns of the partition grid.
static PartitionGrid getPartitionGrid(Graph graph)
          Returns the partition grid associated with the given graph.
 RowDescriptor getRow(int index)
          Returns the row with the given index.
 YList getRows()
          Returns the rows of the partition grid.
 boolean isColumnOrderOptimizationEnabled()
          Returns whether the order of the columns should be chosen automatically.
 boolean isRowOrderOptimizationEnabled()
          Returns whether the order of the rows should be chosen automatically.
 void prepareOrientationChange(OrientationLayouter orientationLayouter, OrientationLayouter.Transformer transformer)
          A method that is called at the beginning of the OrientationLayouter stage.
 void setColumnOrderOptimizationEnabled(boolean enabled)
          Specifies whether the order of the columns should be chosen automatically to minimize edge lengths.
 void setRowOrderOptimizationEnabled(boolean enabled)
          Specifies whether the order of the rows should be chosen automatically to minimize edge lengths.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARTITION_GRID_DPKEY

public static final Object PARTITION_GRID_DPKEY
DataProvider key used to store the PartitionGrid structure. The incremental hierarchic layouter uses the graph instance to access the data provider. If the provider contains a partition grid structure this structure will be considered during layout.


PARTITION_CELL_DPKEY

public static final Object PARTITION_CELL_DPKEY
DataProvider key used to store PartitionCellId instances for nodes of the graph. Each node is placed inside the columns/rows defined by the corresponding partition cell identifier. Instances can be shared among multiple nodes, but don't have to be shared.

See Also:
PartitionCellId
Constructor Detail

PartitionGrid

public PartitionGrid()
Constructs an empty partition grid.


PartitionGrid

public PartitionGrid(int rowCount,
                     int columnCount)
Constructs a partition grid with rowCount rows and columnCount columns.

Parameters:
rowCount - the number of rows
columnCount - the number of columns

PartitionGrid

public PartitionGrid(int rowCount,
                     int columnCount,
                     double rowInsets,
                     double columnInsets,
                     double minRowSize,
                     double minColumnSize)
Constructs a partition grid with rowCount rows and columnCount columns as well as the given insets and min sizes.

Parameters:
rowCount - the number of rows
columnCount - the number of columns
rowInsets - the top and bottom insets of the rows
columnInsets - the left and right insets of the columns
minRowSize - the minimum row height
minColumnSize - the minimum column width
Method Detail

isColumnOrderOptimizationEnabled

public boolean isColumnOrderOptimizationEnabled()
Returns whether the order of the columns should be chosen automatically. The default is true.

Returns:
true if the order should be chosen automatically

setColumnOrderOptimizationEnabled

public void setColumnOrderOptimizationEnabled(boolean enabled)
Specifies whether the order of the columns should be chosen automatically to minimize edge lengths.

For all columns where ColumnDescriptor.setIndexFixed(boolean) is set to true, the relative ordering given by the indices is preserved. The remaining columns may be resorted so that the overall edge lengths are minimized.


isRowOrderOptimizationEnabled

public boolean isRowOrderOptimizationEnabled()
Returns whether the order of the rows should be chosen automatically. The default is true.

Returns:
true if the order should be chosen automatically

setRowOrderOptimizationEnabled

public void setRowOrderOptimizationEnabled(boolean enabled)
Specifies whether the order of the rows should be chosen automatically to minimize edge lengths.

For all rows where RowDescriptor.setIndexFixed(boolean) is set to true, the relative ordering given by the indices is preserved. The remaining rows may be resorted so that the overall edge lengths are minimized.


createColumnSpanId

public PartitionCellId createColumnSpanId(int columnIndex)
Creates a partition cell identifier that represents a cell spanning a whole column. Note: this identifier can only be used for group nodes. A group node mapped to such a partition cell identifier represents the column, i.e., its enclosing boundary corresponds to that of the column.

Parameters:
columnIndex - the column index of the column defining the cell
Returns:
the partition cell identifier

createCellSpanId

public 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. Note: this identifier can only be used for group nodes. 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 partition cell identifier represents all cells defined by a row with index between fromRow and toRow (both including) and a column with index between fromCol and toCol (both including).

Parameters:
fromRowIndex - the row index of the topmost row defining the cell
fromColIndex - the column index of the leftmost column defining the cell
toRowIndex - the row index of the bottommost row defining the cell
toColIndex - the column index of the rightmost column defining the cell
Returns:
the partition cell identifier

createCellSpanId

public PartitionCellId createCellSpanId(Collection rowList,
                                        Collection columnList)
Creates a partition cell identifier that represents a multi-cell spanning multiple columns and rows. Note: this identifier can only be used for group nodes. 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 partition cell identifier represents all cells defined by a column of columnList and a row of rowList.

Parameters:
rowList - the rows defining the cell
columnList - the columns defining the cell
Returns:
the partition cell identifier

createCellSpanId

public 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. Note: this identifier can only be used for group nodes. 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 partition cell identifier represents all cells defined by a row between fromRow and toRow (both including) and a column between fromCol and toCol (both including).

Parameters:
fromRow - the topmost row defining the cell
fromCol - the leftmost column defining the cell
toRow - the bottommost row defining the cell
toCol - the rightmost column defining the cell
Returns:
the partition cell identifier

createRowSpanId

public PartitionCellId createRowSpanId(int rowIndex)
Creates a partition cell identifier that represents a cell spanning a whole row. Note: this identifier can only be used for group nodes. A group node mapped to such a partition cell identifier represents the row, i.e., its enclosing boundary corresponds to that of the row.

Parameters:
rowIndex - the row index of the row defining the cell
Returns:
the partition cell identifier

getPartitionGrid

public static PartitionGrid getPartitionGrid(Graph graph)
Returns the partition grid associated with the given graph.

Parameters:
graph - the graph
Returns:
the partition grid of the graph or null if the graph has no associated partition grid

addRow

public RowDescriptor addRow()
Adds a new row to the partition grid. The index of the row (as returned by RowDescriptor.getIndex()) is set to the size of the list returned by getRows().

Returns:
the new row.

addColumn

public ColumnDescriptor addColumn()
Adds a new column to the partition grid. The index of the column (as returned by ColumnDescriptor.getIndex()) is set to the size of the list returned by getColumns().

Returns:
the new column.

getRow

public RowDescriptor getRow(int index)
Returns the row with the given index.

Parameters:
index - the index of the row to be returned
Returns:
the row with the given index or null if there is no such row

getColumn

public ColumnDescriptor getColumn(int index)
Returns the column with the given index.

Parameters:
index - the index of the column to be returned
Returns:
the column with the given index or null if there is no such column

getRows

public YList getRows()
Returns the rows of the partition grid.

Returns:
the rows

getColumns

public YList getColumns()
Returns the columns of the partition grid.

Returns:
the columns

createCellId

public PartitionCellId createCellId(RowDescriptor rd,
                                    ColumnDescriptor cd)
Creates a partition cell identifier that represents the cell defined by the given column and row.

Parameters:
rd - the row defining the cell
cd - the column defining the cell
Returns:
the partition cell identifier

createCellId

public PartitionCellId createCellId(int rowIndex,
                                    int columnIndex)
Creates a partition cell identifier that represents the cell defined by the given column and row.

Parameters:
rowIndex - the row index of the row defining the cell
columnIndex - the column index of the column defining the cell
Returns:
the partition cell identifier

finalizeOrientationChange

public void finalizeOrientationChange(OrientationLayouter orientationLayouter,
                                      OrientationLayouter.Transformer transformer)
A method that is called at the end of the OrientationLayouter stage.

Parameters:
orientationLayouter - the instance of the orientation layouter
transformer - provides a method for transferring a point to its final position
See Also:
OrientationLayouter

prepareOrientationChange

public void prepareOrientationChange(OrientationLayouter orientationLayouter,
                                     OrientationLayouter.Transformer transformer)
A method that is called at the beginning of the OrientationLayouter stage.

Parameters:
orientationLayouter - the instance of the orientation layouter
transformer - provides a method for transferring an original point to its temporary position
See Also:
OrientationLayouter

© Copyright 2000-2013,
yWorks GmbH.
All rights reserved.