net.sf.jasperreports.engine.export
Class JRGridLayout

java.lang.Object
  extended by net.sf.jasperreports.engine.export.JRGridLayout

public class JRGridLayout
extends java.lang.Object

Utility class used by grid exporters to create a grid for page layout.

Version:
$Id: JRGridLayout.java 5377 2012-05-11 13:50:50Z shertage $
Author:
Lucian Chirita (lucianc@users.sourceforge.net)

Nested Class Summary
protected static class JRGridLayout.BoxKey
           
 
Constructor Summary
protected JRGridLayout(ExporterNature nature, ElementWrapper[] wrappers, int width, int height, int offsetX, int offsetY, java.lang.String address)
          Constructor.
  JRGridLayout(ExporterNature nature, java.util.List<JRPrintElement> elements, int width, int height, int offsetX, int offsetY)
          Constructor.
  JRGridLayout(ExporterNature nature, java.util.List<JRPrintElement> elements, int width, int height, int offsetX, int offsetY, CutsInfo xCuts)
          Constructor.
 
Method Summary
protected static void addXCuts(ExporterNature nature, java.util.List<JRPrintElement> elementsList, int elementOffsetX, CutsInfo xCuts)
          This static method calculates the X cuts for a list of print elements and stores them in the list indicated by the xCuts parameter.
static CutsInfo calculateXCuts(ExporterNature nature, java.util.List<JRPrintPage> pages, int startPageIndex, int endPageIndex, int width, int offsetX)
          This static method calculates all the X cuts for a list of pages.
protected  void createCuts(ElementWrapper[] wrappers, int elementOffsetX, int elementOffsetY, boolean createXCuts)
           
 int getColumnWidth(int col)
           
 JRExporterGridCell[][] getGrid()
          Returns the constructed element grid.
 int getMaxRowHeight(int rowIndex)
           
protected  int getNextVirtualFrameIndex()
           
 int getRowHeight(int row)
           
static int getRowHeight(JRExporterGridCell[] row)
           
 int getWidth()
          Returns the width available for the grid.
 CutsInfo getXCuts()
          Returns the list of cut points on the X axis for the grid.
 CutsInfo getYCuts()
          Returns the list of cut points on the Y axis for the grid.
protected  void horizontallyMergeEmptyCells(int startRow, int startCol, int endRow, int endCol)
           
protected  boolean isOverlap(int row1, int col1, int row2, int col2)
           
protected  void layoutGrid(ElementWrapper[] wrappers)
          Constructs the element grid.
protected  void setFrameCellsStyle(JRPrintFrame frame, int row1, int col1, int row2, int col2)
           
protected  void setGridElement(ElementWrapper wrapper, int row1, int col1, int row2, int col2)
           
protected  void setGridElements(ElementWrapper[] wrappers, int elementOffsetX, int elementOffsetY, int startRow, int startCol, int endRow, int endCol)
           
protected  void setMargins(ElementWrapper[] wrappers)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JRGridLayout

public JRGridLayout(ExporterNature nature,
                    java.util.List<JRPrintElement> elements,
                    int width,
                    int height,
                    int offsetX,
                    int offsetY)
Constructor.

Parameters:
elements - the elements that should arranged in a grid
width - the width available for the grid
height - the height available for the grid
offsetX - horizontal element position offset
offsetY - vertical element position offset

JRGridLayout

public JRGridLayout(ExporterNature nature,
                    java.util.List<JRPrintElement> elements,
                    int width,
                    int height,
                    int offsetX,
                    int offsetY,
                    CutsInfo xCuts)
Constructor.

Parameters:
elements - the elements that should arranged in a grid
width - the width available for the grid
height - the height available for the grid
offsetX - horizontal element position offset
offsetY - vertical element position offset
xCuts - An optional list of pre-calculated X cuts.

JRGridLayout

protected JRGridLayout(ExporterNature nature,
                       ElementWrapper[] wrappers,
                       int width,
                       int height,
                       int offsetX,
                       int offsetY,
                       java.lang.String address)
Constructor.

Parameters:
wrappers - the element wrappers that should arranged in a grid
width - the width available for the grid
height - the height available for the grid
offsetX - horizontal element position offset
offsetY - vertical element position offset
address - element address
Method Detail

layoutGrid

protected void layoutGrid(ElementWrapper[] wrappers)
Constructs the element grid.


createCuts

protected void createCuts(ElementWrapper[] wrappers,
                          int elementOffsetX,
                          int elementOffsetY,
                          boolean createXCuts)

setMargins

protected void setMargins(ElementWrapper[] wrappers)

setGridElements

protected void setGridElements(ElementWrapper[] wrappers,
                               int elementOffsetX,
                               int elementOffsetY,
                               int startRow,
                               int startCol,
                               int endRow,
                               int endCol)

horizontallyMergeEmptyCells

protected void horizontallyMergeEmptyCells(int startRow,
                                           int startCol,
                                           int endRow,
                                           int endCol)

isOverlap

protected boolean isOverlap(int row1,
                            int col1,
                            int row2,
                            int col2)

setGridElement

protected void setGridElement(ElementWrapper wrapper,
                              int row1,
                              int col1,
                              int row2,
                              int col2)

setFrameCellsStyle

protected void setFrameCellsStyle(JRPrintFrame frame,
                                  int row1,
                                  int col1,
                                  int row2,
                                  int col2)

getGrid

public JRExporterGridCell[][] getGrid()
Returns the constructed element grid.

Returns:
the constructed element grid

getXCuts

public CutsInfo getXCuts()
Returns the list of cut points on the X axis for the grid.

Returns:
the list of cut points on the X axis for the grid

getYCuts

public CutsInfo getYCuts()
Returns the list of cut points on the Y axis for the grid.

Returns:
the list of cut points on the Y axis for the grid

getWidth

public int getWidth()
Returns the width available for the grid.

Returns:
the width available for the grid

getColumnWidth

public int getColumnWidth(int col)

getRowHeight

public int getRowHeight(int row)

getMaxRowHeight

public int getMaxRowHeight(int rowIndex)

getRowHeight

public static int getRowHeight(JRExporterGridCell[] row)

calculateXCuts

public static CutsInfo calculateXCuts(ExporterNature nature,
                                      java.util.List<JRPrintPage> pages,
                                      int startPageIndex,
                                      int endPageIndex,
                                      int width,
                                      int offsetX)
This static method calculates all the X cuts for a list of pages.

Parameters:
pages - The list of pages.
startPageIndex - The first page to consider.
endPageIndex - The last page to consider.
width - The page width
offsetX - horizontal element position offset

addXCuts

protected static void addXCuts(ExporterNature nature,
                               java.util.List<JRPrintElement> elementsList,
                               int elementOffsetX,
                               CutsInfo xCuts)
This static method calculates the X cuts for a list of print elements and stores them in the list indicated by the xCuts parameter.

Parameters:
elementsList - The list of elements to be used to determine the X cuts.
elementOffsetX - horizontal element position offset
xCuts - The list to which the X cuts are to be added.

getNextVirtualFrameIndex

protected int getNextVirtualFrameIndex()


© 2001-2010 Jaspersoft Corporation www.jaspersoft.com