Package adams.data.image
Class IntArrayMatrixView
- java.lang.Object
-
- adams.data.image.IntArrayMatrixView
-
- All Implemented Interfaces:
BufferedImageSupporter
,SpreadSheetSupporter
,Serializable
public class IntArrayMatrixView extends Object implements Serializable, BufferedImageSupporter, SpreadSheetSupporter
Allows a matrix view (2-dim) of an array (1-dim).- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description IntArrayMatrixView(int[] data, int width, int height)
Initializes the matrix view.IntArrayMatrixView(int width, int height)
Initializes the matrix view with an empty array.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
get(int position)
Returns the value at the specified position.int
get(int x, int y)
Returns the value at the specified location.int[]
getData()
Returns the underlying data.int
getHeight()
Returns the height of the matrix.int[]
getRGBA(int position)
Returns the RGBA values at the specified location.int[]
getRGBA(int x, int y)
Returns the RGBA values at the specified location.int
getWidth()
Returns the width of the matrix.void
set(int position, int value)
Sets the value at the specified location.void
set(int x, int y, int value)
Sets the value at the specified location.void
setRGBA(int position, int[] rgba)
Sets the RGBA values at the specified location.void
setRGBA(int x, int y, int[] rgba)
Sets the RGBA values at the specified location.int
size()
Returns the number of data points (height * width).BufferedImage
toBufferedImage()
Turns the matrix into an image.BufferedImage
toBufferedImage(int type)
Turns the matrix into an image.SpreadSheet
toSpreadSheet()
Returns the content as spreadsheet.String
toString()
Returns a short description of the view.
-
-
-
Constructor Detail
-
IntArrayMatrixView
public IntArrayMatrixView(int width, int height)
Initializes the matrix view with an empty array.- Parameters:
width
- the width of the matrixheight
- the height of the matrix
-
IntArrayMatrixView
public IntArrayMatrixView(int[] data, int width, int height)
Initializes the matrix view.- Parameters:
data
- the 1-dim array datawidth
- the width of the matrixheight
- the height of the matrix
-
-
Method Detail
-
getData
public int[] getData()
Returns the underlying data.- Returns:
- the data
-
getWidth
public int getWidth()
Returns the width of the matrix.- Returns:
- the width
-
getHeight
public int getHeight()
Returns the height of the matrix.- Returns:
- the height
-
size
public int size()
Returns the number of data points (height * width).- Returns:
- the number of data points
-
get
public int get(int position)
Returns the value at the specified position.- Parameters:
position
- the 0-based position in the underlying array- Returns:
- the value at the position
-
getRGBA
public int[] getRGBA(int position)
Returns the RGBA values at the specified location.- Parameters:
position
- the 0-based position in the underlying array- Returns:
- the RGBA values at the position
-
get
public int get(int x, int y)
Returns the value at the specified location.- Parameters:
x
- the 0-based columny
- the 0-based row- Returns:
- the value at the position
-
getRGBA
public int[] getRGBA(int x, int y)
Returns the RGBA values at the specified location.- Parameters:
x
- the 0-based columny
- the 0-based row- Returns:
- the RGBA values at the position
-
set
public void set(int position, int value)
Sets the value at the specified location.- Parameters:
position
- the 0-based position in the underlying arrayvalue
- the value to set
-
setRGBA
public void setRGBA(int position, int[] rgba)
Sets the RGBA values at the specified location.- Parameters:
position
- the 0-based position in the underlying arrayrgba
- the RGBA values to set
-
set
public void set(int x, int y, int value)
Sets the value at the specified location.- Parameters:
x
- the 0-based columny
- the 0-based rowvalue
- the value to set
-
setRGBA
public void setRGBA(int x, int y, int[] rgba)
Sets the RGBA values at the specified location.- Parameters:
x
- the 0-based columny
- the 0-based rowrgba
- the RGBA values to set
-
toString
public String toString()
Returns a short description of the view.
-
toBufferedImage
public BufferedImage toBufferedImage(int type)
Turns the matrix into an image.- Parameters:
type
- the BufferedImage type- Returns:
- the image
-
toBufferedImage
public BufferedImage toBufferedImage()
Turns the matrix into an image.- Specified by:
toBufferedImage
in interfaceBufferedImageSupporter
- Returns:
- the image
-
toSpreadSheet
public SpreadSheet toSpreadSheet()
Returns the content as spreadsheet.- Specified by:
toSpreadSheet
in interfaceSpreadSheetSupporter
- Returns:
- the content
-
-