Package org.opensourcephysics.display
Class ByteImage
java.lang.Object
org.opensourcephysics.display.ByteImage
- All Implemented Interfaces:
Drawable,Measurable
A ByteImage contains an array of bytes int[row][col]
where each integer represents an image pixel. The row index determines the y-location
of the pixel and the col index determines the x-location in the drawing panel.
- Version:
- 1.0
- Author:
- Wolfgang Christian
-
Constructor Summary
ConstructorsConstructorDescriptionByteImage(byte[][] data) Constructs ByteImage with the given data.ByteImage(ColorModel colorModel, byte[][] data) Constructs IntegerImage with the given ColorModel and data. -
Method Summary
Modifier and TypeMethodDescriptionvoiddraw(DrawingPanel panel, Graphics g) Draws the image.static ByteImagegetBinaryImage(byte[][] data) Gets a two-color ByteImage with 0 -> red and 1 -> blue.static ByteImagegetColorImage(Color[] colors, byte[][] data) booleandoublegetXMax()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.voidsetBlock(int row_offset, int col_offset, byte[][] val) Sets an offset block to new values.voidsetCell(int row, int col, byte val) Sets a cell to a new value.voidsetCol(int col, byte[] val) Sets a column to new values.voidsetMinMax(double _xmin, double _xmax, double _ymin, double _ymax) voidsetRow(int row, byte[] val) Sets array elements in a row to new values.voidsetVisible(boolean b) voidsetXMax(double _xmax) voidsetXMin(double _xmin) voidsetYMax(double _ymax) voidsetYMin(double _ymin) voidupdateImage(byte[][] val) Sets new values assuming that the integer array has not changed.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
-
ByteImage
public ByteImage(byte[][] data) Constructs ByteImage with the given data.- Parameters:
data-
-
ByteImage
Constructs IntegerImage with the given ColorModel and data.- Parameters:
colorModel-data-
-
-
Method Details
-
setVisible
public void setVisible(boolean b) -
getVisible
public boolean getVisible() -
getBinaryImage
Gets a two-color ByteImage with 0 -> red and 1 -> blue. -
getColorImage
-
updateImage
public void updateImage(byte[][] val) Sets new values assuming that the integer array has not changed.- Parameters:
val-
-
setBlock
public void setBlock(int row_offset, int col_offset, byte[][] val) Sets an offset block to new values.- Parameters:
row_offset-col_offset-val-
-
setRow
public void setRow(int row, byte[] val) Sets array elements in a row to new values.- Parameters:
row-val-
-
setCol
public void setCol(int col, byte[] val) Sets a column to new values.- Parameters:
col-val-
-
setCell
public void setCell(int row, int col, byte val) Sets a cell to a new value. -
draw
Draws the image. -
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
-
getXMax
public double getXMax()Description copied from interface:MeasurableGets the maximum x needed to draw this object.- Specified by:
getXMaxin interfaceMeasurable- Returns:
- maximum
-
getYMin
public double getYMin()Description copied from interface:MeasurableGets the minimum y needed to draw this object.- Specified by:
getYMinin interfaceMeasurable- Returns:
- minimum
-
getYMax
public double getYMax()Description copied from interface:MeasurableGets the maximum y needed to draw this object.- Specified by:
getYMaxin interfaceMeasurable- Returns:
- minimum
-
setXMin
public void setXMin(double _xmin) -
setXMax
public void setXMax(double _xmax) -
setYMin
public void setYMin(double _ymin) -
setYMax
public void setYMax(double _ymax) -
setMinMax
public void setMinMax(double _xmin, double _xmax, double _ymin, double _ymax)
-