remove ResultPoint trait uses of Point

Point already has `x` and `y` properties, so accessing
them with `getX()` and `getY()` is needlessly verbose.
These calls have been removed, though the trait impl is
still presen for the time being, since the OneDReader
proc macro requires it.
This commit is contained in:
Vukašin Stepanović
2023-02-16 15:54:07 +00:00
parent 9889555b02
commit 0992e85e6c
16 changed files with 137 additions and 147 deletions

View File

@@ -18,7 +18,7 @@ use std::rc::Rc;
use crate::{
common::{BitMatrix, Result},
point, Exceptions, Point, ResultPoint,
point, Exceptions, Point,
};
/**
@@ -58,13 +58,13 @@ impl BoundingBox {
if leftUnspecified {
newTopRight = topRight.ok_or(Exceptions::IllegalStateException(None))?;
newBottomRight = bottomRight.ok_or(Exceptions::IllegalStateException(None))?;
newTopLeft = point(0.0, newTopRight.getY());
newBottomLeft = point(0.0, newBottomRight.getY());
newTopLeft = point(0.0, newTopRight.y);
newBottomLeft = point(0.0, newBottomRight.y);
} else if rightUnspecified {
newTopLeft = topLeft.ok_or(Exceptions::IllegalStateException(None))?;
newBottomLeft = bottomLeft.ok_or(Exceptions::IllegalStateException(None))?;
newTopRight = point(image.getWidth() as f32 - 1.0, newTopLeft.getY());
newBottomRight = point(image.getWidth() as f32 - 1.0, newBottomLeft.getY());
newTopRight = point(image.getWidth() as f32 - 1.0, newTopLeft.y);
newBottomRight = point(image.getWidth() as f32 - 1.0, newBottomLeft.y);
} else {
newTopLeft = topLeft.ok_or(Exceptions::IllegalStateException(None))?;
newTopRight = topRight.ok_or(Exceptions::IllegalStateException(None))?;
@@ -74,10 +74,10 @@ impl BoundingBox {
Ok(BoundingBox {
image,
minX: newTopLeft.getX().min(newBottomLeft.getX()) as u32,
maxX: newTopRight.getX().max(newBottomRight.getX()) as u32,
minY: newTopLeft.getY().min(newTopRight.getY()) as u32,
maxY: newBottomLeft.getY().max(newBottomRight.getY()) as u32,
minX: newTopLeft.x.min(newBottomLeft.x) as u32,
maxX: newTopRight.x.max(newBottomRight.x) as u32,
minY: newTopLeft.y.min(newTopRight.y) as u32,
maxY: newBottomLeft.y.max(newBottomRight.y) as u32,
topLeft: newTopLeft,
bottomLeft: newBottomLeft,
topRight: newTopRight,
@@ -140,11 +140,11 @@ impl BoundingBox {
if missingStartRows > 0 {
let top = if isLeft { self.topLeft } else { self.topRight };
let mut newMinY = top.getY() - missingStartRows as f32;
let mut newMinY = top.y - missingStartRows as f32;
if newMinY < 0.0 {
newMinY = 0.0;
}
let newTop = point(top.getX(), newMinY);
let newTop = point(top.x, newMinY);
if isLeft {
newTopLeft = newTop;
} else {
@@ -158,11 +158,11 @@ impl BoundingBox {
} else {
self.bottomRight
};
let mut newMaxY = bottom.getY() as u32 + missingEndRows;
let mut newMaxY = bottom.y as u32 + missingEndRows;
if newMaxY >= self.image.getHeight() {
newMaxY = self.image.getHeight() - 1;
}
let newBottom = point(bottom.getX(), newMaxY as f32);
let newBottom = point(bottom.x, newMaxY as f32);
if isLeft {
newBottomLeft = newBottom;
} else {

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
use crate::{pdf417::pdf_417_common, ResultPoint};
use crate::pdf417::pdf_417_common;
use super::{
BarcodeMetadata, BarcodeValue, Codeword, DetectionRXingResultColumn,
@@ -63,8 +63,8 @@ impl DetectionRXingResultRowIndicatorColumn for DetectionRXingResultColumn {
boundingBox.getBottomRight()
};
let firstRow = self.imageRowToCodewordIndex(top.getY() as u32);
let lastRow = self.imageRowToCodewordIndex(bottom.getY() as u32);
let firstRow = self.imageRowToCodewordIndex(top.y as u32);
let lastRow = self.imageRowToCodewordIndex(bottom.y as u32);
// We need to be careful using the average row height. Barcode could be skewed so that we have smaller and
// taller rows
let averageRowHeight: f64 =
@@ -263,8 +263,8 @@ fn adjustIncompleteIndicatorColumnRowNumbers(
} else {
boundingBox.getBottomRight()
};
let firstRow = col.imageRowToCodewordIndex(top.getY() as u32);
let lastRow = col.imageRowToCodewordIndex(bottom.getY() as u32);
let firstRow = col.imageRowToCodewordIndex(top.y as u32);
let lastRow = col.imageRowToCodewordIndex(bottom.y as u32);
let averageRowHeight: f64 =
(lastRow as f64 - firstRow as f64) / barcodeMetadata.getRowCount() as f64;
let codewords = col.getCodewordsMut();

View File

@@ -19,7 +19,7 @@ use std::rc::Rc;
use crate::{
common::{BitMatrix, DecoderRXingResult, Result},
pdf417::pdf_417_common,
Exceptions, Point, ResultPoint,
Exceptions, Point,
};
use super::{
@@ -368,8 +368,8 @@ fn getRowIndicatorColumn<'a>(
for i in 0..2 {
// for (int i = 0; i < 2; i++) {
let increment: i32 = if i == 0 { 1 } else { -1 };
let mut startColumn: u32 = startPoint.getX() as u32;
let mut imageRow: i32 = startPoint.getY() as i32;
let mut startColumn: u32 = startPoint.x as u32;
let mut imageRow: i32 = startPoint.y as i32;
while imageRow <= boundingBox.getMaxY() as i32 && imageRow >= boundingBox.getMinY() as i32 {
// for (int imageRow = (int) startPoint.getY(); imageRow <= boundingBox.getMaxY() &&
// imageRow >= boundingBox.getMinY(); imageRow += increment) {

View File

@@ -16,7 +16,7 @@
use crate::{
common::{BitMatrix, Result},
point, BinaryBitmap, DecodingHintDictionary, Exceptions, Point, ResultPoint,
point, BinaryBitmap, DecodingHintDictionary, Exceptions, Point,
};
use std::borrow::Cow;
@@ -137,10 +137,10 @@ pub fn detect(multiple: bool, bitMatrix: &BitMatrix) -> Option<Vec<[Option<Point
column = 0;
for barcodeCoordinate in &barcodeCoordinates {
if let Some(coord_1) = barcodeCoordinate[1] {
row = row.max(coord_1.getY() as u32);
row = row.max(coord_1.y as u32);
}
if let Some(coord_3) = barcodeCoordinate[3] {
row = row.max(coord_3.getY() as u32);
row = row.max(coord_3.y as u32);
}
}
row += ROW_STEP;
@@ -154,11 +154,11 @@ pub fn detect(multiple: bool, bitMatrix: &BitMatrix) -> Option<Vec<[Option<Point
// if we didn't find a right row indicator column, then continue the search for the next barcode after the
// start pattern of the barcode just found.
if let Some(vert_2) = vertices[2] {
column = vert_2.getX() as u32;
row = vert_2.getY() as u32;
column = vert_2.x as u32;
row = vert_2.y as u32;
} else {
column = vertices[4].as_ref().unwrap().getX() as u32;
row = vertices[4].as_ref().unwrap().getY() as u32;
column = vertices[4].as_ref().unwrap().x as u32;
row = vertices[4].as_ref().unwrap().y as u32;
}
}
Some(barcodeCoordinates)
@@ -193,8 +193,8 @@ fn findVertices(matrix: &BitMatrix, startRow: u32, startColumn: u32) -> Option<[
);
if let Some(result_4) = result[4] {
startColumn = result_4.getX() as u32;
startRow = result_4.getY() as u32;
startColumn = result_4.x as u32;
startRow = result_4.y as u32;
}
copyToRXingResult(
&mut result,
@@ -258,10 +258,7 @@ fn findRowsWithPattern(
// Last row of the current symbol that contains pattern
if found {
let mut skippedRowCount = 0;
let mut previousRowLoc = [
result[0].as_ref()?.getX() as u32,
result[1].as_ref()?.getX() as u32,
];
let mut previousRowLoc = [result[0].as_ref()?.x as u32, result[1].as_ref()?.x as u32];
while stopRow < height {
if let Some(loc) = findGuardPattern(
matrix,

View File

@@ -19,7 +19,7 @@ use std::collections::HashMap;
use crate::{
common::Result, multi::MultipleBarcodeReader, BarcodeFormat, BinaryBitmap,
DecodingHintDictionary, Exceptions, Point, RXingResult, RXingResultMetadataType,
RXingResultMetadataValue, Reader, ResultPoint,
RXingResultMetadataValue, Reader,
};
use super::{
@@ -153,7 +153,7 @@ impl PDF417Reader {
fn getMaxWidth(p1: &Option<Point>, p2: &Option<Point>) -> u64 {
if let (Some(p1), Some(p2)) = (p1, p2) {
(p1.getX() - p2.getX()).abs() as u64
(p1.x - p2.x).abs() as u64
} else {
0
}
@@ -161,7 +161,7 @@ impl PDF417Reader {
fn getMinWidth(p1: &Option<Point>, p2: &Option<Point>) -> u64 {
if let (Some(p1), Some(p2)) = (p1, p2) {
(p1.getX() - p2.getX()).abs() as u64
(p1.x - p2.x).abs() as u64
} else {
u32::MAX as u64
}