com.jrefinery.report.targets.table
Class TableGridLayout

java.lang.Object
  |
  +--com.jrefinery.report.targets.table.TableGridLayout

public class TableGridLayout
extends java.lang.Object

The table grid layout is used to layout the collected TableCellData object from the TableGrid into the table. The cells position is calculated by comparing the cell bounds with the collected x and y-cuts.

Author:
Thomas Morgner

Nested Class Summary
static class TableGridLayout.Element
          The Element class encapsulates all TableCellData-object within a single grid cell.
 
Constructor Summary
TableGridLayout(int[] pxCuts, int[] pyCuts, TableCellData[] positions)
          Creates a new TableGridLayout.
 
Method Summary
protected  void add(TableCellData pos)
          Adds the table cell data position into the table grid.
protected  void addToGrid(int posX, int posY, TableGridPosition gPos)
          Adds the gridposition into the table, positionated at the cell (posX, posY).
 int getColumnEnd(int column)
          Returns the end position of the given column in points.
 int getColumnStart(int column)
          Returns the start position of the given column in points.
 TableGridLayout.Element getData(int x, int y)
          Returns the element located in the specified cell.
 int getHeight()
          Returns the number of rows of the table.
 int getRowEnd(int row)
          Returns the start position of the given row in points.
 int getRowStart(int row)
          Returns the start position of the given row in points.
 int getWidth()
          Returns the number of columns of the table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableGridLayout

public TableGridLayout(int[] pxCuts,
                       int[] pyCuts,
                       TableCellData[] positions)
Creates a new TableGridLayout.

Parameters:
pxCuts - the collected horizontal cell bounds from the TableGrid,.
pyCuts - the collected vertical cell bounds from the TableGrid.
positions - the positions collected by the table grid.
Method Detail

add

protected void add(TableCellData pos)
Adds the table cell data position into the table grid. The coordinates are calculated by using the sorted x- and y-cuts.

Parameters:
pos - the new position that should be added into the grid

addToGrid

protected void addToGrid(int posX,
                         int posY,
                         TableGridPosition gPos)
Adds the gridposition into the table, positionated at the cell (posX, posY).

Parameters:
posX - the x position within the tablegrid.
posY - the y position within the tablegrid.
gPos - the TableGridPosition that should be added to the table.
Throws:
java.lang.IndexOutOfBoundsException - if posX or posY are invalid.
java.lang.NullPointerException - if the given table grid position is invalid

getData

public TableGridLayout.Element getData(int x,
                                       int y)
Returns the element located in the specified cell.

Parameters:
x - the table column
y - the table row
Returns:
the element, or null, if there is no element defined.

getWidth

public int getWidth()
Returns the number of columns of the table.

Returns:
the width of the table, the number of columns.

getHeight

public int getHeight()
Returns the number of rows of the table.

Returns:
the height of the table, the number of rows.

getColumnStart

public int getColumnStart(int column)
Returns the start position of the given column in points.

Parameters:
column - the column
Returns:
the position of the column in points

getRowStart

public int getRowStart(int row)
Returns the start position of the given row in points.

Parameters:
row - the row
Returns:
the position of the row in points

getColumnEnd

public int getColumnEnd(int column)
Returns the end position of the given column in points.

Parameters:
column - the column
Returns:
the end position of the column in points

getRowEnd

public int getRowEnd(int row)
Returns the start position of the given row in points.

Parameters:
row - the row
Returns:
the end position of the column in points