Print
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.
GridColumn
,
PrintIterator.minimumSize()
,
PrintIterator.preferredSize()
Modifier and Type | Field | Description |
---|---|---|
static int |
BORDER_OVERLAP |
Constant cell spacing value indicating that the borders of adjacent cells
should overlap.
|
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 | Description |
---|---|
GridPrint() |
Constructs a GridPrint with no columns and a default look.
|
GridPrint(java.lang.String columns) |
Constructs a GridPrint with the given columns and a default look.
|
GridPrint(java.lang.String columns,
int spacing) |
Deprecated.
use GridPrint(String) instead, then set a DefaultGridLook on
the grid with the desired cell spacing.
|
GridPrint(java.lang.String columns,
int horizontalSpacing,
int verticalSpacing) |
Deprecated.
use GridPrint(String) instead, then set a DefaultGridLook on
the grid with the desired cell spacing.
|
GridPrint(java.lang.String columns,
GridLook look) |
Constructs a GridPrint with the given columns and look.
|
GridPrint(GridColumn[] columns) |
Constructs a GridPrint with the given columns and a default look.
|
GridPrint(GridColumn[] columns,
int spacing) |
Deprecated.
use GridPrint(GridColumn[]) instead, then set a
DefaultGridLook on the grid with the desired cell spacing.
|
GridPrint(GridColumn[] columns,
int horizontalSpacing,
int verticalSpacing) |
Deprecated.
use GridPrint(GridColumn[]) instead, then set a
DefaultGridLook on the grid with the desired cell spacing.
|
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.
|
Modifier and Type | Method | 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 |
add(Print cell,
int colspan,
int hAlignment) |
Deprecated.
Use
add(int, Print, int) instead. |
void |
addColumn(int index,
java.lang.String column) |
Inserts the column at the specified position in the grid.
|
void |
addColumn(int index,
GridColumn 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 |
addColumn(GridColumn column) |
Adds the column on the right edge of the grid.
|
void |
addColumns(int index,
java.lang.String columns) |
Inserts the columns at the specified position in the grid.
|
void |
addColumns(int index,
GridColumn[] 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 |
addColumns(GridColumn[] 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 |
addFooter(Print cell,
int colspan,
int hAlignment) |
Deprecated.
Use
addFooter(int, Print, int) instead. |
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.
|
void |
addHeader(Print cell,
int colspan,
int hAlignment) |
Deprecated.
Use
addHeader(int, Print, int) instead. |
boolean |
equals(java.lang.Object obj) |
|
org.eclipse.swt.graphics.RGB |
getBodyBackground() |
Deprecated.
this functionality has been moved to DefaultGridLook.
|
GridCell[][] |
getBodyCells() |
Returns an array containing the body cells in the grid.
|
Border |
getCellBorder() |
Deprecated.
this functionality has been moved to DefaultGridLook.
|
int[][] |
getColumnGroups() |
Returns current column groups.
|
GridColumn[] |
getColumns() |
Returns an array of
GridColumn s which are the columns in the
receiver. |
org.eclipse.swt.graphics.RGB |
getFooterBackground() |
Deprecated.
this functionality has been moved to DefualtGridLook.
|
GridCell[][] |
getFooterCells() |
Returns an array containing the footer cells in the grid.
|
org.eclipse.swt.graphics.RGB |
getHeaderBackground() |
Deprecated.
this functionality has been moved to DefaultGridLook.
|
GridCell[][] |
getHeaderCells() |
Returns an array containing the header cells in this grid.
|
int |
getHorizontalSpacing() |
Deprecated.
this functionality has been moved to DefaultGridLook.
|
GridLook |
getLook() |
Returns the grid's look.
|
int |
getVerticalSpacing() |
Deprecated.
this functionality has been moved to DefaultGridLook.
|
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 |
setBodyBackground(org.eclipse.swt.graphics.RGB bodyBackground) |
Deprecated.
this functionality has been moved to DefaultGridLook.
|
void |
setCellBorder(Border border) |
Deprecated.
this functionality has been moved to DefaultGridLook.
|
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 |
setFooterBackground(org.eclipse.swt.graphics.RGB footerBackground) |
Deprecated.
this functionality has been moved to DefaultGridLook.
|
void |
setHeaderBackground(org.eclipse.swt.graphics.RGB headerBackground) |
Deprecated.
this functionality has been moved to DefaultGridLook.
|
void |
setHorizontalSpacing(int horizontalSpacing) |
Deprecated.
this functionality has been moved to DefaultGridLook.
|
void |
setLook(GridLook look) |
Sets the grid's look.
|
void |
setVerticalSpacing(int verticalSpacing) |
Deprecated.
this functionality has been moved to DefaultGridLook.
|
public static final int REMAINDER
public static final int PREFERRED
public static final int BORDER_OVERLAP
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(java.lang.String columns, int spacing)
columns
- a comma-separated list of column specs.spacing
- the spacing (in points) between grid cells.BORDER_OVERLAP
public GridPrint(java.lang.String columns, int horizontalSpacing, int verticalSpacing)
columns
- a comma-separated list of column specs.horizontalSpacing
- the horizontal spacing (in points) between grid cells.verticalSpacing
- the vertical spacing (in points) between grid cells.GridColumn.parse(String)
,
BORDER_OVERLAP
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 GridPrint(GridColumn[] columns, int spacing)
columns
- the columns for the new grid.spacing
- the spacing (in points) between grid cells.BORDER_OVERLAP
public GridPrint(GridColumn[] columns, int horizontalSpacing, int verticalSpacing)
columns
- the columns for the new grid.horizontalSpacing
- the horizontal spacing (in points) between grid cells.verticalSpacing
- the vertical spacing (in points) between grid cells.BORDER_OVERLAP
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 void addHeader(Print cell, int colspan, int hAlignment)
addHeader(int, Print, int)
instead. GridPrint's
addHeader method signatures have been rearranged to coincide
with the GridColumn column spec format:
[alignment]:content:[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 GridCell[][] getHeaderCells()
public GridCell[][] getBodyCells()
public GridCell[][] getFooterCells()
public org.eclipse.swt.graphics.RGB getHeaderBackground()
public void setHeaderBackground(org.eclipse.swt.graphics.RGB headerBackground)
headerBackground
- the new background color (defaults to the body background if
null).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 void add(Print cell, int colspan, int hAlignment)
add(int, Print, int)
instead. GridPrint's add
method signatures have been rearranged to coincide with the
GridColumn column spec format: [alignment]:content:[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 org.eclipse.swt.graphics.RGB getBodyBackground()
public void setBodyBackground(org.eclipse.swt.graphics.RGB bodyBackground)
bodyBackground
- the new background color (no background is drawn if null).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 void addFooter(Print cell, int colspan, int hAlignment)
addFooter(int, Print, int)
instead. GridPrint's
addFooter method signatures have been rearranged to coincide
with the GridColumn column spec format:
[alignment]:content:[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 org.eclipse.swt.graphics.RGB getFooterBackground()
public void setFooterBackground(org.eclipse.swt.graphics.RGB footerBackground)
footerBackground
- the new background color (defaults to body background if
null).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 Border getCellBorder()
public void setCellBorder(Border border)
border
- the new body cell border.public int getHorizontalSpacing()
public void setHorizontalSpacing(int horizontalSpacing)
horizontalSpacing
- the new horizontal spacing. A value of BORDER_OVERLAP
indicates that the borders should be overlapped instead of
spaced.public int getVerticalSpacing()
public void setVerticalSpacing(int verticalSpacing)
verticalSpacing
- the new vertical spacing. A value of BORDER_OVERLAP
indicates that the borders should be overlapped instead of
spaced.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