Class GridView


  • class GridView
    extends java.lang.Object
    This class represents a view on a grid, which returns cells one by one in a specified order. Also it allows to place a cell on a grid in this specific order and resizes the grid if needed.
    • Field Detail

      • grid

        private final Grid grid
      • restrictYGrow

        private boolean restrictYGrow
      • restrictXGrow

        private boolean restrictXGrow
      • hasNext

        private boolean hasNext
      • rightMargin

        private int rightMargin
      • bottomMargin

        private int bottomMargin
    • Constructor Detail

      • GridView

        GridView​(Grid grid,
                 GridFlow iterationOrder)
    • Method Detail

      • hasNext

        public boolean hasNext()
      • reset

        GridView.Pos reset​(int y,
                           int x,
                           int rightMargin,
                           int bottomMargin)
        Resets grid view and sets it up for processing new element If sparse algorithm is used then x and y positions on a grid are not reset.
        Parameters:
        y - left upper corner y position of an element on the grid
        x - left upper corner x position of an element on the grid
        rightMargin - specifies how many cells not to process at the right end of a grid
        bottomMargin - specifies how many cells not to process at the bottom end of a grid
        Returns:
        first element position
      • fit

        boolean fit​(int width,
                    int height)
        Try to fit cell at the current position. If cell is fit, then update current flow cursor axis by width/height of a laid out cell.
        Parameters:
        width - width of the cell
        height - height of the cell
        Returns:
        true if cell is fit, false otherwise
      • resetCursorIfIntersectingCellIsPlaced

        void resetCursorIfIntersectingCellIsPlaced()
        Reset cursor to the start of a grid if placed a cell, which intersects current flow axis. This is needed because such cells should be placed out of order and it's expected that they are go first while constructing the grid.
      • increaseDefaultCursor

        void increaseDefaultCursor​(GridView.Pos cellSizes)
        Increase cursor in current flow axis
        Parameters:
        cellSizes - cell width and height values
      • increaseDefaultAxis

        void increaseDefaultAxis()
      • isFixed

        boolean isFixed()
        Determines if current grid view can be iterated.
        Returns:
        true if fixed false otherwise