- java.lang.Object
-
- org.dhatim.fastexcel.BitMatrix
-
- All Implemented Interfaces:
Cloneable
public final class BitMatrix extends Object implements Cloneable
Represents a 2D matrix of bits. In function arguments below, and throughout the common module, x is the column position, and y is the row position. The ordering is always x, y. The origin is at the top-left.
Internally the bits are represented in a 1-D array of 32-bit ints. However, each row begins with a new int. This is done intentionally so that we can copy out a row into a BitArray very efficiently.
The ordering of bits is row-major. Within each int, the least significant bits are used first, meaning they represent lower x values. This is compatible with BitArray's implementation.
- Author:
- Sean Owen, dswitkin@google.com (Daniel Switkin)
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclear()Clears all bits (sets to false).BitMatrixclone()booleanequals(Object o)voidflip()Flips every bit in the matrix.voidflip(int x, int y)Flips the given bit.booleanget(int x, int y)Gets the requested bit, where true means black.intgetHeight()intgetRowSize()intgetWidth()inthashCode()voidset(int x, int y)Sets the given bit to true.voidsetRegion(int left, int top, int width, int height)Sets a square region of the bit matrix to true.StringtoString()StringtoString(String setString, String unsetString)StringtoString(String setString, String unsetString, String lineSeparator)Deprecated.calltoString(String,String)only, which uses \n line separator alwaysvoidunset(int x, int y)
-
-
-
Method Detail
-
get
public boolean get(int x, int y)Gets the requested bit, where true means black.
- Parameters:
x- The horizontal component (i.e. which column)y- The vertical component (i.e. which row)- Returns:
- value of given bit in matrix
-
set
public void set(int x, int y)Sets the given bit to true.
- Parameters:
x- The horizontal component (i.e. which column)y- The vertical component (i.e. which row)
-
unset
public void unset(int x, int y)
-
flip
public void flip(int x, int y)Flips the given bit.
- Parameters:
x- The horizontal component (i.e. which column)y- The vertical component (i.e. which row)
-
flip
public void flip()
Flips every bit in the matrix.
-
clear
public void clear()
Clears all bits (sets to false).
-
setRegion
public void setRegion(int left, int top, int width, int height)Sets a square region of the bit matrix to true.
- Parameters:
left- The horizontal position to begin at (inclusive)top- The vertical position to begin at (inclusive)width- The width of the regionheight- The height of the region
-
getWidth
public int getWidth()
- Returns:
- The width of the matrix
-
getHeight
public int getHeight()
- Returns:
- The height of the matrix
-
getRowSize
public int getRowSize()
- Returns:
- The row size of the matrix
-
toString
public String toString()
-
toString
public String toString(String setString, String unsetString)
- Parameters:
setString- representation of a set bitunsetString- representation of an unset bit- Returns:
- string representation of entire matrix utilizing given strings
-
toString
@Deprecated public String toString(String setString, String unsetString, String lineSeparator)
Deprecated.calltoString(String,String)only, which uses \n line separator always- Parameters:
setString- representation of a set bitunsetString- representation of an unset bitlineSeparator- newline character in string representation- Returns:
- string representation of entire matrix utilizing given strings and line separator
-
clone
public BitMatrix clone()
-
-