Package org.opensourcephysics.display
Class Grid
java.lang.Object
org.opensourcephysics.display.Grid
- All Implemented Interfaces:
Drawable
- Direct Known Subclasses:
CellLatticeOSX
,SiteLattice
Grid draws a rectangular grid on a data panel.
- Version:
- 1.0
- Author:
- Wolfgang Christian
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGrid
(int n) Constructs a square grid of the given size with a spacing of 1.Grid
(int nx, int ny) Constructs an (nx,ny) grid an x spacing of 1 and a y spacing of 1.Grid
(int _nx, int _ny, double xmin, double xmax, double ymin, double ymax) Constructs a grid with the given number of x and y points and the given range. -
Method Summary
Modifier and TypeMethodDescriptionvoid
draw
(DrawingPanel panel, Graphics g) Draws a representation of an object in a drawing panel.int[]
getCellPoint
(double x, double y) Gets the cell column and row index for the specified locationgetClosestGridPoint
(double x, double y) Gets the grid point closest to the specified locationgetColor()
Gets the drawing color.double
getDx()
Gets the x separation between x gid lines.double
getDy()
Gets the y separation between x gid lines.double
getXMax()
Gets the maximum value of x.double
getXMin()
Gets the minimum value of x.double
getYMax()
Gets the maximum value of y.double
getYMin()
Gets the minimum value of y.boolean
Checks if the grid is visible.void
Sets the drawing color.void
setMinMax
(double _xmin, double _xmax, double _ymin, double _ymax) Assigns a scale to the grid in world units.void
setVisible
(boolean isVisible) Sets the visible flag.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.opensourcephysics.display.Drawable
isInteractive
-
Field Details
-
nx
protected int nx -
ny
protected int ny -
xmin
protected double xmin -
xmax
protected double xmax -
ymin
protected double ymin -
ymax
protected double ymax -
dx
protected double dx -
dy
protected double dy -
color
-
generalPath
-
visible
protected boolean visible
-
-
Constructor Details
-
Grid
public Grid(int n) Constructs a square grid of the given size with a spacing of 1.- Parameters:
n
- number of cells on a side
-
Grid
public Grid(int nx, int ny) Constructs an (nx,ny) grid an x spacing of 1 and a y spacing of 1.- Parameters:
nx
- the number of grid lines in the x directionny
- the number of grid lines in the y direction
-
Grid
public Grid(int _nx, int _ny, double xmin, double xmax, double ymin, double ymax) Constructs a grid with the given number of x and y points and the given range.- Parameters:
_nx
- the number of grid lines in the x direction_ny
- the number of grid lines in the y directionxmin
-xmax
-ymin
-ymax
-
-
-
Method Details
-
setVisible
public void setVisible(boolean isVisible) Sets the visible flag. Drawing will be disabled if visible is false.- Parameters:
isVisible
-
-
isVisible
public boolean isVisible()Checks if the grid is visible.- Returns:
- true if visible; false otherwise
-
setColor
Sets the drawing color.- Parameters:
_color
-
-
getColor
Gets the drawing color.- Returns:
- the color
-
getDx
public double getDx()Gets the x separation between x gid lines.- Returns:
- dx
-
getXMin
public double getXMin()Gets the minimum value of x.- Returns:
- xmin
-
getXMax
public double getXMax()Gets the maximum value of x.- Returns:
- xamx
-
getYMin
public double getYMin()Gets the minimum value of y.- Returns:
- ymin
-
getYMax
public double getYMax()Gets the maximum value of y.- Returns:
- ymax
-
getDy
public double getDy()Gets the y separation between x gid lines.- Returns:
- dy
-
setMinMax
public void setMinMax(double _xmin, double _xmax, double _ymin, double _ymax) Assigns a scale to the grid in world units.- Parameters:
_xmin
-_xmax
-_ymin
-_ymax
-
-
draw
Description copied from interface:Drawable
Draws a representation of an object in a drawing panel. -
getCellPoint
public int[] getCellPoint(double x, double y) Gets the cell column and row index for the specified location -
getClosestGridPoint
Gets the grid point closest to the specified location
-