Draft of 'thinking' visualization for barcode scanning. Works for 1D and QR codes.
[zxing.git] / core / src / com / google / zxing / oned / ITFReader.java
index 396cdf3..4b4de2e 100644 (file)
@@ -22,16 +22,15 @@ import com.google.zxing.Result;
 import com.google.zxing.ResultPoint;\r
 import com.google.zxing.DecodeHintType;\r
 import com.google.zxing.common.BitArray;\r
-import com.google.zxing.common.GenericResultPoint;\r
 \r
 import java.util.Hashtable;\r
 \r
 /**\r
  * <p>Implements decoding of the ITF format.</p>\r
  *\r
- * <p>"ITF" stands for Interleaved Two of Five. This Reader will scan ITF barcode with 6, 10 or 14 digits.\r
- * The checksum is optional and is not applied by this Reader. The consumer of the decoded value\r
- * will have to apply a checksum if required.</p>\r
+ * <p>"ITF" stands for Interleaved Two of Five. This Reader will scan ITF barcode with 6, 10 or 14\r
+ * digits. The checksum is optional and is not applied by this Reader. The consumer of the decoded\r
+ * value will have to apply a checksum if required.</p>\r
  *\r
  * <p><a href="http://en.wikipedia.org/wiki/Interleaved_2_of_5">http://en.wikipedia.org/wiki/Interleaved_2_of_5</a>\r
  * is a great reference for Interleaved 2 of 5 information.</p>\r
@@ -78,14 +77,12 @@ public final class ITFReader extends AbstractOneDReader {
 \r
   public Result decodeRow(int rowNumber, BitArray row, Hashtable hints) throws ReaderException {\r
 \r
-    StringBuffer result = new StringBuffer(20);\r
-\r
     // Find out where the Middle section (payload) starts & ends\r
     int[] startRange = decodeStart(row);\r
     int[] endRange = decodeEnd(row);\r
 \r
+    StringBuffer result = new StringBuffer(20);\r
     decodeMiddle(row, startRange[1], endRange[0], result);\r
-\r
     String resultString = result.toString();\r
 \r
     int[] allowedLengths = null;\r
@@ -115,8 +112,8 @@ public final class ITFReader extends AbstractOneDReader {
     return new Result(\r
         resultString,\r
         null, // no natural byte representation for these barcodes\r
-        new ResultPoint[] { new GenericResultPoint(startRange[1], (float) rowNumber),\r
-                            new GenericResultPoint(endRange[0], (float) rowNumber)},\r
+        new ResultPoint[] { new ResultPoint(startRange[1], (float) rowNumber),\r
+                            new ResultPoint(endRange[0], (float) rowNumber)},\r
         BarcodeFormat.ITF);\r
   }\r
 \r
@@ -126,7 +123,8 @@ public final class ITFReader extends AbstractOneDReader {
    * @param resultString {@link StringBuffer} to append decoded chars to\r
    * @throws ReaderException if decoding could not complete successfully\r
    */\r
-  static void decodeMiddle(BitArray row, int payloadStart, int payloadEnd, StringBuffer resultString) throws ReaderException {\r
+  private static void decodeMiddle(BitArray row, int payloadStart, int payloadEnd,\r
+      StringBuffer resultString) throws ReaderException {\r
 \r
     // Digits are interleaved in pairs - 5 black lines for one digit, and the\r
     // 5\r
@@ -258,8 +256,8 @@ public final class ITFReader extends AbstractOneDReader {
       // ref: http://www.barcode-1.net/i25code.html\r
       validateQuietZone(row, endPattern[0]);\r
 \r
-      // Now recalc the indicies of where the 'endblock' starts & stops to\r
-      // accomodate\r
+      // Now recalculate the indices of where the 'endblock' starts & stops to\r
+      // accommodate\r
       // the reversed nature of the search\r
       int temp = endPattern[0];\r
       endPattern[0] = row.getSize() - endPattern[1];\r
@@ -267,7 +265,7 @@ public final class ITFReader extends AbstractOneDReader {
 \r
       return endPattern;\r
     } finally {\r
-      // Put the row back the righ way.\r
+      // Put the row back the right way.\r
       row.reverse();\r
     }\r
   }\r
@@ -281,11 +279,10 @@ public final class ITFReader extends AbstractOneDReader {
    *         ints\r
    * @throws ReaderException if pattern is not found\r
    */\r
-  static int[] findGuardPattern(BitArray row, int rowOffset, int[] pattern) throws ReaderException {\r
-\r
-    // TODO: This is very similar to implementation in AbstractUPCEANReader. Consider if they can be merged to\r
-    // a single method.\r
+  private static int[] findGuardPattern(BitArray row, int rowOffset, int[] pattern) throws ReaderException {\r
 \r
+    // TODO: This is very similar to implementation in AbstractUPCEANReader. Consider if they can be\r
+    // merged to a single method.\r
     int patternLength = pattern.length;\r
     int[] counters = new int[patternLength];\r
     int width = row.getSize();\r