From d0920ceb07da310eb8e10f6a11d5590bcb3184ea Mon Sep 17 00:00:00 2001 From: srowen Date: Tue, 12 Oct 2010 11:38:43 +0000 Subject: [PATCH 1/1] Small style stuff git-svn-id: http://zxing.googlecode.com/svn/trunk@1622 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- .../zxing/datamatrix/decoder/BitMatrixParser.java | 12 +++++------- .../com/google/zxing/datamatrix/decoder/Decoder.java | 2 +- .../src/com/google/zxing/qrcode/decoder/Decoder.java | 6 ++---- .../zxing/qrcode/detector/FinderPatternFinder.java | 10 +++++----- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/core/src/com/google/zxing/datamatrix/decoder/BitMatrixParser.java b/core/src/com/google/zxing/datamatrix/decoder/BitMatrixParser.java index c8210b43..45ffd2d0 100644 --- a/core/src/com/google/zxing/datamatrix/decoder/BitMatrixParser.java +++ b/core/src/com/google/zxing/datamatrix/decoder/BitMatrixParser.java @@ -43,6 +43,10 @@ final class BitMatrixParser { this.readMappingMatrix = new BitMatrix(this.mappingBitMatrix.getWidth(), this.mappingBitMatrix.getHeight()); } + Version getVersion() { + return version; + } + /** *

Creates the version object based on the dimension of the original bit matrix from * the datamatrix code.

@@ -54,15 +58,9 @@ final class BitMatrixParser { * @throws FormatException if the dimensions of the mapping matrix are not valid * Data Matrix dimensions. */ - Version readVersion(BitMatrix bitMatrix) throws FormatException { - - if (version != null) { - return version; - } - + private static Version readVersion(BitMatrix bitMatrix) throws FormatException { int numRows = bitMatrix.getHeight(); int numColumns = bitMatrix.getWidth(); - return Version.getVersionForDimensions(numRows, numColumns); } diff --git a/core/src/com/google/zxing/datamatrix/decoder/Decoder.java b/core/src/com/google/zxing/datamatrix/decoder/Decoder.java index 58f8c98a..47ecac95 100644 --- a/core/src/com/google/zxing/datamatrix/decoder/Decoder.java +++ b/core/src/com/google/zxing/datamatrix/decoder/Decoder.java @@ -73,7 +73,7 @@ public final class Decoder { // Construct a parser and read version, error-correction level BitMatrixParser parser = new BitMatrixParser(bits); - Version version = parser.readVersion(bits); + Version version = parser.getVersion(); // Read codewords byte[] codewords = parser.readCodewords(); diff --git a/core/src/com/google/zxing/qrcode/decoder/Decoder.java b/core/src/com/google/zxing/qrcode/decoder/Decoder.java index 22cdeb02..520e076f 100644 --- a/core/src/com/google/zxing/qrcode/decoder/Decoder.java +++ b/core/src/com/google/zxing/qrcode/decoder/Decoder.java @@ -52,12 +52,10 @@ public final class Decoder { * * @param image booleans representing white/black QR Code modules * @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 ChecksumException if error correction fails */ - public DecoderResult decode(boolean[][] image, Hashtable hints) - throws ChecksumException, FormatException, NotFoundException { + public DecoderResult decode(boolean[][] image, Hashtable hints) throws ChecksumException, FormatException { int dimension = image.length; BitMatrix bits = new BitMatrix(dimension); for (int i = 0; i < dimension; i++) { @@ -70,7 +68,7 @@ public final class Decoder { 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); } diff --git a/core/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java b/core/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java index ebed5d06..9968f009 100755 --- a/core/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java +++ b/core/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java @@ -553,7 +553,7 @@ public class FinderPatternFinder { */ private static class FurthestFromAverageComparator implements Comparator { private final float average; - public FurthestFromAverageComparator(float f) { + private FurthestFromAverageComparator(float f) { average = f; } public int compare(Object center1, Object center2) { @@ -568,16 +568,16 @@ public class FinderPatternFinder { */ private static class CenterComparator implements Comparator { private final float average; - public CenterComparator(float f) { + private CenterComparator(float f) { average = f; } public int compare(Object center1, Object center2) { - if (((FinderPattern) center2).getCount() != ((FinderPattern) center1).getCount()) { - return ((FinderPattern) center2).getCount() - ((FinderPattern) center1).getCount(); - } else { + if (((FinderPattern) center2).getCount() == ((FinderPattern) center1).getCount()) { float dA = Math.abs(((FinderPattern) center2).getEstimatedModuleSize() - average); float dB = Math.abs(((FinderPattern) center1).getEstimatedModuleSize() - average); return dA < dB ? 1 : (dA == dB ? 0 : -1); + } else { + return ((FinderPattern) center2).getCount() - ((FinderPattern) center1).getCount(); } } } -- 2.20.1