|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opensourcephysics.display2d.ArrayData
public class ArrayData
ArrayData stores numeric data for 2d visualizations using a 2d array for each component.
Data components can represent almost anything. For example, we can store vectors as follows:
data=new double [3][n][m]<\code>
data[0] = length[][] <\code>
data[1] = a[][] <\code>
data[2] = b[][] <\code>
<\pre>
- Version:
- 1.0
- Author:
- Wolfgang Christian
Field Summary
protected double
bottom
protected boolean
cellData
protected double[][][]
data
protected double
dx
protected double
dy
protected double
left
protected java.lang.String[]
names
protected double
right
protected double
top
Constructor Summary
ArrayData(int ix,
int iy,
int nsamples)
Constructor ArrayData
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.
double
getDy()
Gets the change in y between grid rows.
double
getLeft()
Gets the x value for the first column in the grid.
static XML.ObjectLoader
getLoader()
Returns the XML.ObjectLoader for this class.
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 index)
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 of the grid data using a cell model.
void
setCenteredCellScale(double xmin,
double xmax,
double ymin,
double ymax)
Sets the grid such that the centers of the corner cells match the given coordinates.
void
setComponentName(int i,
java.lang.String name)
Sets the name of the component.
void
setScale(double _left,
double _right,
double _bottom,
double _top)
Sets the left, right, bottom, and top of the grid data using a lattice model.
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.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
data
protected double[][][] data
left
protected double left
right
protected double right
bottom
protected double bottom
top
protected double top
dx
protected double dx
dy
protected double dy
cellData
protected boolean cellData
names
protected java.lang.String[] names
Constructor Detail
ArrayData
public ArrayData(int ix,
int iy,
int nsamples)
- Constructor ArrayData
- Parameters:
ix
- iy
- nsamples
-
Method Detail
setComponentName
public void setComponentName(int i,
java.lang.String name)
- Sets the name of the component.
- Specified by:
setComponentName
in interface GridData
- Parameters:
i
- int the component indexname
- String
getComponentName
public java.lang.String getComponentName(int i)
- Gets the name of the component,
- Specified by:
getComponentName
in interface GridData
- Parameters:
i
- int the component index
- Returns:
- String the name
getComponentCount
public int getComponentCount()
- Gets the number of data components.
- Specified by:
getComponentCount
in interface GridData
- Returns:
- int
setScale
public void setScale(double _left,
double _right,
double _bottom,
double _top)
- Sets the left, right, bottom, and top of the grid data using a lattice model.
- Specified by:
setScale
in interface GridData
- Parameters:
_left
- _right
- _bottom
- _top
-
isCellData
public boolean isCellData()
- Gets the cellData flag.
- Specified by:
isCellData
in interface GridData
- Returns:
- true if cell data.
getValue
public double getValue(int ix,
int iy,
int component)
- Gets the value of the given component at the given location.
- Specified by:
getValue
in interface GridData
- Parameters:
ix
- x indexiy
- y indexcomponent
-
- Returns:
- the value.
setValue
public void setValue(int ix,
int iy,
int component,
double value)
- Sets the value of the given component at the given location.
- Specified by:
setValue
in interface GridData
- Parameters:
ix
- x indexiy
- y indexcomponent
- value
-
getNx
public int getNx()
- Gets the number of x entries.
- Specified by:
getNx
in interface GridData
- Returns:
- nx
getNy
public int getNy()
- Gets the number of y entries.
- Specified by:
getNy
in interface GridData
- Returns:
- ny
setCellScale
public void setCellScale(double _left,
double _right,
double _bottom,
double _top)
- Sets the left, right, bottom, and top of the grid data using a cell model.
Coordinates are centered on each cell and will NOT include the edges.
- Specified by:
setCellScale
in interface GridData
- Parameters:
_left
- _right
- _bottom
- _top
-
setCenteredCellScale
public void setCenteredCellScale(double xmin,
double xmax,
double ymin,
double ymax)
- Sets the grid such that 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.
- Specified by:
setCenteredCellScale
in interface GridData
- Parameters:
xmin
- xmax
- ymin
- ymax
-
interpolate
public double interpolate(double x,
double y,
int index)
- Estimates the value of a component at an untabulated point, (x,y).
Interpolate uses bilinear interpolation on the grid. Although the interpolating
function is continous across the grid boundaries, the gradient changes discontinuously
at the grid-square boundaries.
- Specified by:
interpolate
in interface GridData
- Parameters:
x
- the untabulated xy
- the untabulated yindex
-
- Returns:
- the interpolated sample
interpolate
public 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 grid boundaries, the gradient changes discontinuously
at the grid square boundaries.
- Specified by:
interpolate
in interface GridData
- Parameters:
x
- untabulated xy
- untabulated yindexes
- to be interpolatedvalues
- array will contain the interpolated values
- Returns:
- the interpolated array
getData
public double[][][] getData()
- Gets the array containing the data.
- Specified by:
getData
in interface GridData
- Returns:
- the data
getZRange
public double[] getZRange(int n)
- Gets the minimum and maximum values of the n-th component.
- Specified by:
getZRange
in interface GridData
- Parameters:
n
- the component
- Returns:
- {zmin,zmax}
getLeft
public final double getLeft()
- Gets the x value for the first column in the grid.
- Specified by:
getLeft
in interface GridData
- Returns:
- the leftmost x value
getRight
public final double getRight()
- Gets the x value for the right column in the grid.
- Specified by:
getRight
in interface GridData
- Returns:
- the rightmost x value
getTop
public final double getTop()
- Gets the y value for the first row of the grid.
- Specified by:
getTop
in interface GridData
- Returns:
- the topmost y value
getBottom
public final double getBottom()
- Gets the y value for the last row of the grid.
- Specified by:
getBottom
in interface GridData
- Returns:
- the bottommost y value
getDx
public final double getDx()
- Gets the change in x between grid columns.
- Specified by:
getDx
in interface GridData
- Returns:
- the bottommost y value
getDy
public final double getDy()
- Gets the change in y between grid rows.
- Specified by:
getDy
in interface GridData
- Returns:
- the bottommost y value
indexToX
public double indexToX(int i)
- Gets the x coordinate for the given index.
- Specified by:
indexToX
in interface GridData
- Parameters:
i
- int
- Returns:
- double the x coordinate
indexToY
public double indexToY(int i)
- Gets the y coordinate for the given index.
- Specified by:
indexToY
in interface GridData
- Parameters:
i
- int
- Returns:
- double the y coordinate
xToIndex
public int xToIndex(double x)
- Gets closest index from the given x world coordinate.
- Specified by:
xToIndex
in interface GridData
- Parameters:
x
- double the coordinate
- Returns:
- int the index
yToIndex
public int yToIndex(double y)
- Gets closest index from the given y world coordinate.
- Specified by:
yToIndex
in interface GridData
- Parameters:
y
- double the coordinate
- Returns:
- int the index
getLoader
public static XML.ObjectLoader getLoader()
- Returns the XML.ObjectLoader for this class.
- Returns:
- the object loader
Overview
Package
Class
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD