Package org.opensourcephysics.display2d
Interface ByteLattice
- All Superinterfaces:
Drawable,Measurable
- All Known Subinterfaces:
CellLattice.OSLattice
- All Known Implementing Classes:
BinaryLattice,ByteRaster,CellLattice,CellLatticeOSX,CellLatticePC,SiteLattice
The ByteLattice interface defines a lattice visualization component where each
array element can assume one of 256 values.
Known implementations are: ByteRaster, CellLattice, and SiteLattice.
- Version:
- 1.0
- Author:
- Wolfgang Christian
-
Method Summary
Modifier and TypeMethodDescriptionvoidCreates the default palette.intgetNx()Gets the number of x entries.intgetNy()Gets the number of y entries.bytegetValue(int ix, int iy) Gets a value from the given location.intindexFromPoint(double x, double y) Determines the lattice index (row-major order) from given x and y world coordinates.voidRandomizes the values.voidresizeLattice(int _nx, int _ny) Resizes the lattice.voidsetAll(byte[][] val, double xmin, double xmax, double ymin, double ymax) Sets the lattice values and scale.voidsetBlock(byte[][] val) Sets a block of data starting at (0,0) to new values.voidsetBlock(int ix_offset, int iy_offset, byte[][] val) Sets a block of data to new values.voidsetCol(int ix, int iy_offset, byte[] val) Sets a column to new values.voidsetColorPalette(Color[] colors) Sets the color palette.voidSets the color for grid line boundariesvoidsetIndexedColor(int i, Color color) Sets the color for a single index.voidsetMinMax(double xmin, double xmax, double ymin, double ymax) Assigns a scale to the lattice in world units.voidsetRow(int iy, int ix_offset, byte[] val) Sets a row to new values.voidsetShowGridLines(boolean showGridLines) Outlines the lattice boundaries with a grid.voidsetValue(int ix, int iy, byte val) Sets the given x,y location to a value.voidsetVisible(boolean isVisible) Sets the visibility of the lattice.voidsetXMax(double xmax) Sets xmax.voidsetXMin(double xmin) Sets xmin.voidsetYMax(double ymax) Sets ymax.voidsetYMin(double ymin) Sets ymin.Shows the color associated with each value.intxToIndex(double x) Gets closest index from the given x world coordinate.intyToIndex(double y) Gets closest index from the given y world coordinate.Methods inherited from interface org.opensourcephysics.display.Drawable
draw, isInteractiveMethods inherited from interface org.opensourcephysics.display.Measurable
getXMax, getXMin, getYMax, getYMin, isMeasured
-
Method Details
-
getNx
int getNx()Gets the number of x entries.- Returns:
- nx
-
getNy
int getNy()Gets the number of y entries.- Returns:
- ny
-
indexFromPoint
int indexFromPoint(double x, double y) Determines the lattice index (row-major order) from given x and y world coordinates. Returns -1 if the world coordinates are outside the lattice.- Parameters:
x-y-- Returns:
- index
-
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
-
getValue
byte getValue(int ix, int iy) Gets a value from the given location.- Parameters:
ix-iy-- Returns:
- the value.
-
setValue
void setValue(int ix, int iy, byte val) Sets the given x,y location to a value.- Parameters:
ix-iy-val-
-
randomize
void randomize()Randomizes the values. -
resizeLattice
void resizeLattice(int _nx, int _ny) Resizes the lattice.- Parameters:
_nx-_ny-
-
setAll
void setAll(byte[][] val, double xmin, double xmax, double ymin, double ymax) Sets the lattice values and scale. The lattice is resized to fit the new data if needed.- Parameters:
val- int[][] the new valuesxmin- doublexmax- doubleymin- doubleymax- double
-
setBlock
void setBlock(int ix_offset, int iy_offset, byte[][] val) Sets a block of data to new values.- Parameters:
ix_offset- the x offset into the latticeiy_offset- the y offset into the latticeval-
-
setBlock
void setBlock(byte[][] val) Sets a block of data starting at (0,0) to new values.- Parameters:
val-
-
setCol
void setCol(int ix, int iy_offset, byte[] val) Sets a column to new values.- Parameters:
ix- the x index of the columniy_offset- the y offset in the columnval- values in column
-
setRow
void setRow(int iy, int ix_offset, byte[] val) Sets a row to new values.- Parameters:
iy- the y index of the rowix_offset- the x offset in the rowval-
-
setShowGridLines
void setShowGridLines(boolean showGridLines) Outlines the lattice boundaries with a grid.- Parameters:
showGridLines-
-
setGridLineColor
Sets the color for grid line boundaries- Parameters:
c-
-
showLegend
JFrame showLegend()Shows the color associated with each value.- Returns:
- the JFrame containing the legend
-
setVisible
void setVisible(boolean isVisible) Sets the visibility of the lattice. Drawing will be disabled if visible is false.- Parameters:
isVisible-
-
setColorPalette
Sets the color palette.- Parameters:
colors-
-
setIndexedColor
Sets the color for a single index.- Parameters:
i-color-
-
setMinMax
void setMinMax(double xmin, double xmax, double ymin, double ymax) Assigns a scale to the lattice in world units. This method does not change lattice values; it assigns units corners of the lattice.- Parameters:
xmin-xmax-ymin-ymax-
-
setXMin
void setXMin(double xmin) Sets xmin.- Parameters:
xmin- double
-
setXMax
void setXMax(double xmax) Sets xmax.- Parameters:
xmax- double
-
setYMin
void setYMin(double ymin) Sets ymin.- Parameters:
ymin- double
-
setYMax
void setYMax(double ymax) Sets ymax.- Parameters:
ymax- double
-
createDefaultColors
void createDefaultColors()Creates the default palette.
-