Class JRGridLayout
- java.lang.Object
-
- net.sf.jasperreports.engine.export.JRGridLayout
-
public class JRGridLayout extends Object
Utility class used by grid exporters to create a grid for page layout.- Author:
- Lucian Chirita (lucianc@users.sourceforge.net)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
JRGridLayout.BoxKey
-
Constructor Summary
Constructors Modifier Constructor Description JRGridLayout(ExporterNature nature, List<JRPrintElement> elements, int width, int height, int offsetX, int offsetY)
Constructor.JRGridLayout(ExporterNature nature, List<JRPrintElement> elements, int width, int height, int offsetX, int offsetY, CutsInfo xCuts)
Constructor.protected
JRGridLayout(JRGridLayout parent, List<JRPrintElement> elements, int width, int height, int offsetX, int offsetY, PrintElementIndex parentElementIndex)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static void
addXCuts(ExporterNature nature, 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, JasperPrint jasperPrint, int startPageIndex, int endPageIndex, int offsetX)
This static method calculates all the X cuts for a list of pages.protected GridCellSize
cellSize(int width, int height, int colSpan, int rowSpan)
protected GridCellStyle
cellStyle(Color backcolor, Color forecolor, JRLineBox box)
protected JRExporterGridCell
changeStyle(JRExporterGridCell cell, GridCellStyle newStyle)
protected void
createCuts(List<JRPrintElement> elements, int elementOffsetX, int elementOffsetY, boolean createXCuts)
protected EmptyGridCell
emptyCell(GridCellSize size, GridCellStyle style)
int
getColumnWidth(int col)
JRPrintElement
getElement(PrintElementIndex parentIndex, int index)
Grid
getGrid()
Returns the constructed element grid.int
getMaxRowHeight(int rowIndex)
int
getRowHeight(int row)
static int
getRowHeight(GridRow 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
isEmpty(JRExporterGridCell cell)
protected boolean
isOverlap(int row1, int col1, int row2, int col2)
protected void
layoutGrid(PrintElementIndex parentElementIndex, List<JRPrintElement> elements)
Constructs the element grid.protected void
setFrameCellsStyle(JRPrintFrame frame, int row1, int col1, int row2, int col2)
protected void
setGridElement(JRPrintElement element, PrintElementIndex parentIndex, int elementIndex, int row1, int col1, int row2, int col2)
protected void
setGridElements(PrintElementIndex parentIndex, List<JRPrintElement> elements, int elementOffsetX, int elementOffsetY, int startRow, int startCol, int endRow, int endCol)
protected void
setMargins(List<JRPrintElement> elements)
protected void
spanEmptyCell(int row, int col, int spanWidth, int colSpan)
-
-
-
Constructor Detail
-
JRGridLayout
public JRGridLayout(ExporterNature nature, List<JRPrintElement> elements, int width, int height, int offsetX, int offsetY)
Constructor.- Parameters:
elements
- the elements that should arranged in a gridwidth
- the width available for the gridheight
- the height available for the gridoffsetX
- horizontal element position offsetoffsetY
- vertical element position offset
-
JRGridLayout
public JRGridLayout(ExporterNature nature, List<JRPrintElement> elements, int width, int height, int offsetX, int offsetY, CutsInfo xCuts)
Constructor.- Parameters:
elements
- the elements that should arranged in a gridwidth
- the width available for the gridheight
- the height available for the gridoffsetX
- horizontal element position offsetoffsetY
- vertical element position offsetxCuts
- An optional list of pre-calculated X cuts.
-
JRGridLayout
protected JRGridLayout(JRGridLayout parent, List<JRPrintElement> elements, int width, int height, int offsetX, int offsetY, PrintElementIndex parentElementIndex)
Constructor.- Parameters:
width
- the width available for the gridheight
- the height available for the gridoffsetX
- horizontal element position offsetoffsetY
- vertical element position offset
-
-
Method Detail
-
getElement
public JRPrintElement getElement(PrintElementIndex parentIndex, int index)
-
layoutGrid
protected void layoutGrid(PrintElementIndex parentElementIndex, List<JRPrintElement> elements)
Constructs the element grid.- Parameters:
parentElementIndex
-
-
cellSize
protected GridCellSize cellSize(int width, int height, int colSpan, int rowSpan)
-
createCuts
protected void createCuts(List<JRPrintElement> elements, int elementOffsetX, int elementOffsetY, boolean createXCuts)
-
setMargins
protected void setMargins(List<JRPrintElement> elements)
-
setGridElements
protected void setGridElements(PrintElementIndex parentIndex, List<JRPrintElement> elements, int elementOffsetX, int elementOffsetY, int startRow, int startCol, int endRow, int endCol)
-
emptyCell
protected EmptyGridCell emptyCell(GridCellSize size, GridCellStyle style)
-
horizontallyMergeEmptyCells
protected void horizontallyMergeEmptyCells(int startRow, int startCol, int endRow, int endCol)
-
spanEmptyCell
protected void spanEmptyCell(int row, int col, int spanWidth, int colSpan)
-
isEmpty
protected boolean isEmpty(JRExporterGridCell cell)
-
isOverlap
protected boolean isOverlap(int row1, int col1, int row2, int col2)
-
setGridElement
protected void setGridElement(JRPrintElement element, PrintElementIndex parentIndex, int elementIndex, int row1, int col1, int row2, int col2)
-
cellStyle
protected GridCellStyle cellStyle(Color backcolor, Color forecolor, JRLineBox box)
-
setFrameCellsStyle
protected void setFrameCellsStyle(JRPrintFrame frame, int row1, int col1, int row2, int col2)
-
changeStyle
protected JRExporterGridCell changeStyle(JRExporterGridCell cell, GridCellStyle newStyle)
-
getGrid
public Grid 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(GridRow row)
-
calculateXCuts
public static CutsInfo calculateXCuts(ExporterNature nature, JasperPrint jasperPrint, int startPageIndex, int endPageIndex, int offsetX)
This static method calculates all the X cuts for a list of pages.- Parameters:
jasperPrint
- The JasperPrint document.startPageIndex
- The first page to consider.endPageIndex
- The last page to consider.offsetX
- horizontal element position offset
-
addXCuts
protected static void addXCuts(ExporterNature nature, 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 offsetxCuts
- The list to which the X cuts are to be added.
-
-