org.opensourcephysics.display2d
Interface ByteLattice

All Superinterfaces:
Drawable, Measurable
All Known Implementing Classes:
BinaryLattice, ByteRaster, CellLattice, CellLatticeOSX, CellLatticePC, SiteLattice

public interface ByteLattice
extends Measurable

The ByteLattice interface defines a lattice visualization componnent where each array element can assume one of 256 values. Known implementations are: ByteRaster, CellLattice, and SiteLattice.


Method Summary
 void createDefaultColors()
          Creates the default palette.
 int getNx()
          Gets the number of x entries.
 int getNy()
          Gets the number of y entries.
 byte getValue(int ix, int iy)
          Gets a value from the given location.
 int indexFromPoint(double x, double y)
          Determines the lattice index (row-major order) from given x and y world coordinates.
 void randomize()
          Randomizes the values.
 void resizeLattice(int _nx, int _ny)
          Resizes the lattice.
 void setAll(byte[][] val, double xmin, double xmax, double ymin, double ymax)
          Sets the lattice values and scale.
 void setBlock(byte[][] val)
          Sets a block of data starting at (0,0) to new values.
 void setBlock(int ix_offset, int iy_offset, byte[][] val)
          Sets a block of data to new values.
 void setCol(int ix, int iy_offset, byte[] val)
          Sets a column to new values.
 void setColorPalette(java.awt.Color[] colors)
          Sets the color palette.
 void setGridLineColor(java.awt.Color c)
          Sets the color for grid line boundaries
 void setIndexedColor(int i, java.awt.Color color)
          Sets the color for a single index.
 void setMinMax(double xmin, double xmax, double ymin, double ymax)
          Assigns a scale to the lattice in world units.
 void setRow(int iy, int ix_offset, byte[] val)
          Sets a row to new values.
 void setShowGridLines(boolean showGridLines)
          Outlines the lattice boundaries with a grid.
 void setValue(int ix, int iy, byte val)
          Sets the given x,y location to a value.
 void setVisible(boolean isVisible)
          Sets the visibility of the lattice.
 void setXMax(double xmax)
          Sets xmax.
 void setXMin(double xmin)
          Sets xmin.
 void setYMax(double ymax)
          Sets ymax.
 void setYMin(double ymin)
          Sets ymin.
 javax.swing.JFrame showLegend()
          Shows the color associated with each value.
 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 interface org.opensourcephysics.display.Measurable
getXMax, getXMin, getYMax, getYMin, isMeasured
 
Methods inherited from interface org.opensourcephysics.display.Drawable
draw
 

Method Detail

getNx

public int getNx()
Gets the number of x entries.

Returns:
nx

getNy

public int getNy()
Gets the number of y entries.

Returns:
ny

indexFromPoint

public 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

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

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

yToIndex

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

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

getValue

public byte getValue(int ix,
                     int iy)
Gets a value from the given location.

Parameters:
ix -
iy -
Returns:
the value.

setValue

public void setValue(int ix,
                     int iy,
                     byte val)
Sets the given x,y location to a value.

Parameters:
ix -
iy -
val -

randomize

public void randomize()
Randomizes the values.


resizeLattice

public void resizeLattice(int _nx,
                          int _ny)
Resizes the lattice.

Parameters:
_nx -
_ny -

setAll

public 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 values
xmin - double
xmax - double
ymin - double
ymax - double

setBlock

public 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 lattice
iy_offset - the y offset into the lattice
val -

setBlock

public void setBlock(byte[][] val)
Sets a block of data starting at (0,0) to new values.

Parameters:
val -

setCol

public void setCol(int ix,
                   int iy_offset,
                   byte[] val)
Sets a column to new values.

Parameters:
ix - the x index of the column
iy_offset - the y offset in the column
val - values in column

setRow

public void setRow(int iy,
                   int ix_offset,
                   byte[] val)
Sets a row to new values.

Parameters:
iy - the y index of the row
ix_offset - the x offset in the row
val -

setShowGridLines

public void setShowGridLines(boolean showGridLines)
Outlines the lattice boundaries with a grid.

Parameters:
showGridLines -

setGridLineColor

public void setGridLineColor(java.awt.Color c)
Sets the color for grid line boundaries

Parameters:
c -

showLegend

public javax.swing.JFrame showLegend()
Shows the color associated with each value.

Returns:
the JFrame containing the legend

setVisible

public void setVisible(boolean isVisible)
Sets the visibility of the lattice. Drawing will be disabled if visible is false.

Parameters:
isVisible -

setColorPalette

public void setColorPalette(java.awt.Color[] colors)
Sets the color palette.

Parameters:
colors -

setIndexedColor

public void setIndexedColor(int i,
                            java.awt.Color color)
Sets the color for a single index.

Parameters:
i -
color -

setMinMax

public 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

public void setXMin(double xmin)
Sets xmin.

Parameters:
xmin - double

setXMax

public void setXMax(double xmax)
Sets xmax.

Parameters:
xmax - double

setYMin

public void setYMin(double ymin)
Sets ymin.

Parameters:
ymin - double

setYMax

public void setYMax(double ymax)
Sets ymax.

Parameters:
ymax - double

createDefaultColors

public void createDefaultColors()
Creates the default palette.