japlot.jaxodraw
Class JaxoGrid
- java.lang.Object
-
- japlot.jaxodraw.JaxoGrid
-
public class JaxoGrid extends java.lang.ObjectDraws agrid on the canvas.
-
-
Constructor Summary
Constructors Constructor and Description JaxoGrid(int gs, java.lang.String hx)Constructor: Sets the dimension to the current screen size and the grid size to gs.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description intgetGridSize()Returns the current size of the grid.booleangetGridType()Returns the type of the grid.voidjaxoDrawGrid(java.awt.Graphics2D g2)Draws the grid.voidsetGridSize(int gs)Sets the size of the grid to the given value.voidsetGridType(boolean hx)Sets the type of the grid (false: rectangular, true: hexagonal).intsnapX(int x)Returns the x coordinate of the grid point that is closest to the given coordinate.intsnapY(int y)Returns the y coordinate of the grid point that is closest to the given coordinate.
-
-
-
Constructor Detail
-
JaxoGrid
public JaxoGrid(int gs, java.lang.String hx)Constructor: Sets the dimension to the current screen size and the grid size to gs.- Parameters:
hx- A string that indicates whether the grid is hexagonal or not.gs- The grid size to be set.
-
-
Method Detail
-
snapX
public final int snapX(int x)
Returns the x coordinate of the grid point that is closest to the given coordinate.- Parameters:
x- The current x coordinate.- Returns:
- The x coordinate of the grid point corresponding to x.
-
snapY
public final int snapY(int y)
Returns the y coordinate of the grid point that is closest to the given coordinate.- Parameters:
y- The current y coordinate.- Returns:
- The y coordinate of the grid point corresponding to y.
-
jaxoDrawGrid
public final void jaxoDrawGrid(java.awt.Graphics2D g2)
Draws the grid.- Parameters:
g2- The graphics context to draw the grid.
-
setGridSize
public final void setGridSize(int gs)
Sets the size of the grid to the given value.- Parameters:
gs- The gridsize to be set.
-
getGridSize
public final int getGridSize()
Returns the current size of the grid.- Returns:
- The grid size.
-
setGridType
public final void setGridType(boolean hx)
Sets the type of the grid (false: rectangular, true: hexagonal).- Parameters:
hx- The gridtype to be set.
-
getGridType
public final boolean getGridType()
Returns the type of the grid.- Returns:
- The gridtype (false: rectangular, true: hexagonal).
-
-
DMelt 3.0 © DataMelt by jWork.ORG