Class JRGridLayout
java.lang.Object
net.sf.jasperreports.engine.export.JRGridLayout
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 -
Constructor Summary
ConstructorsModifierConstructorDescriptionJRGridLayout(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.protectedJRGridLayout(JRGridLayout parent, List<JRPrintElement> elements, int width, int height, int offsetX, int offsetY, PrintElementIndex parentElementIndex) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidaddXCuts(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 CutsInfocalculateXCuts(ExporterNature nature, JasperPrint jasperPrint, int startPageIndex, int endPageIndex, int offsetX) This static method calculates all the X cuts for a list of pages.protected GridCellSizecellSize(int width, int height, int colSpan, int rowSpan) protected GridCellStyleprotected JRExporterGridCellchangeStyle(JRExporterGridCell cell, GridCellStyle newStyle) protected voidcreateCuts(List<JRPrintElement> elements, int elementOffsetX, int elementOffsetY, boolean createXCuts) protected EmptyGridCellemptyCell(GridCellSize size, GridCellStyle style) intgetColumnWidth(int col) getElement(PrintElementIndex parentIndex, int index) getGrid()Returns the constructed element grid.intgetMaxRowHeight(int rowIndex) intgetRowHeight(int row) static intgetRowHeight(GridRow row) intgetWidth()Returns the width available for the grid.getXCuts()Returns the list of cut points on the X axis for the grid.getYCuts()Returns the list of cut points on the Y axis for the grid.protected voidhorizontallyMergeEmptyCells(int startRow, int startCol, int endRow, int endCol) protected booleanisEmpty(JRExporterGridCell cell) protected booleanisOverlap(int row1, int col1, int row2, int col2) protected voidlayoutGrid(PrintElementIndex parentElementIndex, List<JRPrintElement> elements) Constructs the element grid.protected voidsetFrameCellsStyle(JRPrintFrame frame, int row1, int col1, int row2, int col2) protected voidsetGridElement(JRPrintElement element, PrintElementIndex parentIndex, int elementIndex, int row1, int col1, int row2, int col2) protected voidsetGridElements(PrintElementIndex parentIndex, List<JRPrintElement> elements, int elementOffsetX, int elementOffsetY, int startRow, int startCol, int endRow, int endCol) protected voidsetMargins(List<JRPrintElement> elements) protected voidspanEmptyCell(int row, int col, int spanWidth, int colSpan)
-
Constructor Details
-
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 Details
-
getElement
-
layoutGrid
Constructs the element grid.- Parameters:
parentElementIndex-
-
cellSize
-
createCuts
protected void createCuts(List<JRPrintElement> elements, int elementOffsetX, int elementOffsetY, boolean createXCuts) -
setMargins
-
setGridElements
protected void setGridElements(PrintElementIndex parentIndex, List<JRPrintElement> elements, int elementOffsetX, int elementOffsetY, int startRow, int startCol, int endRow, int endCol) -
emptyCell
-
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
-
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
-
setFrameCellsStyle
-
changeStyle
-
getGrid
Returns the constructed element grid.- Returns:
- the constructed element grid
-
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
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
-
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.
-