Small style stuff
[zxing.git] / core / src / com / google / zxing / qrcode / detector / AlignmentPattern.java
index deafa5f..6fc1a2c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007 Google Inc.
+ * Copyright 2007 ZXing authors
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,42 +22,27 @@ import com.google.zxing.ResultPoint;
  * <p>Encapsulates an alignment pattern, which are the smaller square patterns found in
  * all but the simplest QR Codes.</p>
  *
- * @author srowen@google.com (Sean Owen)
+ * @author Sean Owen
  */
-public final class AlignmentPattern implements ResultPoint {
+public final class AlignmentPattern extends ResultPoint {
 
-  private final float posX;
-  private final float posY;
   private final float estimatedModuleSize;
 
   AlignmentPattern(float posX, float posY, float estimatedModuleSize) {
-    this.posX = posX;
-    this.posY = posY;
+    super(posX, posY);
     this.estimatedModuleSize = estimatedModuleSize;
   }
 
-  public float getX() {
-    return posX;
-  }
-
-  public float getY() {
-    return posY;
-  }
-
-  float getEstimatedModuleSize() {
-    return estimatedModuleSize;
-  }
-
   /**
    * <p>Determines if this alignment pattern "about equals" an alignment pattern at the stated
    * position and size -- meaning, it is at nearly the same center with nearly the same size.</p>
    */
   boolean aboutEquals(float moduleSize, float i, float j) {
-    return
-        Math.abs(i - posY) <= moduleSize &&
-            Math.abs(j - posX) <= moduleSize &&
-            (Math.abs(moduleSize - estimatedModuleSize) <= 1.0f ||
-                Math.abs(moduleSize - estimatedModuleSize) / estimatedModuleSize <= 0.1f);
+    if (Math.abs(i - getY()) <= moduleSize && Math.abs(j - getX()) <= moduleSize) {
+      float moduleSizeDiff = Math.abs(moduleSize - estimatedModuleSize);
+      return moduleSizeDiff <= 1.0f || moduleSizeDiff / estimatedModuleSize <= 1.0f;
+    }
+    return false;
   }
 
 }
\ No newline at end of file