org.grinvin.gred.guides

Class GridLines

Implemented Interfaces:
Guides

public class GridLines
extends AbstractGuides

Guides based on a square grid within the -1.0 - 1.0 rectangle. The number of horizontal and vertical grid lines is configurable.

Nested Class Summary

Nested classes/interfaces inherited from class org.grinvin.gred.guides.AbstractGuides

AbstractGuides.ButtonIcon

Field Summary

Fields inherited from class org.grinvin.gred.guides.AbstractGuides

GUIDE_COLOR, GUIDE_STROKE, buttonIcon

Constructor Summary

GridLines(int numberOfRows, int numberOfColumns)
Create a new object of this type.

Method Summary

void
paint(Graphics2D g2, double scale, double maxX, double maxY)
Paint a grid with the requested number of subdivisions
void
setNumberOfDivisions(int numberOfRows, int numberOfColumns)
Set the number of divisions used by this grid.
void
snap(double[] coords)
Snap coordinates to the closest grid position.

Methods inherited from class org.grinvin.gred.guides.AbstractGuides

getButtonIcon, paint, snap

Constructor Details

GridLines

public GridLines(int numberOfRows,
                 int numberOfColumns)
Create a new object of this type.
Parameters:
numberOfRows - Number of rows in the grid, i.e., one less than the number of horizontal grid lines.
numberOfColumns - Number of columns in the grid, i.e., one less than the number of vertical grid lines.

Method Details

paint

public void paint(Graphics2D g2,
                  double scale,
                  double maxX,
                  double maxY)
Paint a grid with the requested number of subdivisions
Specified by:
paint in interface Guides
Overrides:
paint in interface AbstractGuides

setNumberOfDivisions

public void setNumberOfDivisions(int numberOfRows,
                                 int numberOfColumns)
Set the number of divisions used by this grid.
Parameters:
numberOfRows - Number of rows in the grid, i.e., one less than the number of horizontal grid lines.
numberOfColumns - Number of columns in the grid, i.e., one less than the number of vertical grid lines.

snap

public void snap(double[] coords)
Snap coordinates to the closest grid position.
Specified by:
snap in interface Guides
Overrides:
snap in interface AbstractGuides