Package org.opensourcephysics.display2d
Class CellLatticeOSX
java.lang.Object
org.opensourcephysics.display.Grid
org.opensourcephysics.display2d.CellLatticeOSX
- All Implemented Interfaces:
 Drawable,Measurable,ByteLattice,CellLattice.OSLattice
A Mac version of CellLattice that displays an array where each array element can assume one of 256
  values.
 Early versions of Java on Mac OSX were not able to set pixels in an image raster.  This class implements an alternate CellLattice
 that does not use an image raster.
 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. The
  lattice is drawn as an array of rectangles to distinguish between the two
  possible values.
- Version:
 - 1.0
 - Author:
 - Wolfgang Christian, Joshua Gould
 
- 
Field Summary
 - 
Constructor Summary
ConstructorsConstructorDescriptionCellLatticeOSX(int nx, int ny) Constructs a Cell lattice with the given size. - 
Method Summary
Modifier and TypeMethodDescriptionvoidCreates the default palette.Creates a new SiteLattice containing the same data as this lattice.voiddraw(DrawingPanel panel, Graphics g) Draws the lattice and the grid.intgetNx()Gets the number of x entries.intgetNy()Gets the number of y entries.bytegetValue(int col, int row) Gets a lattice site value.intindexFromPoint(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.booleanMethod isMeasuredvoidRandomizes the lattice values.voidresizeLattice(int _nx, int _ny) Resizes the lattice.voidsetAll(byte[][] val) Sets a block of data to new values.voidsetAll(byte[][] val, double xmin, double xmax, double ymin, double ymax) Sets the lattice values and scale.voidsetBlock(byte[][] val) Sets a block of cells to new values.voidsetBlock(int ix_offset, int iy_offset, byte[][] val) Sets a block of cells using byte values.voidsetBlock(int ix_offset, int iy_offset, int[][] val) Sets a block of cells using integer values.voidsetCol(int ix, int iy_offset, byte[] val) Sets a column to new values.voidsetColorPalette(Color[] _colors) Sets the color palette.voidsetGridLineColor(Color _color) Sets the grid line color.voidsetIndexedColor(int i, Color color) Sets the color for a single index.voidsetRow(int iy, int ix_offset, byte[] val) Sets a row to new values.voidsetShowGridLines(boolean showGridLines) Sets the visibility of the grid connecting the sites.voidsetShowVisible(boolean isVisible) Sets the visibility of the sites.voidsetValue(int ix, int iy, byte val) Sets the given x,y location to a new value.voidsetVisible(boolean isVisible) Sets the visibility of the lattice.voidsetXMax(double _value) Sets xmax.voidsetXMin(double _value) Sets xmin.voidsetYMax(double _value) Sets ymax.voidsetYMin(double _value) 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 class org.opensourcephysics.display.Grid
getCellPoint, getClosestGridPoint, getColor, getDx, getDy, getXMax, getXMin, getYMax, getYMin, isVisible, setColor, setMinMaxMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.opensourcephysics.display2d.ByteLattice
setMinMaxMethods inherited from interface org.opensourcephysics.display.Drawable
isInteractiveMethods inherited from interface org.opensourcephysics.display.Measurable
getXMax, getXMin, getYMax, getYMin 
- 
Constructor Details
- 
CellLatticeOSX
public CellLatticeOSX(int nx, int ny) Constructs a Cell lattice with the given size. Site values are -128 to 127.- Parameters:
 nx- sites in x dirctionny- sites in y direction
 
 - 
 - 
Method Details
- 
createSiteLattice
Creates a new SiteLattice containing the same data as this lattice.- Specified by:
 createSiteLatticein interfaceCellLattice.OSLattice
 - 
resizeLattice
public void resizeLattice(int _nx, int _ny) Description copied from interface:ByteLatticeResizes the lattice.- Specified by:
 resizeLatticein interfaceByteLattice
 - 
getNx
public int getNx()Gets the number of x entries.- Specified by:
 getNxin interfaceByteLattice- Returns:
 - nx
 
 - 
getNy
public int getNy()Gets the number of y entries.- Specified by:
 getNyin interfaceByteLattice- 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.- Specified by:
 indexFromPointin interfaceByteLattice- Parameters:
 x-y-- Returns:
 - index
 
 - 
xToIndex
public int xToIndex(double x) Gets closest index from the given x world coordinate.- Specified by:
 xToIndexin interfaceByteLattice- Parameters:
 x- double the coordinate- Returns:
 - int the index
 
 - 
yToIndex
public int yToIndex(double y) Gets closest index from the given y world coordinate.- Specified by:
 yToIndexin interfaceByteLattice- Parameters:
 y- double the coordinate- Returns:
 - int the index
 
 - 
setVisible
public void setVisible(boolean isVisible) Sets the visibility of the lattice. Drawing will be disabled if visible is false.- Specified by:
 setVisiblein interfaceByteLattice- Overrides:
 setVisiblein classGrid- Parameters:
 isVisible-
 - 
draw
Draws the lattice and the grid. - 
setBlock
public void setBlock(int ix_offset, int iy_offset, byte[][] val) Sets a block of cells using byte values.- Specified by:
 setBlockin interfaceByteLattice- Parameters:
 ix_offset- intiy_offset- intval- byte[][]
 - 
setAll
public void setAll(byte[][] val) Sets a block of data to new values. The lattice is resized to fit the new data if needed.- Parameters:
 val-
 - 
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.- Specified by:
 setAllin interfaceByteLattice- Parameters:
 val- int[][] the new valuesxmin- doublexmax- doubleymin- doubleymax- double
 - 
setBlock
public void setBlock(int ix_offset, int iy_offset, int[][] val) Sets a block of cells using integer values.- Specified by:
 setBlockin interfaceCellLattice.OSLattice- Parameters:
 ix_offset- intiy_offset- intval- int[][]
 - 
setBlock
public void setBlock(byte[][] val) Sets a block of cells to new values.- Specified by:
 setBlockin interfaceByteLattice- Parameters:
 val-
 - 
setCol
public void setCol(int ix, int iy_offset, byte[] val) Sets a column to new values.- Specified by:
 setColin interfaceByteLattice- Parameters:
 ix- the x index of the columniy_offset- the y offset in the columnval- values in column
 - 
setRow
public void setRow(int iy, int ix_offset, byte[] val) Sets a row to new values.- Specified by:
 setRowin interfaceByteLattice- Parameters:
 iy- the y index of the rowix_offset- the x offset in the rowval-
 - 
setValue
public void setValue(int ix, int iy, byte val) Sets the given x,y location to a new value.- Specified by:
 setValuein interfaceByteLattice- Parameters:
 ix-iy-val-
 - 
getValue
public byte getValue(int col, int row) Gets a lattice site value.- Specified by:
 getValuein interfaceByteLattice- Parameters:
 row-col-- Returns:
 - the cell value.
 
 - 
setShowVisible
public void setShowVisible(boolean isVisible) Sets the visibility of the sites. Drawing will be disabled if visible is false.- Parameters:
 isVisible-
 - 
setShowGridLines
public void setShowGridLines(boolean showGridLines) Sets the visibility of the grid connecting the sites.- Specified by:
 setShowGridLinesin interfaceByteLattice- Parameters:
 showGridLines-
 - 
randomize
public void randomize()Randomizes the lattice values.- Specified by:
 randomizein interfaceByteLattice
 - 
showLegend
Shows the color associated with each value.- Specified by:
 showLegendin interfaceByteLattice- Returns:
 - the JFrame containing the legend
 
 - 
setColorPalette
Sets the color palette.- Specified by:
 setColorPalettein interfaceByteLattice- Parameters:
 _colors-
 - 
setGridLineColor
Sets the grid line color.- Specified by:
 setGridLineColorin interfaceByteLattice- Parameters:
 _color-
 - 
setIndexedColor
Sets the color for a single index.- Specified by:
 setIndexedColorin interfaceByteLattice- Parameters:
 i-color-
 - 
isMeasured
public boolean isMeasured()Method isMeasured- Specified by:
 isMeasuredin interfaceMeasurable- Returns:
 
 - 
setXMin
public void setXMin(double _value) Description copied from interface:ByteLatticeSets xmin.- Specified by:
 setXMinin interfaceByteLattice- Parameters:
 _value- double
 - 
setXMax
public void setXMax(double _value) Description copied from interface:ByteLatticeSets xmax.- Specified by:
 setXMaxin interfaceByteLattice- Parameters:
 _value- double
 - 
setYMin
public void setYMin(double _value) Description copied from interface:ByteLatticeSets ymin.- Specified by:
 setYMinin interfaceByteLattice- Parameters:
 _value- double
 - 
setYMax
public void setYMax(double _value) Description copied from interface:ByteLatticeSets ymax.- Specified by:
 setYMaxin interfaceByteLattice- Parameters:
 _value- double
 - 
createDefaultColors
public void createDefaultColors()Creates the default palette.- Specified by:
 createDefaultColorsin interfaceByteLattice
 
 -