public final class GridPrint extends java.lang.Object implements Print
GridPrint uses a column sizing algorithm based on the W3C
recommendation for automatic layout of tables. GridPrint deviates from
the recommendation on one important point: if there is less width available
on the print device than the calculated "minimum" size of the grid, the
columns will be scaled down to less than their calculated minimum
widths. Only when one of the columns goes below its "absolute minimum" will
the grid fail to print ( PrintIterator.next(int, int)
returns null).
GridPrint offers three basic methods of specifying column size.
In addition, any column can be given a grow attribute. In the event a grid is not as wide as the page, those columns with the grow attribute set will be widened to fill the extra space.
Because GridPrint scales columns according to their minimum sizes in the worst-case scenario, the absolute minimum size of a GridPrint is dependant on its child prints and is not clearly defined.
If a grid has one of more columns with the grow attribute set, the grid is horizontally greedy. Greedy prints take up all the available space on the page.
Modifier and Type | Field and Description |
---|---|
(package private) java.util.List<java.util.List<GridCell>> |
body
Two-dimensional list of all body cells.
|
static int |
BORDER_OVERLAP
Constant cell spacing value indicating that the borders of adjacent cells
should overlap.
|
(package private) boolean |
cellClippingEnabled |
(package private) int[][] |
columnGroups
Array of column groups.
|
(package private) java.util.List<GridColumn> |
columns
The columns for this grid.
|
(package private) java.util.List<java.util.List<GridCell>> |
footer
Two-dimension list of all footer cells.
|
(package private) java.util.List<java.util.List<GridCell>> |
header
Two-dimension list of all header cells.
|
static int |
PREFERRED
Constant column size value indicating that the column should be given its
preferred size.
|
static int |
REMAINDER
Constant colspan value indicating that all remaining columns in the row
should be used.
|
Constructor and Description |
---|
GridPrint()
Constructs a GridPrint with no columns and a default look.
|
GridPrint(GridColumn[] columns)
Constructs a GridPrint with the given columns and a default look.
|
GridPrint(GridColumn[] columns,
GridLook look)
Constructs a GridPrint with the given columns and look.
|
GridPrint(GridLook look)
Constructs a GridPrint with no columns and the given look.
|
GridPrint(java.lang.String columns)
Constructs a GridPrint with the given columns and a default look.
|
GridPrint(java.lang.String columns,
GridLook look)
Constructs a GridPrint with the given columns and look.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int hAlignment,
int vAlignment,
Print cell)
Adds the Print to the grid body, using the given colspan and alignment.
|
void |
add(int hAlignment,
int vAlignment,
Print cell,
int colspan)
Adds the Print to the grid body, using the given colspan and alignment.
|
void |
add(int hAlignment,
Print cell)
Adds the Print to the grid body, using the given colspan and alignment.
|
void |
add(int hAlignment,
Print cell,
int colspan)
Adds the Print to the grid body, using the given colspan and alignment.
|
void |
add(Print cell)
Adds the Print to the grid body, with the default alignment and a colspan
of 1.
|
void |
add(Print cell,
int colspan)
Adds the Print to the grid body, with the given colspan and the default
alignment.
|
void |
addColumn(GridColumn column)
Adds the column on the right edge of the grid.
|
void |
addColumn(int index,
GridColumn column)
Inserts the column at the specified position in the grid.
|
void |
addColumn(int index,
java.lang.String column)
Inserts the column at the specified position in the grid.
|
void |
addColumn(java.lang.String column)
Adds the column on the right edge of the grid.
|
void |
addColumns(GridColumn[] columns)
Adds the columns on the right edge of the grid.
|
void |
addColumns(int index,
GridColumn[] columns)
Inserts the columns at the specified position in the grid.
|
void |
addColumns(int index,
java.lang.String columns)
Inserts the columns at the specified position in the grid.
|
void |
addColumns(java.lang.String columns)
Adds the columns on the right edge of the grid.
|
void |
addFooter(int hAlignment,
int vAlignment,
Print cell)
Adds the Print to the grid footer, using the given colspan and alignment.
|
void |
addFooter(int hAlignment,
int vAlignment,
Print cell,
int colspan)
Adds the Print to the grid footer, using the given colspan and alignment.
|
void |
addFooter(int hAlignment,
Print cell)
Adds the Print to the grid footer, using the given colspan and alignment.
|
void |
addFooter(int hAlignment,
Print cell,
int colspan)
Adds the Print to the grid footer, using the given colspan and alignment.
|
void |
addFooter(Print cell)
Adds the Print to the grid footer, with the default alignment and a
colspan of 1.
|
void |
addFooter(Print cell,
int colspan)
Adds the Print to the grid footer, with the given colspan and the default
alignment.
|
void |
addHeader(int hAlignment,
int vAlignment,
Print cell)
Adds the Print to the grid header, using the given alignment.
|
void |
addHeader(int hAlignment,
int vAlignment,
Print cell,
int colspan)
Adds the Print to the grid header, using the given colspan and alignment.
|
void |
addHeader(int hAlignment,
Print cell)
Adds the Print to the grid header, using the given alignment.
|
void |
addHeader(int hAlignment,
Print cell,
int colspan)
Adds the Print to the grid header, using the given colspan and alignment.
|
void |
addHeader(Print cell)
Adds the Print to the grid header, with default alignment and a colspan
of 1.
|
void |
addHeader(Print cell,
int colspan)
Adds the Print to the grid header, with the given colspan and the default
alignment.
|
boolean |
equals(java.lang.Object obj) |
GridCell[][] |
getBodyCells()
Returns an array containing the body cells in the grid.
|
int[][] |
getColumnGroups()
Returns current column groups.
|
GridColumn[] |
getColumns()
Returns an array of
GridColumn s which are the columns in the
receiver. |
GridCell[][] |
getFooterCells()
Returns an array containing the footer cells in the grid.
|
GridCell[][] |
getHeaderCells()
Returns an array containing the header cells in this grid.
|
GridLook |
getLook()
Returns the grid's look.
|
int |
hashCode() |
boolean |
isCellClippingEnabled()
Returns whether individual body cells in the grid may be broken across
pages.
|
PrintIterator |
iterator(org.eclipse.swt.graphics.Device device,
org.eclipse.swt.graphics.GC gc)
Returns a PrintIterator for laying out the contents of this Print.
|
void |
setCellClippingEnabled(boolean cellClippingEnabled)
Sets whether individual body cells in the grid may be broken across
pages.
|
void |
setColumnGroups(int[][] columnGroups)
Sets the column groups to the given two-dimension array.
|
void |
setLook(GridLook look)
Sets the grid's look.
|
public static final int REMAINDER
public static final int PREFERRED
public static final int BORDER_OVERLAP
final java.util.List<GridColumn> columns
int[][] columnGroups
final java.util.List<java.util.List<GridCell>> header
final java.util.List<java.util.List<GridCell>> body
boolean cellClippingEnabled
final java.util.List<java.util.List<GridCell>> footer
public GridPrint()
public GridPrint(GridLook look)
look
- the look to apply to the constructed grid.public GridPrint(java.lang.String columns)
columns
- a comma-separated list of parseable column specs.GridColumn.parse(String)
public GridPrint(java.lang.String columns, GridLook look)
columns
- a comma-separated list of parseable column specs.look
- the look to apply to the constructed grid.GridColumn.parse(String)
public GridPrint(GridColumn[] columns)
columns
- the columns for the new grid.public GridPrint(GridColumn[] columns, GridLook look)
columns
- the columns for the new grid.look
- the look to apply to the constructed grid.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public void addColumn(java.lang.String column)
column
- the column to add to the grid.GridColumn.parse(String)
public void addColumn(GridColumn column)
column
- the column to add to the grid.public void addColumn(int index, java.lang.String column)
index
- the insert position.column
- the column to be inserted.GridColumn.parse(String)
public void addColumn(int index, GridColumn column)
index
- the insert position.column
- the column to be inserted.public void addColumns(java.lang.String columns)
columns
- the columns to add to the grid.GridColumn.parse(String)
public void addColumns(GridColumn[] columns)
columns
- the columns to add to the grid.public void addColumns(int index, java.lang.String columns)
index
- the insert position.columns
- the columns to be inserted.GridColumn.parse(String)
public void addColumns(int index, GridColumn[] columns)
index
- the insert position.columns
- the columns to be inserted.GridColumn.parse(String)
public GridColumn[] getColumns()
GridColumn
s which are the columns in the
receiver.GridColumn
s which are the columns in the
receiver.public void addHeader(Print cell)
cell
- the print to add.public void addHeader(int hAlignment, Print cell)
hAlignment
- the horizontal alignment of the print within the grid cell.
One of SWT.DEFAULT
, SWT.LEFT
,
SWT.CENTER
or SWT.RIGHT
.cell
- the print to add.public void addHeader(int hAlignment, int vAlignment, Print cell)
hAlignment
- the horizontal alignment of the print within the grid cell.
One of SWT.DEFAULT
, SWT.LEFT
,
SWT.CENTER
or SWT.RIGHT
.vAlignment
- the vertical alignment of the print within the grid cell. One
of SWT.DEFAULT
, SWT.TOP
, SWT.CENTER
,
SWT.BOTTOM
, or SWT.FILL
. A value of FILL
indicates that the cell is vertically greedy, so GridPrint
will limit the cell's height to the tallest non-FILL cell in
the row.cell
- the print to add.public void addHeader(Print cell, int colspan)
cell
- the print to add.colspan
- the number of columns to span, or REMAINDER
to span the rest of the row.public void addHeader(int hAlignment, Print cell, int colspan)
cell
- the print to add.colspan
- the number of columns to span, or REMAINDER
to span the rest of the row.hAlignment
- the horizontal alignment of the print within the grid cell.
One of SWT.DEFAULT
, SWT.LEFT
,
SWT.CENTER
or SWT.RIGHT
.public void addHeader(int hAlignment, int vAlignment, Print cell, int colspan)
hAlignment
- the horizontal alignment of the print within the grid cell.
One of SWT.DEFAULT
, SWT.LEFT
,
SWT.CENTER
or SWT.RIGHT
.vAlignment
- the vertical alignment of the print within the grid cell. One
of SWT.DEFAULT
, SWT.TOP
, SWT.CENTER
,
SWT.BOTTOM
, or SWT.FILL
. A value of FILL
indicates that the cell is vertically greedy, so GridPrint
will limit the cell's height to the tallest non-FILL cell in
the row.cell
- the print to add.colspan
- the number of columns to span, or REMAINDER
to span the rest of the row.public GridCell[][] getHeaderCells()
public GridCell[][] getBodyCells()
public GridCell[][] getFooterCells()
public void add(Print cell)
cell
- the print to add.public void add(int hAlignment, Print cell)
hAlignment
- the horizontal alignment of the print within the grid cell.
One of SWT.DEFAULT
, SWT.LEFT
,
SWT.CENTER
or SWT.RIGHT
.cell
- the print to add.public void add(int hAlignment, int vAlignment, Print cell)
hAlignment
- the horizontal alignment of the print within the grid cell.
One of SWT.DEFAULT
, SWT.LEFT
,
SWT.CENTER
or SWT.RIGHT
.vAlignment
- the vertical alignment of the print within the grid cell. One
of SWT.DEFAULT
, SWT.TOP
, SWT.CENTER
,
SWT.BOTTOM
, or SWT.FILL
. A value of FILL
indicates that the cell is vertically greedy, so GridPrint
will limit the cell's height to the tallest non-FILL cell in
the row.cell
- the print to add.public void add(Print cell, int colspan)
cell
- the print to add.colspan
- the number of columns to span, or REMAINDER
to span the rest of the row.public void add(int hAlignment, Print cell, int colspan)
hAlignment
- the horizontal alignment of the print within the grid cell.
One of SWT.DEFAULT
, SWT.LEFT
,
SWT.CENTER
or SWT.RIGHT
.cell
- the print to add.colspan
- the number of columns to span, or REMAINDER
to span the rest of the row.public void add(int hAlignment, int vAlignment, Print cell, int colspan)
hAlignment
- the horizontal alignment of the print within the grid cell.
One of SWT.DEFAULT
, SWT.LEFT
,
SWT.CENTER
or SWT.RIGHT
.vAlignment
- the vertical alignment of the print within the grid cell. One
of SWT.DEFAULT
, SWT.TOP
, SWT.CENTER
,
SWT.BOTTOM
, or SWT.FILL
. A value of FILL
indicates that the cell is vertically greedy, so GridPrint
will limit the cell's height to the tallest non-FILL cell in
the row.cell
- the print to add.colspan
- the number of columns to span, or REMAINDER
to span the rest of the row.public boolean isCellClippingEnabled()
public void setCellClippingEnabled(boolean cellClippingEnabled)
cellClippingEnabled
- whether to enabled cell clipping.public void addFooter(Print cell)
cell
- the print to add.public void addFooter(int hAlignment, Print cell)
hAlignment
- the horizontal alignment of the print within the grid cell.
One of SWT.DEFAULT
, SWT.LEFT
,
SWT.CENTER
or SWT.RIGHT
.cell
- the print to add.public void addFooter(int hAlignment, int vAlignment, Print cell)
hAlignment
- the horizontal alignment of the print within the grid cell.
One of SWT.DEFAULT
, SWT.LEFT
,
SWT.CENTER
or SWT.RIGHT
.vAlignment
- the vertical alignment of the print within the grid cell. One
of SWT.DEFAULT
, SWT.TOP
, SWT.CENTER
,
SWT.BOTTOM
, or SWT.FILL
. A value of FILL
indicates that the cell is vertically greedy, so GridPrint
will limit the cell's height to the tallest non-FILL cell in
the row.cell
- the print to add.public void addFooter(Print cell, int colspan)
cell
- the print to add.colspan
- the number of columns to span, or REMAINDER
to span the rest of the row.public void addFooter(int hAlignment, Print cell, int colspan)
hAlignment
- the horizontal alignment of the print within the grid cell.
One of SWT.DEFAULT
, SWT.LEFT
,
SWT.CENTER
or SWT.RIGHT
.cell
- the print to add.colspan
- the number of columns to span, or REMAINDER
to span the rest of the row.public void addFooter(int hAlignment, int vAlignment, Print cell, int colspan)
hAlignment
- the horizontal alignment of the print within the grid cell.
One of SWT.DEFAULT
, SWT.LEFT
,
SWT.CENTER
or SWT.RIGHT
.vAlignment
- the vertical alignment of the print within the grid cell. One
of SWT.DEFAULT
, SWT.TOP
, SWT.CENTER
,
SWT.BOTTOM
, or SWT.FILL
. A value of FILL
indicates that the cell is vertically greedy, so GridPrint
will limit the cell's height to the tallest non-FILL cell in
the row.cell
- the print to add.colspan
- the number of columns to span, or REMAINDER
to span the rest of the row.public int[][] getColumnGroups()
public void setColumnGroups(int[][] columnGroups)
The following statement causes columns 0 and 2 to be the same size, and columns 1 and 3 to be the same size.
grid.setColumnGroups(new int[][] { { 0, 2 }, { 1, 3 } });
The behavior of this property is undefined when a column belongs to more than one group.
Note: Column grouping is enforced before column weights. Therefore, columns in the same group should be given the same weight to ensure they are laid out at the same width.
columnGroups
- the new column groups.public GridLook getLook()
public void setLook(GridLook look)
look
- the new look.public PrintIterator iterator(org.eclipse.swt.graphics.Device device, org.eclipse.swt.graphics.GC gc)
Print