Class 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)
    • 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 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,
                            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​(JRGridLayout parent,
                               List<JRPrintElement> elements,
                               int width,
                               int height,
                               int offsetX,
                               int offsetY,
                               PrintElementIndex parentElementIndex)
        Constructor.
        Parameters:
        width - the width available for the grid
        height - the height available for the grid
        offsetX - horizontal element position offset
        offsetY - vertical element position offset
    • Method Detail

      • 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)
      • setGridElements

        protected void setGridElements​(PrintElementIndex parentIndex,
                                       List<JRPrintElement> elements,
                                       int elementOffsetX,
                                       int elementOffsetY,
                                       int startRow,
                                       int startCol,
                                       int endRow,
                                       int endCol)
      • horizontallyMergeEmptyCells

        protected void horizontallyMergeEmptyCells​(int startRow,
                                                   int startCol,
                                                   int endRow,
                                                   int endCol)
      • spanEmptyCell

        protected void spanEmptyCell​(int row,
                                     int col,
                                     int spanWidth,
                                     int colSpan)
      • 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)
      • setFrameCellsStyle

        protected void setFrameCellsStyle​(JRPrintFrame frame,
                                          int row1,
                                          int col1,
                                          int row2,
                                          int col2)
      • 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 offset
        xCuts - The list to which the X cuts are to be added.