mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Small style stuff
git-svn-id: https://zxing.googlecode.com/svn/trunk@1622 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
78e1460bfd
commit
eaecf26bf6
|
@ -43,6 +43,10 @@ final class BitMatrixParser {
|
||||||
this.readMappingMatrix = new BitMatrix(this.mappingBitMatrix.getWidth(), this.mappingBitMatrix.getHeight());
|
this.readMappingMatrix = new BitMatrix(this.mappingBitMatrix.getWidth(), this.mappingBitMatrix.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Version getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Creates the version object based on the dimension of the original bit matrix from
|
* <p>Creates the version object based on the dimension of the original bit matrix from
|
||||||
* the datamatrix code.</p>
|
* the datamatrix code.</p>
|
||||||
|
@ -54,15 +58,9 @@ final class BitMatrixParser {
|
||||||
* @throws FormatException if the dimensions of the mapping matrix are not valid
|
* @throws FormatException if the dimensions of the mapping matrix are not valid
|
||||||
* Data Matrix dimensions.
|
* Data Matrix dimensions.
|
||||||
*/
|
*/
|
||||||
Version readVersion(BitMatrix bitMatrix) throws FormatException {
|
private static Version readVersion(BitMatrix bitMatrix) throws FormatException {
|
||||||
|
|
||||||
if (version != null) {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
int numRows = bitMatrix.getHeight();
|
int numRows = bitMatrix.getHeight();
|
||||||
int numColumns = bitMatrix.getWidth();
|
int numColumns = bitMatrix.getWidth();
|
||||||
|
|
||||||
return Version.getVersionForDimensions(numRows, numColumns);
|
return Version.getVersionForDimensions(numRows, numColumns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ public final class Decoder {
|
||||||
|
|
||||||
// Construct a parser and read version, error-correction level
|
// Construct a parser and read version, error-correction level
|
||||||
BitMatrixParser parser = new BitMatrixParser(bits);
|
BitMatrixParser parser = new BitMatrixParser(bits);
|
||||||
Version version = parser.readVersion(bits);
|
Version version = parser.getVersion();
|
||||||
|
|
||||||
// Read codewords
|
// Read codewords
|
||||||
byte[] codewords = parser.readCodewords();
|
byte[] codewords = parser.readCodewords();
|
||||||
|
|
|
@ -52,12 +52,10 @@ public final class Decoder {
|
||||||
*
|
*
|
||||||
* @param image booleans representing white/black QR Code modules
|
* @param image booleans representing white/black QR Code modules
|
||||||
* @return text and bytes encoded within the QR Code
|
* @return text and bytes encoded within the QR Code
|
||||||
* @throws NotFoundException if the QR Code cannot be found
|
|
||||||
* @throws FormatException if the QR Code cannot be decoded
|
* @throws FormatException if the QR Code cannot be decoded
|
||||||
* @throws ChecksumException if error correction fails
|
* @throws ChecksumException if error correction fails
|
||||||
*/
|
*/
|
||||||
public DecoderResult decode(boolean[][] image, Hashtable hints)
|
public DecoderResult decode(boolean[][] image, Hashtable hints) throws ChecksumException, FormatException {
|
||||||
throws ChecksumException, FormatException, NotFoundException {
|
|
||||||
int dimension = image.length;
|
int dimension = image.length;
|
||||||
BitMatrix bits = new BitMatrix(dimension);
|
BitMatrix bits = new BitMatrix(dimension);
|
||||||
for (int i = 0; i < dimension; i++) {
|
for (int i = 0; i < dimension; i++) {
|
||||||
|
@ -70,7 +68,7 @@ public final class Decoder {
|
||||||
return decode(bits, hints);
|
return decode(bits, hints);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DecoderResult decode(BitMatrix bits) throws ChecksumException, FormatException, NotFoundException {
|
public DecoderResult decode(BitMatrix bits) throws ChecksumException, FormatException {
|
||||||
return decode(bits, null);
|
return decode(bits, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -553,7 +553,7 @@ public class FinderPatternFinder {
|
||||||
*/
|
*/
|
||||||
private static class FurthestFromAverageComparator implements Comparator {
|
private static class FurthestFromAverageComparator implements Comparator {
|
||||||
private final float average;
|
private final float average;
|
||||||
public FurthestFromAverageComparator(float f) {
|
private FurthestFromAverageComparator(float f) {
|
||||||
average = f;
|
average = f;
|
||||||
}
|
}
|
||||||
public int compare(Object center1, Object center2) {
|
public int compare(Object center1, Object center2) {
|
||||||
|
@ -568,16 +568,16 @@ public class FinderPatternFinder {
|
||||||
*/
|
*/
|
||||||
private static class CenterComparator implements Comparator {
|
private static class CenterComparator implements Comparator {
|
||||||
private final float average;
|
private final float average;
|
||||||
public CenterComparator(float f) {
|
private CenterComparator(float f) {
|
||||||
average = f;
|
average = f;
|
||||||
}
|
}
|
||||||
public int compare(Object center1, Object center2) {
|
public int compare(Object center1, Object center2) {
|
||||||
if (((FinderPattern) center2).getCount() != ((FinderPattern) center1).getCount()) {
|
if (((FinderPattern) center2).getCount() == ((FinderPattern) center1).getCount()) {
|
||||||
return ((FinderPattern) center2).getCount() - ((FinderPattern) center1).getCount();
|
|
||||||
} else {
|
|
||||||
float dA = Math.abs(((FinderPattern) center2).getEstimatedModuleSize() - average);
|
float dA = Math.abs(((FinderPattern) center2).getEstimatedModuleSize() - average);
|
||||||
float dB = Math.abs(((FinderPattern) center1).getEstimatedModuleSize() - average);
|
float dB = Math.abs(((FinderPattern) center1).getEstimatedModuleSize() - average);
|
||||||
return dA < dB ? 1 : (dA == dB ? 0 : -1);
|
return dA < dB ? 1 : (dA == dB ? 0 : -1);
|
||||||
|
} else {
|
||||||
|
return ((FinderPattern) center2).getCount() - ((FinderPattern) center1).getCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue