com.pdfjet
Class Table

java.lang.Object
  extended by com.pdfjet.Table

public class Table
extends java.lang.Object

Used to create table objects and draw them on a page. Please see Example_08.


Field Summary
static int DATA_HAS_0_HEADER_ROWS
           
static int DATA_HAS_1_HEADER_ROWS
           
static int DATA_HAS_2_HEADER_ROWS
           
static int DATA_HAS_3_HEADER_ROWS
           
static int DATA_HAS_4_HEADER_ROWS
           
static int DATA_HAS_5_HEADER_ROWS
           
static int DATA_HAS_6_HEADER_ROWS
           
static int DATA_HAS_7_HEADER_ROWS
           
static int DATA_HAS_8_HEADER_ROWS
           
static int DATA_HAS_9_HEADER_ROWS
           
 
Constructor Summary
Table()
          Create a table object.
 
Method Summary
 void autoAdjustColumnWidths()
          Auto adjusts the widths of all columns so that they are just wide enough to hold the text without truncation.
 Point drawOn(Page page)
          Draws this table on the specified page.
 Cell getCellAt(int row, int col)
          Returns the cell at the specified row and column.
 Cell getCellAtRowColumn(int row, int col)
          Returns the cell at the specified row and column.
 java.util.List<Cell> getColumn(int index)
          Returns a list of cell for the specified column.
 java.util.List<Cell> 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.
 java.util.List<Cell> getRow(int index)
          Returns a list of cell for the specified row.
 java.util.List<Cell> getRowAtIndex(int index)
           
 int getRowsRendered()
          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 hasMoreData()
          Returns true if the table contains more data that needs to be drawn on a page.
 void removeLineBetweenRows(int index1, int index2)
          Removes the horizontal lines between the rows from index1 to index2.
 void resetRenderedPagesCount()
          Resets the rendered pages count.
 void rightAlignNumbers()
          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 setData(java.util.List<java.util.List<Cell>> tableData)
          Sets the table data.
 void setData(java.util.List<java.util.List<Cell>> tableData, int numOfHeaderRows)
          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 setNoCellBorders()
          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 wrapAroundCellText()
          Wraps around the text in all cells so it fits the column width.
 void wrapAroundCellText2()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATA_HAS_0_HEADER_ROWS

public static final int DATA_HAS_0_HEADER_ROWS
See Also:
Constant Field Values

DATA_HAS_1_HEADER_ROWS

public static final int DATA_HAS_1_HEADER_ROWS
See Also:
Constant Field Values

DATA_HAS_2_HEADER_ROWS

public static final int DATA_HAS_2_HEADER_ROWS
See Also:
Constant Field Values

DATA_HAS_3_HEADER_ROWS

public static final int DATA_HAS_3_HEADER_ROWS
See Also:
Constant Field Values

DATA_HAS_4_HEADER_ROWS

public static final int DATA_HAS_4_HEADER_ROWS
See Also:
Constant Field Values

DATA_HAS_5_HEADER_ROWS

public static final int DATA_HAS_5_HEADER_ROWS
See Also:
Constant Field Values

DATA_HAS_6_HEADER_ROWS

public static final int DATA_HAS_6_HEADER_ROWS
See Also:
Constant Field Values

DATA_HAS_7_HEADER_ROWS

public static final int DATA_HAS_7_HEADER_ROWS
See Also:
Constant Field Values

DATA_HAS_8_HEADER_ROWS

public static final int DATA_HAS_8_HEADER_ROWS
See Also:
Constant Field Values

DATA_HAS_9_HEADER_ROWS

public static final int DATA_HAS_9_HEADER_ROWS
See Also:
Constant Field Values
Constructor Detail

Table

public Table()
Create a table object.

Method Detail

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

public void setData(java.util.List<java.util.List<Cell>> tableData)
             throws java.lang.Exception
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:
java.lang.Exception

setData

public void setData(java.util.List<java.util.List<Cell>> tableData,
                    int numOfHeaderRows)
             throws java.lang.Exception
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:
java.lang.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

public void removeLineBetweenRows(int index1,
                                  int index2)
                           throws java.lang.Exception
Removes the horizontal lines between the rows from index1 to index2.

Throws:
java.lang.Exception

setTextAlignInColumn

public void setTextAlignInColumn(int index,
                                 int alignment)
                          throws java.lang.Exception
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:
java.lang.Exception

setTextColorInColumn

public void setTextColorInColumn(int index,
                                 int color)
                          throws java.lang.Exception
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:
java.lang.Exception

setFontInColumn

public void setFontInColumn(int index,
                            Font font)
                     throws java.lang.Exception
Sets the font for the specified column.

Parameters:
index - the column index.
font - the font.
Throws:
java.lang.Exception

setTextColorInRow

public void setTextColorInRow(int index,
                              int color)
                       throws java.lang.Exception
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:
java.lang.Exception

setFontInRow

public void setFontInRow(int index,
                         Font font)
                  throws java.lang.Exception
Sets the font for the specified row.

Parameters:
index - the row index.
font - the font.
Throws:
java.lang.Exception

setColumnWidth

public void setColumnWidth(int index,
                           float width)
                    throws java.lang.Exception
Sets the width of the column with the specified index.

Parameters:
index - the index of specified column.
width - the specified width.
Throws:
java.lang.Exception

getColumnWidth

public float getColumnWidth(int index)
                     throws java.lang.Exception
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:
java.lang.Exception

getCellAt

public Cell getCellAt(int row,
                      int col)
               throws java.lang.Exception
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:
java.lang.Exception

getCellAtRowColumn

public Cell getCellAtRowColumn(int row,
                               int col)
                        throws java.lang.Exception
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:
java.lang.Exception

getRow

public java.util.List<Cell> getRow(int index)
                            throws java.lang.Exception
Returns a list of cell for the specified row.

Parameters:
index - the index of the specified row.
Returns:
the list of cells.
Throws:
java.lang.Exception

getRowAtIndex

public java.util.List<Cell> getRowAtIndex(int index)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

getColumn

public java.util.List<Cell> getColumn(int index)
                               throws java.lang.Exception
Returns a list of cell for the specified column.

Parameters:
index - the index of the specified column.
Returns:
the list of cells.
Throws:
java.lang.Exception

getColumnAtIndex

public java.util.List<Cell> getColumnAtIndex(int index)
                                      throws java.lang.Exception
Throws:
java.lang.Exception

getNumberOfPages

public int getNumberOfPages(Page page)
                     throws java.lang.Exception
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:
java.lang.Exception

drawOn

public Point drawOn(Page page)
             throws java.lang.Exception
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:
java.lang.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.

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.


wrapAroundCellText2

public void wrapAroundCellText2()