|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.zxing.common.BitMatrix
public final class BitMatrix
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.
Field Summary | ||
---|---|---|
int[] |
bits
|
|
int |
height
|
|
int |
rowSize
|
|
int |
width
|
Constructor Summary | ||
---|---|---|
BitMatrix(int dimension)
|
||
BitMatrix(int width,
int height)
|
Method Summary | ||
---|---|---|
void |
clear()
Clears all bits (sets to false). |
|
boolean |
equals(Object o)
Indicates whether some other object is "equal to" this one. |
|
void |
flip(int x,
int y)
Flips the given bit. |
|
boolean |
get(int x,
int y)
Gets the requested bit, where true means black. |
|
int[] |
getBottomRightOnBit()
|
|
int |
getDimension()
This method is for compatibility with older code. |
|
int |
getHeight()
|
|
BitArray |
getRow(int y,
BitArray row)
A fast method to retrieve one row of data from the matrix as a BitArray. |
|
int[] |
getTopLeftOnBit()
This is useful in detecting a corner of a 'pure' barcode. |
|
int |
getWidth()
|
|
int |
hashCode()
Returns a hash code value for the object. |
|
void |
set(int x,
int y)
Sets the given bit to true. |
|
void |
setRegion(int left,
int top,
int width,
int height)
Sets a square region of the bit matrix to true. |
|
String |
toString()
Returns a string representation of the object. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final int width
public final int height
public final int rowSize
public final int[] bits
Constructor Detail |
---|
public BitMatrix(int dimension)
public BitMatrix(int width, int height)
Method Detail |
---|
public boolean get(int x, int y)
Gets the requested bit, where true means black.
x
- The horizontal component (i.e. which column)y
- The vertical component (i.e. which row)
public void set(int x, int y)
Sets the given bit to true.
x
- The horizontal component (i.e. which column)y
- The vertical component (i.e. which row)public void flip(int x, int y)
Flips the given bit.
x
- The horizontal component (i.e. which column)y
- The vertical component (i.e. which row)public void clear()
public void setRegion(int left, int top, int width, int height)
Sets a square region of the bit matrix to true.
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 regionpublic BitArray getRow(int y, BitArray row)
y
- The row to retrieverow
- An optional caller-allocated BitArray, will be allocated if null or too small
public int[] getTopLeftOnBit()
public int[] getBottomRightOnBit()
public int getWidth()
public int getHeight()
public int getDimension()
public boolean equals(Object o)
Object
The equals
method implements an equivalence relation:
x
,
x.equals(x)
should return true
.
x
and
y
, x.equals(y)
should return
true
if and only if y.equals(x)
returns
true
.
x
,
y
, and z
, if x.equals(y)
returns true
and y.equals(z)
returns
true
, then x.equals(z)
should return
true
.
x
and y
, multiple invocations of x.equals(y)
consistently return true
or consistently return
false
, provided no information used in
equals
comparisons on the object is modified.
x
,
x.equals(null)
should return false
.
The equals method for class Object
implements
the most discriminating possible equivalence relation on objects;
that is, for any reference values x
and y
,
this method returns true
if and only if x
and
y
refer to the same object (x==y
has the
value true
).
equals
in class Object
o
- the reference object with which to compare.
true
if this object is the same as the obj
argument; false
otherwise.Boolean.hashCode()
,
Hashtable
public int hashCode()
Object
java.util.Hashtable
.
The general contract of hashCode
is:
hashCode
method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hashtables.
As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)
hashCode
in class Object
Object.equals(java.lang.Object)
,
Hashtable
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal