Package net.atthegate.server.service.pdf
Class Table
java.lang.Object
net.atthegate.server.service.pdf.Table
Used to create table objects and draw them on a page.
Please see Example_08.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Auto adjusts the widths of all columns so that they are just wide enough to hold the text without truncation.Draws this table on the specified page.getCellAt
(int row, int col) Returns the cell at the specified row and column.getCellAtRowColumn
(int row, int col) Returns the cell at the specified row and column.getColumn
(int index) Returns a list of cell for the specified column.getColumnAtIndex
(int index) float
getColumnWidth
(int index) Returns the column width of the column at the specified index.int
getNumberOfPages
(Page page) Returns the total number of pages that are required to draw this table on.getRow
(int index) Returns a list of cell for the specified row.getRowAtIndex
(int index) int
Returns the number of data rows that have been rendered so far.float
getWidth()
Returns the width of this table when drawn on a page.boolean
Returns true if the table contains more data that needs to be drawn on a page.void
This method removes borders that have the same color and overlap 100%.void
removeLineBetweenRows
(int index1, int index2) Removes the horizontal lines between the rows from index1 to index2.void
Resets the rendered pages count.void
Sets the alignment of the numbers to the right.void
setBottomMargin
(double bottom_margin) Sets the bottom margin for this table.void
setBottomMargin
(float bottom_margin) Sets the bottom margin for this table.void
setCellBordersColor
(int color) Sets the color of the cell border lines.void
setCellBordersWidth
(float width) Sets the width of the cell border lines.void
setColumnWidth
(int index, float width) Sets the width of the column with the specified index.void
Sets the table data.void
Sets the table data and specifies the number of header rows in this data.void
setFontInColumn
(int index, Font font) Sets the font for the specified column.void
setFontInRow
(int index, Font font) Sets the font for the specified row.void
setLocation
(float x, float y) Sets the location (x, y) of the top left corner of this table on the page.void
Sets all table cells borders to false.void
setPosition
(double x, double y) Sets the position (x, y) of the top left corner of this table on the page.void
setPosition
(float x, float y) Sets the position (x, y) of the top left corner of this table on the page.void
setTextAlignInColumn
(int index, int alignment) Sets the text alignment in the specified column.void
setTextColorInColumn
(int index, int color) Sets the color of the text in the specified column.void
setTextColorInRow
(int index, int color) Sets the color of the text in the specified row.void
Wraps around the text in all cells so it fits the column width.void
Deprecated.
-
Field Details
-
DATA_HAS_0_HEADER_ROWS
public static final int DATA_HAS_0_HEADER_ROWS- See Also:
-
DATA_HAS_1_HEADER_ROWS
public static final int DATA_HAS_1_HEADER_ROWS- See Also:
-
DATA_HAS_2_HEADER_ROWS
public static final int DATA_HAS_2_HEADER_ROWS- See Also:
-
DATA_HAS_3_HEADER_ROWS
public static final int DATA_HAS_3_HEADER_ROWS- See Also:
-
DATA_HAS_4_HEADER_ROWS
public static final int DATA_HAS_4_HEADER_ROWS- See Also:
-
DATA_HAS_5_HEADER_ROWS
public static final int DATA_HAS_5_HEADER_ROWS- See Also:
-
DATA_HAS_6_HEADER_ROWS
public static final int DATA_HAS_6_HEADER_ROWS- See Also:
-
DATA_HAS_7_HEADER_ROWS
public static final int DATA_HAS_7_HEADER_ROWS- See Also:
-
DATA_HAS_8_HEADER_ROWS
public static final int DATA_HAS_8_HEADER_ROWS- See Also:
-
DATA_HAS_9_HEADER_ROWS
public static final int DATA_HAS_9_HEADER_ROWS- See Also:
-
-
Constructor Details
-
Table
public Table()Create a table object.
-
-
Method Details
-
setPosition
public void setPosition(double x, double y) Sets the position (x, y) of the top left corner of this table on the page.- Parameters:
x
- the x coordinate of the top left point of the table.y
- the y coordinate of the top left point of the table.
-
setPosition
public void setPosition(float x, float y) Sets the position (x, y) of the top left corner of this table on the page.- Parameters:
x
- the x coordinate of the top left point of the table.y
- the y coordinate of the top left point of the table.
-
setLocation
public void setLocation(float x, float y) Sets the location (x, y) of the top left corner of this table on the page.- Parameters:
x
- the x coordinate of the top left point of the table.y
- the y coordinate of the top left point of the table.
-
setBottomMargin
public void setBottomMargin(double bottom_margin) Sets the bottom margin for this table.- Parameters:
bottom_margin
- the margin.
-
setBottomMargin
public void setBottomMargin(float bottom_margin) Sets the bottom margin for this table.- Parameters:
bottom_margin
- the margin.
-
setData
Sets the table data. The table data is a perfect grid of cells. All cell should be an unique object and you can not reuse blank cell objects. Even if one or more cells have colspan bigger than zero the number of cells in the row will not change.- Parameters:
tableData
- the table data.- Throws:
Exception
-
setData
Sets the table data and specifies the number of header rows in this data.- Parameters:
tableData
- the table data.numOfHeaderRows
- the number of header rows in this data.- Throws:
Exception
-
autoAdjustColumnWidths
public void autoAdjustColumnWidths()Auto adjusts the widths of all columns so that they are just wide enough to hold the text without truncation. -
rightAlignNumbers
public void rightAlignNumbers()Sets the alignment of the numbers to the right. -
removeLineBetweenRows
Removes the horizontal lines between the rows from index1 to index2.- Throws:
Exception
-
setTextAlignInColumn
Sets the text alignment in the specified column.- Parameters:
index
- the index of the specified column.alignment
- the specified alignment. Supported values: Align.LEFT, Align.RIGHT, Align.CENTER and Align.JUSTIFY.- Throws:
Exception
-
setTextColorInColumn
Sets the color of the text in the specified column.- Parameters:
index
- the index of the specified column.color
- the color specified as an integer.- Throws:
Exception
-
setFontInColumn
Sets the font for the specified column.- Parameters:
index
- the column index.font
- the font.- Throws:
Exception
-
setTextColorInRow
Sets the color of the text in the specified row.- Parameters:
index
- the index of the specified row.color
- the color specified as an integer.- Throws:
Exception
-
setFontInRow
Sets the font for the specified row.- Parameters:
index
- the row index.font
- the font.- Throws:
Exception
-
setColumnWidth
Sets the width of the column with the specified index.- Parameters:
index
- the index of specified column.width
- the specified width.- Throws:
Exception
-
getColumnWidth
Returns the column width of the column at the specified index.- Parameters:
index
- the index of the column.- Returns:
- the width of the column.
- Throws:
Exception
-
getCellAt
Returns the cell at the specified row and column.- Parameters:
row
- the specified row.col
- the specified column.- Returns:
- the cell at the specified row and column.
- Throws:
Exception
-
getCellAtRowColumn
Returns the cell at the specified row and column.- Parameters:
row
- the specified row.col
- the specified column.- Returns:
- the cell at the specified row and column.
- Throws:
Exception
-
getRow
Returns a list of cell for the specified row.- Parameters:
index
- the index of the specified row.- Returns:
- the list of cells.
- Throws:
Exception
-
getRowAtIndex
- Throws:
Exception
-
getColumn
Returns a list of cell for the specified column.- Parameters:
index
- the index of the specified column.- Returns:
- the list of cells.
- Throws:
Exception
-
getColumnAtIndex
- Throws:
Exception
-
getNumberOfPages
Returns the total number of pages that are required to draw this table on.- Parameters:
page
- the type of pages we are drawing this table on.- Returns:
- the number of pages.
- Throws:
Exception
-
drawOn
Draws this table on the specified page.- Parameters:
page
- the page to draw this table on.- Returns:
- Point the point on the page where to draw the next component.
- Throws:
Exception
-
hasMoreData
public boolean hasMoreData()Returns true if the table contains more data that needs to be drawn on a page. -
getWidth
public float getWidth()Returns the width of this table when drawn on a page.- Returns:
- the widht of this table.
-
getRowsRendered
public int getRowsRendered()Returns the number of data rows that have been rendered so far.- Returns:
- the number of data rows that have been rendered so far.
-
wrapAroundCellText2
Deprecated.Just calls the wrapAroundCellText method. -
wrapAroundCellText
public void wrapAroundCellText()Wraps around the text in all cells so it fits the column width. This method should be called after all calls to setColumnWidth and autoAdjustColumnWidths. -
setNoCellBorders
public void setNoCellBorders()Sets all table cells borders to false. -
setCellBordersColor
public void setCellBordersColor(int color) Sets the color of the cell border lines.- Parameters:
color
- the color of the cell border lines.
-
setCellBordersWidth
public void setCellBordersWidth(float width) Sets the width of the cell border lines.- Parameters:
width
- the width of the border lines.
-
resetRenderedPagesCount
public void resetRenderedPagesCount()Resets the rendered pages count. Call this method if you have to draw this table more than one time. -
mergeOverlaidBorders
public void mergeOverlaidBorders()This method removes borders that have the same color and overlap 100%. The result is improved onscreen rendering of thin border lines by some PDF viewers.
-