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.

Version:
1.0
Author:
Wolfgang Christian

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

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 values
xmin - double
xmax - double
ymin - double
ymax - 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 lattice
iy_offset - the y offset into the lattice
val -

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 column
iy_offset - the y offset in the column
val - 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 row
ix_offset - the x offset in the row
val -

setShowGridLines

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

Parameters:
showGridLines -

setGridLineColor

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

Parameters:
c -

showLegend

javax.swing.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

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

Parameters:
colors -

setIndexedColor

void setIndexedColor(int i,
                     java.awt.Color color)
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.