org.opensourcephysics.display2d
Interface GridData

All Known Implementing Classes:
ArrayData, FlatData, GridPointData

public interface GridData

The GridData interface defines methods for objects that store data on a grid.

Version:
1.0
Author:
Wolfgang Christian

Method Summary
 double getBottom()
          Gets the y value for the last row of the grid.
 int getComponentCount()
          Gets the number of data components.
 java.lang.String getComponentName(int i)
          Gets the name of the component
 double[][][] getData()
          Gets the array containing the data.
 double getDx()
          Gets the change in x between grid columns moving from right to left.
 double getDy()
          Gets the change in y between grid rows moving from top to bottom.
 double getLeft()
          Gets the x value for the first column in the grid.
 int getNx()
          Gets the number of x entries.
 int getNy()
          Gets the number of y entries.
 double getRight()
          Gets the x value for the right column in the grid.
 double getTop()
          Gets the y value for the first row of the grid.
 double getValue(int ix, int iy, int component)
          Gets the value of the given component at the given location.
 double[] getZRange(int n)
          Gets the minimum and maximum values of the n-th component.
 double indexToX(int i)
          Gets the x coordinate for the given index.
 double indexToY(int i)
          Gets the y coordinate for the given index.
 double interpolate(double x, double y, int component)
          Estimates the value of a component at an untabulated point, (x,y).
 double[] interpolate(double x, double y, int[] indexes, double[] values)
          Estimates multiple sample components at an untabulated point, (x,y).
 boolean isCellData()
          Gets the cellData flag.
 void setCellScale(double left, double right, double bottom, double top)
          Sets the left, right, bottom, and top bounds of the grid using a cell model and sets the cellScale flag.
 void setCenteredCellScale(double xmin, double xmax, double ymin, double ymax)
          Sets the grid such the centers of the corner cells match the given coordinates.
 void setComponentName(int component, java.lang.String name)
          Sets the name of the component.
 void setScale(double xmin, double xmax, double ymin, double ymax)
          Sets the the grid data using a lattice model and clears the cellScale flag.
 void setValue(int ix, int iy, int component, double value)
          Sets the value of the given component at the given location.
 int xToIndex(double x)
          Gets closest index from the given x world coordinate.
 int yToIndex(double y)
          Gets closest index from the given y world coordinate.
 

Method Detail

interpolate

double interpolate(double x,
                   double y,
                   int component)
Estimates the value of a component at an untabulated point, (x,y). Interpolate often uses bilinear interpolation on the grid. Although the interpolating function is continous across the cell boundaries, the gradient changes discontinuously at the cell boundaries.

Parameters:
x - the untabulated x
y - the untabulated y
component - the component index
Returns:
the interpolated sample

interpolate

double[] interpolate(double x,
                     double y,
                     int[] indexes,
                     double[] values)
Estimates multiple sample components at an untabulated point, (x,y). Interpolate uses bilinear interpolation on the grid. Although the interpolating function is continous across the cell boundaries, the gradient changes discontinuously at the cell boundaries.

Parameters:
x - the untabulated x
y - the untabulated y
indexes - to be interpolated
values - the array that will contain the interpolated values
Returns:
the interpolated array

setScale

void setScale(double xmin,
              double xmax,
              double ymin,
              double ymax)
Sets the the grid data using a lattice model and clears the cellScale flag. The left, right, top, and bottom bounds match the max and min values.

Parameters:
xmin -
xmax -
ymin -
ymax -

setCellScale

void setCellScale(double left,
                  double right,
                  double bottom,
                  double top)
Sets the left, right, bottom, and top bounds of the grid using a cell model and sets the cellScale flag. Coordinates are centered on each cell and are inside the bounds.

Parameters:
left -
right -
bottom -
top -

setCenteredCellScale

void setCenteredCellScale(double xmin,
                          double xmax,
                          double ymin,
                          double ymax)
Sets the grid such the centers of the corner cells match the given coordinates. Coordinates are centered on each cell and the bounds are ouside the max and min values.

Parameters:
xmin -
xmax -
ymin -
ymax -

isCellData

boolean isCellData()
Gets the cellData flag.

Returns:
true if cell data.

setComponentName

void setComponentName(int component,
                      java.lang.String name)
Sets the name of the component.

Parameters:
component - int
name - String

getComponentName

java.lang.String getComponentName(int i)
Gets the name of the component

Parameters:
i - int
Returns:
String

getComponentCount

int getComponentCount()
Gets the number of data components.

Returns:
int

getValue

double getValue(int ix,
                int iy,
                int component)
Gets the value of the given component at the given location.

Parameters:
ix - x index
iy - y index
component -
Returns:
the value.

setValue

void setValue(int ix,
              int iy,
              int component,
              double value)
Sets the value of the given component at the given location.

Parameters:
ix - x index
iy - y index
component -
value -

getNx

int getNx()
Gets the number of x entries.

Returns:
nx

getNy

int getNy()
Gets the number of y entries.

Returns:
ny

getData

double[][][] getData()
Gets the array containing the data.

Returns:
the data

getZRange

double[] getZRange(int n)
Gets the minimum and maximum values of the n-th component.

Returns:
{zmin,zmax}

getLeft

double getLeft()
Gets the x value for the first column in the grid.

Returns:
the leftmost x value

getRight

double getRight()
Gets the x value for the right column in the grid.

Returns:
the rightmost x value

getTop

double getTop()
Gets the y value for the first row of the grid.

Returns:
the topmost y value

getBottom

double getBottom()
Gets the y value for the last row of the grid.

Returns:
the bottommost y value

getDx

double getDx()
Gets the change in x between grid columns moving from right to left.

Returns:
the change in x

getDy

double getDy()
Gets the change in y between grid rows moving from top to bottom. The change in y is usually negative because y values usually decrease as pixel coordinates increase from top to bottom on a computer screen.

Returns:
the change in y

indexToX

double indexToX(int i)
Gets the x coordinate for the given index.

Parameters:
i - int
Returns:
double the x coordinate

indexToY

double indexToY(int i)
Gets the y coordinate for the given index.

Parameters:
i - int
Returns:
double the y coordinate

xToIndex

int xToIndex(double x)
Gets closest index from the given x world coordinate.

Parameters:
x - double the coordinate
Returns:
int the index

yToIndex

int yToIndex(double y)
Gets closest index from the given y world coordinate.

Parameters:
y - double the coordinate
Returns:
int the index