Package org.opensourcephysics.display2d
Class TriangularByteLattice
java.lang.Object
org.opensourcephysics.display2d.TriangularByteLattice
- All Implemented Interfaces:
Drawable,Measurable
A TriangularByteLattice is an array where each array element can assume one
of 256 values. Values can be set between -128 and 127. Because byte values
larger than 127 overflow to negative, values can also be set between 0 and
255.
- Version:
- 1.0
- Author:
- Joshua Gould, Wolfgang Christian
-
Constructor Summary
ConstructorsConstructorDescriptionTriangularByteLattice(int _row, int _col) Constructs a byte lattice with the given size. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoiddraw(DrawingPanel panel, Graphics g) Draws the lattice.intgetCell(int row, int col) Gets a lattice cell value.doublegetXMax()Gets the maximum x needed to draw this object.doublegetXMin()Gets the minimum x needed to draw this object.doublegetYMax()Gets the maximum y needed to draw this object.doublegetYMin()Gets the minimum y needed to draw this object.booleanDetermines if information is available to set min/max values.voidRanomizes the lattice values.voidresizeLattice(int _row, int _col) voidsetBlock(int row_offset, int col_offset, byte[][] val) Sets a block of cells to new values.voidsetBlock(int row_offset, int col_offset, int[][] val) Sets a block of cells to new values.voidsetCell(int row, int col, byte val) Sets a lattice cell to a new value.voidsetCol(int row_offset, int col, byte[] val) Sets a column of cells to new values.voidsetColorPalette(Color[] colors) Sets the color palette.voidsetIndexedColor(int i, Color color) Sets the color for a single index.voidsetMinMax(double xmin, double xmax, double ymin, double ymax) voidsetRow(int row, int col_offset, byte[] val) Sets a row of cells to new values.voidsetVisible(boolean _vis) voidShows the color associated with each value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.opensourcephysics.display.Drawable
isInteractive
-
Constructor Details
-
TriangularByteLattice
public TriangularByteLattice(int _row, int _col) Constructs a byte lattice with the given size. Cell values are -128 to 127.- Parameters:
_row- the number of rows_col- the number of columns
-
-
Method Details
-
resizeLattice
public void resizeLattice(int _row, int _col) -
setVisible
public void setVisible(boolean _vis) -
setMinMax
public void setMinMax(double xmin, double xmax, double ymin, double ymax) -
draw
Draws the lattice. -
setBlock
public void setBlock(int row_offset, int col_offset, byte[][] val) Sets a block of cells to new values.- Parameters:
row_offset-col_offset-val-
-
setBlock
public void setBlock(int row_offset, int col_offset, int[][] val) Sets a block of cells to new values.- Parameters:
row_offset-col_offset-val-
-
setCol
public void setCol(int row_offset, int col, byte[] val) Sets a column of cells to new values.- Parameters:
row_offset-col-val-
-
setRow
public void setRow(int row, int col_offset, byte[] val) Sets a row of cells to new values.- Parameters:
row-col_offset-val-
-
setCell
public void setCell(int row, int col, byte val) Sets a lattice cell to a new value.- Parameters:
row-col-val-
-
getCell
public int getCell(int row, int col) Gets a lattice cell value.- Parameters:
row-col-- Returns:
- the cell value.
-
randomize
public void randomize()Ranomizes the lattice values. -
showLegend
public void showLegend()Shows the color associated with each value. -
setColorPalette
Sets the color palette.- Parameters:
colors-
-
setIndexedColor
Sets the color for a single index.- Parameters:
i-color-
-
isMeasured
public boolean isMeasured()Description copied from interface:MeasurableDetermines if information is available to set min/max values. Objects that store data should return false if data is null.- Specified by:
isMeasuredin interfaceMeasurable- Returns:
- true if min/max values are valid
-
getXMin
public double getXMin()Description copied from interface:MeasurableGets the minimum x needed to draw this object.- Specified by:
getXMinin interfaceMeasurable- Returns:
- minimum
-
getYMin
public double getYMin()Description copied from interface:MeasurableGets the minimum y needed to draw this object.- Specified by:
getYMinin interfaceMeasurable- Returns:
- minimum
-
getXMax
public double getXMax()Description copied from interface:MeasurableGets the maximum x needed to draw this object.- Specified by:
getXMaxin interfaceMeasurable- Returns:
- maximum
-
getYMax
public double getYMax()Description copied from interface:MeasurableGets the maximum y needed to draw this object.- Specified by:
getYMaxin interfaceMeasurable- Returns:
- minimum
-
createDefaultColors
public void createDefaultColors()
-