Move character encoding logic out to common, try again to improve its handling of...
[zxing.git] / core / src / com / google / zxing / qrcode / decoder / Version.java
index 172deca..497a63f 100755 (executable)
@@ -16,7 +16,7 @@
 \r
 package com.google.zxing.qrcode.decoder;\r
 \r
-import com.google.zxing.ReaderException;\r
+import com.google.zxing.FormatException;\r
 import com.google.zxing.common.BitMatrix;\r
 \r
 /**\r
@@ -91,16 +91,16 @@ public final class Version {
    *\r
    * @param dimension dimension in modules\r
    * @return {@link Version} for a QR Code of that dimension\r
-   * @throws ReaderException if dimension is not 1 mod 4\r
+   * @throws FormatException if dimension is not 1 mod 4\r
    */\r
-  public static Version getProvisionalVersionForDimension(int dimension) throws ReaderException {\r
+  public static Version getProvisionalVersionForDimension(int dimension) throws FormatException {\r
     if (dimension % 4 != 1) {\r
-      throw ReaderException.getInstance();\r
+      throw FormatException.getFormatInstance();\r
     }\r
     try {\r
       return getVersionForNumber((dimension - 17) >> 2);\r
     } catch (IllegalArgumentException iae) {\r
-      throw ReaderException.getInstance();\r
+      throw FormatException.getFormatInstance();\r
     }\r
   }\r
 \r
@@ -147,9 +147,9 @@ public final class Version {
     // Top left finder pattern + separator + format\r
     bitMatrix.setRegion(0, 0, 9, 9);\r
     // Top right finder pattern + separator + format\r
-    bitMatrix.setRegion(0, dimension - 8, 9, 8);\r
-    // Bottom left finder pattern + separator + format\r
     bitMatrix.setRegion(dimension - 8, 0, 8, 9);\r
+    // Bottom left finder pattern + separator + format\r
+    bitMatrix.setRegion(0, dimension - 8, 9, 8);\r
 \r
     // Alignment patterns\r
     int max = alignmentPatternCenters.length;\r
@@ -160,20 +160,20 @@ public final class Version {
           // No alignment patterns near the three finder paterns\r
           continue;\r
         }\r
-        bitMatrix.setRegion(i, alignmentPatternCenters[y] - 2, 5, 5);\r
+        bitMatrix.setRegion(alignmentPatternCenters[y] - 2, i, 5, 5);\r
       }\r
     }\r
 \r
     // Vertical timing pattern\r
-    bitMatrix.setRegion(9, 6, dimension - 17, 1);\r
-    // Horizontal timing pattern\r
     bitMatrix.setRegion(6, 9, 1, dimension - 17);\r
+    // Horizontal timing pattern\r
+    bitMatrix.setRegion(9, 6, dimension - 17, 1);\r
 \r
     if (versionNumber > 6) {\r
       // Version info, top right\r
-      bitMatrix.setRegion(0, dimension - 11, 6, 3);\r
-      // Version info, bottom left\r
       bitMatrix.setRegion(dimension - 11, 0, 3, 6);\r
+      // Version info, bottom left\r
+      bitMatrix.setRegion(0, dimension - 11, 6, 3);\r
     }\r
 \r
     return bitMatrix;\r
@@ -189,12 +189,12 @@ public final class Version {
     private final int ecCodewordsPerBlock;\r
     private final ECB[] ecBlocks;\r
 \r
-    private ECBlocks(int ecCodewordsPerBlock, ECB ecBlocks) {\r
+    ECBlocks(int ecCodewordsPerBlock, ECB ecBlocks) {\r
       this.ecCodewordsPerBlock = ecCodewordsPerBlock;\r
       this.ecBlocks = new ECB[]{ecBlocks};\r
     }\r
 \r
-    private ECBlocks(int ecCodewordsPerBlock, ECB ecBlocks1, ECB ecBlocks2) {\r
+    ECBlocks(int ecCodewordsPerBlock, ECB ecBlocks1, ECB ecBlocks2) {\r
       this.ecCodewordsPerBlock = ecCodewordsPerBlock;\r
       this.ecBlocks = new ECB[]{ecBlocks1, ecBlocks2};\r
     }\r