Package com.itextpdf.layout.renderer
Class Grid
java.lang.Object
com.itextpdf.layout.renderer.Grid
This class represents a grid of elements.
Complex elements (which span over few cells of a grid) are stored as duplicates.
For example if element with width = 2, height = 3 added to a grid, grid will store it as 6 elements each having
width = height = 1.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
This class is used to properly initialize starting values for grid.private static class
This class is used to place cells on grid.private static final class
This comparator sorts cells so ones with both fixed row and column positions would go first, then cells with fixed column and then all other cells.private static class
(package private) static enum
private static final class
This comparator sorts cells so ones with both fixed row and column positions would go first, then cells with fixed row and then all other cells. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
Column start offset, it is not zero only if there are cells with negative indexes.private int
Row start offset, it is not zero only if there are cells with negative indexes.private GridCell[][]
Cells container.private final List
<Collection<GridCell>> Unique grid cells cached values. -
Constructor Summary
ConstructorsConstructorDescriptionGrid
(int initialRowsCount, int initialColumnsCount, int columnOffset, int rowOffset) Creates new grid instance. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Add cell in the grid, checking that it would fit and initializing it bottom left corner (x, y).(package private) int
collapseNullLines
(Grid.GridOrder order, int minSize) Deletes all null rows/columns depending on the given values.private int
(package private) int
get column start offset or grid "zero column" position.(package private) final int
Gets the current number of rows of grid.(package private) final int
Gets the current number of rows of grid.(package private) int
get row start offset or grid "zero row" position.(package private) final GridCell[][]
getRows()
Get internal matrix of cells.(package private) Collection
<GridCell> getUniqueGridCells
(Grid.GridOrder iterationOrder) Get all unique cells in the grid.(package private) final void
resize
(int height, int width) Resize grid if needed, so it would have given number of rows/columns.
-
Field Details
-
rows
Cells container. -
rowOffset
private int rowOffsetRow start offset, it is not zero only if there are cells with negative indexes. Such cells should not be covered by templates, so the offset represents row from which template values should be considered. -
columnOffset
private int columnOffsetColumn start offset, it is not zero only if there are cells with negative indexes. Such cells should not be covered by templates, so the offset represents column from which template values should be considered. -
uniqueCells
Unique grid cells cached values. first value of array contains unique cells in order from left to right and the second value contains cells in order from top to bottom. -
itemsWithoutPlace
-
-
Constructor Details
-
Grid
Grid(int initialRowsCount, int initialColumnsCount, int columnOffset, int rowOffset) Creates new grid instance.- Parameters:
initialRowsCount
- initial number of row for the gridinitialColumnsCount
- initial number of columns for the gridcolumnOffset
- actual start(zero) position of columns, from where template should be appliedrowOffset
- actual start(zero) position of rows, from where template should be applied
-
-
Method Details
-
getRows
Get internal matrix of cells.- Returns:
- matrix of cells.
-
getNumberOfRows
final int getNumberOfRows()Gets the current number of rows of grid.- Returns:
- the number of rows
-
getNumberOfColumns
final int getNumberOfColumns()Gets the current number of rows of grid.- Returns:
- the number of columns
-
getRowOffset
int getRowOffset()get row start offset or grid "zero row" position.- Returns:
- row start offset if there are negative indexes, 0 otherwise
-
getColumnOffset
int getColumnOffset()get column start offset or grid "zero column" position.- Returns:
- column start offset if there are negative indexes, 0 otherwise
-
getUniqueGridCells
Get all unique cells in the grid. Internally big cells (height * width > 1) are stored in multiple quantities For example, cell with height = 2 and width = 2 will have 4 instances on a grid (width * height) to simplify internal grid processing. This method counts such cells as one and returns a list of unique cells. The result is cached since grid can't be changed after creation.- Parameters:
iterationOrder
- if {GridOrder.ROW} the order of cells is from left to right, top to bottom if {GridOrder.COLUMN} the order of cells is from top to bottom, left to right- Returns:
- collection of unique grid cells.
-
resize
final void resize(int height, int width) Resize grid if needed, so it would have given number of rows/columns.- Parameters:
height
- new grid heightwidth
- new grid width
-
collapseNullLines
Deletes all null rows/columns depending on the given values. If resulting grid size is less than provided minSize than some null lines will be preserved.- Parameters:
order
- which null lines to remove -Grid.GridOrder.ROW
to remove rowsGrid.GridOrder.COLUMN
to remove columnsminSize
- minimal size of the resulting grid- Returns:
- the number of left lines in given order
-
addCell
Add cell in the grid, checking that it would fit and initializing it bottom left corner (x, y).- Parameters:
cell
- cell to and in the grid
-
determineNullLinesStart
-