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 4015 2010-10-27 10:44:19Z teodord $
Author:
Lucian Chirita ([email protected])

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 elements, int width, int height, int offsetX, int offsetY)
          Constructor.
  JRGridLayout(ExporterNature nature, java.util.List elements, int width, int height, int offsetX, int offsetY, CutsInfo xCuts)
          Constructor.
 
Method Summary
protected static void addXCuts(ExporterNature nature, java.util.List 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 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)
           
 JRExporterGridCell[][] getGrid()
          Returns the constructed element grid.
static int getMaxRowHeight(JRExporterGridCell[] row)
           
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 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 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

getRowHeight

public int getRowHeight(int row)

getMaxRowHeight

public static int getMaxRowHeight(JRExporterGridCell[] row)

getRowHeight

public static int getRowHeight(JRExporterGridCell[] row)

calculateXCuts

public static CutsInfo calculateXCuts(ExporterNature nature,
                                      java.util.List 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 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()


Copyright © 2011. All Rights Reserved.