/*
- * 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.
* the corners of QR Codes. It also encapsulates a count of similar finder patterns,
* as a convenience to the finder's bookkeeping.</p>
*
- * @author srowen@google.com (Sean Owen)
+ * @author Sean Owen
*/
-public final class FinderPattern implements ResultPoint {
+public final class FinderPattern extends ResultPoint {
- private final float posX;
- private final float posY;
private final float estimatedModuleSize;
private int count;
FinderPattern(float posX, float posY, float estimatedModuleSize) {
- this.posX = posX;
- this.posY = posY;
+ super(posX, posY);
this.estimatedModuleSize = estimatedModuleSize;
this.count = 1;
}
- public float getX() {
- return posX;
- }
-
- public float getY() {
- return posY;
- }
-
- float getEstimatedModuleSize() {
+ public float getEstimatedModuleSize() {
return estimatedModuleSize;
}
* 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;
}
}