Interface Grid

All Known Implementing Classes:
BoundedGrid, NoOpGrid

public interface Grid
A Grid can be used to align points. Currently, this feature is only used to let annotations snap to grid points when creating, moving or editing them.

To ease working with grids a NoOpGrid will be used when no specific grid is specified for a document. See Grids.getGridForDocument(com.levigo.jadice.document.Document).

A Grid expects all units to be in document platform (docp) format.

Grids can be unbounded (infinite width / height) or have fixed bounds. A grid contains equally sized, rectangular Cells.

Grid bounds can be used to create a margin around the grid. Example:

  • A page with size 100x100
  • Grid bounds 10, 10, 80, 80
  • The result is that grid alignment is only performed within the grid bounds. In this example there is a gap of 10 at all edges.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    The Grid.SnapTo defines the 'anchor' or 'snap location' for a cell.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the full grid bounds as a Rectangle2D.
    Returns the Cell corresponding to the given point.
    Returns a rectangle in jadice document units which represents the grid at the given Cell.
    double
    Returns the cell height of the grid.
    double
    Returns the cell width of the grid.
    snap(Point2D point, Grid.SnapTo snapTo)
    Returns an aligned point which is residing on its corresponding Cell at the position determined by Grid.SnapTo.
  • Method Details

    • getBounds

      Rectangle2D getBounds()
      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.

      Returns:
      the grid bounds or null if no bounds are set
    • snap

      Point2D snap(Point2D point, Grid.SnapTo snapTo)
      Returns an aligned point which is residing on its corresponding Cell at the position determined by Grid.SnapTo.
      Parameters:
      point - 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

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

      Rectangle2D getCellBounds(Cell cell)
      Returns a rectangle in jadice document units which represents the grid at the given Cell.
      Parameters:
      cell - the cell
      Returns:
      the rectangle representing the bounds of the given cell in jadice document units
    • getCellWidth

      double getCellWidth()
      Returns the cell width of the grid.
    • getCellHeight

      double getCellHeight()
      Returns the cell height of the grid.