Class BoundedGrid

java.lang.Object
com.levigo.jadice.web.client.grid.BoundedGrid
All Implemented Interfaces:
Grid

public class BoundedGrid extends Object implements Grid
A simple standard implementation of a Grid that may specify bounds defining an offset and borders.

The rectangular Cells are all of the same size. All lengths are expected to be given in document platform (docp) units.

  • Constructor Details

    • BoundedGrid

      public BoundedGrid(double cellWidth, double cellHeight)
      Creates a new unbounded grid (infinite width / height of the full grid) with the given cell size.
      Parameters:
      cellWidth - the width of a single cell in docp units
      cellHeight - the height of a single cell in docp units
    • BoundedGrid

      public BoundedGrid(Rectangle2D bounds, double cellWidth, double cellHeight)
      Creates a new grid with the given bounds and cell size.
      Parameters:
      bounds - the bounds of the grid in docp units; null is allowed here and represents a grid without offset or bounds
      cellWidth - the cell width in docp units
      cellHeight - the cell height in docp units
  • Method Details

    • getCellWidth

      public double getCellWidth()
      Description copied from interface: Grid
      Returns the cell width of the grid.
      Specified by:
      getCellWidth in interface Grid
    • getCellHeight

      public double getCellHeight()
      Description copied from interface: Grid
      Returns the cell height of the grid.
      Specified by:
      getCellHeight in interface Grid
    • snap

      public Point2D snap(Point2D srcPoint, Grid.SnapTo snapTo)
      Description copied from interface: Grid
      Returns an aligned point which is residing on its corresponding Cell at the position determined by Grid.SnapTo.
      Specified by:
      snap in interface Grid
      Parameters:
      srcPoint - the point in jadice document units to be aligned
      snapTo - where the aligned point shall reside (e.g. center of grid element, top_left, etc)
      Returns:
      the aligned point
    • getCell

      public Cell getCell(Point2D point)
      Description copied from interface: Grid
      Returns the Cell corresponding to the given point. A point located on the border of two cells belongs to the right / bottom cell.
      Specified by:
      getCell in interface Grid
      Parameters:
      point - the point in jadice document units to get the cell for
      Returns:
      the Cell
    • getCellBounds

      public Rectangle2D getCellBounds(Cell cell)
      Description copied from interface: Grid
      Returns a rectangle in jadice document units which represents the grid at the given Cell.
      Specified by:
      getCellBounds in interface Grid
      Parameters:
      cell - the cell
      Returns:
      the rectangle representing the bounds of the given cell in jadice document units
    • getBounds

      public Rectangle2D getBounds()
      Description copied from interface: Grid
      Returns the full grid bounds as a Rectangle2D.

      This makes it possible to create margins/offsets. E.g. if the page size is 100x100, the grid bounds could be set to (10, 10, 80, 80) to specify a border of 10 on each edge.

      Specified by:
      getBounds in interface Grid
      Returns:
      the grid bounds or null if no bounds are set
    • toString

      public String toString()
      Overrides:
      toString in class Object