this.readMappingMatrix = new BitMatrix(this.mappingBitMatrix.getWidth(), this.mappingBitMatrix.getHeight());\r
}\r
\r
+ Version getVersion() {\r
+ return version;\r
+ }\r
+\r
/**\r
* <p>Creates the version object based on the dimension of the original bit matrix from \r
* the datamatrix code.</p>\r
* @throws FormatException if the dimensions of the mapping matrix are not valid\r
* Data Matrix dimensions.\r
*/\r
- Version readVersion(BitMatrix bitMatrix) throws FormatException {\r
-\r
- if (version != null) {\r
- return version;\r
- }\r
-\r
+ private static Version readVersion(BitMatrix bitMatrix) throws FormatException {\r
int numRows = bitMatrix.getHeight();\r
int numColumns = bitMatrix.getWidth();\r
- \r
return Version.getVersionForDimensions(numRows, numColumns);\r
}\r
\r
\r
// Construct a parser and read version, error-correction level\r
BitMatrixParser parser = new BitMatrixParser(bits);\r
- Version version = parser.readVersion(bits);\r
+ Version version = parser.getVersion();\r
\r
// Read codewords\r
byte[] codewords = parser.readCodewords();\r
*\r
* @param image booleans representing white/black QR Code modules\r
* @return text and bytes encoded within the QR Code\r
- * @throws NotFoundException if the QR Code cannot be found\r
* @throws FormatException if the QR Code cannot be decoded\r
* @throws ChecksumException if error correction fails\r
*/\r
- public DecoderResult decode(boolean[][] image, Hashtable hints)\r
- throws ChecksumException, FormatException, NotFoundException {\r
+ public DecoderResult decode(boolean[][] image, Hashtable hints) throws ChecksumException, FormatException {\r
int dimension = image.length;\r
BitMatrix bits = new BitMatrix(dimension);\r
for (int i = 0; i < dimension; i++) {\r
return decode(bits, hints);\r
}\r
\r
- public DecoderResult decode(BitMatrix bits) throws ChecksumException, FormatException, NotFoundException {\r
+ public DecoderResult decode(BitMatrix bits) throws ChecksumException, FormatException {\r
return decode(bits, null);\r
}\r
\r
*/\r
private static class FurthestFromAverageComparator implements Comparator {\r
private final float average;\r
- public FurthestFromAverageComparator(float f) {\r
+ private FurthestFromAverageComparator(float f) {\r
average = f;\r
}\r
public int compare(Object center1, Object center2) {\r
*/\r
private static class CenterComparator implements Comparator {\r
private final float average;\r
- public CenterComparator(float f) {\r
+ private CenterComparator(float f) {\r
average = f;\r
}\r
public int compare(Object center1, Object center2) {\r
- if (((FinderPattern) center2).getCount() != ((FinderPattern) center1).getCount()) {\r
- return ((FinderPattern) center2).getCount() - ((FinderPattern) center1).getCount();\r
- } else {\r
+ if (((FinderPattern) center2).getCount() == ((FinderPattern) center1).getCount()) {\r
float dA = Math.abs(((FinderPattern) center2).getEstimatedModuleSize() - average);\r
float dB = Math.abs(((FinderPattern) center1).getEstimatedModuleSize() - average);\r
return dA < dB ? 1 : (dA == dB ? 0 : -1);\r
+ } else {\r
+ return ((FinderPattern) center2).getCount() - ((FinderPattern) center1).getCount();\r
}\r
}\r
}\r