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 Cell
s.
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 ClassesModifier and TypeInterfaceDescriptionstatic enum
TheGrid.SnapTo
defines the 'anchor' or 'snap location' for a cell. -
Method Summary
Modifier and TypeMethodDescriptionReturns the full grid bounds as a Rectangle2D.Returns theCell
corresponding to the given point.getCellBounds
(Cell cell) Returns a rectangle in jadice document units which represents the grid at the givenCell
.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 correspondingCell
at the position determined byGrid.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
Returns an aligned point which is residing on its correspondingCell
at the position determined byGrid.SnapTo
.- Parameters:
point
- the point in jadice document units to be alignedsnapTo
- where the aligned point shall reside (e.g. center of grid element, top_left, etc)- Returns:
- the aligned point
-
getCell
Returns theCell
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
Returns a rectangle in jadice document units which represents the grid at the givenCell
.- 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.
-