Package adams.data.image
Class BooleanArrayMatrixView
- java.lang.Object
-
- adams.data.image.BooleanArrayMatrixView
-
- All Implemented Interfaces:
BufferedImageSupporter
,Serializable
public class BooleanArrayMatrixView extends Object implements Serializable, BufferedImageSupporter
Allows a matrix view (2-dim) of an array (1-dim).- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BooleanArrayMatrixView(boolean[][] data)
Initializes the matrix view the provided boolean matrix (gets turned into an array in the process).BooleanArrayMatrixView(boolean[] data, int width, int height)
Initializes the matrix view.BooleanArrayMatrixView(int width, int height)
Initializes the matrix view with an empty array.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
get(int x, int y)
Returns the value at the specified location.boolean[]
getData()
Returns the underlying data.int
getHeight()
Returns the height of the matrix.int
getWidth()
Returns the width of the matrix.static boolean[]
matrixToArray(boolean[][] data)
Turns the matrix into an array.void
set(int x, int y, boolean value)
Sets the value at the specified location.BufferedImage
toBufferedImage()
Turns the matrix into an image.BufferedImage
toBufferedImage(int type)
Turns the matrix into an image.String
toString()
Returns a short description of the view.
-
-
-
Constructor Detail
-
BooleanArrayMatrixView
public BooleanArrayMatrixView(int width, int height)
Initializes the matrix view with an empty array.- Parameters:
width
- the width of the matrixheight
- the height of the matrix
-
BooleanArrayMatrixView
public BooleanArrayMatrixView(boolean[][] data)
Initializes the matrix view the provided boolean matrix (gets turned into an array in the process).- Parameters:
data
- the matrix to use
-
BooleanArrayMatrixView
public BooleanArrayMatrixView(boolean[] 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 boolean[] 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
-
get
public boolean 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
-
set
public void set(int x, int y, boolean value)
Sets the value at the specified location.- Parameters:
x
- the 0-based columny
- the 0-based rowvalue
- the value 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
-
matrixToArray
public static boolean[] matrixToArray(boolean[][] data)
Turns the matrix into an array.- Parameters:
data
- the matrix to convert- Returns:
- the generated array
-
-