Class Table
- All Implemented Interfaces:
Block
An immutable table: a rectangular grid of cells, each holding its own blocks (paragraphs, pictures and nested tables), with optional merged ranges.
The grid is always rectangular. A merged range keeps its covered cells in the grid; they are simply not shown, so inserting or deleting a row never has to reshape the grid.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA rectangular range of cells shown as one, anchored at its top-left cell. -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal intThe number of leading rows repeated at the top of every page the table spans.final StringThe block id.final List<Table.Merge> The merged ranges, never overlapping. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncell(int row, int column) The blocks of one cell.cellText(int row, int column) The text of one cell without formatting, paragraphs joined by newlines.intcolumns()The number of columns.The preferred column widths in points, one per column, or an empty list when the columns share the width equally.booleancovered(int row, int column) Whether a cell is hidden inside a merge anchored elsewhere.deleteColumn(int at) A copy without one column.deleteRow(int at) A copy without one row.booleanTwo tables are equal when their id, cells, merges, header rows and column widths are.inthashCode()A hash consistent withequals.id()The block id.insertColumn(int at) A copy with a column of empty cells inserted.insertRow(int at) A copy with a row of empty cells inserted.static TableCreates a table whose cells each hold one paragraph of plain text.introws()The number of rows.span(int row, int column) The merge anchored at a cell.A copy with one cell's blocks replaced.withColumnWidths(float... points) A copy with preferred column widths.withHeaderRows(int value) A copy with a different number of header rows.withMerges(List<Table.Merge> value) A copy with different merges.
-
Field Details
-
id
The block id. -
headerRows
public final int headerRowsThe number of leading rows repeated at the top of every page the table spans. -
merges
The merged ranges, never overlapping.
-
-
Constructor Details
-
Table
Creates a table.
Parameters
-
id: the block id -
cells: the rows; every row must have the same number of cells and every cell is a list of blocks. The lists are copied. -
merges: merged ranges, or null for none -
headerRows: the number of header rows
-
-
-
Method Details
-
columnWidths
-
withColumnWidths
A copy with preferred column widths.
Parameters
points: one positive width per column, in points; null or empty for equal columns
Returns
the copy
-
id
-
rows
public int rows()The number of rows.
Returns
the row count
-
columns
public int columns()The number of columns.
Returns
the column count
-
cell
-
cellText
The text of one cell without formatting, paragraphs joined by newlines.
Parameters
-
row: the row -
column: the column
Returns
the characters
-
-
span
The merge anchored at a cell.
Parameters
-
row: the row -
column: the column
Returns
the merge, or null when none starts there
-
-
covered
public boolean covered(int row, int column) Whether a cell is hidden inside a merge anchored elsewhere.
Parameters
-
row: the row -
column: the column
Returns
true when covered
-
-
withCell
-
withMerges
A copy with different merges.
Parameters
value: the merges
Returns
the copy
-
withHeaderRows
A copy with a different number of header rows.
Parameters
value: the header row count
Returns
the copy
-
insertRow
A copy with a row of empty cells inserted. Merges below move down; a merge the new row passes through grows by one.
Parameters
at: the new row's index, 0 torows()
Returns
the copy
-
deleteRow
A copy without one row. Merges shrink or disappear with it.
Parameters
at: the row to delete
Returns
the copy
-
insertColumn
A copy with a column of empty cells inserted.
Parameters
at: the new column's index, 0 tocolumns()
Returns
the copy
-
deleteColumn
A copy without one column.
Parameters
at: the column to delete
Returns
the copy
-
ofText
-
equals
-
hashCode
-