Package org.opensourcephysics.display
Class IntegerImage
java.lang.Object
org.opensourcephysics.display.IntegerImage
- All Implemented Interfaces:
Drawable,Measurable
A IntegerImage contains an array of integers 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
ConstructorsConstructorDescriptionIntegerImage(int[][] data) Constructs IntegerImage with the given data.IntegerImage(ColorModel colorModel, int[][] data) Constructs IntegerImage with the given ColorModel and data. -
Method Summary
Modifier and TypeMethodDescriptionvoiddraw(DrawingPanel panel, Graphics g) Draws the image and the grid.static IntegerImageget256ColorImage(int[][] data) Gets a 256 color IntegerImage with 0 -> blue, 128->green, and 255 -> red.static IntegerImagegetBinaryImage(int[][] data) Gets a two-color IntegerImage with 0 -> red and 1 -> blue.static IntegerImagegetColorImage(Color[] colors, int[][] data) static IntegerImagegetGrayscaleImage(int[][] data) Creates an IntegerImage with a gray-scale palette.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.voidsetBlock(int row_offset, int col_offset, int[][] val) Sets an offset block to new values.voidsetCell(int row, int col, int val) Sets a cell to a new value.voidsetCol(int col, int[] val) Sets a column to new values.voidsetMinMax(double _xmin, double _xmax, double _ymin, double _ymax) voidsetRow(int row, int[] val) Sets array elements in a row to new values.voidsetXMax(double _xmax) voidsetXMin(double _xmin) voidsetYMax(double _ymax) voidsetYMin(double _ymin) voidupdateImage(int[][] 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
-
IntegerImage
public IntegerImage(int[][] data) Constructs IntegerImage with the given data.- Parameters:
data-
-
IntegerImage
Constructs IntegerImage with the given ColorModel and data.- Parameters:
colorModel-data-
-
-
Method Details
-
getGrayscaleImage
Creates an IntegerImage with a gray-scale palette.- Parameters:
data-- Returns:
-
getBinaryImage
Gets a two-color IntegerImage with 0 -> red and 1 -> blue. -
get256ColorImage
Gets a 256 color IntegerImage with 0 -> blue, 128->green, and 255 -> red. -
getColorImage
-
updateImage
public void updateImage(int[][] val) Sets new values assuming that the integer array has not changed.- Parameters:
val-
-
setBlock
public void setBlock(int row_offset, int col_offset, int[][] val) Sets an offset block to new values.- Parameters:
row_offset-col_offset-val-
-
setRow
public void setRow(int row, int[] val) Sets array elements in a row to new values.- Parameters:
row-val-
-
setCol
public void setCol(int col, int[] val) Sets a column to new values.- Parameters:
col-val-
-
setCell
public void setCell(int row, int col, int val) Sets a cell to a new value. -
draw
Draws the image and the grid. -
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)
-