org.pentaho.reporting.engine.classic.core.modules.output.table.base
Class SheetLayout

java.lang.Object
  extended by org.pentaho.reporting.engine.classic.core.modules.output.table.base.SheetLayout

public final class SheetLayout
extends Object

The sheet layout is used to build the background map and to collect the x- and y-cell-borders.


Constructor Summary
SheetLayout(boolean strict, boolean ellipseAsRectangle)
          Creates a new TableGrid-object.
 
Method Summary
 boolean add(RenderBox element, long shift)
          Adds the bounds of the given TableCellData to the grid.
 void addRenderableContent(RenderableReplacedContentBox element, long shift)
           
 long getCellWidth(int startCell)
           
 long getCellWidth(int startCell, int endCell)
          Computes the height of the given row.
 int getColSpan(int x1, long endPosition)
           
 int getColumnCount()
          The current number of columns.
 long getMaxHeight()
           
 long getMaxWidth()
           
 int getRowCount()
          The current number of rows.
 long getRowHeight(int row)
          Computes the height of the given row.
 long getRowHeight(int startRow, int endRow)
           
 int getRowSpan(int y1, long endPosition)
           
 TableRectangle getTableBounds(long x, long y, long width, long height, TableRectangle rect)
          Returns the position of the given element within the table.
 TableRectangle getTableBounds(StrictBounds bounds, TableRectangle rect)
          Returns the position of the given element within the table.
 TableRectangle getTableBoundsWithCache(long x, long y, long width, long height, TableRectangle rect)
           
 long getXPosition(int col)
           
 long getYPosition(int row)
           
 boolean isEmpty()
           
 boolean isStrict()
          Gets the strict mode flag.
 void pageCompleted()
          A Callback method to inform the sheet layout, that the current page is complete, and no more content will be added.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SheetLayout

public SheetLayout(boolean strict,
                   boolean ellipseAsRectangle)
Creates a new TableGrid-object. If strict mode is enabled, all cell bounds are used to create the table grid, resulting in a more complex layout.

Parameters:
strict - the strict mode for the layout.
ellipseAsRectangle - a flag that defines whether ellipse-objects are translated into rectangles and therefore create backgrounds.
Method Detail

add

public boolean add(RenderBox element,
                   long shift)
Adds the bounds of the given TableCellData to the grid. The bounds given must be the same as the bounds of the element, or the layouting might produce surprising results.

This method will do nothing, if the element has a width and height of zero and does not define any anchors.

Parameters:
element - the position that should be added to the grid (might be null).
shift - the vertical shift which adjusts the visual position of the content.
Returns:
true, if the box has not changed and can be safely skipped.
Throws:
NullPointerException - if the bounds are null

addRenderableContent

public void addRenderableContent(RenderableReplacedContentBox element,
                                 long shift)

isStrict

public boolean isStrict()
Gets the strict mode flag.

Returns:
true, if strict mode is enabled, false otherwise.

isEmpty

public boolean isEmpty()

getTableBounds

public TableRectangle getTableBounds(long x,
                                     long y,
                                     long width,
                                     long height,
                                     TableRectangle rect)
Returns the position of the given element within the table. The TableRectangle contains row and cell indices, no layout coordinates.

Parameters:
x - the element bounds for which the table bounds should be found.
y - the element bounds for which the table bounds should be found.
width - the element bounds for which the table bounds should be found.
height - the element bounds for which the table bounds should be found.
rect - the returned rectangle or null, if a new instance should be created
Returns:
the filled table rectangle.

getTableBoundsWithCache

public TableRectangle getTableBoundsWithCache(long x,
                                              long y,
                                              long width,
                                              long height,
                                              TableRectangle rect)

getColSpan

public int getColSpan(int x1,
                      long endPosition)

getRowSpan

public int getRowSpan(int y1,
                      long endPosition)

getTableBounds

public TableRectangle getTableBounds(StrictBounds bounds,
                                     TableRectangle rect)
Returns the position of the given element within the table. The TableRectangle contains row and cell indices, no layout coordinates.

Parameters:
bounds - the element bounds for which the table bounds should be found.
rect - the returned rectangle or null, if a new instance should be created
Returns:
the filled table rectangle.

pageCompleted

public void pageCompleted()
A Callback method to inform the sheet layout, that the current page is complete, and no more content will be added.


getRowHeight

public long getRowHeight(int row)
Computes the height of the given row.

Parameters:
row - the row, for which the height should be computed.
Returns:
the height of the row.
Throws:
IndexOutOfBoundsException - if the row is invalid.

getMaxHeight

public long getMaxHeight()

getMaxWidth

public long getMaxWidth()

getCellWidth

public long getCellWidth(int startCell)

getCellWidth

public long getCellWidth(int startCell,
                         int endCell)
Computes the height of the given row.

Parameters:
startCell - the first cell in the range
endCell - the last cell included in the cell range
Returns:
the height of the row.
Throws:
IndexOutOfBoundsException - if the row is invalid.

getRowHeight

public long getRowHeight(int startRow,
                         int endRow)

getColumnCount

public int getColumnCount()
The current number of columns. Of course, this value begins to be reliable, once the number of columns is known (that is at the end of the layouting process).

Returns:
the number columns.

getRowCount

public int getRowCount()
The current number of rows. Of course, this value begins to be reliable, once the number of rows is known (that is at the end of the layouting process).

Returns:
the number columns.

getXPosition

public long getXPosition(int col)

getYPosition

public long getYPosition(int row)