|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.opensourcephysics.display.MeasuredImage
org.opensourcephysics.display2d.BinaryLattice
public class BinaryLattice
A BinaryLattice is an array where each array element has a value of 0 or 1. The lattice is drawn as an array of rectangles to distinguish between the two possible values.
| Field Summary |
|---|
| Fields inherited from class org.opensourcephysics.display.MeasuredImage |
|---|
image, xmax, xmin, ymax, ymin |
| Constructor Summary | |
|---|---|
BinaryLattice(int _nx,
int _ny)
Constructs a binary lattice with the given size. |
|
| Method Summary | |
|---|---|
void |
createDefaultColors()
Creates the default palette. |
void |
draw(DrawingPanel panel,
java.awt.Graphics g)
Draws the lattice and the grid. |
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 Returns -1 if the world coordinates are outside the lattice. |
void |
randomize()
Ranomizes the lattice values. |
void |
resizeLattice(int _nx,
int _ny)
Resize the lattice. |
void |
setAll(byte[][] val)
Sets a block of data to new values. |
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 cells to new values. |
void |
setBlock(int x_offset,
int y_offset,
int[][] val)
Sets a block of cells to new values. |
void |
setCol(int ix,
int iy_offset,
byte[] val)
Sets a column of cells to new values. |
void |
setCol(int ix,
int iy_offset,
int[] val)
Sets a column of cells to new values. |
void |
setColorPalette(java.awt.Color[] colors)
Sets color palette. |
void |
setGridLineColor(java.awt.Color color)
Sets the grid color. |
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)
Scales the grid to the given values in world units. |
void |
setRow(int iy,
int ix_offset,
byte[] val)
Sets a row of cells to new values starting at the given column. |
void |
setRow(int iy,
int ix_offset,
int[] val)
Sets a row of cells to new values starting at the given column. |
void |
setShowGrid(boolean showGrid)
Sets the show grid option. |
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 |
setValue(int ix,
int iy,
int val)
Sets a cell at the given location to a new value. |
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 class org.opensourcephysics.display.MeasuredImage |
|---|
getXMax, getXMin, getYMax, getYMin, isMeasured, setImage, setVisible, setXMax, setXMin, setYMax, setYMin |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.opensourcephysics.display2d.ByteLattice |
|---|
setVisible, setXMax, setXMin, setYMax, setYMin |
| Methods inherited from interface org.opensourcephysics.display.Measurable |
|---|
getXMax, getXMin, getYMax, getYMin, isMeasured |
| Constructor Detail |
|---|
public BinaryLattice(int _nx,
int _ny)
_nx - the number of values in x direction_ny - the number of values in y direction| Method Detail |
|---|
public void createDefaultColors()
createDefaultColors in interface ByteLattice
public void resizeLattice(int _nx,
int _ny)
resizeLattice in interface ByteLattice_nx - number of x sites_ny - number of y sitespublic void randomize()
randomize in interface ByteLattice
public void draw(DrawingPanel panel,
java.awt.Graphics g)
draw in interface Drawabledraw in class MeasuredImagepanel - g - public void setAll(byte[][] val)
val -
public void setAll(byte[][] val,
double xmin,
double xmax,
double ymin,
double ymax)
setAll in interface ByteLatticeval - int[][] the new valuesxmin - doublexmax - doubleymin - doubleymax - double
public void setMinMax(double xmin,
double xmax,
double ymin,
double ymax)
setMinMax in interface ByteLatticesetMinMax in class MeasuredImagexmin - xmax - ymin - ymax -
public void setBlock(int x_offset,
int y_offset,
int[][] val)
x_offset - inty_offset - intval - int[][]
public void setBlock(int ix_offset,
int iy_offset,
byte[][] val)
setBlock in interface ByteLatticeix_offset - iy_offset - val - the value arraypublic void setBlock(byte[][] val)
setBlock in interface ByteLatticeval -
public void setCol(int ix,
int iy_offset,
int[] val)
ix - iy_offset - val - the array of values
public void setCol(int ix,
int iy_offset,
byte[] val)
setCol in interface ByteLatticeix - iy_offset - val - the array of values
public void setRow(int iy,
int ix_offset,
int[] val)
iy - ix_offset - the x offsetval - the value array
public void setRow(int iy,
int ix_offset,
byte[] val)
setRow in interface ByteLatticeiy - ix_offset - the x offsetval - the value array
public void setValue(int ix,
int iy,
int val)
ix - iy - val -
public void setValue(int ix,
int iy,
byte val)
ByteLattice
setValue in interface ByteLattice
public byte getValue(int ix,
int iy)
getValue in interface ByteLatticeix - iy -
public int getNx()
getNx in interface ByteLatticepublic int getNy()
getNy in interface ByteLatticepublic void setShowGrid(boolean showGrid)
showGrid - public void setColorPalette(java.awt.Color[] colors)
setColorPalette in interface ByteLatticecolors -
public void setIndexedColor(int i,
java.awt.Color color)
setIndexedColor in interface ByteLatticei - color - public void setGridLineColor(java.awt.Color color)
setGridLineColor in interface ByteLatticecolor - public void setShowGridLines(boolean showGridLines)
ByteLattice
setShowGridLines in interface ByteLatticepublic int xToIndex(double x)
xToIndex in interface ByteLatticex - double the coordinate
public int yToIndex(double y)
yToIndex in interface ByteLatticey - double the coordinate
public int indexFromPoint(double x,
double y)
indexFromPoint in interface ByteLatticex - y -
public javax.swing.JFrame showLegend()
ByteLattice
showLegend in interface ByteLattice
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||