mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 12:22:34 +00:00
move all Result to RXingResult
This commit is contained in:
@@ -83,10 +83,10 @@ public enum DecodeHintType {
|
||||
RETURN_CODABAR_START_END(Void.class),
|
||||
|
||||
/**
|
||||
* The caller needs to be notified via callback when a possible {@link ResultPoint}
|
||||
* is found. Maps to a {@link ResultPointCallback}.
|
||||
* The caller needs to be notified via callback when a possible {@link RXingResultPoint}
|
||||
* is found. Maps to a {@link RXingResultPointCallback}.
|
||||
*/
|
||||
NEED_RESULT_POINT_CALLBACK(ResultPointCallback.class),
|
||||
NEED_RESULT_POINT_CALLBACK(RXingResultPointCallback.class),
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,7 +52,7 @@ public final class MultiFormatReader implements Reader {
|
||||
* @throws NotFoundException Any errors which occurred
|
||||
*/
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image) throws NotFoundException {
|
||||
public RXingResult decode(BinaryBitmap image) throws NotFoundException {
|
||||
setHints(null);
|
||||
return decodeInternal(image);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public final class MultiFormatReader implements Reader {
|
||||
* @throws NotFoundException Any errors which occurred
|
||||
*/
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
public RXingResult decode(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
setHints(hints);
|
||||
return decodeInternal(image);
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public final class MultiFormatReader implements Reader {
|
||||
* @return The contents of the image
|
||||
* @throws NotFoundException Any errors which occurred
|
||||
*/
|
||||
public Result decodeWithState(BinaryBitmap image) throws NotFoundException {
|
||||
public RXingResult decodeWithState(BinaryBitmap image) throws NotFoundException {
|
||||
// Make sure to set up the default state so we don't crash
|
||||
if (readers == null) {
|
||||
setHints(null);
|
||||
@@ -166,7 +166,7 @@ public final class MultiFormatReader implements Reader {
|
||||
}
|
||||
}
|
||||
|
||||
private Result decodeInternal(BinaryBitmap image) throws NotFoundException {
|
||||
private RXingResult decodeInternal(BinaryBitmap image) throws NotFoundException {
|
||||
if (readers != null) {
|
||||
for (Reader reader : readers) {
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
|
||||
@@ -41,7 +41,7 @@ public interface Reader {
|
||||
* @throws ChecksumException if a potential barcode is found but does not pass its checksum
|
||||
* @throws FormatException if a potential barcode is found but format is invalid
|
||||
*/
|
||||
Result decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException;
|
||||
RXingResult decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException;
|
||||
|
||||
/**
|
||||
* Locates and decodes a barcode in some format within an image. This method also accepts
|
||||
@@ -57,7 +57,7 @@ public interface Reader {
|
||||
* @throws ChecksumException if a potential barcode is found but does not pass its checksum
|
||||
* @throws FormatException if a potential barcode is found but format is invalid
|
||||
*/
|
||||
Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
|
||||
RXingResult decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, ChecksumException, FormatException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,36 +24,36 @@ import java.util.Map;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class Result {
|
||||
public final class RXingResult {
|
||||
|
||||
private final String text;
|
||||
private final byte[] rawBytes;
|
||||
private final int numBits;
|
||||
private ResultPoint[] resultPoints;
|
||||
private RXingResultPoint[] resultPoints;
|
||||
private final BarcodeFormat format;
|
||||
private Map<ResultMetadataType,Object> resultMetadata;
|
||||
private Map<RXingResultMetadataType,Object> resultMetadata;
|
||||
private final long timestamp;
|
||||
|
||||
public Result(String text,
|
||||
public RXingResult(String text,
|
||||
byte[] rawBytes,
|
||||
ResultPoint[] resultPoints,
|
||||
RXingResultPoint[] resultPoints,
|
||||
BarcodeFormat format) {
|
||||
this(text, rawBytes, resultPoints, format, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public Result(String text,
|
||||
public RXingResult(String text,
|
||||
byte[] rawBytes,
|
||||
ResultPoint[] resultPoints,
|
||||
RXingResultPoint[] resultPoints,
|
||||
BarcodeFormat format,
|
||||
long timestamp) {
|
||||
this(text, rawBytes, rawBytes == null ? 0 : 8 * rawBytes.length,
|
||||
resultPoints, format, timestamp);
|
||||
}
|
||||
|
||||
public Result(String text,
|
||||
public RXingResult(String text,
|
||||
byte[] rawBytes,
|
||||
int numBits,
|
||||
ResultPoint[] resultPoints,
|
||||
RXingResultPoint[] resultPoints,
|
||||
BarcodeFormat format,
|
||||
long timestamp) {
|
||||
this.text = text;
|
||||
@@ -92,7 +92,7 @@ public final class Result {
|
||||
* identifying finder patterns or the corners of the barcode. The exact meaning is
|
||||
* specific to the type of barcode that was decoded.
|
||||
*/
|
||||
public ResultPoint[] getResultPoints() {
|
||||
public RXingResultPoint[] getRXingResultPoints() {
|
||||
return resultPoints;
|
||||
}
|
||||
|
||||
@@ -104,22 +104,22 @@ public final class Result {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link Map} mapping {@link ResultMetadataType} keys to values. May be
|
||||
* @return {@link Map} mapping {@link RXingResultMetadataType} keys to values. May be
|
||||
* {@code null}. This contains optional metadata about what was detected about the barcode,
|
||||
* like orientation.
|
||||
*/
|
||||
public Map<ResultMetadataType,Object> getResultMetadata() {
|
||||
public Map<RXingResultMetadataType,Object> getRXingResultMetadata() {
|
||||
return resultMetadata;
|
||||
}
|
||||
|
||||
public void putMetadata(ResultMetadataType type, Object value) {
|
||||
public void putMetadata(RXingResultMetadataType type, Object value) {
|
||||
if (resultMetadata == null) {
|
||||
resultMetadata = new EnumMap<>(ResultMetadataType.class);
|
||||
resultMetadata = new EnumMap<>(RXingResultMetadataType.class);
|
||||
}
|
||||
resultMetadata.put(type, value);
|
||||
}
|
||||
|
||||
public void putAllMetadata(Map<ResultMetadataType,Object> metadata) {
|
||||
public void putAllMetadata(Map<RXingResultMetadataType,Object> metadata) {
|
||||
if (metadata != null) {
|
||||
if (resultMetadata == null) {
|
||||
resultMetadata = metadata;
|
||||
@@ -129,12 +129,12 @@ public final class Result {
|
||||
}
|
||||
}
|
||||
|
||||
public void addResultPoints(ResultPoint[] newPoints) {
|
||||
ResultPoint[] oldPoints = resultPoints;
|
||||
public void addRXingResultPoints(RXingResultPoint[] newPoints) {
|
||||
RXingResultPoint[] oldPoints = resultPoints;
|
||||
if (oldPoints == null) {
|
||||
resultPoints = newPoints;
|
||||
} else if (newPoints != null && newPoints.length > 0) {
|
||||
ResultPoint[] allPoints = new ResultPoint[oldPoints.length + newPoints.length];
|
||||
RXingResultPoint[] allPoints = new RXingResultPoint[oldPoints.length + newPoints.length];
|
||||
System.arraycopy(oldPoints, 0, allPoints, 0, oldPoints.length);
|
||||
System.arraycopy(newPoints, 0, allPoints, oldPoints.length, newPoints.length);
|
||||
resultPoints = allPoints;
|
||||
|
||||
@@ -22,7 +22,7 @@ package com.google.zxing;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public enum ResultMetadataType {
|
||||
public enum RXingResultMetadataType {
|
||||
|
||||
/**
|
||||
* Unspecified, application-specific metadata. Maps to an unspecified {@link Object}.
|
||||
@@ -40,7 +40,7 @@ public enum ResultMetadataType {
|
||||
|
||||
/**
|
||||
* <p>2D barcode formats typically encode text, but allow for a sort of 'byte mode'
|
||||
* which is sometimes used to encode binary data. While {@link Result} makes available
|
||||
* which is sometimes used to encode binary data. While {@link RXingResult} makes available
|
||||
* the complete raw bytes in the barcode for these formats, it does not offer the bytes
|
||||
* from the byte segments alone.</p>
|
||||
*
|
||||
|
||||
@@ -24,12 +24,12 @@ import com.google.zxing.common.detector.MathUtils;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public class ResultPoint {
|
||||
public class RXingResultPoint {
|
||||
|
||||
private final float x;
|
||||
private final float y;
|
||||
|
||||
public ResultPoint(float x, float y) {
|
||||
public RXingResultPoint(float x, float y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
@@ -44,8 +44,8 @@ public class ResultPoint {
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object other) {
|
||||
if (other instanceof ResultPoint) {
|
||||
ResultPoint otherPoint = (ResultPoint) other;
|
||||
if (other instanceof RXingResultPoint) {
|
||||
RXingResultPoint otherPoint = (RXingResultPoint) other;
|
||||
return x == otherPoint.x && y == otherPoint.y;
|
||||
}
|
||||
return false;
|
||||
@@ -62,21 +62,21 @@ public class ResultPoint {
|
||||
}
|
||||
|
||||
/**
|
||||
* Orders an array of three ResultPoints in an order [A,B,C] such that AB is less than AC
|
||||
* Orders an array of three RXingResultPoints in an order [A,B,C] such that AB is less than AC
|
||||
* and BC is less than AC, and the angle between BC and BA is less than 180 degrees.
|
||||
*
|
||||
* @param patterns array of three {@code ResultPoint} to order
|
||||
* @param patterns array of three {@code RXingResultPoint} to order
|
||||
*/
|
||||
public static void orderBestPatterns(ResultPoint[] patterns) {
|
||||
public static void orderBestPatterns(RXingResultPoint[] patterns) {
|
||||
|
||||
// Find distances between pattern centers
|
||||
float zeroOneDistance = distance(patterns[0], patterns[1]);
|
||||
float oneTwoDistance = distance(patterns[1], patterns[2]);
|
||||
float zeroTwoDistance = distance(patterns[0], patterns[2]);
|
||||
|
||||
ResultPoint pointA;
|
||||
ResultPoint pointB;
|
||||
ResultPoint pointC;
|
||||
RXingResultPoint pointA;
|
||||
RXingResultPoint pointB;
|
||||
RXingResultPoint pointC;
|
||||
// Assume one closest to other two is B; A and C will just be guesses at first
|
||||
if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) {
|
||||
pointB = patterns[0];
|
||||
@@ -97,7 +97,7 @@ public class ResultPoint {
|
||||
// we want for A, B, C. If it's negative, then we've got it flipped around and
|
||||
// should swap A and C.
|
||||
if (crossProductZ(pointA, pointB, pointC) < 0.0f) {
|
||||
ResultPoint temp = pointA;
|
||||
RXingResultPoint temp = pointA;
|
||||
pointA = pointC;
|
||||
pointC = temp;
|
||||
}
|
||||
@@ -112,16 +112,16 @@ public class ResultPoint {
|
||||
* @param pattern2 second pattern
|
||||
* @return distance between two points
|
||||
*/
|
||||
public static float distance(ResultPoint pattern1, ResultPoint pattern2) {
|
||||
public static float distance(RXingResultPoint pattern1, RXingResultPoint pattern2) {
|
||||
return MathUtils.distance(pattern1.x, pattern1.y, pattern2.x, pattern2.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the z component of the cross product between vectors BC and BA.
|
||||
*/
|
||||
private static float crossProductZ(ResultPoint pointA,
|
||||
ResultPoint pointB,
|
||||
ResultPoint pointC) {
|
||||
private static float crossProductZ(RXingResultPoint pointA,
|
||||
RXingResultPoint pointB,
|
||||
RXingResultPoint pointC) {
|
||||
float bX = pointB.x;
|
||||
float bY = pointB.y;
|
||||
return ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX));
|
||||
|
||||
@@ -22,8 +22,8 @@ package com.google.zxing;
|
||||
*
|
||||
* @see DecodeHintType#NEED_RESULT_POINT_CALLBACK
|
||||
*/
|
||||
public interface ResultPointCallback {
|
||||
public interface RXingResultPointCallback {
|
||||
|
||||
void foundPossibleResultPoint(ResultPoint point);
|
||||
void foundPossibleRXingResultPoint(RXingResultPoint point);
|
||||
|
||||
}
|
||||
|
||||
@@ -16,24 +16,24 @@
|
||||
|
||||
package com.google.zxing.aztec;
|
||||
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.common.DetectorResult;
|
||||
import com.google.zxing.common.DetectorRXingResult;
|
||||
|
||||
/**
|
||||
* <p>Extends {@link DetectorResult} with more information specific to the Aztec format,
|
||||
* <p>Extends {@link DetectorRXingResult} with more information specific to the Aztec format,
|
||||
* like the number of layers and whether it's compact.</p>
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class AztecDetectorResult extends DetectorResult {
|
||||
public final class AztecDetectorRXingResult extends DetectorRXingResult {
|
||||
|
||||
private final boolean compact;
|
||||
private final int nbDatablocks;
|
||||
private final int nbLayers;
|
||||
|
||||
public AztecDetectorResult(BitMatrix bits,
|
||||
ResultPoint[] points,
|
||||
public AztecDetectorRXingResult(BitMatrix bits,
|
||||
RXingResultPoint[] points,
|
||||
boolean compact,
|
||||
int nbDatablocks,
|
||||
int nbLayers) {
|
||||
|
||||
@@ -22,13 +22,13 @@ import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Reader;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.ResultPointCallback;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.RXingResultPointCallback;
|
||||
import com.google.zxing.aztec.decoder.Decoder;
|
||||
import com.google.zxing.aztec.detector.Detector;
|
||||
import com.google.zxing.common.DecoderResult;
|
||||
import com.google.zxing.common.DecoderRXingResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -48,33 +48,33 @@ public final class AztecReader implements Reader {
|
||||
* @throws FormatException if a Data Matrix code cannot be decoded
|
||||
*/
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image) throws NotFoundException, FormatException {
|
||||
public RXingResult decode(BinaryBitmap image) throws NotFoundException, FormatException {
|
||||
return decode(image, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
|
||||
public RXingResult decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, FormatException {
|
||||
|
||||
NotFoundException notFoundException = null;
|
||||
FormatException formatException = null;
|
||||
Detector detector = new Detector(image.getBlackMatrix());
|
||||
ResultPoint[] points = null;
|
||||
DecoderResult decoderResult = null;
|
||||
RXingResultPoint[] points = null;
|
||||
DecoderRXingResult decoderRXingResult = null;
|
||||
try {
|
||||
AztecDetectorResult detectorResult = detector.detect(false);
|
||||
points = detectorResult.getPoints();
|
||||
decoderResult = new Decoder().decode(detectorResult);
|
||||
AztecDetectorRXingResult detectorRXingResult = detector.detect(false);
|
||||
points = detectorRXingResult.getPoints();
|
||||
decoderRXingResult = new Decoder().decode(detectorRXingResult);
|
||||
} catch (NotFoundException e) {
|
||||
notFoundException = e;
|
||||
} catch (FormatException e) {
|
||||
formatException = e;
|
||||
}
|
||||
if (decoderResult == null) {
|
||||
if (decoderRXingResult == null) {
|
||||
try {
|
||||
AztecDetectorResult detectorResult = detector.detect(true);
|
||||
points = detectorResult.getPoints();
|
||||
decoderResult = new Decoder().decode(detectorResult);
|
||||
AztecDetectorRXingResult detectorRXingResult = detector.detect(true);
|
||||
points = detectorRXingResult.getPoints();
|
||||
decoderRXingResult = new Decoder().decode(detectorRXingResult);
|
||||
} catch (NotFoundException | FormatException e) {
|
||||
if (notFoundException != null) {
|
||||
throw notFoundException;
|
||||
@@ -87,30 +87,30 @@ public final class AztecReader implements Reader {
|
||||
}
|
||||
|
||||
if (hints != null) {
|
||||
ResultPointCallback rpcb = (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
|
||||
RXingResultPointCallback rpcb = (RXingResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
|
||||
if (rpcb != null) {
|
||||
for (ResultPoint point : points) {
|
||||
rpcb.foundPossibleResultPoint(point);
|
||||
for (RXingResultPoint point : points) {
|
||||
rpcb.foundPossibleRXingResultPoint(point);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Result result = new Result(decoderResult.getText(),
|
||||
decoderResult.getRawBytes(),
|
||||
decoderResult.getNumBits(),
|
||||
RXingResult result = new RXingResult(decoderRXingResult.getText(),
|
||||
decoderRXingResult.getRawBytes(),
|
||||
decoderRXingResult.getNumBits(),
|
||||
points,
|
||||
BarcodeFormat.AZTEC,
|
||||
System.currentTimeMillis());
|
||||
|
||||
List<byte[]> byteSegments = decoderResult.getByteSegments();
|
||||
List<byte[]> byteSegments = decoderRXingResult.getByteSegments();
|
||||
if (byteSegments != null) {
|
||||
result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments);
|
||||
result.putMetadata(RXingResultMetadataType.BYTE_SEGMENTS, byteSegments);
|
||||
}
|
||||
String ecLevel = decoderResult.getECLevel();
|
||||
String ecLevel = decoderRXingResult.getECLevel();
|
||||
if (ecLevel != null) {
|
||||
result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
|
||||
result.putMetadata(RXingResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
|
||||
}
|
||||
result.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]z" + decoderResult.getSymbologyModifier());
|
||||
result.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]z" + decoderRXingResult.getSymbologyModifier());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -62,10 +62,10 @@ public final class AztecWriter implements Writer {
|
||||
throw new IllegalArgumentException("Can only encode AZTEC, but got " + format);
|
||||
}
|
||||
AztecCode aztec = Encoder.encode(contents, eccPercent, layers, charset);
|
||||
return renderResult(aztec, width, height);
|
||||
return renderRXingResult(aztec, width, height);
|
||||
}
|
||||
|
||||
private static BitMatrix renderResult(AztecCode code, int width, int height) {
|
||||
private static BitMatrix renderRXingResult(AztecCode code, int width, int height) {
|
||||
BitMatrix input = code.getMatrix();
|
||||
if (input == null) {
|
||||
throw new IllegalStateException();
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
package com.google.zxing.aztec.decoder;
|
||||
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.aztec.AztecDetectorResult;
|
||||
import com.google.zxing.aztec.AztecDetectorRXingResult;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.common.CharacterSetECI;
|
||||
import com.google.zxing.common.DecoderResult;
|
||||
import com.google.zxing.common.DecoderRXingResult;
|
||||
import com.google.zxing.common.reedsolomon.GenericGF;
|
||||
import com.google.zxing.common.reedsolomon.ReedSolomonDecoder;
|
||||
import com.google.zxing.common.reedsolomon.ReedSolomonException;
|
||||
@@ -75,19 +75,19 @@ public final class Decoder {
|
||||
|
||||
private static final Charset DEFAULT_ENCODING = StandardCharsets.ISO_8859_1;
|
||||
|
||||
private AztecDetectorResult ddata;
|
||||
private AztecDetectorRXingResult ddata;
|
||||
|
||||
public DecoderResult decode(AztecDetectorResult detectorResult) throws FormatException {
|
||||
ddata = detectorResult;
|
||||
BitMatrix matrix = detectorResult.getBits();
|
||||
public DecoderRXingResult decode(AztecDetectorRXingResult detectorRXingResult) throws FormatException {
|
||||
ddata = detectorRXingResult;
|
||||
BitMatrix matrix = detectorRXingResult.getBits();
|
||||
boolean[] rawbits = extractBits(matrix);
|
||||
CorrectedBitsResult correctedBits = correctBits(rawbits);
|
||||
CorrectedBitsRXingResult correctedBits = correctBits(rawbits);
|
||||
byte[] rawBytes = convertBoolArrayToByteArray(correctedBits.correctBits);
|
||||
String result = getEncodedData(correctedBits.correctBits);
|
||||
DecoderResult decoderResult =
|
||||
new DecoderResult(rawBytes, result, null, String.format("%d%%", correctedBits.ecLevel));
|
||||
decoderResult.setNumBits(correctedBits.correctBits.length);
|
||||
return decoderResult;
|
||||
DecoderRXingResult decoderRXingResult =
|
||||
new DecoderRXingResult(rawBytes, result, null, String.format("%d%%", correctedBits.ecLevel));
|
||||
decoderRXingResult.setNumBits(correctedBits.correctBits.length);
|
||||
return decoderRXingResult;
|
||||
}
|
||||
|
||||
// This method is used for testing the high-level encoder
|
||||
@@ -262,11 +262,11 @@ public final class Decoder {
|
||||
}
|
||||
}
|
||||
|
||||
static final class CorrectedBitsResult {
|
||||
static final class CorrectedBitsRXingResult {
|
||||
private final boolean[] correctBits;
|
||||
private final int ecLevel;
|
||||
|
||||
CorrectedBitsResult(boolean[] correctBits, int ecLevel) {
|
||||
CorrectedBitsRXingResult(boolean[] correctBits, int ecLevel) {
|
||||
this.correctBits = correctBits;
|
||||
this.ecLevel = ecLevel;
|
||||
}
|
||||
@@ -278,7 +278,7 @@ public final class Decoder {
|
||||
* @return the corrected array
|
||||
* @throws FormatException if the input contains too many errors
|
||||
*/
|
||||
private CorrectedBitsResult correctBits(boolean[] rawbits) throws FormatException {
|
||||
private CorrectedBitsRXingResult correctBits(boolean[] rawbits) throws FormatException {
|
||||
GenericGF gf;
|
||||
int codewordSize;
|
||||
|
||||
@@ -343,7 +343,7 @@ public final class Decoder {
|
||||
}
|
||||
}
|
||||
|
||||
return new CorrectedBitsResult(correctedBits, 100 * (numCodewords - numDataCodewords) / numCodewords);
|
||||
return new CorrectedBitsRXingResult(correctedBits, 100 * (numCodewords - numDataCodewords) / numCodewords);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package com.google.zxing.aztec.detector;
|
||||
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.aztec.AztecDetectorResult;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.aztec.AztecDetectorRXingResult;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.common.GridSampler;
|
||||
import com.google.zxing.common.detector.MathUtils;
|
||||
@@ -55,7 +55,7 @@ public final class Detector {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public AztecDetectorResult detect() throws NotFoundException {
|
||||
public AztecDetectorRXingResult detect() throws NotFoundException {
|
||||
return detect(false);
|
||||
}
|
||||
|
||||
@@ -63,20 +63,20 @@ public final class Detector {
|
||||
* Detects an Aztec Code in an image.
|
||||
*
|
||||
* @param isMirror if true, image is a mirror-image of original
|
||||
* @return {@link AztecDetectorResult} encapsulating results of detecting an Aztec Code
|
||||
* @return {@link AztecDetectorRXingResult} encapsulating results of detecting an Aztec Code
|
||||
* @throws NotFoundException if no Aztec Code can be found
|
||||
*/
|
||||
public AztecDetectorResult detect(boolean isMirror) throws NotFoundException {
|
||||
public AztecDetectorRXingResult detect(boolean isMirror) throws NotFoundException {
|
||||
|
||||
// 1. Get the center of the aztec matrix
|
||||
Point pCenter = getMatrixCenter();
|
||||
|
||||
// 2. Get the center points of the four diagonal points just outside the bull's eye
|
||||
// [topRight, bottomRight, bottomLeft, topLeft]
|
||||
ResultPoint[] bullsEyeCorners = getBullsEyeCorners(pCenter);
|
||||
RXingResultPoint[] bullsEyeCorners = getBullsEyeCorners(pCenter);
|
||||
|
||||
if (isMirror) {
|
||||
ResultPoint temp = bullsEyeCorners[0];
|
||||
RXingResultPoint temp = bullsEyeCorners[0];
|
||||
bullsEyeCorners[0] = bullsEyeCorners[2];
|
||||
bullsEyeCorners[2] = temp;
|
||||
}
|
||||
@@ -92,9 +92,9 @@ public final class Detector {
|
||||
bullsEyeCorners[(shift + 3) % 4]);
|
||||
|
||||
// 5. Get the corners of the matrix.
|
||||
ResultPoint[] corners = getMatrixCornerPoints(bullsEyeCorners);
|
||||
RXingResultPoint[] corners = getMatrixCornerPoints(bullsEyeCorners);
|
||||
|
||||
return new AztecDetectorResult(bits, corners, compact, nbDataBlocks, nbLayers);
|
||||
return new AztecDetectorRXingResult(bits, corners, compact, nbDataBlocks, nbLayers);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,7 +103,7 @@ public final class Detector {
|
||||
* @param bullsEyeCorners the array of bull's eye corners
|
||||
* @throws NotFoundException in case of too many errors or invalid parameters
|
||||
*/
|
||||
private void extractParameters(ResultPoint[] bullsEyeCorners) throws NotFoundException {
|
||||
private void extractParameters(RXingResultPoint[] bullsEyeCorners) throws NotFoundException {
|
||||
if (!isValid(bullsEyeCorners[0]) || !isValid(bullsEyeCorners[1]) ||
|
||||
!isValid(bullsEyeCorners[2]) || !isValid(bullsEyeCorners[3])) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
@@ -232,7 +232,7 @@ public final class Detector {
|
||||
* @return The corners of the bull-eye
|
||||
* @throws NotFoundException If no valid bull-eye can be found
|
||||
*/
|
||||
private ResultPoint[] getBullsEyeCorners(Point pCenter) throws NotFoundException {
|
||||
private RXingResultPoint[] getBullsEyeCorners(Point pCenter) throws NotFoundException {
|
||||
|
||||
Point pina = pCenter;
|
||||
Point pinb = pCenter;
|
||||
@@ -274,14 +274,14 @@ public final class Detector {
|
||||
|
||||
// Expand the square by .5 pixel in each direction so that we're on the border
|
||||
// between the white square and the black square
|
||||
ResultPoint pinax = new ResultPoint(pina.getX() + 0.5f, pina.getY() - 0.5f);
|
||||
ResultPoint pinbx = new ResultPoint(pinb.getX() + 0.5f, pinb.getY() + 0.5f);
|
||||
ResultPoint pincx = new ResultPoint(pinc.getX() - 0.5f, pinc.getY() + 0.5f);
|
||||
ResultPoint pindx = new ResultPoint(pind.getX() - 0.5f, pind.getY() - 0.5f);
|
||||
RXingResultPoint pinax = new RXingResultPoint(pina.getX() + 0.5f, pina.getY() - 0.5f);
|
||||
RXingResultPoint pinbx = new RXingResultPoint(pinb.getX() + 0.5f, pinb.getY() + 0.5f);
|
||||
RXingResultPoint pincx = new RXingResultPoint(pinc.getX() - 0.5f, pinc.getY() + 0.5f);
|
||||
RXingResultPoint pindx = new RXingResultPoint(pind.getX() - 0.5f, pind.getY() - 0.5f);
|
||||
|
||||
// Expand the square so that its corners are the centers of the points
|
||||
// just outside the bull's eye.
|
||||
return expandSquare(new ResultPoint[]{pinax, pinbx, pincx, pindx},
|
||||
return expandSquare(new RXingResultPoint[]{pinax, pinbx, pincx, pindx},
|
||||
2 * nbCenterLayers - 3,
|
||||
2 * nbCenterLayers);
|
||||
}
|
||||
@@ -293,15 +293,15 @@ public final class Detector {
|
||||
*/
|
||||
private Point getMatrixCenter() {
|
||||
|
||||
ResultPoint pointA;
|
||||
ResultPoint pointB;
|
||||
ResultPoint pointC;
|
||||
ResultPoint pointD;
|
||||
RXingResultPoint pointA;
|
||||
RXingResultPoint pointB;
|
||||
RXingResultPoint pointC;
|
||||
RXingResultPoint pointD;
|
||||
|
||||
//Get a white rectangle that can be the border of the matrix in center bull's eye or
|
||||
try {
|
||||
|
||||
ResultPoint[] cornerPoints = new WhiteRectangleDetector(image).detect();
|
||||
RXingResultPoint[] cornerPoints = new WhiteRectangleDetector(image).detect();
|
||||
pointA = cornerPoints[0];
|
||||
pointB = cornerPoints[1];
|
||||
pointC = cornerPoints[2];
|
||||
@@ -313,10 +313,10 @@ public final class Detector {
|
||||
// In that case, surely in the bull's eye, we try to expand the rectangle.
|
||||
int cx = image.getWidth() / 2;
|
||||
int cy = image.getHeight() / 2;
|
||||
pointA = getFirstDifferent(new Point(cx + 7, cy - 7), false, 1, -1).toResultPoint();
|
||||
pointB = getFirstDifferent(new Point(cx + 7, cy + 7), false, 1, 1).toResultPoint();
|
||||
pointC = getFirstDifferent(new Point(cx - 7, cy + 7), false, -1, 1).toResultPoint();
|
||||
pointD = getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toResultPoint();
|
||||
pointA = getFirstDifferent(new Point(cx + 7, cy - 7), false, 1, -1).toRXingResultPoint();
|
||||
pointB = getFirstDifferent(new Point(cx + 7, cy + 7), false, 1, 1).toRXingResultPoint();
|
||||
pointC = getFirstDifferent(new Point(cx - 7, cy + 7), false, -1, 1).toRXingResultPoint();
|
||||
pointD = getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toRXingResultPoint();
|
||||
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ public final class Detector {
|
||||
// This will ensure that we end up with a white rectangle in center bull's eye
|
||||
// in order to compute a more accurate center.
|
||||
try {
|
||||
ResultPoint[] cornerPoints = new WhiteRectangleDetector(image, 15, cx, cy).detect();
|
||||
RXingResultPoint[] cornerPoints = new WhiteRectangleDetector(image, 15, cx, cy).detect();
|
||||
pointA = cornerPoints[0];
|
||||
pointB = cornerPoints[1];
|
||||
pointC = cornerPoints[2];
|
||||
@@ -336,10 +336,10 @@ public final class Detector {
|
||||
} catch (NotFoundException e) {
|
||||
// This exception can be in case the initial rectangle is white
|
||||
// In that case we try to expand the rectangle.
|
||||
pointA = getFirstDifferent(new Point(cx + 7, cy - 7), false, 1, -1).toResultPoint();
|
||||
pointB = getFirstDifferent(new Point(cx + 7, cy + 7), false, 1, 1).toResultPoint();
|
||||
pointC = getFirstDifferent(new Point(cx - 7, cy + 7), false, -1, 1).toResultPoint();
|
||||
pointD = getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toResultPoint();
|
||||
pointA = getFirstDifferent(new Point(cx + 7, cy - 7), false, 1, -1).toRXingResultPoint();
|
||||
pointB = getFirstDifferent(new Point(cx + 7, cy + 7), false, 1, 1).toRXingResultPoint();
|
||||
pointC = getFirstDifferent(new Point(cx - 7, cy + 7), false, -1, 1).toRXingResultPoint();
|
||||
pointD = getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toRXingResultPoint();
|
||||
}
|
||||
|
||||
// Recompute the center of the rectangle
|
||||
@@ -355,7 +355,7 @@ public final class Detector {
|
||||
* @param bullsEyeCorners the array of bull's eye corners
|
||||
* @return the array of aztec code corners
|
||||
*/
|
||||
private ResultPoint[] getMatrixCornerPoints(ResultPoint[] bullsEyeCorners) {
|
||||
private RXingResultPoint[] getMatrixCornerPoints(RXingResultPoint[] bullsEyeCorners) {
|
||||
return expandSquare(bullsEyeCorners, 2 * nbCenterLayers, getDimension());
|
||||
}
|
||||
|
||||
@@ -365,10 +365,10 @@ public final class Detector {
|
||||
* diagonal just outside the bull's eye.
|
||||
*/
|
||||
private BitMatrix sampleGrid(BitMatrix image,
|
||||
ResultPoint topLeft,
|
||||
ResultPoint topRight,
|
||||
ResultPoint bottomRight,
|
||||
ResultPoint bottomLeft) throws NotFoundException {
|
||||
RXingResultPoint topLeft,
|
||||
RXingResultPoint topRight,
|
||||
RXingResultPoint bottomRight,
|
||||
RXingResultPoint bottomLeft) throws NotFoundException {
|
||||
|
||||
GridSampler sampler = GridSampler.getInstance();
|
||||
int dimension = getDimension();
|
||||
@@ -397,7 +397,7 @@ public final class Detector {
|
||||
* @param size number of bits
|
||||
* @return the array of bits as an int (first bit is high-order bit of result)
|
||||
*/
|
||||
private int sampleLine(ResultPoint p1, ResultPoint p2, int size) {
|
||||
private int sampleLine(RXingResultPoint p1, RXingResultPoint p2, int size) {
|
||||
int result = 0;
|
||||
|
||||
float d = distance(p1, p2);
|
||||
@@ -529,31 +529,31 @@ public final class Detector {
|
||||
* @param newSide the new length of the size of the square in the target bit matrix
|
||||
* @return the corners of the expanded square
|
||||
*/
|
||||
private static ResultPoint[] expandSquare(ResultPoint[] cornerPoints, int oldSide, int newSide) {
|
||||
private static RXingResultPoint[] expandSquare(RXingResultPoint[] cornerPoints, int oldSide, int newSide) {
|
||||
float ratio = newSide / (2.0f * oldSide);
|
||||
float dx = cornerPoints[0].getX() - cornerPoints[2].getX();
|
||||
float dy = cornerPoints[0].getY() - cornerPoints[2].getY();
|
||||
float centerx = (cornerPoints[0].getX() + cornerPoints[2].getX()) / 2.0f;
|
||||
float centery = (cornerPoints[0].getY() + cornerPoints[2].getY()) / 2.0f;
|
||||
|
||||
ResultPoint result0 = new ResultPoint(centerx + ratio * dx, centery + ratio * dy);
|
||||
ResultPoint result2 = new ResultPoint(centerx - ratio * dx, centery - ratio * dy);
|
||||
RXingResultPoint result0 = new RXingResultPoint(centerx + ratio * dx, centery + ratio * dy);
|
||||
RXingResultPoint result2 = new RXingResultPoint(centerx - ratio * dx, centery - ratio * dy);
|
||||
|
||||
dx = cornerPoints[1].getX() - cornerPoints[3].getX();
|
||||
dy = cornerPoints[1].getY() - cornerPoints[3].getY();
|
||||
centerx = (cornerPoints[1].getX() + cornerPoints[3].getX()) / 2.0f;
|
||||
centery = (cornerPoints[1].getY() + cornerPoints[3].getY()) / 2.0f;
|
||||
ResultPoint result1 = new ResultPoint(centerx + ratio * dx, centery + ratio * dy);
|
||||
ResultPoint result3 = new ResultPoint(centerx - ratio * dx, centery - ratio * dy);
|
||||
RXingResultPoint result1 = new RXingResultPoint(centerx + ratio * dx, centery + ratio * dy);
|
||||
RXingResultPoint result3 = new RXingResultPoint(centerx - ratio * dx, centery - ratio * dy);
|
||||
|
||||
return new ResultPoint[]{result0, result1, result2, result3};
|
||||
return new RXingResultPoint[]{result0, result1, result2, result3};
|
||||
}
|
||||
|
||||
private boolean isValid(int x, int y) {
|
||||
return x >= 0 && x < image.getWidth() && y >= 0 && y < image.getHeight();
|
||||
}
|
||||
|
||||
private boolean isValid(ResultPoint point) {
|
||||
private boolean isValid(RXingResultPoint point) {
|
||||
int x = MathUtils.round(point.getX());
|
||||
int y = MathUtils.round(point.getY());
|
||||
return isValid(x, y);
|
||||
@@ -563,7 +563,7 @@ public final class Detector {
|
||||
return MathUtils.distance(a.getX(), a.getY(), b.getX(), b.getY());
|
||||
}
|
||||
|
||||
private static float distance(ResultPoint a, ResultPoint b) {
|
||||
private static float distance(RXingResultPoint a, RXingResultPoint b) {
|
||||
return MathUtils.distance(a.getX(), a.getY(), b.getX(), b.getY());
|
||||
}
|
||||
|
||||
@@ -578,8 +578,8 @@ public final class Detector {
|
||||
private final int x;
|
||||
private final int y;
|
||||
|
||||
ResultPoint toResultPoint() {
|
||||
return new ResultPoint(x, y);
|
||||
RXingResultPoint toRXingResultPoint() {
|
||||
return new RXingResultPoint(x, y);
|
||||
}
|
||||
|
||||
Point(int x, int y) {
|
||||
|
||||
@@ -26,7 +26,7 @@ package com.google.zxing.client.result;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
abstract class AbstractDoCoMoResultParser extends ResultParser {
|
||||
abstract class AbstractDoCoMoRXingResultParser extends RXingResultParser {
|
||||
|
||||
static String[] matchDoCoMoPrefixedField(String prefix, String rawText) {
|
||||
return matchPrefixedField(prefix, rawText, ';', true);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.zxing.client.result;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -29,10 +29,10 @@ import java.util.List;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class AddressBookAUResultParser extends ResultParser {
|
||||
public final class AddressBookAURXingResultParser extends RXingResultParser {
|
||||
|
||||
@Override
|
||||
public AddressBookParsedResult parse(Result result) {
|
||||
public AddressBookParsedRXingResult parse(RXingResult result) {
|
||||
String rawText = getMassagedText(result);
|
||||
// MEMORY is mandatory; seems like a decent indicator, as does end-of-record separator CR/LF
|
||||
if (!rawText.contains("MEMORY") || !rawText.contains("\r\n")) {
|
||||
@@ -49,7 +49,7 @@ public final class AddressBookAUResultParser extends ResultParser {
|
||||
String note = matchSinglePrefixedField("MEMORY:", rawText, '\r', false);
|
||||
String address = matchSinglePrefixedField("ADD:", rawText, '\r', true);
|
||||
String[] addresses = address == null ? null : new String[] {address};
|
||||
return new AddressBookParsedResult(maybeWrap(name),
|
||||
return new AddressBookParsedRXingResult(maybeWrap(name),
|
||||
null,
|
||||
pronunciation,
|
||||
phoneNumbers,
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.zxing.client.result;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
/**
|
||||
* Implements the "MECARD" address book entry format.
|
||||
@@ -33,10 +33,10 @@ import com.google.zxing.Result;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class AddressBookDoCoMoResultParser extends AbstractDoCoMoResultParser {
|
||||
public final class AddressBookDoCoMoRXingResultParser extends AbstractDoCoMoRXingResultParser {
|
||||
|
||||
@Override
|
||||
public AddressBookParsedResult parse(Result result) {
|
||||
public AddressBookParsedRXingResult parse(RXingResult result) {
|
||||
String rawText = getMassagedText(result);
|
||||
if (!rawText.startsWith("MECARD:")) {
|
||||
return null;
|
||||
@@ -62,7 +62,7 @@ public final class AddressBookDoCoMoResultParser extends AbstractDoCoMoResultPar
|
||||
// honor it when found in the wild.
|
||||
String org = matchSingleDoCoMoPrefixedField("ORG:", rawText, true);
|
||||
|
||||
return new AddressBookParsedResult(maybeWrap(name),
|
||||
return new AddressBookParsedRXingResult(maybeWrap(name),
|
||||
null,
|
||||
pronunciation,
|
||||
phoneNumbers,
|
||||
|
||||
@@ -22,7 +22,7 @@ package com.google.zxing.client.result;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class AddressBookParsedResult extends ParsedResult {
|
||||
public final class AddressBookParsedRXingResult extends ParsedRXingResult {
|
||||
|
||||
private final String[] names;
|
||||
private final String[] nicknames;
|
||||
@@ -41,7 +41,7 @@ public final class AddressBookParsedResult extends ParsedResult {
|
||||
private final String[] urls;
|
||||
private final String[] geo;
|
||||
|
||||
public AddressBookParsedResult(String[] names,
|
||||
public AddressBookParsedRXingResult(String[] names,
|
||||
String[] phoneNumbers,
|
||||
String[] phoneTypes,
|
||||
String[] emails,
|
||||
@@ -66,7 +66,7 @@ public final class AddressBookParsedResult extends ParsedResult {
|
||||
null);
|
||||
}
|
||||
|
||||
public AddressBookParsedResult(String[] names,
|
||||
public AddressBookParsedRXingResult(String[] names,
|
||||
String[] nicknames,
|
||||
String pronunciation,
|
||||
String[] phoneNumbers,
|
||||
@@ -82,7 +82,7 @@ public final class AddressBookParsedResult extends ParsedResult {
|
||||
String title,
|
||||
String[] urls,
|
||||
String[] geo) {
|
||||
super(ParsedResultType.ADDRESSBOOK);
|
||||
super(ParsedRXingResultType.ADDRESSBOOK);
|
||||
if (phoneNumbers != null && phoneTypes != null && phoneNumbers.length != phoneTypes.length) {
|
||||
throw new IllegalArgumentException("Phone numbers and types lengths differ");
|
||||
}
|
||||
@@ -199,7 +199,7 @@ public final class AddressBookParsedResult extends ParsedResult {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayResult() {
|
||||
public String getDisplayRXingResult() {
|
||||
StringBuilder result = new StringBuilder(100);
|
||||
maybeAppend(names, result);
|
||||
maybeAppend(nicknames, result);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.zxing.client.result;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -28,14 +28,14 @@ import java.util.List;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class BizcardResultParser extends AbstractDoCoMoResultParser {
|
||||
public final class BizcardRXingResultParser extends AbstractDoCoMoRXingResultParser {
|
||||
|
||||
// Yes, we extend AbstractDoCoMoResultParser since the format is very much
|
||||
// Yes, we extend AbstractDoCoMoRXingResultParser since the format is very much
|
||||
// like the DoCoMo MECARD format, but this is not technically one of
|
||||
// DoCoMo's proposed formats
|
||||
|
||||
@Override
|
||||
public AddressBookParsedResult parse(Result result) {
|
||||
public AddressBookParsedRXingResult parse(RXingResult result) {
|
||||
String rawText = getMassagedText(result);
|
||||
if (!rawText.startsWith("BIZCARD:")) {
|
||||
return null;
|
||||
@@ -51,7 +51,7 @@ public final class BizcardResultParser extends AbstractDoCoMoResultParser {
|
||||
String phoneNumber3 = matchSingleDoCoMoPrefixedField("F:", rawText, true);
|
||||
String email = matchSingleDoCoMoPrefixedField("E:", rawText, true);
|
||||
|
||||
return new AddressBookParsedResult(maybeWrap(fullName),
|
||||
return new AddressBookParsedRXingResult(maybeWrap(fullName),
|
||||
null,
|
||||
null,
|
||||
buildPhoneNumbers(phoneNumber1, phoneNumber2, phoneNumber3),
|
||||
|
||||
@@ -16,15 +16,15 @@
|
||||
|
||||
package com.google.zxing.client.result;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
/**
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class BookmarkDoCoMoResultParser extends AbstractDoCoMoResultParser {
|
||||
public final class BookmarkDoCoMoRXingResultParser extends AbstractDoCoMoRXingResultParser {
|
||||
|
||||
@Override
|
||||
public URIParsedResult parse(Result result) {
|
||||
public URIParsedRXingResult parse(RXingResult result) {
|
||||
String rawText = result.getText();
|
||||
if (!rawText.startsWith("MEBKM:")) {
|
||||
return null;
|
||||
@@ -35,7 +35,7 @@ public final class BookmarkDoCoMoResultParser extends AbstractDoCoMoResultParser
|
||||
return null;
|
||||
}
|
||||
String uri = rawUri[0];
|
||||
return URIResultParser.isBasicallyValidURI(uri) ? new URIParsedResult(uri, title) : null;
|
||||
return URIRXingResultParser.isBasicallyValidURI(uri) ? new URIParsedRXingResult(uri, title) : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.util.regex.Pattern;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class CalendarParsedResult extends ParsedResult {
|
||||
public final class CalendarParsedRXingResult extends ParsedRXingResult {
|
||||
|
||||
private static final Pattern RFC2445_DURATION =
|
||||
Pattern.compile("P(?:(\\d+)W)?(?:(\\d+)D)?(?:T(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+)S)?)?");
|
||||
@@ -59,7 +59,7 @@ public final class CalendarParsedResult extends ParsedResult {
|
||||
private final double latitude;
|
||||
private final double longitude;
|
||||
|
||||
public CalendarParsedResult(String summary,
|
||||
public CalendarParsedRXingResult(String summary,
|
||||
String startString,
|
||||
String endString,
|
||||
String durationString,
|
||||
@@ -69,7 +69,7 @@ public final class CalendarParsedResult extends ParsedResult {
|
||||
String description,
|
||||
double latitude,
|
||||
double longitude) {
|
||||
super(ParsedResultType.CALENDAR);
|
||||
super(ParsedRXingResultType.CALENDAR);
|
||||
this.summary = summary;
|
||||
|
||||
try {
|
||||
@@ -177,7 +177,7 @@ public final class CalendarParsedResult extends ParsedResult {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayResult() {
|
||||
public String getDisplayRXingResult() {
|
||||
StringBuilder result = new StringBuilder(100);
|
||||
maybeAppend(summary, result);
|
||||
maybeAppend(format(startAllDay, start), result);
|
||||
|
||||
@@ -22,7 +22,7 @@ package com.google.zxing.client.result;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class EmailAddressParsedResult extends ParsedResult {
|
||||
public final class EmailAddressParsedRXingResult extends ParsedRXingResult {
|
||||
|
||||
private final String[] tos;
|
||||
private final String[] ccs;
|
||||
@@ -30,16 +30,16 @@ public final class EmailAddressParsedResult extends ParsedResult {
|
||||
private final String subject;
|
||||
private final String body;
|
||||
|
||||
EmailAddressParsedResult(String to) {
|
||||
EmailAddressParsedRXingResult(String to) {
|
||||
this(new String[] {to}, null, null, null, null);
|
||||
}
|
||||
|
||||
EmailAddressParsedResult(String[] tos,
|
||||
EmailAddressParsedRXingResult(String[] tos,
|
||||
String[] ccs,
|
||||
String[] bccs,
|
||||
String subject,
|
||||
String body) {
|
||||
super(ParsedResultType.EMAIL_ADDRESS);
|
||||
super(ParsedRXingResultType.EMAIL_ADDRESS);
|
||||
this.tos = tos;
|
||||
this.ccs = ccs;
|
||||
this.bccs = bccs;
|
||||
@@ -86,7 +86,7 @@ public final class EmailAddressParsedResult extends ParsedResult {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayResult() {
|
||||
public String getDisplayRXingResult() {
|
||||
StringBuilder result = new StringBuilder(30);
|
||||
maybeAppend(tos, result);
|
||||
maybeAppend(ccs, result);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.zxing.client.result;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -27,12 +27,12 @@ import java.util.regex.Pattern;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class EmailAddressResultParser extends ResultParser {
|
||||
public final class EmailAddressRXingResultParser extends RXingResultParser {
|
||||
|
||||
private static final Pattern COMMA = Pattern.compile(",");
|
||||
|
||||
@Override
|
||||
public EmailAddressParsedResult parse(Result result) {
|
||||
public EmailAddressParsedRXingResult parse(RXingResult result) {
|
||||
String rawText = getMassagedText(result);
|
||||
if (rawText.startsWith("mailto:") || rawText.startsWith("MAILTO:")) {
|
||||
// If it starts with mailto:, assume it is definitely trying to be an email address
|
||||
@@ -73,12 +73,12 @@ public final class EmailAddressResultParser extends ResultParser {
|
||||
subject = nameValues.get("subject");
|
||||
body = nameValues.get("body");
|
||||
}
|
||||
return new EmailAddressParsedResult(tos, ccs, bccs, subject, body);
|
||||
return new EmailAddressParsedRXingResult(tos, ccs, bccs, subject, body);
|
||||
} else {
|
||||
if (!EmailDoCoMoResultParser.isBasicallyValidEmailAddress(rawText)) {
|
||||
if (!EmailDoCoMoRXingResultParser.isBasicallyValidEmailAddress(rawText)) {
|
||||
return null;
|
||||
}
|
||||
return new EmailAddressParsedResult(rawText);
|
||||
return new EmailAddressParsedRXingResult(rawText);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.zxing.client.result;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -27,12 +27,12 @@ import java.util.regex.Pattern;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class EmailDoCoMoResultParser extends AbstractDoCoMoResultParser {
|
||||
public final class EmailDoCoMoRXingResultParser extends AbstractDoCoMoRXingResultParser {
|
||||
|
||||
private static final Pattern ATEXT_ALPHANUMERIC = Pattern.compile("[a-zA-Z0-9@.!#$%&'*+\\-/=?^_`{|}~]+");
|
||||
|
||||
@Override
|
||||
public EmailAddressParsedResult parse(Result result) {
|
||||
public EmailAddressParsedRXingResult parse(RXingResult result) {
|
||||
String rawText = getMassagedText(result);
|
||||
if (!rawText.startsWith("MATMSG:")) {
|
||||
return null;
|
||||
@@ -48,7 +48,7 @@ public final class EmailDoCoMoResultParser extends AbstractDoCoMoResultParser {
|
||||
}
|
||||
String subject = matchSingleDoCoMoPrefixedField("SUB:", rawText, false);
|
||||
String body = matchSingleDoCoMoPrefixedField("BODY:", rawText, false);
|
||||
return new EmailAddressParsedResult(tos, null, null, subject, body);
|
||||
return new EmailAddressParsedRXingResult(tos, null, null, subject, body);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,7 +36,7 @@ import java.util.Objects;
|
||||
* @author Antonio Manuel Benjumea Conde, Servinform, S.A.
|
||||
* @author Agustín Delgado, Servinform, S.A.
|
||||
*/
|
||||
public final class ExpandedProductParsedResult extends ParsedResult {
|
||||
public final class ExpandedProductParsedRXingResult extends ParsedRXingResult {
|
||||
|
||||
public static final String KILOGRAM = "KG";
|
||||
public static final String POUND = "LB";
|
||||
@@ -58,7 +58,7 @@ public final class ExpandedProductParsedResult extends ParsedResult {
|
||||
// For AIS that not exist in this object
|
||||
private final Map<String,String> uncommonAIs;
|
||||
|
||||
public ExpandedProductParsedResult(String rawText,
|
||||
public ExpandedProductParsedRXingResult(String rawText,
|
||||
String productID,
|
||||
String sscc,
|
||||
String lotNumber,
|
||||
@@ -73,7 +73,7 @@ public final class ExpandedProductParsedResult extends ParsedResult {
|
||||
String priceIncrement,
|
||||
String priceCurrency,
|
||||
Map<String,String> uncommonAIs) {
|
||||
super(ParsedResultType.PRODUCT);
|
||||
super(ParsedRXingResultType.PRODUCT);
|
||||
this.rawText = rawText;
|
||||
this.productID = productID;
|
||||
this.sscc = sscc;
|
||||
@@ -93,11 +93,11 @@ public final class ExpandedProductParsedResult extends ParsedResult {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof ExpandedProductParsedResult)) {
|
||||
if (!(o instanceof ExpandedProductParsedRXingResult)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ExpandedProductParsedResult other = (ExpandedProductParsedResult) o;
|
||||
ExpandedProductParsedRXingResult other = (ExpandedProductParsedRXingResult) o;
|
||||
|
||||
return Objects.equals(productID, other.productID)
|
||||
&& Objects.equals(sscc, other.sscc)
|
||||
@@ -193,7 +193,7 @@ public final class ExpandedProductParsedResult extends ParsedResult {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayResult() {
|
||||
public String getDisplayRXingResult() {
|
||||
return String.valueOf(rawText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
/**
|
||||
* Parses strings of digits that represent a RSS Extended code.
|
||||
@@ -38,13 +38,13 @@ import com.google.zxing.Result;
|
||||
* @author Antonio Manuel Benjumea Conde, Servinform, S.A.
|
||||
* @author Agustín Delgado, Servinform, S.A.
|
||||
*/
|
||||
public final class ExpandedProductResultParser extends ResultParser {
|
||||
public final class ExpandedProductRXingResultParser extends RXingResultParser {
|
||||
|
||||
@Override
|
||||
public ExpandedProductParsedResult parse(Result result) {
|
||||
public ExpandedProductParsedRXingResult parse(RXingResult result) {
|
||||
BarcodeFormat format = result.getBarcodeFormat();
|
||||
if (format != BarcodeFormat.RSS_EXPANDED) {
|
||||
// ExtendedProductParsedResult NOT created. Not a RSS Expanded barcode
|
||||
// ExtendedProductParsedRXingResult NOT created. Not a RSS Expanded barcode
|
||||
return null;
|
||||
}
|
||||
String rawText = getMassagedText(result);
|
||||
@@ -70,7 +70,7 @@ public final class ExpandedProductResultParser extends ResultParser {
|
||||
String ai = findAIvalue(i, rawText);
|
||||
if (ai == null) {
|
||||
// Error. Code doesn't match with RSS expanded pattern
|
||||
// ExtendedProductParsedResult NOT created. Not match with RSS Expanded pattern
|
||||
// ExtendedProductParsedRXingResult NOT created. Not match with RSS Expanded pattern
|
||||
return null;
|
||||
}
|
||||
i += ai.length() + 2;
|
||||
@@ -110,7 +110,7 @@ public final class ExpandedProductResultParser extends ResultParser {
|
||||
case "3108":
|
||||
case "3109":
|
||||
weight = value;
|
||||
weightType = ExpandedProductParsedResult.KILOGRAM;
|
||||
weightType = ExpandedProductParsedRXingResult.KILOGRAM;
|
||||
weightIncrement = ai.substring(3);
|
||||
break;
|
||||
case "3200":
|
||||
@@ -124,7 +124,7 @@ public final class ExpandedProductResultParser extends ResultParser {
|
||||
case "3208":
|
||||
case "3209":
|
||||
weight = value;
|
||||
weightType = ExpandedProductParsedResult.POUND;
|
||||
weightType = ExpandedProductParsedRXingResult.POUND;
|
||||
weightIncrement = ai.substring(3);
|
||||
break;
|
||||
case "3920":
|
||||
@@ -141,7 +141,7 @@ public final class ExpandedProductResultParser extends ResultParser {
|
||||
if (value.length() < 4) {
|
||||
// The value must have more of 3 symbols (3 for currency and
|
||||
// 1 at least for the price)
|
||||
// ExtendedProductParsedResult NOT created. Not match with RSS Expanded pattern
|
||||
// ExtendedProductParsedRXingResult NOT created. Not match with RSS Expanded pattern
|
||||
return null;
|
||||
}
|
||||
price = value.substring(3);
|
||||
@@ -155,7 +155,7 @@ public final class ExpandedProductResultParser extends ResultParser {
|
||||
}
|
||||
}
|
||||
|
||||
return new ExpandedProductParsedResult(rawText,
|
||||
return new ExpandedProductParsedRXingResult(rawText,
|
||||
productID,
|
||||
sscc,
|
||||
lotNumber,
|
||||
|
||||
@@ -22,15 +22,15 @@ package com.google.zxing.client.result;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class GeoParsedResult extends ParsedResult {
|
||||
public final class GeoParsedRXingResult extends ParsedRXingResult {
|
||||
|
||||
private final double latitude;
|
||||
private final double longitude;
|
||||
private final double altitude;
|
||||
private final String query;
|
||||
|
||||
GeoParsedResult(double latitude, double longitude, double altitude, String query) {
|
||||
super(ParsedResultType.GEO);
|
||||
GeoParsedRXingResult(double latitude, double longitude, double altitude, String query) {
|
||||
super(ParsedRXingResultType.GEO);
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.altitude = altitude;
|
||||
@@ -83,7 +83,7 @@ public final class GeoParsedResult extends ParsedResult {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayResult() {
|
||||
public String getDisplayRXingResult() {
|
||||
StringBuilder result = new StringBuilder(20);
|
||||
result.append(latitude);
|
||||
result.append(", ");
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.zxing.client.result;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -29,13 +29,13 @@ import java.util.regex.Pattern;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class GeoResultParser extends ResultParser {
|
||||
public final class GeoRXingResultParser extends RXingResultParser {
|
||||
|
||||
private static final Pattern GEO_URL_PATTERN =
|
||||
Pattern.compile("geo:([\\-0-9.]+),([\\-0-9.]+)(?:,([\\-0-9.]+))?(?:\\?(.*))?", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
@Override
|
||||
public GeoParsedResult parse(Result result) {
|
||||
public GeoParsedRXingResult parse(RXingResult result) {
|
||||
CharSequence rawText = getMassagedText(result);
|
||||
Matcher matcher = GEO_URL_PATTERN.matcher(rawText);
|
||||
if (!matcher.matches()) {
|
||||
@@ -67,7 +67,7 @@ public final class GeoResultParser extends ResultParser {
|
||||
} catch (NumberFormatException ignored) {
|
||||
return null;
|
||||
}
|
||||
return new GeoParsedResult(latitude, longitude, altitude, query);
|
||||
return new GeoParsedRXingResult(latitude, longitude, altitude, query);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,12 +21,12 @@ package com.google.zxing.client.result;
|
||||
*
|
||||
* @author jbreiden@google.com (Jeff Breidenbach)
|
||||
*/
|
||||
public final class ISBNParsedResult extends ParsedResult {
|
||||
public final class ISBNParsedRXingResult extends ParsedRXingResult {
|
||||
|
||||
private final String isbn;
|
||||
|
||||
ISBNParsedResult(String isbn) {
|
||||
super(ParsedResultType.ISBN);
|
||||
ISBNParsedRXingResult(String isbn) {
|
||||
super(ParsedRXingResultType.ISBN);
|
||||
this.isbn = isbn;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public final class ISBNParsedResult extends ParsedResult {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayResult() {
|
||||
public String getDisplayRXingResult() {
|
||||
return isbn;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,20 +17,20 @@
|
||||
package com.google.zxing.client.result;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
/**
|
||||
* Parses strings of digits that represent a ISBN.
|
||||
*
|
||||
* @author jbreiden@google.com (Jeff Breidenbach)
|
||||
*/
|
||||
public final class ISBNResultParser extends ResultParser {
|
||||
public final class ISBNRXingResultParser extends RXingResultParser {
|
||||
|
||||
/**
|
||||
* See <a href="http://www.bisg.org/isbn-13/for.dummies.html">ISBN-13 For Dummies</a>
|
||||
*/
|
||||
@Override
|
||||
public ISBNParsedResult parse(Result result) {
|
||||
public ISBNParsedRXingResult parse(RXingResult result) {
|
||||
BarcodeFormat format = result.getBarcodeFormat();
|
||||
if (format != BarcodeFormat.EAN_13) {
|
||||
return null;
|
||||
@@ -44,7 +44,7 @@ public final class ISBNResultParser extends ResultParser {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ISBNParsedResult(rawText);
|
||||
return new ISBNParsedRXingResult(rawText);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.google.zxing.client.result;
|
||||
/**
|
||||
* <p>Abstract class representing the result of decoding a barcode, as more than
|
||||
* a String -- as some type of structured data. This might be a subclass which represents
|
||||
* a URL, or an e-mail address. {@link ResultParser#parseResult(com.google.zxing.Result)} will turn a raw
|
||||
* a URL, or an e-mail address. {@link RXingResultParser#parseRXingResult(com.google.zxing.RXingResult)} will turn a raw
|
||||
* decoded string into the most appropriate type of structured representation.</p>
|
||||
*
|
||||
* <p>Thanks to Jeff Griffin for proposing rewrite of these classes that relies less
|
||||
@@ -27,23 +27,23 @@ package com.google.zxing.client.result;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public abstract class ParsedResult {
|
||||
public abstract class ParsedRXingResult {
|
||||
|
||||
private final ParsedResultType type;
|
||||
private final ParsedRXingResultType type;
|
||||
|
||||
protected ParsedResult(ParsedResultType type) {
|
||||
protected ParsedRXingResult(ParsedRXingResultType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public final ParsedResultType getType() {
|
||||
public final ParsedRXingResultType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public abstract String getDisplayResult();
|
||||
public abstract String getDisplayRXingResult();
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return getDisplayResult();
|
||||
return getDisplayRXingResult();
|
||||
}
|
||||
|
||||
public static void maybeAppend(String value, StringBuilder result) {
|
||||
|
||||
@@ -22,7 +22,7 @@ package com.google.zxing.client.result;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public enum ParsedResultType {
|
||||
public enum ParsedRXingResultType {
|
||||
|
||||
ADDRESSBOOK,
|
||||
EMAIL_ADDRESS,
|
||||
|
||||
@@ -21,17 +21,17 @@ package com.google.zxing.client.result;
|
||||
*
|
||||
* @author dswitkin@google.com (Daniel Switkin)
|
||||
*/
|
||||
public final class ProductParsedResult extends ParsedResult {
|
||||
public final class ProductParsedRXingResult extends ParsedRXingResult {
|
||||
|
||||
private final String productID;
|
||||
private final String normalizedProductID;
|
||||
|
||||
ProductParsedResult(String productID) {
|
||||
ProductParsedRXingResult(String productID) {
|
||||
this(productID, productID);
|
||||
}
|
||||
|
||||
ProductParsedResult(String productID, String normalizedProductID) {
|
||||
super(ParsedResultType.PRODUCT);
|
||||
ProductParsedRXingResult(String productID, String normalizedProductID) {
|
||||
super(ParsedRXingResultType.PRODUCT);
|
||||
this.productID = productID;
|
||||
this.normalizedProductID = normalizedProductID;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public final class ProductParsedResult extends ParsedResult {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayResult() {
|
||||
public String getDisplayRXingResult() {
|
||||
return productID;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.google.zxing.client.result;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.oned.UPCEReader;
|
||||
|
||||
/**
|
||||
@@ -25,11 +25,11 @@ import com.google.zxing.oned.UPCEReader;
|
||||
*
|
||||
* @author dswitkin@google.com (Daniel Switkin)
|
||||
*/
|
||||
public final class ProductResultParser extends ResultParser {
|
||||
public final class ProductRXingResultParser extends RXingResultParser {
|
||||
|
||||
// Treat all UPC and EAN variants as UPCs, in the sense that they are all product barcodes.
|
||||
@Override
|
||||
public ProductParsedResult parse(Result result) {
|
||||
public ProductParsedRXingResult parse(RXingResult result) {
|
||||
BarcodeFormat format = result.getBarcodeFormat();
|
||||
if (!(format == BarcodeFormat.UPC_A || format == BarcodeFormat.UPC_E ||
|
||||
format == BarcodeFormat.EAN_8 || format == BarcodeFormat.EAN_13)) {
|
||||
@@ -49,7 +49,7 @@ public final class ProductResultParser extends ResultParser {
|
||||
normalizedProductID = rawText;
|
||||
}
|
||||
|
||||
return new ProductParsedResult(rawText, normalizedProductID);
|
||||
return new ProductParsedRXingResult(rawText, normalizedProductID);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.zxing.client.result;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
@@ -29,7 +29,7 @@ import java.util.regex.Pattern;
|
||||
/**
|
||||
* <p>Abstract class representing the result of decoding a barcode, as more than
|
||||
* a String -- as some type of structured data. This might be a subclass which represents
|
||||
* a URL, or an e-mail address. {@link #parseResult(Result)} will turn a raw
|
||||
* a URL, or an e-mail address. {@link #parseRXingResult(RXingResult)} will turn a raw
|
||||
* decoded string into the most appropriate type of structured representation.</p>
|
||||
*
|
||||
* <p>Thanks to Jeff Griffin for proposing rewrite of these classes that relies less
|
||||
@@ -37,29 +37,29 @@ import java.util.regex.Pattern;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public abstract class ResultParser {
|
||||
public abstract class RXingResultParser {
|
||||
|
||||
private static final ResultParser[] PARSERS = {
|
||||
new BookmarkDoCoMoResultParser(),
|
||||
new AddressBookDoCoMoResultParser(),
|
||||
new EmailDoCoMoResultParser(),
|
||||
new AddressBookAUResultParser(),
|
||||
new VCardResultParser(),
|
||||
new BizcardResultParser(),
|
||||
new VEventResultParser(),
|
||||
new EmailAddressResultParser(),
|
||||
new SMTPResultParser(),
|
||||
new TelResultParser(),
|
||||
new SMSMMSResultParser(),
|
||||
new SMSTOMMSTOResultParser(),
|
||||
new GeoResultParser(),
|
||||
new WifiResultParser(),
|
||||
new URLTOResultParser(),
|
||||
new URIResultParser(),
|
||||
new ISBNResultParser(),
|
||||
new ProductResultParser(),
|
||||
new ExpandedProductResultParser(),
|
||||
new VINResultParser(),
|
||||
private static final RXingResultParser[] PARSERS = {
|
||||
new BookmarkDoCoMoRXingResultParser(),
|
||||
new AddressBookDoCoMoRXingResultParser(),
|
||||
new EmailDoCoMoRXingResultParser(),
|
||||
new AddressBookAURXingResultParser(),
|
||||
new VCardRXingResultParser(),
|
||||
new BizcardRXingResultParser(),
|
||||
new VEventRXingResultParser(),
|
||||
new EmailAddressRXingResultParser(),
|
||||
new SMTPRXingResultParser(),
|
||||
new TelRXingResultParser(),
|
||||
new SMSMMSRXingResultParser(),
|
||||
new SMSTOMMSTORXingResultParser(),
|
||||
new GeoRXingResultParser(),
|
||||
new WifiRXingResultParser(),
|
||||
new URLTORXingResultParser(),
|
||||
new URIRXingResultParser(),
|
||||
new ISBNRXingResultParser(),
|
||||
new ProductRXingResultParser(),
|
||||
new ExpandedProductRXingResultParser(),
|
||||
new VINRXingResultParser(),
|
||||
};
|
||||
|
||||
private static final Pattern DIGITS = Pattern.compile("\\d+");
|
||||
@@ -70,16 +70,16 @@ public abstract class ResultParser {
|
||||
static final String[] EMPTY_STR_ARRAY = new String[0];
|
||||
|
||||
/**
|
||||
* Attempts to parse the raw {@link Result}'s contents as a particular type
|
||||
* of information (email, URL, etc.) and return a {@link ParsedResult} encapsulating
|
||||
* Attempts to parse the raw {@link RXingResult}'s contents as a particular type
|
||||
* of information (email, URL, etc.) and return a {@link ParsedRXingResult} encapsulating
|
||||
* the result of parsing.
|
||||
*
|
||||
* @param theResult the raw {@link Result} to parse
|
||||
* @return {@link ParsedResult} encapsulating the parsing result
|
||||
* @param theRXingResult the raw {@link RXingResult} to parse
|
||||
* @return {@link ParsedRXingResult} encapsulating the parsing result
|
||||
*/
|
||||
public abstract ParsedResult parse(Result theResult);
|
||||
public abstract ParsedRXingResult parse(RXingResult theRXingResult);
|
||||
|
||||
protected static String getMassagedText(Result result) {
|
||||
protected static String getMassagedText(RXingResult result) {
|
||||
String text = result.getText();
|
||||
if (text.startsWith(BYTE_ORDER_MARK)) {
|
||||
text = text.substring(1);
|
||||
@@ -87,14 +87,14 @@ public abstract class ResultParser {
|
||||
return text;
|
||||
}
|
||||
|
||||
public static ParsedResult parseResult(Result theResult) {
|
||||
for (ResultParser parser : PARSERS) {
|
||||
ParsedResult result = parser.parse(theResult);
|
||||
public static ParsedRXingResult parseRXingResult(RXingResult theRXingResult) {
|
||||
for (RXingResultParser parser : PARSERS) {
|
||||
ParsedRXingResult result = parser.parse(theRXingResult);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return new TextParsedResult(theResult.getText(), null);
|
||||
return new TextParsedRXingResult(theRXingResult.getText(), null);
|
||||
}
|
||||
|
||||
protected static void maybeAppend(String value, StringBuilder result) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.zxing.client.result;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -38,10 +38,10 @@ import java.util.Map;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class SMSMMSResultParser extends ResultParser {
|
||||
public final class SMSMMSRXingResultParser extends RXingResultParser {
|
||||
|
||||
@Override
|
||||
public SMSParsedResult parse(Result result) {
|
||||
public SMSParsedRXingResult parse(RXingResult result) {
|
||||
String rawText = getMassagedText(result);
|
||||
if (!(rawText.startsWith("sms:") || rawText.startsWith("SMS:") ||
|
||||
rawText.startsWith("mms:") || rawText.startsWith("MMS:"))) {
|
||||
@@ -80,7 +80,7 @@ public final class SMSMMSResultParser extends ResultParser {
|
||||
}
|
||||
addNumberVia(numbers, vias, smsURIWithoutQuery.substring(lastComma + 1));
|
||||
|
||||
return new SMSParsedResult(numbers.toArray(EMPTY_STR_ARRAY),
|
||||
return new SMSParsedRXingResult(numbers.toArray(EMPTY_STR_ARRAY),
|
||||
vias.toArray(EMPTY_STR_ARRAY),
|
||||
subject,
|
||||
body);
|
||||
|
||||
@@ -22,29 +22,29 @@ package com.google.zxing.client.result;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class SMSParsedResult extends ParsedResult {
|
||||
public final class SMSParsedRXingResult extends ParsedRXingResult {
|
||||
|
||||
private final String[] numbers;
|
||||
private final String[] vias;
|
||||
private final String subject;
|
||||
private final String body;
|
||||
|
||||
public SMSParsedResult(String number,
|
||||
public SMSParsedRXingResult(String number,
|
||||
String via,
|
||||
String subject,
|
||||
String body) {
|
||||
super(ParsedResultType.SMS);
|
||||
super(ParsedRXingResultType.SMS);
|
||||
this.numbers = new String[] {number};
|
||||
this.vias = new String[] {via};
|
||||
this.subject = subject;
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public SMSParsedResult(String[] numbers,
|
||||
public SMSParsedRXingResult(String[] numbers,
|
||||
String[] vias,
|
||||
String subject,
|
||||
String body) {
|
||||
super(ParsedResultType.SMS);
|
||||
super(ParsedRXingResultType.SMS);
|
||||
this.numbers = numbers;
|
||||
this.vias = vias;
|
||||
this.subject = subject;
|
||||
@@ -103,7 +103,7 @@ public final class SMSParsedResult extends ParsedResult {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayResult() {
|
||||
public String getDisplayRXingResult() {
|
||||
StringBuilder result = new StringBuilder(100);
|
||||
maybeAppend(numbers, result);
|
||||
maybeAppend(subject, result);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.zxing.client.result;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
/**
|
||||
* <p>Parses an "smsto:" URI result, whose format is not standardized but appears to be like:
|
||||
@@ -28,10 +28,10 @@ import com.google.zxing.Result;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class SMSTOMMSTOResultParser extends ResultParser {
|
||||
public final class SMSTOMMSTORXingResultParser extends RXingResultParser {
|
||||
|
||||
@Override
|
||||
public SMSParsedResult parse(Result result) {
|
||||
public SMSParsedRXingResult parse(RXingResult result) {
|
||||
String rawText = getMassagedText(result);
|
||||
if (!(rawText.startsWith("smsto:") || rawText.startsWith("SMSTO:") ||
|
||||
rawText.startsWith("mmsto:") || rawText.startsWith("MMSTO:"))) {
|
||||
@@ -46,7 +46,7 @@ public final class SMSTOMMSTOResultParser extends ResultParser {
|
||||
body = number.substring(bodyStart + 1);
|
||||
number = number.substring(0, bodyStart);
|
||||
}
|
||||
return new SMSParsedResult(number, null, null, body);
|
||||
return new SMSParsedRXingResult(number, null, null, body);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.zxing.client.result;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
/**
|
||||
* <p>Parses an "smtp:" URI result, whose format is not standardized but appears to be like:
|
||||
@@ -24,10 +24,10 @@ import com.google.zxing.Result;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class SMTPResultParser extends ResultParser {
|
||||
public final class SMTPRXingResultParser extends RXingResultParser {
|
||||
|
||||
@Override
|
||||
public EmailAddressParsedResult parse(Result result) {
|
||||
public EmailAddressParsedRXingResult parse(RXingResult result) {
|
||||
String rawText = getMassagedText(result);
|
||||
if (!(rawText.startsWith("smtp:") || rawText.startsWith("SMTP:"))) {
|
||||
return null;
|
||||
@@ -45,7 +45,7 @@ public final class SMTPResultParser extends ResultParser {
|
||||
subject = subject.substring(0, colon);
|
||||
}
|
||||
}
|
||||
return new EmailAddressParsedResult(new String[] {emailAddress},
|
||||
return new EmailAddressParsedRXingResult(new String[] {emailAddress},
|
||||
null,
|
||||
null,
|
||||
subject,
|
||||
|
||||
@@ -21,14 +21,14 @@ package com.google.zxing.client.result;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class TelParsedResult extends ParsedResult {
|
||||
public final class TelParsedRXingResult extends ParsedRXingResult {
|
||||
|
||||
private final String number;
|
||||
private final String telURI;
|
||||
private final String title;
|
||||
|
||||
public TelParsedResult(String number, String telURI, String title) {
|
||||
super(ParsedResultType.TEL);
|
||||
public TelParsedRXingResult(String number, String telURI, String title) {
|
||||
super(ParsedRXingResultType.TEL);
|
||||
this.number = number;
|
||||
this.telURI = telURI;
|
||||
this.title = title;
|
||||
@@ -47,7 +47,7 @@ public final class TelParsedResult extends ParsedResult {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayResult() {
|
||||
public String getDisplayRXingResult() {
|
||||
StringBuilder result = new StringBuilder(20);
|
||||
maybeAppend(number, result);
|
||||
maybeAppend(title, result);
|
||||
|
||||
@@ -16,17 +16,17 @@
|
||||
|
||||
package com.google.zxing.client.result;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
/**
|
||||
* Parses a "tel:" URI result, which specifies a phone number.
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class TelResultParser extends ResultParser {
|
||||
public final class TelRXingResultParser extends RXingResultParser {
|
||||
|
||||
@Override
|
||||
public TelParsedResult parse(Result result) {
|
||||
public TelParsedRXingResult parse(RXingResult result) {
|
||||
String rawText = getMassagedText(result);
|
||||
if (!rawText.startsWith("tel:") && !rawText.startsWith("TEL:")) {
|
||||
return null;
|
||||
@@ -36,7 +36,7 @@ public final class TelResultParser extends ResultParser {
|
||||
// Drop tel, query portion
|
||||
int queryStart = rawText.indexOf('?', 4);
|
||||
String number = queryStart < 0 ? rawText.substring(4) : rawText.substring(4, queryStart);
|
||||
return new TelParsedResult(number, telURI, null);
|
||||
return new TelParsedRXingResult(number, telURI, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,13 +22,13 @@ package com.google.zxing.client.result;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class TextParsedResult extends ParsedResult {
|
||||
public final class TextParsedRXingResult extends ParsedRXingResult {
|
||||
|
||||
private final String text;
|
||||
private final String language;
|
||||
|
||||
public TextParsedResult(String text, String language) {
|
||||
super(ParsedResultType.TEXT);
|
||||
public TextParsedRXingResult(String text, String language) {
|
||||
super(ParsedRXingResultType.TEXT);
|
||||
this.text = text;
|
||||
this.language = language;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ public final class TextParsedResult extends ParsedResult {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayResult() {
|
||||
public String getDisplayRXingResult() {
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,13 +21,13 @@ package com.google.zxing.client.result;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class URIParsedResult extends ParsedResult {
|
||||
public final class URIParsedRXingResult extends ParsedRXingResult {
|
||||
|
||||
private final String uri;
|
||||
private final String title;
|
||||
|
||||
public URIParsedResult(String uri, String title) {
|
||||
super(ParsedResultType.URI);
|
||||
public URIParsedRXingResult(String uri, String title) {
|
||||
super(ParsedRXingResultType.URI);
|
||||
this.uri = massageURI(uri);
|
||||
this.title = title;
|
||||
}
|
||||
@@ -43,15 +43,15 @@ public final class URIParsedResult extends ParsedResult {
|
||||
/**
|
||||
* @return true if the URI contains suspicious patterns that may suggest it intends to
|
||||
* mislead the user about its true nature
|
||||
* @deprecated see {@link URIResultParser#isPossiblyMaliciousURI(String)}
|
||||
* @deprecated see {@link URIRXingResultParser#isPossiblyMaliciousURI(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isPossiblyMaliciousURI() {
|
||||
return URIResultParser.isPossiblyMaliciousURI(uri);
|
||||
return URIRXingResultParser.isPossiblyMaliciousURI(uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayResult() {
|
||||
public String getDisplayRXingResult() {
|
||||
StringBuilder result = new StringBuilder(30);
|
||||
maybeAppend(title, result);
|
||||
maybeAppend(uri, result);
|
||||
@@ -79,7 +79,7 @@ public final class URIParsedResult extends ParsedResult {
|
||||
if (nextSlash < 0) {
|
||||
nextSlash = uri.length();
|
||||
}
|
||||
return ResultParser.isSubstringOfDigits(uri, start, nextSlash - start);
|
||||
return RXingResultParser.isSubstringOfDigits(uri, start, nextSlash - start);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.zxing.client.result;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -26,7 +26,7 @@ import java.util.regex.Pattern;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class URIResultParser extends ResultParser {
|
||||
public final class URIRXingResultParser extends RXingResultParser {
|
||||
|
||||
private static final Pattern ALLOWED_URI_CHARS_PATTERN =
|
||||
Pattern.compile("[-._~:/?#\\[\\]@!$&'()*+,;=%A-Za-z0-9]+");
|
||||
@@ -39,18 +39,18 @@ public final class URIResultParser extends ResultParser {
|
||||
"(/|\\?|$)"); // query, path or nothing
|
||||
|
||||
@Override
|
||||
public URIParsedResult parse(Result result) {
|
||||
public URIParsedRXingResult parse(RXingResult result) {
|
||||
String rawText = getMassagedText(result);
|
||||
// We specifically handle the odd "URL" scheme here for simplicity and add "URI" for fun
|
||||
// Assume anything starting this way really means to be a URI
|
||||
if (rawText.startsWith("URL:") || rawText.startsWith("URI:")) {
|
||||
return new URIParsedResult(rawText.substring(4).trim(), null);
|
||||
return new URIParsedRXingResult(rawText.substring(4).trim(), null);
|
||||
}
|
||||
rawText = rawText.trim();
|
||||
if (!isBasicallyValidURI(rawText) || isPossiblyMaliciousURI(rawText)) {
|
||||
return null;
|
||||
}
|
||||
return new URIParsedResult(rawText, null);
|
||||
return new URIParsedRXingResult(rawText, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.zxing.client.result;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
/**
|
||||
* Parses the "URLTO" result format, which is of the form "URLTO:[title]:[url]".
|
||||
@@ -25,10 +25,10 @@ import com.google.zxing.Result;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class URLTOResultParser extends ResultParser {
|
||||
public final class URLTORXingResultParser extends RXingResultParser {
|
||||
|
||||
@Override
|
||||
public URIParsedResult parse(Result result) {
|
||||
public URIParsedRXingResult parse(RXingResult result) {
|
||||
String rawText = getMassagedText(result);
|
||||
if (!rawText.startsWith("urlto:") && !rawText.startsWith("URLTO:")) {
|
||||
return null;
|
||||
@@ -39,7 +39,7 @@ public final class URLTOResultParser extends ResultParser {
|
||||
}
|
||||
String title = titleEnd <= 6 ? null : rawText.substring(6, titleEnd);
|
||||
String uri = rawText.substring(titleEnd + 1);
|
||||
return new URIParsedResult(uri, title);
|
||||
return new URIParsedRXingResult(uri, title);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.zxing.client.result;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@@ -34,7 +34,7 @@ import java.util.regex.Pattern;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class VCardResultParser extends ResultParser {
|
||||
public final class VCardRXingResultParser extends RXingResultParser {
|
||||
|
||||
private static final Pattern BEGIN_VCARD = Pattern.compile("BEGIN:VCARD", Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern VCARD_LIKE_DATE = Pattern.compile("\\d{4}-?\\d{2}-?\\d{2}");
|
||||
@@ -48,7 +48,7 @@ public final class VCardResultParser extends ResultParser {
|
||||
private static final Pattern SEMICOLON_OR_COMMA = Pattern.compile("[;,]");
|
||||
|
||||
@Override
|
||||
public AddressBookParsedResult parse(Result result) {
|
||||
public AddressBookParsedRXingResult parse(RXingResult result) {
|
||||
// Although we should insist on the raw text ending with "END:VCARD", there's no reason
|
||||
// to throw out everything else we parsed just because this was omitted. In fact, Eclair
|
||||
// is doing just that, and we can't parse its contacts without this leniency.
|
||||
@@ -82,7 +82,7 @@ public final class VCardResultParser extends ResultParser {
|
||||
if (geo != null && geo.length != 2) {
|
||||
geo = null;
|
||||
}
|
||||
return new AddressBookParsedResult(toPrimaryValues(names),
|
||||
return new AddressBookParsedRXingResult(toPrimaryValues(names),
|
||||
nicknames,
|
||||
null,
|
||||
toPrimaryValues(phoneNumbers),
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.zxing.client.result;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -26,10 +26,10 @@ import java.util.List;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class VEventResultParser extends ResultParser {
|
||||
public final class VEventRXingResultParser extends RXingResultParser {
|
||||
|
||||
@Override
|
||||
public CalendarParsedResult parse(Result result) {
|
||||
public CalendarParsedRXingResult parse(RXingResult result) {
|
||||
String rawText = getMassagedText(result);
|
||||
int vEventStart = rawText.indexOf("BEGIN:VEVENT");
|
||||
if (vEventStart < 0) {
|
||||
@@ -74,7 +74,7 @@ public final class VEventResultParser extends ResultParser {
|
||||
}
|
||||
|
||||
try {
|
||||
return new CalendarParsedResult(summary,
|
||||
return new CalendarParsedRXingResult(summary,
|
||||
start,
|
||||
end,
|
||||
duration,
|
||||
@@ -91,12 +91,12 @@ public final class VEventResultParser extends ResultParser {
|
||||
|
||||
private static String matchSingleVCardPrefixedField(CharSequence prefix,
|
||||
String rawText) {
|
||||
List<String> values = VCardResultParser.matchSingleVCardPrefixedField(prefix, rawText, true, false);
|
||||
List<String> values = VCardRXingResultParser.matchSingleVCardPrefixedField(prefix, rawText, true, false);
|
||||
return values == null || values.isEmpty() ? null : values.get(0);
|
||||
}
|
||||
|
||||
private static String[] matchVCardPrefixedField(CharSequence prefix, String rawText) {
|
||||
List<List<String>> values = VCardResultParser.matchVCardPrefixedField(prefix, rawText, true, false);
|
||||
List<List<String>> values = VCardRXingResultParser.matchVCardPrefixedField(prefix, rawText, true, false);
|
||||
if (values == null || values.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ package com.google.zxing.client.result;
|
||||
/**
|
||||
* Represents a parsed result that encodes a Vehicle Identification Number (VIN).
|
||||
*/
|
||||
public final class VINParsedResult extends ParsedResult {
|
||||
public final class VINParsedRXingResult extends ParsedRXingResult {
|
||||
|
||||
private final String vin;
|
||||
private final String worldManufacturerID;
|
||||
@@ -32,7 +32,7 @@ public final class VINParsedResult extends ParsedResult {
|
||||
private final char plantCode;
|
||||
private final String sequentialNumber;
|
||||
|
||||
public VINParsedResult(String vin,
|
||||
public VINParsedRXingResult(String vin,
|
||||
String worldManufacturerID,
|
||||
String vehicleDescriptorSection,
|
||||
String vehicleIdentifierSection,
|
||||
@@ -41,7 +41,7 @@ public final class VINParsedResult extends ParsedResult {
|
||||
int modelYear,
|
||||
char plantCode,
|
||||
String sequentialNumber) {
|
||||
super(ParsedResultType.VIN);
|
||||
super(ParsedRXingResultType.VIN);
|
||||
this.vin = vin;
|
||||
this.worldManufacturerID = worldManufacturerID;
|
||||
this.vehicleDescriptorSection = vehicleDescriptorSection;
|
||||
@@ -90,7 +90,7 @@ public final class VINParsedResult extends ParsedResult {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayResult() {
|
||||
public String getDisplayRXingResult() {
|
||||
StringBuilder result = new StringBuilder(50);
|
||||
result.append(worldManufacturerID).append(' ');
|
||||
result.append(vehicleDescriptorSection).append(' ');
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.google.zxing.client.result;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -26,13 +26,13 @@ import java.util.regex.Pattern;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class VINResultParser extends ResultParser {
|
||||
public final class VINRXingResultParser extends RXingResultParser {
|
||||
|
||||
private static final Pattern IOQ = Pattern.compile("[IOQ]");
|
||||
private static final Pattern AZ09 = Pattern.compile("[A-Z0-9]{17}");
|
||||
|
||||
@Override
|
||||
public VINParsedResult parse(Result result) {
|
||||
public VINParsedRXingResult parse(RXingResult result) {
|
||||
if (result.getBarcodeFormat() != BarcodeFormat.CODE_39) {
|
||||
return null;
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public final class VINResultParser extends ResultParser {
|
||||
return null;
|
||||
}
|
||||
String wmi = rawText.substring(0, 3);
|
||||
return new VINParsedResult(rawText,
|
||||
return new VINParsedRXingResult(rawText,
|
||||
wmi,
|
||||
rawText.substring(3, 9),
|
||||
rawText.substring(9, 17),
|
||||
|
||||
@@ -21,7 +21,7 @@ package com.google.zxing.client.result;
|
||||
*
|
||||
* @author Vikram Aggarwal
|
||||
*/
|
||||
public final class WifiParsedResult extends ParsedResult {
|
||||
public final class WifiParsedRXingResult extends ParsedRXingResult {
|
||||
|
||||
private final String ssid;
|
||||
private final String networkEncryption;
|
||||
@@ -32,15 +32,15 @@ public final class WifiParsedResult extends ParsedResult {
|
||||
private final String eapMethod;
|
||||
private final String phase2Method;
|
||||
|
||||
public WifiParsedResult(String networkEncryption, String ssid, String password) {
|
||||
public WifiParsedRXingResult(String networkEncryption, String ssid, String password) {
|
||||
this(networkEncryption, ssid, password, false);
|
||||
}
|
||||
|
||||
public WifiParsedResult(String networkEncryption, String ssid, String password, boolean hidden) {
|
||||
public WifiParsedRXingResult(String networkEncryption, String ssid, String password, boolean hidden) {
|
||||
this(networkEncryption, ssid, password, hidden, null, null, null, null);
|
||||
}
|
||||
|
||||
public WifiParsedResult(String networkEncryption,
|
||||
public WifiParsedRXingResult(String networkEncryption,
|
||||
String ssid,
|
||||
String password,
|
||||
boolean hidden,
|
||||
@@ -48,7 +48,7 @@ public final class WifiParsedResult extends ParsedResult {
|
||||
String anonymousIdentity,
|
||||
String eapMethod,
|
||||
String phase2Method) {
|
||||
super(ParsedResultType.WIFI);
|
||||
super(ParsedRXingResultType.WIFI);
|
||||
this.ssid = ssid;
|
||||
this.networkEncryption = networkEncryption;
|
||||
this.password = password;
|
||||
@@ -92,7 +92,7 @@ public final class WifiParsedResult extends ParsedResult {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayResult() {
|
||||
public String getDisplayRXingResult() {
|
||||
StringBuilder result = new StringBuilder(80);
|
||||
maybeAppend(ssid, result);
|
||||
maybeAppend(networkEncryption, result);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.zxing.client.result;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
@SuppressWarnings("checkstyle:lineLength")
|
||||
/**
|
||||
@@ -36,10 +36,10 @@ import com.google.zxing.Result;
|
||||
* @author Sean Owen
|
||||
* @author Steffen Kieß
|
||||
*/
|
||||
public final class WifiResultParser extends ResultParser {
|
||||
public final class WifiRXingResultParser extends RXingResultParser {
|
||||
|
||||
@Override
|
||||
public WifiParsedResult parse(Result result) {
|
||||
public WifiParsedRXingResult parse(RXingResult result) {
|
||||
String rawText = getMassagedText(result);
|
||||
if (!rawText.startsWith("WIFI:")) {
|
||||
return null;
|
||||
@@ -74,6 +74,6 @@ public final class WifiResultParser extends ResultParser {
|
||||
String anonymousIdentity = matchSinglePrefixedField("A:", rawText, ';', false);
|
||||
String eapMethod = matchSinglePrefixedField("E:", rawText, ';', false);
|
||||
|
||||
return new WifiParsedResult(type, ssid, pass, hidden, identity, anonymousIdentity, eapMethod, phase2Method);
|
||||
return new WifiParsedRXingResult(type, ssid, pass, hidden, identity, anonymousIdentity, eapMethod, phase2Method);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class DecoderResult {
|
||||
public final class DecoderRXingResult {
|
||||
|
||||
private final byte[] rawBytes;
|
||||
private int numBits;
|
||||
@@ -39,14 +39,14 @@ public final class DecoderResult {
|
||||
private final int structuredAppendSequenceNumber;
|
||||
private final int symbologyModifier;
|
||||
|
||||
public DecoderResult(byte[] rawBytes,
|
||||
public DecoderRXingResult(byte[] rawBytes,
|
||||
String text,
|
||||
List<byte[]> byteSegments,
|
||||
String ecLevel) {
|
||||
this(rawBytes, text, byteSegments, ecLevel, -1, -1, 0);
|
||||
}
|
||||
|
||||
public DecoderResult(byte[] rawBytes,
|
||||
public DecoderRXingResult(byte[] rawBytes,
|
||||
String text,
|
||||
List<byte[]> byteSegments,
|
||||
String ecLevel,
|
||||
@@ -54,7 +54,7 @@ public final class DecoderResult {
|
||||
this(rawBytes, text, byteSegments, ecLevel, -1, -1, symbologyModifier);
|
||||
}
|
||||
|
||||
public DecoderResult(byte[] rawBytes,
|
||||
public DecoderRXingResult(byte[] rawBytes,
|
||||
String text,
|
||||
List<byte[]> byteSegments,
|
||||
String ecLevel,
|
||||
@@ -63,7 +63,7 @@ public final class DecoderResult {
|
||||
this(rawBytes, text, byteSegments, ecLevel, saSequence, saParity, 0);
|
||||
}
|
||||
|
||||
public DecoderResult(byte[] rawBytes,
|
||||
public DecoderRXingResult(byte[] rawBytes,
|
||||
String text,
|
||||
List<byte[]> byteSegments,
|
||||
String ecLevel,
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.zxing.common;
|
||||
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
|
||||
/**
|
||||
* <p>Encapsulates the result of detecting a barcode in an image. This includes the raw
|
||||
@@ -25,12 +25,12 @@ import com.google.zxing.ResultPoint;
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public class DetectorResult {
|
||||
public class DetectorRXingResult {
|
||||
|
||||
private final BitMatrix bits;
|
||||
private final ResultPoint[] points;
|
||||
private final RXingResultPoint[] points;
|
||||
|
||||
public DetectorResult(BitMatrix bits, ResultPoint[] points) {
|
||||
public DetectorRXingResult(BitMatrix bits, RXingResultPoint[] points) {
|
||||
this.bits = bits;
|
||||
this.points = points;
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public class DetectorResult {
|
||||
return bits;
|
||||
}
|
||||
|
||||
public final ResultPoint[] getPoints() {
|
||||
public final RXingResultPoint[] getPoints() {
|
||||
return points;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
//package com.google.zxing.common.detector;
|
||||
use crate::{NotFoundException,ResultPoint};
|
||||
use crate::{NotFoundException,RXingResultPoint};
|
||||
use crate::common::BitMatrix;
|
||||
|
||||
|
||||
@@ -42,13 +42,13 @@ public final class MonochromeRectangleDetector {
|
||||
* <p>Detects a rectangular region of black and white -- mostly black -- with a region of mostly
|
||||
* white, in an image.</p>
|
||||
*
|
||||
* @return {@link ResultPoint}[] describing the corners of the rectangular region. The first and
|
||||
* @return {@link RXingResultPoint}[] describing the corners of the rectangular region. The first and
|
||||
* last points are opposed on the diagonal, as are the second and third. The first point will be
|
||||
* the topmost point and the last, the bottommost. The second point will be leftmost and the
|
||||
* third, the rightmost
|
||||
* @throws NotFoundException if no Data Matrix Code can be found
|
||||
*/
|
||||
public ResultPoint[] detect() throws NotFoundException {
|
||||
public RXingResultPoint[] detect() throws NotFoundException {
|
||||
int height = image.getHeight();
|
||||
int width = image.getWidth();
|
||||
int halfHeight = height / 2;
|
||||
@@ -60,16 +60,16 @@ public final class MonochromeRectangleDetector {
|
||||
int bottom = height;
|
||||
int left = 0;
|
||||
int right = width;
|
||||
ResultPoint pointA = findCornerFromCenter(halfWidth, 0, left, right,
|
||||
RXingResultPoint pointA = findCornerFromCenter(halfWidth, 0, left, right,
|
||||
halfHeight, -deltaY, top, bottom, halfWidth / 2);
|
||||
top = (int) pointA.getY() - 1;
|
||||
ResultPoint pointB = findCornerFromCenter(halfWidth, -deltaX, left, right,
|
||||
RXingResultPoint pointB = findCornerFromCenter(halfWidth, -deltaX, left, right,
|
||||
halfHeight, 0, top, bottom, halfHeight / 2);
|
||||
left = (int) pointB.getX() - 1;
|
||||
ResultPoint pointC = findCornerFromCenter(halfWidth, deltaX, left, right,
|
||||
RXingResultPoint pointC = findCornerFromCenter(halfWidth, deltaX, left, right,
|
||||
halfHeight, 0, top, bottom, halfHeight / 2);
|
||||
right = (int) pointC.getX() + 1;
|
||||
ResultPoint pointD = findCornerFromCenter(halfWidth, 0, left, right,
|
||||
RXingResultPoint pointD = findCornerFromCenter(halfWidth, 0, left, right,
|
||||
halfHeight, deltaY, top, bottom, halfWidth / 2);
|
||||
bottom = (int) pointD.getY() + 1;
|
||||
|
||||
@@ -77,7 +77,7 @@ public final class MonochromeRectangleDetector {
|
||||
pointA = findCornerFromCenter(halfWidth, 0, left, right,
|
||||
halfHeight, -deltaY, top, bottom, halfWidth / 4);
|
||||
|
||||
return new ResultPoint[] { pointA, pointB, pointC, pointD };
|
||||
return new RXingResultPoint[] { pointA, pointB, pointC, pointD };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,10 +95,10 @@ public final class MonochromeRectangleDetector {
|
||||
* @param bottom maximum value of y
|
||||
* @param maxWhiteRun maximum run of white pixels that can still be considered to be within
|
||||
* the barcode
|
||||
* @return a {@link ResultPoint} encapsulating the corner that was found
|
||||
* @return a {@link RXingResultPoint} encapsulating the corner that was found
|
||||
* @throws NotFoundException if such a point cannot be found
|
||||
*/
|
||||
private ResultPoint findCornerFromCenter(int centerX,
|
||||
private RXingResultPoint findCornerFromCenter(int centerX,
|
||||
int deltaX,
|
||||
int left,
|
||||
int right,
|
||||
@@ -129,21 +129,21 @@ public final class MonochromeRectangleDetector {
|
||||
if (lastRange[0] < centerX) {
|
||||
if (lastRange[1] > centerX) {
|
||||
// straddle, choose one or the other based on direction
|
||||
return new ResultPoint(lastRange[deltaY > 0 ? 0 : 1], lastY);
|
||||
return new RXingResultPoint(lastRange[deltaY > 0 ? 0 : 1], lastY);
|
||||
}
|
||||
return new ResultPoint(lastRange[0], lastY);
|
||||
return new RXingResultPoint(lastRange[0], lastY);
|
||||
} else {
|
||||
return new ResultPoint(lastRange[1], lastY);
|
||||
return new RXingResultPoint(lastRange[1], lastY);
|
||||
}
|
||||
} else {
|
||||
int lastX = x - deltaX;
|
||||
if (lastRange[0] < centerY) {
|
||||
if (lastRange[1] > centerY) {
|
||||
return new ResultPoint(lastX, lastRange[deltaX < 0 ? 0 : 1]);
|
||||
return new RXingResultPoint(lastX, lastRange[deltaX < 0 ? 0 : 1]);
|
||||
}
|
||||
return new ResultPoint(lastX, lastRange[0]);
|
||||
return new RXingResultPoint(lastX, lastRange[0]);
|
||||
} else {
|
||||
return new ResultPoint(lastX, lastRange[1]);
|
||||
return new RXingResultPoint(lastX, lastRange[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.google.zxing.common.detector;
|
||||
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
|
||||
/**
|
||||
@@ -75,14 +75,14 @@ public final class WhiteRectangleDetector {
|
||||
* region until it finds a white rectangular region.
|
||||
* </p>
|
||||
*
|
||||
* @return {@link ResultPoint}[] describing the corners of the rectangular
|
||||
* @return {@link RXingResultPoint}[] describing the corners of the rectangular
|
||||
* region. The first and last points are opposed on the diagonal, as
|
||||
* are the second and third. The first point will be the topmost
|
||||
* point and the last, the bottommost. The second point will be
|
||||
* leftmost and the third, the rightmost
|
||||
* @throws NotFoundException if no Data Matrix Code can be found
|
||||
*/
|
||||
public ResultPoint[] detect() throws NotFoundException {
|
||||
public RXingResultPoint[] detect() throws NotFoundException {
|
||||
|
||||
int left = leftInit;
|
||||
int right = rightInit;
|
||||
@@ -186,7 +186,7 @@ public final class WhiteRectangleDetector {
|
||||
|
||||
int maxSize = right - left;
|
||||
|
||||
ResultPoint z = null;
|
||||
RXingResultPoint z = null;
|
||||
for (int i = 1; z == null && i < maxSize; i++) {
|
||||
z = getBlackPointOnSegment(left, down - i, left + i, down);
|
||||
}
|
||||
@@ -195,7 +195,7 @@ public final class WhiteRectangleDetector {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
ResultPoint t = null;
|
||||
RXingResultPoint t = null;
|
||||
//go down right
|
||||
for (int i = 1; t == null && i < maxSize; i++) {
|
||||
t = getBlackPointOnSegment(left, up + i, left + i, up);
|
||||
@@ -205,7 +205,7 @@ public final class WhiteRectangleDetector {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
ResultPoint x = null;
|
||||
RXingResultPoint x = null;
|
||||
//go down left
|
||||
for (int i = 1; x == null && i < maxSize; i++) {
|
||||
x = getBlackPointOnSegment(right, up + i, right - i, up);
|
||||
@@ -215,7 +215,7 @@ public final class WhiteRectangleDetector {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
ResultPoint y = null;
|
||||
RXingResultPoint y = null;
|
||||
//go up left
|
||||
for (int i = 1; y == null && i < maxSize; i++) {
|
||||
y = getBlackPointOnSegment(right, down - i, right - i, down);
|
||||
@@ -232,7 +232,7 @@ public final class WhiteRectangleDetector {
|
||||
}
|
||||
}
|
||||
|
||||
private ResultPoint getBlackPointOnSegment(float aX, float aY, float bX, float bY) {
|
||||
private RXingResultPoint getBlackPointOnSegment(float aX, float aY, float bX, float bY) {
|
||||
int dist = MathUtils.round(MathUtils.distance(aX, aY, bX, bY));
|
||||
float xStep = (bX - aX) / dist;
|
||||
float yStep = (bY - aY) / dist;
|
||||
@@ -241,7 +241,7 @@ public final class WhiteRectangleDetector {
|
||||
int x = MathUtils.round(aX + i * xStep);
|
||||
int y = MathUtils.round(aY + i * yStep);
|
||||
if (image.get(x, y)) {
|
||||
return new ResultPoint(x, y);
|
||||
return new RXingResultPoint(x, y);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -254,14 +254,14 @@ public final class WhiteRectangleDetector {
|
||||
* @param z left most point
|
||||
* @param x right most point
|
||||
* @param t top most point
|
||||
* @return {@link ResultPoint}[] describing the corners of the rectangular
|
||||
* @return {@link RXingResultPoint}[] describing the corners of the rectangular
|
||||
* region. The first and last points are opposed on the diagonal, as
|
||||
* are the second and third. The first point will be the topmost
|
||||
* point and the last, the bottommost. The second point will be
|
||||
* leftmost and the third, the rightmost
|
||||
*/
|
||||
private ResultPoint[] centerEdges(ResultPoint y, ResultPoint z,
|
||||
ResultPoint x, ResultPoint t) {
|
||||
private RXingResultPoint[] centerEdges(RXingResultPoint y, RXingResultPoint z,
|
||||
RXingResultPoint x, RXingResultPoint t) {
|
||||
|
||||
//
|
||||
// t t
|
||||
@@ -280,17 +280,17 @@ public final class WhiteRectangleDetector {
|
||||
float tj = t.getY();
|
||||
|
||||
if (yi < width / 2.0f) {
|
||||
return new ResultPoint[]{
|
||||
new ResultPoint(ti - CORR, tj + CORR),
|
||||
new ResultPoint(zi + CORR, zj + CORR),
|
||||
new ResultPoint(xi - CORR, xj - CORR),
|
||||
new ResultPoint(yi + CORR, yj - CORR)};
|
||||
return new RXingResultPoint[]{
|
||||
new RXingResultPoint(ti - CORR, tj + CORR),
|
||||
new RXingResultPoint(zi + CORR, zj + CORR),
|
||||
new RXingResultPoint(xi - CORR, xj - CORR),
|
||||
new RXingResultPoint(yi + CORR, yj - CORR)};
|
||||
} else {
|
||||
return new ResultPoint[]{
|
||||
new ResultPoint(ti + CORR, tj + CORR),
|
||||
new ResultPoint(zi + CORR, zj - CORR),
|
||||
new ResultPoint(xi - CORR, xj + CORR),
|
||||
new ResultPoint(yi - CORR, yj - CORR)};
|
||||
return new RXingResultPoint[]{
|
||||
new RXingResultPoint(ti + CORR, tj + CORR),
|
||||
new RXingResultPoint(zi + CORR, zj - CORR),
|
||||
new RXingResultPoint(xi - CORR, xj + CORR),
|
||||
new RXingResultPoint(yi - CORR, yj - CORR)};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,12 +23,12 @@ import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Reader;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.common.DecoderResult;
|
||||
import com.google.zxing.common.DetectorResult;
|
||||
import com.google.zxing.common.DecoderRXingResult;
|
||||
import com.google.zxing.common.DetectorRXingResult;
|
||||
import com.google.zxing.datamatrix.decoder.Decoder;
|
||||
import com.google.zxing.datamatrix.detector.Detector;
|
||||
|
||||
@@ -42,7 +42,7 @@ import java.util.Map;
|
||||
*/
|
||||
public final class DataMatrixReader implements Reader {
|
||||
|
||||
private static final ResultPoint[] NO_POINTS = new ResultPoint[0];
|
||||
private static final RXingResultPoint[] NO_POINTS = new RXingResultPoint[0];
|
||||
|
||||
private final Decoder decoder = new Decoder();
|
||||
|
||||
@@ -55,35 +55,35 @@ public final class DataMatrixReader implements Reader {
|
||||
* @throws ChecksumException if error correction fails
|
||||
*/
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException {
|
||||
public RXingResult decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException {
|
||||
return decode(image, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
|
||||
public RXingResult decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, ChecksumException, FormatException {
|
||||
DecoderResult decoderResult;
|
||||
ResultPoint[] points;
|
||||
DecoderRXingResult decoderRXingResult;
|
||||
RXingResultPoint[] points;
|
||||
if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) {
|
||||
BitMatrix bits = extractPureBits(image.getBlackMatrix());
|
||||
decoderResult = decoder.decode(bits);
|
||||
decoderRXingResult = decoder.decode(bits);
|
||||
points = NO_POINTS;
|
||||
} else {
|
||||
DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect();
|
||||
decoderResult = decoder.decode(detectorResult.getBits());
|
||||
points = detectorResult.getPoints();
|
||||
DetectorRXingResult detectorRXingResult = new Detector(image.getBlackMatrix()).detect();
|
||||
decoderRXingResult = decoder.decode(detectorRXingResult.getBits());
|
||||
points = detectorRXingResult.getPoints();
|
||||
}
|
||||
Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points,
|
||||
RXingResult result = new RXingResult(decoderRXingResult.getText(), decoderRXingResult.getRawBytes(), points,
|
||||
BarcodeFormat.DATA_MATRIX);
|
||||
List<byte[]> byteSegments = decoderResult.getByteSegments();
|
||||
List<byte[]> byteSegments = decoderRXingResult.getByteSegments();
|
||||
if (byteSegments != null) {
|
||||
result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments);
|
||||
result.putMetadata(RXingResultMetadataType.BYTE_SEGMENTS, byteSegments);
|
||||
}
|
||||
String ecLevel = decoderResult.getECLevel();
|
||||
String ecLevel = decoderRXingResult.getECLevel();
|
||||
if (ecLevel != null) {
|
||||
result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
|
||||
result.putMetadata(RXingResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
|
||||
}
|
||||
result.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]d" + decoderResult.getSymbologyModifier());
|
||||
result.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]d" + decoderRXingResult.getSymbologyModifier());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,12 +57,12 @@ final class DataBlock {
|
||||
|
||||
// Now establish DataBlocks of the appropriate size and number of data codewords
|
||||
DataBlock[] result = new DataBlock[totalBlocks];
|
||||
int numResultBlocks = 0;
|
||||
int numRXingResultBlocks = 0;
|
||||
for (Version.ECB ecBlock : ecBlockArray) {
|
||||
for (int i = 0; i < ecBlock.getCount(); i++) {
|
||||
int numDataCodewords = ecBlock.getDataCodewords();
|
||||
int numBlockCodewords = ecBlocks.getECCodewords() + numDataCodewords;
|
||||
result[numResultBlocks++] = new DataBlock(numDataCodewords, new byte[numBlockCodewords]);
|
||||
result[numRXingResultBlocks++] = new DataBlock(numDataCodewords, new byte[numBlockCodewords]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,14 +78,14 @@ final class DataBlock {
|
||||
// first fill out as many elements as all of them have minus 1
|
||||
int rawCodewordsOffset = 0;
|
||||
for (int i = 0; i < shorterBlocksNumDataCodewords; i++) {
|
||||
for (int j = 0; j < numResultBlocks; j++) {
|
||||
for (int j = 0; j < numRXingResultBlocks; j++) {
|
||||
result[j].codewords[i] = rawCodewords[rawCodewordsOffset++];
|
||||
}
|
||||
}
|
||||
|
||||
// Fill out the last data block in the longer ones
|
||||
boolean specialVersion = version.getVersionNumber() == 24;
|
||||
int numLongerBlocks = specialVersion ? 8 : numResultBlocks;
|
||||
int numLongerBlocks = specialVersion ? 8 : numRXingResultBlocks;
|
||||
for (int j = 0; j < numLongerBlocks; j++) {
|
||||
result[j].codewords[longerBlocksNumDataCodewords - 1] = rawCodewords[rawCodewordsOffset++];
|
||||
}
|
||||
@@ -93,8 +93,8 @@ final class DataBlock {
|
||||
// Now add in error correction blocks
|
||||
int max = result[0].codewords.length;
|
||||
for (int i = longerBlocksNumDataCodewords; i < max; i++) {
|
||||
for (int j = 0; j < numResultBlocks; j++) {
|
||||
int jOffset = specialVersion ? (j + 8) % numResultBlocks : j;
|
||||
for (int j = 0; j < numRXingResultBlocks; j++) {
|
||||
int jOffset = specialVersion ? (j + 8) % numRXingResultBlocks : j;
|
||||
int iOffset = specialVersion && jOffset > 7 ? i - 1 : i;
|
||||
result[jOffset].codewords[iOffset] = rawCodewords[rawCodewordsOffset++];
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.google.zxing.datamatrix.decoder;
|
||||
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.common.BitSource;
|
||||
import com.google.zxing.common.DecoderResult;
|
||||
import com.google.zxing.common.DecoderRXingResult;
|
||||
import com.google.zxing.common.ECIStringBuilder;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -86,7 +86,7 @@ final class DecodedBitStreamParser {
|
||||
private DecodedBitStreamParser() {
|
||||
}
|
||||
|
||||
static DecoderResult decode(byte[] bytes) throws FormatException {
|
||||
static DecoderRXingResult decode(byte[] bytes) throws FormatException {
|
||||
BitSource bits = new BitSource(bytes);
|
||||
ECIStringBuilder result = new ECIStringBuilder(100);
|
||||
StringBuilder resultTrailer = new StringBuilder(0);
|
||||
@@ -149,7 +149,7 @@ final class DecodedBitStreamParser {
|
||||
}
|
||||
}
|
||||
|
||||
return new DecoderResult(bytes,
|
||||
return new DecoderRXingResult(bytes,
|
||||
result.toString(),
|
||||
byteSegments.isEmpty() ? null : byteSegments,
|
||||
null,
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.google.zxing.datamatrix.decoder;
|
||||
import com.google.zxing.ChecksumException;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.common.DecoderResult;
|
||||
import com.google.zxing.common.DecoderRXingResult;
|
||||
import com.google.zxing.common.reedsolomon.GenericGF;
|
||||
import com.google.zxing.common.reedsolomon.ReedSolomonDecoder;
|
||||
import com.google.zxing.common.reedsolomon.ReedSolomonException;
|
||||
@@ -47,7 +47,7 @@ public final class Decoder {
|
||||
* @throws FormatException if the Data Matrix Code cannot be decoded
|
||||
* @throws ChecksumException if error correction fails
|
||||
*/
|
||||
public DecoderResult decode(boolean[][] image) throws FormatException, ChecksumException {
|
||||
public DecoderRXingResult decode(boolean[][] image) throws FormatException, ChecksumException {
|
||||
return decode(BitMatrix.parse(image));
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public final class Decoder {
|
||||
* @throws FormatException if the Data Matrix Code cannot be decoded
|
||||
* @throws ChecksumException if error correction fails
|
||||
*/
|
||||
public DecoderResult decode(BitMatrix bits) throws FormatException, ChecksumException {
|
||||
public DecoderRXingResult decode(BitMatrix bits) throws FormatException, ChecksumException {
|
||||
|
||||
// Construct a parser and read version, error-correction level
|
||||
BitMatrixParser parser = new BitMatrixParser(bits);
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
package com.google.zxing.datamatrix.detector;
|
||||
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.common.DetectorResult;
|
||||
import com.google.zxing.common.DetectorRXingResult;
|
||||
import com.google.zxing.common.GridSampler;
|
||||
import com.google.zxing.common.detector.WhiteRectangleDetector;
|
||||
|
||||
@@ -42,14 +42,14 @@ public final class Detector {
|
||||
/**
|
||||
* <p>Detects a Data Matrix Code in an image.</p>
|
||||
*
|
||||
* @return {@link DetectorResult} encapsulating results of detecting a Data Matrix Code
|
||||
* @return {@link DetectorRXingResult} encapsulating results of detecting a Data Matrix Code
|
||||
* @throws NotFoundException if no Data Matrix Code can be found
|
||||
*/
|
||||
public DetectorResult detect() throws NotFoundException {
|
||||
public DetectorRXingResult detect() throws NotFoundException {
|
||||
|
||||
ResultPoint[] cornerPoints = rectangleDetector.detect();
|
||||
RXingResultPoint[] cornerPoints = rectangleDetector.detect();
|
||||
|
||||
ResultPoint[] points = detectSolid1(cornerPoints);
|
||||
RXingResultPoint[] points = detectSolid1(cornerPoints);
|
||||
points = detectSolid2(points);
|
||||
points[3] = correctTopRight(points);
|
||||
if (points[3] == null) {
|
||||
@@ -57,10 +57,10 @@ public final class Detector {
|
||||
}
|
||||
points = shiftToModuleCenter(points);
|
||||
|
||||
ResultPoint topLeft = points[0];
|
||||
ResultPoint bottomLeft = points[1];
|
||||
ResultPoint bottomRight = points[2];
|
||||
ResultPoint topRight = points[3];
|
||||
RXingResultPoint topLeft = points[0];
|
||||
RXingResultPoint bottomLeft = points[1];
|
||||
RXingResultPoint bottomRight = points[2];
|
||||
RXingResultPoint topRight = points[3];
|
||||
|
||||
int dimensionTop = transitionsBetween(topLeft, topRight) + 1;
|
||||
int dimensionRight = transitionsBetween(bottomRight, topRight) + 1;
|
||||
@@ -84,16 +84,16 @@ public final class Detector {
|
||||
dimensionTop,
|
||||
dimensionRight);
|
||||
|
||||
return new DetectorResult(bits, new ResultPoint[]{topLeft, bottomLeft, bottomRight, topRight});
|
||||
return new DetectorRXingResult(bits, new RXingResultPoint[]{topLeft, bottomLeft, bottomRight, topRight});
|
||||
}
|
||||
|
||||
private static ResultPoint shiftPoint(ResultPoint point, ResultPoint to, int div) {
|
||||
private static RXingResultPoint shiftPoint(RXingResultPoint point, RXingResultPoint to, int div) {
|
||||
float x = (to.getX() - point.getX()) / (div + 1);
|
||||
float y = (to.getY() - point.getY()) / (div + 1);
|
||||
return new ResultPoint(point.getX() + x, point.getY() + y);
|
||||
return new RXingResultPoint(point.getX() + x, point.getY() + y);
|
||||
}
|
||||
|
||||
private static ResultPoint moveAway(ResultPoint point, float fromX, float fromY) {
|
||||
private static RXingResultPoint moveAway(RXingResultPoint point, float fromX, float fromY) {
|
||||
float x = point.getX();
|
||||
float y = point.getY();
|
||||
|
||||
@@ -109,19 +109,19 @@ public final class Detector {
|
||||
y += 1;
|
||||
}
|
||||
|
||||
return new ResultPoint(x, y);
|
||||
return new RXingResultPoint(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect a solid side which has minimum transition.
|
||||
*/
|
||||
private ResultPoint[] detectSolid1(ResultPoint[] cornerPoints) {
|
||||
private RXingResultPoint[] detectSolid1(RXingResultPoint[] cornerPoints) {
|
||||
// 0 2
|
||||
// 1 3
|
||||
ResultPoint pointA = cornerPoints[0];
|
||||
ResultPoint pointB = cornerPoints[1];
|
||||
ResultPoint pointC = cornerPoints[3];
|
||||
ResultPoint pointD = cornerPoints[2];
|
||||
RXingResultPoint pointA = cornerPoints[0];
|
||||
RXingResultPoint pointB = cornerPoints[1];
|
||||
RXingResultPoint pointC = cornerPoints[3];
|
||||
RXingResultPoint pointD = cornerPoints[2];
|
||||
|
||||
int trAB = transitionsBetween(pointA, pointB);
|
||||
int trBC = transitionsBetween(pointB, pointC);
|
||||
@@ -132,7 +132,7 @@ public final class Detector {
|
||||
// : :
|
||||
// 1--2
|
||||
int min = trAB;
|
||||
ResultPoint[] points = {pointD, pointA, pointB, pointC};
|
||||
RXingResultPoint[] points = {pointD, pointA, pointB, pointC};
|
||||
if (min > trBC) {
|
||||
min = trBC;
|
||||
points[0] = pointA;
|
||||
@@ -160,20 +160,20 @@ public final class Detector {
|
||||
/**
|
||||
* Detect a second solid side next to first solid side.
|
||||
*/
|
||||
private ResultPoint[] detectSolid2(ResultPoint[] points) {
|
||||
private RXingResultPoint[] detectSolid2(RXingResultPoint[] points) {
|
||||
// A..D
|
||||
// : :
|
||||
// B--C
|
||||
ResultPoint pointA = points[0];
|
||||
ResultPoint pointB = points[1];
|
||||
ResultPoint pointC = points[2];
|
||||
ResultPoint pointD = points[3];
|
||||
RXingResultPoint pointA = points[0];
|
||||
RXingResultPoint pointB = points[1];
|
||||
RXingResultPoint pointC = points[2];
|
||||
RXingResultPoint pointD = points[3];
|
||||
|
||||
// Transition detection on the edge is not stable.
|
||||
// To safely detect, shift the points to the module center.
|
||||
int tr = transitionsBetween(pointA, pointD);
|
||||
ResultPoint pointBs = shiftPoint(pointB, pointC, (tr + 1) * 4);
|
||||
ResultPoint pointCs = shiftPoint(pointC, pointB, (tr + 1) * 4);
|
||||
RXingResultPoint pointBs = shiftPoint(pointB, pointC, (tr + 1) * 4);
|
||||
RXingResultPoint pointCs = shiftPoint(pointC, pointB, (tr + 1) * 4);
|
||||
int trBA = transitionsBetween(pointBs, pointA);
|
||||
int trCD = transitionsBetween(pointCs, pointD);
|
||||
|
||||
@@ -200,28 +200,28 @@ public final class Detector {
|
||||
/**
|
||||
* Calculates the corner position of the white top right module.
|
||||
*/
|
||||
private ResultPoint correctTopRight(ResultPoint[] points) {
|
||||
private RXingResultPoint correctTopRight(RXingResultPoint[] points) {
|
||||
// A..D
|
||||
// | :
|
||||
// B--C
|
||||
ResultPoint pointA = points[0];
|
||||
ResultPoint pointB = points[1];
|
||||
ResultPoint pointC = points[2];
|
||||
ResultPoint pointD = points[3];
|
||||
RXingResultPoint pointA = points[0];
|
||||
RXingResultPoint pointB = points[1];
|
||||
RXingResultPoint pointC = points[2];
|
||||
RXingResultPoint pointD = points[3];
|
||||
|
||||
// shift points for safe transition detection.
|
||||
int trTop = transitionsBetween(pointA, pointD);
|
||||
int trRight = transitionsBetween(pointB, pointD);
|
||||
ResultPoint pointAs = shiftPoint(pointA, pointB, (trRight + 1) * 4);
|
||||
ResultPoint pointCs = shiftPoint(pointC, pointB, (trTop + 1) * 4);
|
||||
RXingResultPoint pointAs = shiftPoint(pointA, pointB, (trRight + 1) * 4);
|
||||
RXingResultPoint pointCs = shiftPoint(pointC, pointB, (trTop + 1) * 4);
|
||||
|
||||
trTop = transitionsBetween(pointAs, pointD);
|
||||
trRight = transitionsBetween(pointCs, pointD);
|
||||
|
||||
ResultPoint candidate1 = new ResultPoint(
|
||||
RXingResultPoint candidate1 = new RXingResultPoint(
|
||||
pointD.getX() + (pointC.getX() - pointB.getX()) / (trTop + 1),
|
||||
pointD.getY() + (pointC.getY() - pointB.getY()) / (trTop + 1));
|
||||
ResultPoint candidate2 = new ResultPoint(
|
||||
RXingResultPoint candidate2 = new RXingResultPoint(
|
||||
pointD.getX() + (pointA.getX() - pointB.getX()) / (trRight + 1),
|
||||
pointD.getY() + (pointA.getY() - pointB.getY()) / (trRight + 1));
|
||||
|
||||
@@ -248,22 +248,22 @@ public final class Detector {
|
||||
/**
|
||||
* Shift the edge points to the module center.
|
||||
*/
|
||||
private ResultPoint[] shiftToModuleCenter(ResultPoint[] points) {
|
||||
private RXingResultPoint[] shiftToModuleCenter(RXingResultPoint[] points) {
|
||||
// A..D
|
||||
// | :
|
||||
// B--C
|
||||
ResultPoint pointA = points[0];
|
||||
ResultPoint pointB = points[1];
|
||||
ResultPoint pointC = points[2];
|
||||
ResultPoint pointD = points[3];
|
||||
RXingResultPoint pointA = points[0];
|
||||
RXingResultPoint pointB = points[1];
|
||||
RXingResultPoint pointC = points[2];
|
||||
RXingResultPoint pointD = points[3];
|
||||
|
||||
// calculate pseudo dimensions
|
||||
int dimH = transitionsBetween(pointA, pointD) + 1;
|
||||
int dimV = transitionsBetween(pointC, pointD) + 1;
|
||||
|
||||
// shift points for safe dimension detection
|
||||
ResultPoint pointAs = shiftPoint(pointA, pointB, dimV * 4);
|
||||
ResultPoint pointCs = shiftPoint(pointC, pointB, dimH * 4);
|
||||
RXingResultPoint pointAs = shiftPoint(pointA, pointB, dimV * 4);
|
||||
RXingResultPoint pointCs = shiftPoint(pointC, pointB, dimH * 4);
|
||||
|
||||
// calculate more precise dimensions
|
||||
dimH = transitionsBetween(pointAs, pointD) + 1;
|
||||
@@ -284,8 +284,8 @@ public final class Detector {
|
||||
pointC = moveAway(pointC, centerX, centerY);
|
||||
pointD = moveAway(pointD, centerX, centerY);
|
||||
|
||||
ResultPoint pointBs;
|
||||
ResultPoint pointDs;
|
||||
RXingResultPoint pointBs;
|
||||
RXingResultPoint pointDs;
|
||||
|
||||
// shift points to the center of each modules
|
||||
pointAs = shiftPoint(pointA, pointB, dimV * 4);
|
||||
@@ -297,18 +297,18 @@ public final class Detector {
|
||||
pointDs = shiftPoint(pointD, pointC, dimV * 4);
|
||||
pointDs = shiftPoint(pointDs, pointA, dimH * 4);
|
||||
|
||||
return new ResultPoint[]{pointAs, pointBs, pointCs, pointDs};
|
||||
return new RXingResultPoint[]{pointAs, pointBs, pointCs, pointDs};
|
||||
}
|
||||
|
||||
private boolean isValid(ResultPoint p) {
|
||||
private boolean isValid(RXingResultPoint p) {
|
||||
return p.getX() >= 0 && p.getX() <= image.getWidth() - 1 && p.getY() > 0 && p.getY() <= image.getHeight() - 1;
|
||||
}
|
||||
|
||||
private static BitMatrix sampleGrid(BitMatrix image,
|
||||
ResultPoint topLeft,
|
||||
ResultPoint bottomLeft,
|
||||
ResultPoint bottomRight,
|
||||
ResultPoint topRight,
|
||||
RXingResultPoint topLeft,
|
||||
RXingResultPoint bottomLeft,
|
||||
RXingResultPoint bottomRight,
|
||||
RXingResultPoint topRight,
|
||||
int dimensionX,
|
||||
int dimensionY) throws NotFoundException {
|
||||
|
||||
@@ -338,7 +338,7 @@ public final class Detector {
|
||||
/**
|
||||
* Counts the number of black/white transitions between two points, using something like Bresenham's algorithm.
|
||||
*/
|
||||
private int transitionsBetween(ResultPoint from, ResultPoint to) {
|
||||
private int transitionsBetween(RXingResultPoint from, RXingResultPoint to) {
|
||||
// See QR Code Detector, sizeOfBlackWhiteBlackRun()
|
||||
int fromX = (int) from.getX();
|
||||
int fromY = (int) from.getY();
|
||||
|
||||
@@ -251,7 +251,7 @@ public final class MinimalEncoder {
|
||||
addEdge(edges, new Edge(input, Mode.EDF, from, 4, previous));
|
||||
}
|
||||
}
|
||||
static Result encodeMinimally(Input input) {
|
||||
static RXingResult encodeMinimally(Input input) {
|
||||
|
||||
@SuppressWarnings("checkstyle:lineLength")
|
||||
/* The minimal encoding is computed by Dijkstra. The acyclic graph is modeled as follows:
|
||||
@@ -474,7 +474,7 @@ public final class MinimalEncoder {
|
||||
if (minimalJ < 0) {
|
||||
throw new RuntimeException("Internal error: failed to encode \"" + input + "\"");
|
||||
}
|
||||
return new Result(edges[inputLength][minimalJ]);
|
||||
return new RXingResult(edges[inputLength][minimalJ]);
|
||||
}
|
||||
|
||||
private static final class Edge {
|
||||
@@ -926,11 +926,11 @@ public final class MinimalEncoder {
|
||||
}
|
||||
}
|
||||
|
||||
private static final class Result {
|
||||
private static final class RXingResult {
|
||||
|
||||
private final byte[] bytes;
|
||||
|
||||
Result(Edge solution) {
|
||||
RXingResult(Edge solution) {
|
||||
Input input = solution.input;
|
||||
int size = 0;
|
||||
List<Byte> bytesAL = new ArrayList<>();
|
||||
|
||||
@@ -23,11 +23,11 @@ import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Reader;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.common.DecoderResult;
|
||||
import com.google.zxing.common.DecoderRXingResult;
|
||||
import com.google.zxing.maxicode.decoder.Decoder;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -37,7 +37,7 @@ import java.util.Map;
|
||||
*/
|
||||
public final class MaxiCodeReader implements Reader {
|
||||
|
||||
private static final ResultPoint[] NO_POINTS = new ResultPoint[0];
|
||||
private static final RXingResultPoint[] NO_POINTS = new RXingResultPoint[0];
|
||||
private static final int MATRIX_WIDTH = 30;
|
||||
private static final int MATRIX_HEIGHT = 33;
|
||||
|
||||
@@ -52,22 +52,22 @@ public final class MaxiCodeReader implements Reader {
|
||||
* @throws ChecksumException if error correction fails
|
||||
*/
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException {
|
||||
public RXingResult decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException {
|
||||
return decode(image, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
|
||||
public RXingResult decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, ChecksumException, FormatException {
|
||||
// Note that MaxiCode reader effectively always assumes PURE_BARCODE mode
|
||||
// and can't detect it in an image
|
||||
BitMatrix bits = extractPureBits(image.getBlackMatrix());
|
||||
DecoderResult decoderResult = decoder.decode(bits, hints);
|
||||
Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), NO_POINTS, BarcodeFormat.MAXICODE);
|
||||
DecoderRXingResult decoderRXingResult = decoder.decode(bits, hints);
|
||||
RXingResult result = new RXingResult(decoderRXingResult.getText(), decoderRXingResult.getRawBytes(), NO_POINTS, BarcodeFormat.MAXICODE);
|
||||
|
||||
String ecLevel = decoderResult.getECLevel();
|
||||
String ecLevel = decoderRXingResult.getECLevel();
|
||||
if (ecLevel != null) {
|
||||
result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
|
||||
result.putMetadata(RXingResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.google.zxing.maxicode.decoder;
|
||||
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.common.DecoderResult;
|
||||
import com.google.zxing.common.DecoderRXingResult;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
|
||||
@@ -84,7 +84,7 @@ final class DecodedBitStreamParser {
|
||||
private DecodedBitStreamParser() {
|
||||
}
|
||||
|
||||
static DecoderResult decode(byte[] bytes, int mode) throws FormatException {
|
||||
static DecoderRXingResult decode(byte[] bytes, int mode) throws FormatException {
|
||||
StringBuilder result = new StringBuilder(144);
|
||||
switch (mode) {
|
||||
case 2:
|
||||
@@ -118,7 +118,7 @@ final class DecodedBitStreamParser {
|
||||
result.append(getMessage(bytes, 1, 77));
|
||||
break;
|
||||
}
|
||||
return new DecoderResult(bytes, result.toString(), null, String.valueOf(mode));
|
||||
return new DecoderRXingResult(bytes, result.toString(), null, String.valueOf(mode));
|
||||
}
|
||||
|
||||
private static int getBit(int bit, byte[] bytes) {
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.google.zxing.ChecksumException;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.common.DecoderResult;
|
||||
import com.google.zxing.common.DecoderRXingResult;
|
||||
import com.google.zxing.common.reedsolomon.GenericGF;
|
||||
import com.google.zxing.common.reedsolomon.ReedSolomonDecoder;
|
||||
import com.google.zxing.common.reedsolomon.ReedSolomonException;
|
||||
@@ -45,11 +45,11 @@ public final class Decoder {
|
||||
rsDecoder = new ReedSolomonDecoder(GenericGF.MAXICODE_FIELD_64);
|
||||
}
|
||||
|
||||
public DecoderResult decode(BitMatrix bits) throws ChecksumException, FormatException {
|
||||
public DecoderRXingResult decode(BitMatrix bits) throws ChecksumException, FormatException {
|
||||
return decode(bits, null);
|
||||
}
|
||||
|
||||
public DecoderResult decode(BitMatrix bits,
|
||||
public DecoderRXingResult decode(BitMatrix bits,
|
||||
Map<DecodeHintType,?> hints) throws FormatException, ChecksumException {
|
||||
BitMatrixParser parser = new BitMatrixParser(bits);
|
||||
byte[] codewords = parser.readCodewords();
|
||||
|
||||
@@ -22,8 +22,8 @@ import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Reader;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -45,13 +45,13 @@ public final class ByQuadrantReader implements Reader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image)
|
||||
public RXingResult decode(BinaryBitmap image)
|
||||
throws NotFoundException, ChecksumException, FormatException {
|
||||
return decode(image, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
|
||||
public RXingResult decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, ChecksumException, FormatException {
|
||||
|
||||
int width = image.getWidth();
|
||||
@@ -67,24 +67,24 @@ public final class ByQuadrantReader implements Reader {
|
||||
}
|
||||
|
||||
try {
|
||||
Result result = delegate.decode(image.crop(halfWidth, 0, halfWidth, halfHeight), hints);
|
||||
makeAbsolute(result.getResultPoints(), halfWidth, 0);
|
||||
RXingResult result = delegate.decode(image.crop(halfWidth, 0, halfWidth, halfHeight), hints);
|
||||
makeAbsolute(result.getRXingResultPoints(), halfWidth, 0);
|
||||
return result;
|
||||
} catch (NotFoundException re) {
|
||||
// continue
|
||||
}
|
||||
|
||||
try {
|
||||
Result result = delegate.decode(image.crop(0, halfHeight, halfWidth, halfHeight), hints);
|
||||
makeAbsolute(result.getResultPoints(), 0, halfHeight);
|
||||
RXingResult result = delegate.decode(image.crop(0, halfHeight, halfWidth, halfHeight), hints);
|
||||
makeAbsolute(result.getRXingResultPoints(), 0, halfHeight);
|
||||
return result;
|
||||
} catch (NotFoundException re) {
|
||||
// continue
|
||||
}
|
||||
|
||||
try {
|
||||
Result result = delegate.decode(image.crop(halfWidth, halfHeight, halfWidth, halfHeight), hints);
|
||||
makeAbsolute(result.getResultPoints(), halfWidth, halfHeight);
|
||||
RXingResult result = delegate.decode(image.crop(halfWidth, halfHeight, halfWidth, halfHeight), hints);
|
||||
makeAbsolute(result.getRXingResultPoints(), halfWidth, halfHeight);
|
||||
return result;
|
||||
} catch (NotFoundException re) {
|
||||
// continue
|
||||
@@ -93,8 +93,8 @@ public final class ByQuadrantReader implements Reader {
|
||||
int quarterWidth = halfWidth / 2;
|
||||
int quarterHeight = halfHeight / 2;
|
||||
BinaryBitmap center = image.crop(quarterWidth, quarterHeight, halfWidth, halfHeight);
|
||||
Result result = delegate.decode(center, hints);
|
||||
makeAbsolute(result.getResultPoints(), quarterWidth, quarterHeight);
|
||||
RXingResult result = delegate.decode(center, hints);
|
||||
makeAbsolute(result.getRXingResultPoints(), quarterWidth, quarterHeight);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -103,12 +103,12 @@ public final class ByQuadrantReader implements Reader {
|
||||
delegate.reset();
|
||||
}
|
||||
|
||||
private static void makeAbsolute(ResultPoint[] points, int leftOffset, int topOffset) {
|
||||
private static void makeAbsolute(RXingResultPoint[] points, int leftOffset, int topOffset) {
|
||||
if (points != null) {
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
ResultPoint relative = points[i];
|
||||
RXingResultPoint relative = points[i];
|
||||
if (relative != null) {
|
||||
points[i] = new ResultPoint(relative.getX() + leftOffset, relative.getY() + topOffset);
|
||||
points[i] = new RXingResultPoint(relative.getX() + leftOffset, relative.getY() + topOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Reader;
|
||||
import com.google.zxing.ReaderException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -31,7 +31,7 @@ import java.util.Map;
|
||||
/**
|
||||
* <p>Attempts to locate multiple barcodes in an image by repeatedly decoding portion of the image.
|
||||
* After one barcode is found, the areas left, above, right and below the barcode's
|
||||
* {@link ResultPoint}s are scanned, recursively.</p>
|
||||
* {@link RXingResultPoint}s are scanned, recursively.</p>
|
||||
*
|
||||
* <p>A caller may want to also employ {@link ByQuadrantReader} when attempting to find multiple
|
||||
* 2D barcodes, like QR Codes, in an image, where the presence of multiple barcodes might prevent
|
||||
@@ -47,7 +47,7 @@ public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader
|
||||
private static final int MIN_DIMENSION_TO_RECUR = 100;
|
||||
private static final int MAX_DEPTH = 4;
|
||||
|
||||
static final Result[] EMPTY_RESULT_ARRAY = new Result[0];
|
||||
static final RXingResult[] EMPTY_RESULT_ARRAY = new RXingResult[0];
|
||||
|
||||
private final Reader delegate;
|
||||
|
||||
@@ -56,14 +56,14 @@ public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result[] decodeMultiple(BinaryBitmap image) throws NotFoundException {
|
||||
public RXingResult[] decodeMultiple(BinaryBitmap image) throws NotFoundException {
|
||||
return decodeMultiple(image, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result[] decodeMultiple(BinaryBitmap image, Map<DecodeHintType,?> hints)
|
||||
public RXingResult[] decodeMultiple(BinaryBitmap image, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException {
|
||||
List<Result> results = new ArrayList<>();
|
||||
List<RXingResult> results = new ArrayList<>();
|
||||
doDecodeMultiple(image, hints, results, 0, 0, 0);
|
||||
if (results.isEmpty()) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
@@ -73,7 +73,7 @@ public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader
|
||||
|
||||
private void doDecodeMultiple(BinaryBitmap image,
|
||||
Map<DecodeHintType,?> hints,
|
||||
List<Result> results,
|
||||
List<RXingResult> results,
|
||||
int xOffset,
|
||||
int yOffset,
|
||||
int currentDepth) {
|
||||
@@ -81,23 +81,23 @@ public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader
|
||||
return;
|
||||
}
|
||||
|
||||
Result result;
|
||||
RXingResult result;
|
||||
try {
|
||||
result = delegate.decode(image, hints);
|
||||
} catch (ReaderException ignored) {
|
||||
return;
|
||||
}
|
||||
boolean alreadyFound = false;
|
||||
for (Result existingResult : results) {
|
||||
if (existingResult.getText().equals(result.getText())) {
|
||||
for (RXingResult existingRXingResult : results) {
|
||||
if (existingRXingResult.getText().equals(result.getText())) {
|
||||
alreadyFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!alreadyFound) {
|
||||
results.add(translateResultPoints(result, xOffset, yOffset));
|
||||
results.add(translateRXingResultPoints(result, xOffset, yOffset));
|
||||
}
|
||||
ResultPoint[] resultPoints = result.getResultPoints();
|
||||
RXingResultPoint[] resultPoints = result.getRXingResultPoints();
|
||||
if (resultPoints == null || resultPoints.length == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader
|
||||
float minY = height;
|
||||
float maxX = 0.0f;
|
||||
float maxY = 0.0f;
|
||||
for (ResultPoint point : resultPoints) {
|
||||
for (RXingResultPoint point : resultPoints) {
|
||||
if (point == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -157,26 +157,26 @@ public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader
|
||||
}
|
||||
}
|
||||
|
||||
private static Result translateResultPoints(Result result, int xOffset, int yOffset) {
|
||||
ResultPoint[] oldResultPoints = result.getResultPoints();
|
||||
if (oldResultPoints == null) {
|
||||
private static RXingResult translateRXingResultPoints(RXingResult result, int xOffset, int yOffset) {
|
||||
RXingResultPoint[] oldRXingResultPoints = result.getRXingResultPoints();
|
||||
if (oldRXingResultPoints == null) {
|
||||
return result;
|
||||
}
|
||||
ResultPoint[] newResultPoints = new ResultPoint[oldResultPoints.length];
|
||||
for (int i = 0; i < oldResultPoints.length; i++) {
|
||||
ResultPoint oldPoint = oldResultPoints[i];
|
||||
RXingResultPoint[] newRXingResultPoints = new RXingResultPoint[oldRXingResultPoints.length];
|
||||
for (int i = 0; i < oldRXingResultPoints.length; i++) {
|
||||
RXingResultPoint oldPoint = oldRXingResultPoints[i];
|
||||
if (oldPoint != null) {
|
||||
newResultPoints[i] = new ResultPoint(oldPoint.getX() + xOffset, oldPoint.getY() + yOffset);
|
||||
newRXingResultPoints[i] = new RXingResultPoint(oldPoint.getX() + xOffset, oldPoint.getY() + yOffset);
|
||||
}
|
||||
}
|
||||
Result newResult = new Result(result.getText(),
|
||||
RXingResult newRXingResult = new RXingResult(result.getText(),
|
||||
result.getRawBytes(),
|
||||
result.getNumBits(),
|
||||
newResultPoints,
|
||||
newRXingResultPoints,
|
||||
result.getBarcodeFormat(),
|
||||
result.getTimestamp());
|
||||
newResult.putAllMetadata(result.getResultMetadata());
|
||||
return newResult;
|
||||
newRXingResult.putAllMetadata(result.getRXingResultMetadata());
|
||||
return newRXingResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.google.zxing.multi;
|
||||
import com.google.zxing.BinaryBitmap;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -31,9 +31,9 @@ import java.util.Map;
|
||||
*/
|
||||
public interface MultipleBarcodeReader {
|
||||
|
||||
Result[] decodeMultiple(BinaryBitmap image) throws NotFoundException;
|
||||
RXingResult[] decodeMultiple(BinaryBitmap image) throws NotFoundException;
|
||||
|
||||
Result[] decodeMultiple(BinaryBitmap image,
|
||||
RXingResult[] decodeMultiple(BinaryBitmap image,
|
||||
Map<DecodeHintType,?> hints) throws NotFoundException;
|
||||
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ import com.google.zxing.BinaryBitmap;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.ReaderException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.common.DecoderResult;
|
||||
import com.google.zxing.common.DetectorResult;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.DecoderRXingResult;
|
||||
import com.google.zxing.common.DetectorRXingResult;
|
||||
import com.google.zxing.multi.MultipleBarcodeReader;
|
||||
import com.google.zxing.multi.qrcode.detector.MultiDetector;
|
||||
import com.google.zxing.qrcode.QRCodeReader;
|
||||
@@ -47,41 +47,41 @@ import java.util.Comparator;
|
||||
*/
|
||||
public final class QRCodeMultiReader extends QRCodeReader implements MultipleBarcodeReader {
|
||||
|
||||
private static final Result[] EMPTY_RESULT_ARRAY = new Result[0];
|
||||
private static final ResultPoint[] NO_POINTS = new ResultPoint[0];
|
||||
private static final RXingResult[] EMPTY_RESULT_ARRAY = new RXingResult[0];
|
||||
private static final RXingResultPoint[] NO_POINTS = new RXingResultPoint[0];
|
||||
|
||||
@Override
|
||||
public Result[] decodeMultiple(BinaryBitmap image) throws NotFoundException {
|
||||
public RXingResult[] decodeMultiple(BinaryBitmap image) throws NotFoundException {
|
||||
return decodeMultiple(image, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result[] decodeMultiple(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
List<Result> results = new ArrayList<>();
|
||||
DetectorResult[] detectorResults = new MultiDetector(image.getBlackMatrix()).detectMulti(hints);
|
||||
for (DetectorResult detectorResult : detectorResults) {
|
||||
public RXingResult[] decodeMultiple(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
List<RXingResult> results = new ArrayList<>();
|
||||
DetectorRXingResult[] detectorRXingResults = new MultiDetector(image.getBlackMatrix()).detectMulti(hints);
|
||||
for (DetectorRXingResult detectorRXingResult : detectorRXingResults) {
|
||||
try {
|
||||
DecoderResult decoderResult = getDecoder().decode(detectorResult.getBits(), hints);
|
||||
ResultPoint[] points = detectorResult.getPoints();
|
||||
DecoderRXingResult decoderRXingResult = getDecoder().decode(detectorRXingResult.getBits(), hints);
|
||||
RXingResultPoint[] points = detectorRXingResult.getPoints();
|
||||
// If the code was mirrored: swap the bottom-left and the top-right points.
|
||||
if (decoderResult.getOther() instanceof QRCodeDecoderMetaData) {
|
||||
((QRCodeDecoderMetaData) decoderResult.getOther()).applyMirroredCorrection(points);
|
||||
if (decoderRXingResult.getOther() instanceof QRCodeDecoderMetaData) {
|
||||
((QRCodeDecoderMetaData) decoderRXingResult.getOther()).applyMirroredCorrection(points);
|
||||
}
|
||||
Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points,
|
||||
RXingResult result = new RXingResult(decoderRXingResult.getText(), decoderRXingResult.getRawBytes(), points,
|
||||
BarcodeFormat.QR_CODE);
|
||||
List<byte[]> byteSegments = decoderResult.getByteSegments();
|
||||
List<byte[]> byteSegments = decoderRXingResult.getByteSegments();
|
||||
if (byteSegments != null) {
|
||||
result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments);
|
||||
result.putMetadata(RXingResultMetadataType.BYTE_SEGMENTS, byteSegments);
|
||||
}
|
||||
String ecLevel = decoderResult.getECLevel();
|
||||
String ecLevel = decoderRXingResult.getECLevel();
|
||||
if (ecLevel != null) {
|
||||
result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
|
||||
result.putMetadata(RXingResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
|
||||
}
|
||||
if (decoderResult.hasStructuredAppend()) {
|
||||
result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE,
|
||||
decoderResult.getStructuredAppendSequenceNumber());
|
||||
result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_PARITY,
|
||||
decoderResult.getStructuredAppendParity());
|
||||
if (decoderRXingResult.hasStructuredAppend()) {
|
||||
result.putMetadata(RXingResultMetadataType.STRUCTURED_APPEND_SEQUENCE,
|
||||
decoderRXingResult.getStructuredAppendSequenceNumber());
|
||||
result.putMetadata(RXingResultMetadataType.STRUCTURED_APPEND_PARITY,
|
||||
decoderRXingResult.getStructuredAppendParity());
|
||||
}
|
||||
results.add(result);
|
||||
} catch (ReaderException re) {
|
||||
@@ -96,32 +96,32 @@ public final class QRCodeMultiReader extends QRCodeReader implements MultipleBar
|
||||
}
|
||||
}
|
||||
|
||||
static List<Result> processStructuredAppend(List<Result> results) {
|
||||
List<Result> newResults = new ArrayList<>();
|
||||
List<Result> saResults = new ArrayList<>();
|
||||
for (Result result : results) {
|
||||
if (result.getResultMetadata().containsKey(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE)) {
|
||||
saResults.add(result);
|
||||
static List<RXingResult> processStructuredAppend(List<RXingResult> results) {
|
||||
List<RXingResult> newRXingResults = new ArrayList<>();
|
||||
List<RXingResult> saRXingResults = new ArrayList<>();
|
||||
for (RXingResult result : results) {
|
||||
if (result.getRXingResultMetadata().containsKey(RXingResultMetadataType.STRUCTURED_APPEND_SEQUENCE)) {
|
||||
saRXingResults.add(result);
|
||||
} else {
|
||||
newResults.add(result);
|
||||
newRXingResults.add(result);
|
||||
}
|
||||
}
|
||||
if (saResults.isEmpty()) {
|
||||
if (saRXingResults.isEmpty()) {
|
||||
return results;
|
||||
}
|
||||
|
||||
// sort and concatenate the SA list items
|
||||
Collections.sort(saResults, new SAComparator());
|
||||
Collections.sort(saRXingResults, new SAComparator());
|
||||
StringBuilder newText = new StringBuilder();
|
||||
ByteArrayOutputStream newRawBytes = new ByteArrayOutputStream();
|
||||
ByteArrayOutputStream newByteSegment = new ByteArrayOutputStream();
|
||||
for (Result saResult : saResults) {
|
||||
newText.append(saResult.getText());
|
||||
byte[] saBytes = saResult.getRawBytes();
|
||||
for (RXingResult saRXingResult : saRXingResults) {
|
||||
newText.append(saRXingResult.getText());
|
||||
byte[] saBytes = saRXingResult.getRawBytes();
|
||||
newRawBytes.write(saBytes, 0, saBytes.length);
|
||||
@SuppressWarnings("unchecked")
|
||||
Iterable<byte[]> byteSegments =
|
||||
(Iterable<byte[]>) saResult.getResultMetadata().get(ResultMetadataType.BYTE_SEGMENTS);
|
||||
(Iterable<byte[]>) saRXingResult.getRXingResultMetadata().get(RXingResultMetadataType.BYTE_SEGMENTS);
|
||||
if (byteSegments != null) {
|
||||
for (byte[] segment : byteSegments) {
|
||||
newByteSegment.write(segment, 0, segment.length);
|
||||
@@ -129,19 +129,19 @@ public final class QRCodeMultiReader extends QRCodeReader implements MultipleBar
|
||||
}
|
||||
}
|
||||
|
||||
Result newResult = new Result(newText.toString(), newRawBytes.toByteArray(), NO_POINTS, BarcodeFormat.QR_CODE);
|
||||
RXingResult newRXingResult = new RXingResult(newText.toString(), newRawBytes.toByteArray(), NO_POINTS, BarcodeFormat.QR_CODE);
|
||||
if (newByteSegment.size() > 0) {
|
||||
newResult.putMetadata(ResultMetadataType.BYTE_SEGMENTS, Collections.singletonList(newByteSegment.toByteArray()));
|
||||
newRXingResult.putMetadata(RXingResultMetadataType.BYTE_SEGMENTS, Collections.singletonList(newByteSegment.toByteArray()));
|
||||
}
|
||||
newResults.add(newResult);
|
||||
return newResults;
|
||||
newRXingResults.add(newRXingResult);
|
||||
return newRXingResults;
|
||||
}
|
||||
|
||||
private static final class SAComparator implements Comparator<Result>, Serializable {
|
||||
private static final class SAComparator implements Comparator<RXingResult>, Serializable {
|
||||
@Override
|
||||
public int compare(Result a, Result b) {
|
||||
int aNumber = (int) a.getResultMetadata().get(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE);
|
||||
int bNumber = (int) b.getResultMetadata().get(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE);
|
||||
public int compare(RXingResult a, RXingResult b) {
|
||||
int aNumber = (int) a.getRXingResultMetadata().get(RXingResultMetadataType.STRUCTURED_APPEND_SEQUENCE);
|
||||
int bNumber = (int) b.getRXingResultMetadata().get(RXingResultMetadataType.STRUCTURED_APPEND_SEQUENCE);
|
||||
return Integer.compare(aNumber, bNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ package com.google.zxing.multi.qrcode.detector;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.ReaderException;
|
||||
import com.google.zxing.ResultPointCallback;
|
||||
import com.google.zxing.RXingResultPointCallback;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.common.DetectorResult;
|
||||
import com.google.zxing.common.DetectorRXingResult;
|
||||
import com.google.zxing.qrcode.detector.Detector;
|
||||
import com.google.zxing.qrcode.detector.FinderPatternInfo;
|
||||
|
||||
@@ -38,16 +38,16 @@ import java.util.Map;
|
||||
*/
|
||||
public final class MultiDetector extends Detector {
|
||||
|
||||
private static final DetectorResult[] EMPTY_DETECTOR_RESULTS = new DetectorResult[0];
|
||||
private static final DetectorRXingResult[] EMPTY_DETECTOR_RESULTS = new DetectorRXingResult[0];
|
||||
|
||||
public MultiDetector(BitMatrix image) {
|
||||
super(image);
|
||||
}
|
||||
|
||||
public DetectorResult[] detectMulti(Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
public DetectorRXingResult[] detectMulti(Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
BitMatrix image = getImage();
|
||||
ResultPointCallback resultPointCallback =
|
||||
hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
|
||||
RXingResultPointCallback resultPointCallback =
|
||||
hints == null ? null : (RXingResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
|
||||
MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image, resultPointCallback);
|
||||
FinderPatternInfo[] infos = finder.findMulti(hints);
|
||||
|
||||
@@ -55,7 +55,7 @@ public final class MultiDetector extends Detector {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
List<DetectorResult> result = new ArrayList<>();
|
||||
List<DetectorRXingResult> result = new ArrayList<>();
|
||||
for (FinderPatternInfo info : infos) {
|
||||
try {
|
||||
result.add(processFinderPatternInfo(info));
|
||||
|
||||
@@ -18,8 +18,8 @@ package com.google.zxing.multi.qrcode.detector;
|
||||
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.ResultPointCallback;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.RXingResultPointCallback;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.qrcode.detector.FinderPattern;
|
||||
import com.google.zxing.qrcode.detector.FinderPatternFinder;
|
||||
@@ -86,7 +86,7 @@ public final class MultiFinderPatternFinder extends FinderPatternFinder {
|
||||
}
|
||||
}
|
||||
|
||||
public MultiFinderPatternFinder(BitMatrix image, ResultPointCallback resultPointCallback) {
|
||||
public MultiFinderPatternFinder(BitMatrix image, RXingResultPointCallback resultPointCallback) {
|
||||
super(image, resultPointCallback);
|
||||
}
|
||||
|
||||
@@ -176,13 +176,13 @@ public final class MultiFinderPatternFinder extends FinderPatternFinder {
|
||||
}
|
||||
|
||||
FinderPattern[] test = {p1, p2, p3};
|
||||
ResultPoint.orderBestPatterns(test);
|
||||
RXingResultPoint.orderBestPatterns(test);
|
||||
|
||||
// Calculate the distances: a = topleft-bottomleft, b=topleft-topright, c = diagonal
|
||||
FinderPatternInfo info = new FinderPatternInfo(test);
|
||||
float dA = ResultPoint.distance(info.getTopLeft(), info.getBottomLeft());
|
||||
float dC = ResultPoint.distance(info.getTopRight(), info.getBottomLeft());
|
||||
float dB = ResultPoint.distance(info.getTopLeft(), info.getTopRight());
|
||||
float dA = RXingResultPoint.distance(info.getTopLeft(), info.getBottomLeft());
|
||||
float dC = RXingResultPoint.distance(info.getTopRight(), info.getBottomLeft());
|
||||
float dB = RXingResultPoint.distance(info.getTopLeft(), info.getTopRight());
|
||||
|
||||
// Check the sizes
|
||||
float estimatedModuleCount = (dA + dB) / (p1.getEstimatedModuleSize() * 2.0f);
|
||||
@@ -276,7 +276,7 @@ public final class MultiFinderPatternFinder extends FinderPatternFinder {
|
||||
FinderPattern[][] patternInfo = selectMultipleBestPatterns();
|
||||
List<FinderPatternInfo> result = new ArrayList<>();
|
||||
for (FinderPattern[] pattern : patternInfo) {
|
||||
ResultPoint.orderBestPatterns(pattern);
|
||||
RXingResultPoint.orderBestPatterns(pattern);
|
||||
result.add(new FinderPatternInfo(pattern));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ package com.google.zxing.oned;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -67,25 +67,25 @@ public final class CodaBarReader extends OneDReader {
|
||||
// for more information see : http://www.mecsw.com/specs/codabar.html
|
||||
|
||||
// Keep some instance variables to avoid reallocations
|
||||
private final StringBuilder decodeRowResult;
|
||||
private final StringBuilder decodeRowRXingResult;
|
||||
private int[] counters;
|
||||
private int counterLength;
|
||||
|
||||
public CodaBarReader() {
|
||||
decodeRowResult = new StringBuilder(20);
|
||||
decodeRowRXingResult = new StringBuilder(20);
|
||||
counters = new int[80];
|
||||
counterLength = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
public RXingResult decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
|
||||
Arrays.fill(counters, 0);
|
||||
setCounters(row);
|
||||
int startOffset = findStartPattern();
|
||||
int nextStart = startOffset;
|
||||
|
||||
decodeRowResult.setLength(0);
|
||||
decodeRowRXingResult.setLength(0);
|
||||
do {
|
||||
int charOffset = toNarrowWidePattern(nextStart);
|
||||
if (charOffset == -1) {
|
||||
@@ -94,10 +94,10 @@ public final class CodaBarReader extends OneDReader {
|
||||
// Hack: We store the position in the alphabet table into a
|
||||
// StringBuilder, so that we can access the decoded patterns in
|
||||
// validatePattern. We'll translate to the actual characters later.
|
||||
decodeRowResult.append((char) charOffset);
|
||||
decodeRowRXingResult.append((char) charOffset);
|
||||
nextStart += 8;
|
||||
// Stop as soon as we see the end character.
|
||||
if (decodeRowResult.length() > 1 &&
|
||||
if (decodeRowRXingResult.length() > 1 &&
|
||||
arrayContains(STARTEND_ENCODING, ALPHABET[charOffset])) {
|
||||
break;
|
||||
}
|
||||
@@ -120,28 +120,28 @@ public final class CodaBarReader extends OneDReader {
|
||||
validatePattern(startOffset);
|
||||
|
||||
// Translate character table offsets to actual characters.
|
||||
for (int i = 0; i < decodeRowResult.length(); i++) {
|
||||
decodeRowResult.setCharAt(i, ALPHABET[decodeRowResult.charAt(i)]);
|
||||
for (int i = 0; i < decodeRowRXingResult.length(); i++) {
|
||||
decodeRowRXingResult.setCharAt(i, ALPHABET[decodeRowRXingResult.charAt(i)]);
|
||||
}
|
||||
// Ensure a valid start and end character
|
||||
char startchar = decodeRowResult.charAt(0);
|
||||
char startchar = decodeRowRXingResult.charAt(0);
|
||||
if (!arrayContains(STARTEND_ENCODING, startchar)) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
char endchar = decodeRowResult.charAt(decodeRowResult.length() - 1);
|
||||
char endchar = decodeRowRXingResult.charAt(decodeRowRXingResult.length() - 1);
|
||||
if (!arrayContains(STARTEND_ENCODING, endchar)) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
// remove stop/start characters character and check if a long enough string is contained
|
||||
if (decodeRowResult.length() <= MIN_CHARACTER_LENGTH) {
|
||||
if (decodeRowRXingResult.length() <= MIN_CHARACTER_LENGTH) {
|
||||
// Almost surely a false positive ( start + stop + at least 1 character)
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
if (hints == null || !hints.containsKey(DecodeHintType.RETURN_CODABAR_START_END)) {
|
||||
decodeRowResult.deleteCharAt(decodeRowResult.length() - 1);
|
||||
decodeRowResult.deleteCharAt(0);
|
||||
decodeRowRXingResult.deleteCharAt(decodeRowRXingResult.length() - 1);
|
||||
decodeRowRXingResult.deleteCharAt(0);
|
||||
}
|
||||
|
||||
int runningCount = 0;
|
||||
@@ -154,14 +154,14 @@ public final class CodaBarReader extends OneDReader {
|
||||
}
|
||||
float right = runningCount;
|
||||
|
||||
Result result = new Result(
|
||||
decodeRowResult.toString(),
|
||||
RXingResult result = new RXingResult(
|
||||
decodeRowRXingResult.toString(),
|
||||
null,
|
||||
new ResultPoint[]{
|
||||
new ResultPoint(left, rowNumber),
|
||||
new ResultPoint(right, rowNumber)},
|
||||
new RXingResultPoint[]{
|
||||
new RXingResultPoint(left, rowNumber),
|
||||
new RXingResultPoint(right, rowNumber)},
|
||||
BarcodeFormat.CODABAR);
|
||||
result.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]F0");
|
||||
result.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]F0");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -169,13 +169,13 @@ public final class CodaBarReader extends OneDReader {
|
||||
// First, sum up the total size of our four categories of stripe sizes;
|
||||
int[] sizes = {0, 0, 0, 0};
|
||||
int[] counts = {0, 0, 0, 0};
|
||||
int end = decodeRowResult.length() - 1;
|
||||
int end = decodeRowRXingResult.length() - 1;
|
||||
|
||||
// We break out of this loop in the middle, in order to handle
|
||||
// inter-character spaces properly.
|
||||
int pos = start;
|
||||
for (int i = 0; i <= end; i++) {
|
||||
int pattern = CHARACTER_ENCODINGS[decodeRowResult.charAt(i)];
|
||||
int pattern = CHARACTER_ENCODINGS[decodeRowRXingResult.charAt(i)];
|
||||
for (int j = 6; j >= 0; j--) {
|
||||
// Even j = bars, while odd j = spaces. Categories 2 and 3 are for
|
||||
// long stripes, while 0 and 1 are for short stripes.
|
||||
@@ -204,7 +204,7 @@ public final class CodaBarReader extends OneDReader {
|
||||
// Now verify that all of the stripes are within the thresholds.
|
||||
pos = start;
|
||||
for (int i = 0; i <= end; i++) {
|
||||
int pattern = CHARACTER_ENCODINGS[decodeRowResult.charAt(i)];
|
||||
int pattern = CHARACTER_ENCODINGS[decodeRowRXingResult.charAt(i)];
|
||||
for (int j = 6; j >= 0; j--) {
|
||||
// Even j = bars, while odd j = spaces. Categories 2 and 3 are for
|
||||
// long stripes, while 0 and 1 are for short stripes.
|
||||
|
||||
@@ -21,9 +21,9 @@ import com.google.zxing.ChecksumException;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -234,7 +234,7 @@ public final class Code128Reader extends OneDReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
public RXingResult decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, FormatException, ChecksumException {
|
||||
|
||||
boolean convertFNC1 = hints != null && hints.containsKey(DecodeHintType.ASSUME_GS1);
|
||||
@@ -547,14 +547,14 @@ public final class Code128Reader extends OneDReader {
|
||||
for (int i = 0; i < rawCodesSize; i++) {
|
||||
rawBytes[i] = rawCodes.get(i);
|
||||
}
|
||||
Result resultObject = new Result(
|
||||
RXingResult resultObject = new RXingResult(
|
||||
result.toString(),
|
||||
rawBytes,
|
||||
new ResultPoint[]{
|
||||
new ResultPoint(left, rowNumber),
|
||||
new ResultPoint(right, rowNumber)},
|
||||
new RXingResultPoint[]{
|
||||
new RXingResultPoint(left, rowNumber),
|
||||
new RXingResultPoint(right, rowNumber)},
|
||||
BarcodeFormat.CODE_128);
|
||||
resultObject.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]C" + symbologyModifier);
|
||||
resultObject.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]C" + symbologyModifier);
|
||||
return resultObject;
|
||||
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public final class Code128Writer extends OneDimensionalCodeWriter {
|
||||
private static final int CODE_FNC_4_A = 101; // Code A
|
||||
private static final int CODE_FNC_4_B = 100; // Code B
|
||||
|
||||
// Results of minimal lookahead for code C
|
||||
// RXingResults of minimal lookahead for code C
|
||||
private enum CType {
|
||||
UNCODABLE,
|
||||
ONE_DIGIT,
|
||||
@@ -249,10 +249,10 @@ public final class Code128Writer extends OneDimensionalCodeWriter {
|
||||
checkWeight++;
|
||||
}
|
||||
}
|
||||
return produceResult(patterns, checkSum);
|
||||
return produceRXingResult(patterns, checkSum);
|
||||
}
|
||||
|
||||
static boolean[] produceResult(Collection<int[]> patterns, int checkSum) {
|
||||
static boolean[] produceRXingResult(Collection<int[]> patterns, int checkSum) {
|
||||
// Compute and append checksum
|
||||
checkSum %= 103;
|
||||
patterns.add(Code128Reader.CODE_PATTERNS[checkSum]);
|
||||
@@ -456,7 +456,7 @@ public final class Code128Writer extends OneDimensionalCodeWriter {
|
||||
}
|
||||
memoizedCost = null;
|
||||
minPath = null;
|
||||
return produceResult(patterns, checkSum[0]);
|
||||
return produceRXingResult(patterns, checkSum[0]);
|
||||
}
|
||||
|
||||
private static void addPattern(Collection<int[]> patterns,
|
||||
|
||||
@@ -21,9 +21,9 @@ import com.google.zxing.ChecksumException;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -56,7 +56,7 @@ public final class Code39Reader extends OneDReader {
|
||||
|
||||
private final boolean usingCheckDigit;
|
||||
private final boolean extendedMode;
|
||||
private final StringBuilder decodeRowResult;
|
||||
private final StringBuilder decodeRowRXingResult;
|
||||
private final int[] counters;
|
||||
|
||||
/**
|
||||
@@ -91,17 +91,17 @@ public final class Code39Reader extends OneDReader {
|
||||
public Code39Reader(boolean usingCheckDigit, boolean extendedMode) {
|
||||
this.usingCheckDigit = usingCheckDigit;
|
||||
this.extendedMode = extendedMode;
|
||||
decodeRowResult = new StringBuilder(20);
|
||||
decodeRowRXingResult = new StringBuilder(20);
|
||||
counters = new int[9];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
public RXingResult decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, ChecksumException, FormatException {
|
||||
|
||||
int[] theCounters = counters;
|
||||
Arrays.fill(theCounters, 0);
|
||||
StringBuilder result = decodeRowResult;
|
||||
StringBuilder result = decodeRowRXingResult;
|
||||
result.setLength(0);
|
||||
|
||||
int[] start = findAsteriskPattern(row, theCounters);
|
||||
@@ -144,7 +144,7 @@ public final class Code39Reader extends OneDReader {
|
||||
int max = result.length() - 1;
|
||||
int total = 0;
|
||||
for (int i = 0; i < max; i++) {
|
||||
total += ALPHABET_STRING.indexOf(decodeRowResult.charAt(i));
|
||||
total += ALPHABET_STRING.indexOf(decodeRowRXingResult.charAt(i));
|
||||
}
|
||||
if (result.charAt(max) != ALPHABET_STRING.charAt(total % 43)) {
|
||||
throw ChecksumException.getChecksumInstance();
|
||||
@@ -167,14 +167,14 @@ public final class Code39Reader extends OneDReader {
|
||||
float left = (start[1] + start[0]) / 2.0f;
|
||||
float right = lastStart + lastPatternSize / 2.0f;
|
||||
|
||||
Result resultObject = new Result(
|
||||
RXingResult resultObject = new RXingResult(
|
||||
resultString,
|
||||
null,
|
||||
new ResultPoint[]{
|
||||
new ResultPoint(left, rowNumber),
|
||||
new ResultPoint(right, rowNumber)},
|
||||
new RXingResultPoint[]{
|
||||
new RXingResultPoint(left, rowNumber),
|
||||
new RXingResultPoint(right, rowNumber)},
|
||||
BarcodeFormat.CODE_39);
|
||||
resultObject.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]A0");
|
||||
resultObject.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]A0");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ import com.google.zxing.ChecksumException;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -55,16 +55,16 @@ public final class Code93Reader extends OneDReader {
|
||||
};
|
||||
static final int ASTERISK_ENCODING = CHARACTER_ENCODINGS[47];
|
||||
|
||||
private final StringBuilder decodeRowResult;
|
||||
private final StringBuilder decodeRowRXingResult;
|
||||
private final int[] counters;
|
||||
|
||||
public Code93Reader() {
|
||||
decodeRowResult = new StringBuilder(20);
|
||||
decodeRowRXingResult = new StringBuilder(20);
|
||||
counters = new int[6];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
public RXingResult decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, ChecksumException, FormatException {
|
||||
|
||||
int[] start = findAsteriskPattern(row);
|
||||
@@ -74,7 +74,7 @@ public final class Code93Reader extends OneDReader {
|
||||
|
||||
int[] theCounters = counters;
|
||||
Arrays.fill(theCounters, 0);
|
||||
StringBuilder result = decodeRowResult;
|
||||
StringBuilder result = decodeRowRXingResult;
|
||||
result.setLength(0);
|
||||
|
||||
char decodedChar;
|
||||
@@ -120,14 +120,14 @@ public final class Code93Reader extends OneDReader {
|
||||
float left = (start[1] + start[0]) / 2.0f;
|
||||
float right = lastStart + lastPatternSize / 2.0f;
|
||||
|
||||
Result resultObject = new Result(
|
||||
RXingResult resultObject = new RXingResult(
|
||||
resultString,
|
||||
null,
|
||||
new ResultPoint[]{
|
||||
new ResultPoint(left, rowNumber),
|
||||
new ResultPoint(right, rowNumber)},
|
||||
new RXingResultPoint[]{
|
||||
new RXingResultPoint(left, rowNumber),
|
||||
new RXingResultPoint(right, rowNumber)},
|
||||
BarcodeFormat.CODE_93);
|
||||
resultObject.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]G0");
|
||||
resultObject.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]G0");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -99,7 +99,7 @@ public final class ITFReader extends OneDReader {
|
||||
};
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
public RXingResult decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
throws FormatException, NotFoundException {
|
||||
|
||||
// Find out where the Middle section (payload) starts & ends
|
||||
@@ -140,13 +140,13 @@ public final class ITFReader extends OneDReader {
|
||||
throw FormatException.getFormatInstance();
|
||||
}
|
||||
|
||||
Result resultObject = new Result(
|
||||
RXingResult resultObject = new RXingResult(
|
||||
resultString,
|
||||
null, // no natural byte representation for these barcodes
|
||||
new ResultPoint[] {new ResultPoint(startRange[1], rowNumber),
|
||||
new ResultPoint(endRange[0], rowNumber)},
|
||||
new RXingResultPoint[] {new RXingResultPoint(startRange[1], rowNumber),
|
||||
new RXingResultPoint(endRange[0], rowNumber)},
|
||||
BarcodeFormat.ITF);
|
||||
resultObject.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]I0");
|
||||
resultObject.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]I0");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Reader;
|
||||
import com.google.zxing.ReaderException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.common.BitArray;
|
||||
import com.google.zxing.oned.rss.RSS14Reader;
|
||||
import com.google.zxing.oned.rss.expanded.RSSExpandedReader;
|
||||
@@ -90,7 +90,7 @@ public final class MultiFormatOneDReader extends OneDReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber,
|
||||
public RXingResult decodeRow(int rowNumber,
|
||||
BitArray row,
|
||||
Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
for (OneDReader reader : readers) {
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Reader;
|
||||
import com.google.zxing.ReaderException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -69,14 +69,14 @@ public final class MultiFormatUPCEANReader extends OneDReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber,
|
||||
public RXingResult decodeRow(int rowNumber,
|
||||
BitArray row,
|
||||
Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
// Compute this location once and reuse it on multiple implementations
|
||||
int[] startGuardPattern = UPCEANReader.findStartGuardPattern(row);
|
||||
for (UPCEANReader reader : readers) {
|
||||
try {
|
||||
Result result = reader.decodeRow(rowNumber, row, startGuardPattern, hints);
|
||||
RXingResult result = reader.decodeRow(rowNumber, row, startGuardPattern, hints);
|
||||
// Special case: a 12-digit code encoded in UPC-A is identical to a "0"
|
||||
// followed by those 12 digits encoded as EAN-13. Each will recognize such a code,
|
||||
// UPC-A as a 12-digit string and EAN-13 as a 13-digit string starting with "0".
|
||||
@@ -99,11 +99,11 @@ public final class MultiFormatUPCEANReader extends OneDReader {
|
||||
|
||||
if (ean13MayBeUPCA && canReturnUPCA) {
|
||||
// Transfer the metadata across
|
||||
Result resultUPCA = new Result(result.getText().substring(1),
|
||||
RXingResult resultUPCA = new RXingResult(result.getText().substring(1),
|
||||
result.getRawBytes(),
|
||||
result.getResultPoints(),
|
||||
result.getRXingResultPoints(),
|
||||
BarcodeFormat.UPC_A);
|
||||
resultUPCA.putAllMetadata(result.getResultMetadata());
|
||||
resultUPCA.putAllMetadata(result.getRXingResultMetadata());
|
||||
return resultUPCA;
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -23,9 +23,9 @@ import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Reader;
|
||||
import com.google.zxing.ReaderException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -42,13 +42,13 @@ import java.util.Map;
|
||||
public abstract class OneDReader implements Reader {
|
||||
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image) throws NotFoundException, FormatException {
|
||||
public RXingResult decode(BinaryBitmap image) throws NotFoundException, FormatException {
|
||||
return decode(image, null);
|
||||
}
|
||||
|
||||
// Note that we don't try rotation without the try harder flag, even if rotation was supported.
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image,
|
||||
public RXingResult decode(BinaryBitmap image,
|
||||
Map<DecodeHintType,?> hints) throws NotFoundException, FormatException {
|
||||
try {
|
||||
return doDecode(image, hints);
|
||||
@@ -56,22 +56,22 @@ public abstract class OneDReader implements Reader {
|
||||
boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
|
||||
if (tryHarder && image.isRotateSupported()) {
|
||||
BinaryBitmap rotatedImage = image.rotateCounterClockwise();
|
||||
Result result = doDecode(rotatedImage, hints);
|
||||
RXingResult result = doDecode(rotatedImage, hints);
|
||||
// Record that we found it rotated 90 degrees CCW / 270 degrees CW
|
||||
Map<ResultMetadataType,?> metadata = result.getResultMetadata();
|
||||
Map<RXingResultMetadataType,?> metadata = result.getRXingResultMetadata();
|
||||
int orientation = 270;
|
||||
if (metadata != null && metadata.containsKey(ResultMetadataType.ORIENTATION)) {
|
||||
if (metadata != null && metadata.containsKey(RXingResultMetadataType.ORIENTATION)) {
|
||||
// But if we found it reversed in doDecode(), add in that result here:
|
||||
orientation = (orientation +
|
||||
(Integer) metadata.get(ResultMetadataType.ORIENTATION)) % 360;
|
||||
(Integer) metadata.get(RXingResultMetadataType.ORIENTATION)) % 360;
|
||||
}
|
||||
result.putMetadata(ResultMetadataType.ORIENTATION, orientation);
|
||||
result.putMetadata(RXingResultMetadataType.ORIENTATION, orientation);
|
||||
// Update result points
|
||||
ResultPoint[] points = result.getResultPoints();
|
||||
RXingResultPoint[] points = result.getRXingResultPoints();
|
||||
if (points != null) {
|
||||
int height = rotatedImage.getHeight();
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
points[i] = new ResultPoint(height - points[i].getY() - 1, points[i].getX());
|
||||
points[i] = new RXingResultPoint(height - points[i].getY() - 1, points[i].getX());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -100,7 +100,7 @@ public abstract class OneDReader implements Reader {
|
||||
* @return The contents of the decoded barcode
|
||||
* @throws NotFoundException Any spontaneous errors which occur
|
||||
*/
|
||||
private Result doDecode(BinaryBitmap image,
|
||||
private RXingResult doDecode(BinaryBitmap image,
|
||||
Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
int width = image.getWidth();
|
||||
int height = image.getHeight();
|
||||
@@ -152,16 +152,16 @@ public abstract class OneDReader implements Reader {
|
||||
}
|
||||
try {
|
||||
// Look for a barcode
|
||||
Result result = decodeRow(rowNumber, row, hints);
|
||||
RXingResult result = decodeRow(rowNumber, row, hints);
|
||||
// We found our barcode
|
||||
if (attempt == 1) {
|
||||
// But it was upside down, so note that
|
||||
result.putMetadata(ResultMetadataType.ORIENTATION, 180);
|
||||
result.putMetadata(RXingResultMetadataType.ORIENTATION, 180);
|
||||
// And remember to flip the result points horizontally.
|
||||
ResultPoint[] points = result.getResultPoints();
|
||||
RXingResultPoint[] points = result.getRXingResultPoints();
|
||||
if (points != null) {
|
||||
points[0] = new ResultPoint(width - points[0].getX() - 1, points[0].getY());
|
||||
points[1] = new ResultPoint(width - points[1].getX() - 1, points[1].getY());
|
||||
points[0] = new RXingResultPoint(width - points[0].getX() - 1, points[0].getY());
|
||||
points[1] = new RXingResultPoint(width - points[1].getX() - 1, points[1].getY());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -285,12 +285,12 @@ public abstract class OneDReader implements Reader {
|
||||
* @param rowNumber row number from top of the row
|
||||
* @param row the black/white pixel data of the row
|
||||
* @param hints decode hints
|
||||
* @return {@link Result} containing encoded string and start/end of barcode
|
||||
* @return {@link RXingResult} containing encoded string and start/end of barcode
|
||||
* @throws NotFoundException if no potential barcode is found
|
||||
* @throws ChecksumException if a potential barcode is found but does not pass its checksum
|
||||
* @throws FormatException if a potential barcode is found but format is invalid
|
||||
*/
|
||||
public abstract Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
public abstract RXingResult decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, ChecksumException, FormatException;
|
||||
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public abstract class OneDimensionalCodeWriter implements Writer {
|
||||
}
|
||||
|
||||
boolean[] code = encode(contents, hints);
|
||||
return renderResult(code, width, height, sidesMargin);
|
||||
return renderRXingResult(code, width, height, sidesMargin);
|
||||
}
|
||||
|
||||
protected Collection<BarcodeFormat> getSupportedWriteFormats() {
|
||||
@@ -100,7 +100,7 @@ public abstract class OneDimensionalCodeWriter implements Writer {
|
||||
/**
|
||||
* @return a byte array of horizontal pixels (0 = white, 1 = black)
|
||||
*/
|
||||
private static BitMatrix renderResult(boolean[] code, int width, int height, int sidesMargin) {
|
||||
private static BitMatrix renderRXingResult(boolean[] code, int width, int height, int sidesMargin) {
|
||||
int inputWidth = code.length;
|
||||
// Add quiet zone on both sides.
|
||||
int fullWidth = inputWidth + sidesMargin;
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.google.zxing.ChecksumException;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -38,29 +38,29 @@ public final class UPCAReader extends UPCEANReader {
|
||||
private final UPCEANReader ean13Reader = new EAN13Reader();
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber,
|
||||
public RXingResult decodeRow(int rowNumber,
|
||||
BitArray row,
|
||||
int[] startGuardRange,
|
||||
Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, FormatException, ChecksumException {
|
||||
return maybeReturnResult(ean13Reader.decodeRow(rowNumber, row, startGuardRange, hints));
|
||||
return maybeReturnRXingResult(ean13Reader.decodeRow(rowNumber, row, startGuardRange, hints));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
public RXingResult decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, FormatException, ChecksumException {
|
||||
return maybeReturnResult(ean13Reader.decodeRow(rowNumber, row, hints));
|
||||
return maybeReturnRXingResult(ean13Reader.decodeRow(rowNumber, row, hints));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image) throws NotFoundException, FormatException {
|
||||
return maybeReturnResult(ean13Reader.decode(image));
|
||||
public RXingResult decode(BinaryBitmap image) throws NotFoundException, FormatException {
|
||||
return maybeReturnRXingResult(ean13Reader.decode(image));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
|
||||
public RXingResult decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, FormatException {
|
||||
return maybeReturnResult(ean13Reader.decode(image, hints));
|
||||
return maybeReturnRXingResult(ean13Reader.decode(image, hints));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,14 +74,14 @@ public final class UPCAReader extends UPCEANReader {
|
||||
return ean13Reader.decodeMiddle(row, startRange, resultString);
|
||||
}
|
||||
|
||||
private static Result maybeReturnResult(Result result) throws FormatException {
|
||||
private static RXingResult maybeReturnRXingResult(RXingResult result) throws FormatException {
|
||||
String text = result.getText();
|
||||
if (text.charAt(0) == '0') {
|
||||
Result upcaResult = new Result(text.substring(1), null, result.getResultPoints(), BarcodeFormat.UPC_A);
|
||||
if (result.getResultMetadata() != null) {
|
||||
upcaResult.putAllMetadata(result.getResultMetadata());
|
||||
RXingResult upcaRXingResult = new RXingResult(text.substring(1), null, result.getRXingResultPoints(), BarcodeFormat.UPC_A);
|
||||
if (result.getRXingResultMetadata() != null) {
|
||||
upcaRXingResult.putAllMetadata(result.getRXingResultMetadata());
|
||||
}
|
||||
return upcaResult;
|
||||
return upcaRXingResult;
|
||||
} else {
|
||||
throw FormatException.getFormatInstance();
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ package com.google.zxing.oned;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.EnumMap;
|
||||
@@ -34,27 +34,27 @@ final class UPCEANExtension2Support {
|
||||
private final int[] decodeMiddleCounters = new int[4];
|
||||
private final StringBuilder decodeRowStringBuffer = new StringBuilder();
|
||||
|
||||
Result decodeRow(int rowNumber, BitArray row, int[] extensionStartRange) throws NotFoundException {
|
||||
RXingResult decodeRow(int rowNumber, BitArray row, int[] extensionStartRange) throws NotFoundException {
|
||||
|
||||
StringBuilder result = decodeRowStringBuffer;
|
||||
result.setLength(0);
|
||||
int end = decodeMiddle(row, extensionStartRange, result);
|
||||
|
||||
String resultString = result.toString();
|
||||
Map<ResultMetadataType,Object> extensionData = parseExtensionString(resultString);
|
||||
Map<RXingResultMetadataType,Object> extensionData = parseExtensionString(resultString);
|
||||
|
||||
Result extensionResult =
|
||||
new Result(resultString,
|
||||
RXingResult extensionRXingResult =
|
||||
new RXingResult(resultString,
|
||||
null,
|
||||
new ResultPoint[] {
|
||||
new ResultPoint((extensionStartRange[0] + extensionStartRange[1]) / 2.0f, rowNumber),
|
||||
new ResultPoint(end, rowNumber),
|
||||
new RXingResultPoint[] {
|
||||
new RXingResultPoint((extensionStartRange[0] + extensionStartRange[1]) / 2.0f, rowNumber),
|
||||
new RXingResultPoint(end, rowNumber),
|
||||
},
|
||||
BarcodeFormat.UPC_EAN_EXTENSION);
|
||||
if (extensionData != null) {
|
||||
extensionResult.putAllMetadata(extensionData);
|
||||
extensionRXingResult.putAllMetadata(extensionData);
|
||||
}
|
||||
return extensionResult;
|
||||
return extensionRXingResult;
|
||||
}
|
||||
|
||||
private int decodeMiddle(BitArray row, int[] startRange, StringBuilder resultString) throws NotFoundException {
|
||||
@@ -98,14 +98,14 @@ final class UPCEANExtension2Support {
|
||||
/**
|
||||
* @param raw raw content of extension
|
||||
* @return formatted interpretation of raw content as a {@link Map} mapping
|
||||
* one {@link ResultMetadataType} to appropriate value, or {@code null} if not known
|
||||
* one {@link RXingResultMetadataType} to appropriate value, or {@code null} if not known
|
||||
*/
|
||||
private static Map<ResultMetadataType,Object> parseExtensionString(String raw) {
|
||||
private static Map<RXingResultMetadataType,Object> parseExtensionString(String raw) {
|
||||
if (raw.length() != 2) {
|
||||
return null;
|
||||
}
|
||||
Map<ResultMetadataType,Object> result = new EnumMap<>(ResultMetadataType.class);
|
||||
result.put(ResultMetadataType.ISSUE_NUMBER, Integer.valueOf(raw));
|
||||
Map<RXingResultMetadataType,Object> result = new EnumMap<>(RXingResultMetadataType.class);
|
||||
result.put(RXingResultMetadataType.ISSUE_NUMBER, Integer.valueOf(raw));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ package com.google.zxing.oned;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.EnumMap;
|
||||
@@ -38,27 +38,27 @@ final class UPCEANExtension5Support {
|
||||
private final int[] decodeMiddleCounters = new int[4];
|
||||
private final StringBuilder decodeRowStringBuffer = new StringBuilder();
|
||||
|
||||
Result decodeRow(int rowNumber, BitArray row, int[] extensionStartRange) throws NotFoundException {
|
||||
RXingResult decodeRow(int rowNumber, BitArray row, int[] extensionStartRange) throws NotFoundException {
|
||||
|
||||
StringBuilder result = decodeRowStringBuffer;
|
||||
result.setLength(0);
|
||||
int end = decodeMiddle(row, extensionStartRange, result);
|
||||
|
||||
String resultString = result.toString();
|
||||
Map<ResultMetadataType,Object> extensionData = parseExtensionString(resultString);
|
||||
Map<RXingResultMetadataType,Object> extensionData = parseExtensionString(resultString);
|
||||
|
||||
Result extensionResult =
|
||||
new Result(resultString,
|
||||
RXingResult extensionRXingResult =
|
||||
new RXingResult(resultString,
|
||||
null,
|
||||
new ResultPoint[] {
|
||||
new ResultPoint((extensionStartRange[0] + extensionStartRange[1]) / 2.0f, rowNumber),
|
||||
new ResultPoint(end, rowNumber),
|
||||
new RXingResultPoint[] {
|
||||
new RXingResultPoint((extensionStartRange[0] + extensionStartRange[1]) / 2.0f, rowNumber),
|
||||
new RXingResultPoint(end, rowNumber),
|
||||
},
|
||||
BarcodeFormat.UPC_EAN_EXTENSION);
|
||||
if (extensionData != null) {
|
||||
extensionResult.putAllMetadata(extensionData);
|
||||
extensionRXingResult.putAllMetadata(extensionData);
|
||||
}
|
||||
return extensionResult;
|
||||
return extensionRXingResult;
|
||||
}
|
||||
|
||||
private int decodeMiddle(BitArray row, int[] startRange, StringBuilder resultString) throws NotFoundException {
|
||||
@@ -127,9 +127,9 @@ final class UPCEANExtension5Support {
|
||||
/**
|
||||
* @param raw raw content of extension
|
||||
* @return formatted interpretation of raw content as a {@link Map} mapping
|
||||
* one {@link ResultMetadataType} to appropriate value, or {@code null} if not known
|
||||
* one {@link RXingResultMetadataType} to appropriate value, or {@code null} if not known
|
||||
*/
|
||||
private static Map<ResultMetadataType,Object> parseExtensionString(String raw) {
|
||||
private static Map<RXingResultMetadataType,Object> parseExtensionString(String raw) {
|
||||
if (raw.length() != 5) {
|
||||
return null;
|
||||
}
|
||||
@@ -137,8 +137,8 @@ final class UPCEANExtension5Support {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
Map<ResultMetadataType,Object> result = new EnumMap<>(ResultMetadataType.class);
|
||||
result.put(ResultMetadataType.SUGGESTED_PRICE, value);
|
||||
Map<RXingResultMetadataType,Object> result = new EnumMap<>(RXingResultMetadataType.class);
|
||||
result.put(RXingResultMetadataType.SUGGESTED_PRICE, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.google.zxing.oned;
|
||||
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.ReaderException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
final class UPCEANExtensionSupport {
|
||||
@@ -28,7 +28,7 @@ final class UPCEANExtensionSupport {
|
||||
private final UPCEANExtension2Support twoSupport = new UPCEANExtension2Support();
|
||||
private final UPCEANExtension5Support fiveSupport = new UPCEANExtension5Support();
|
||||
|
||||
Result decodeRow(int rowNumber, BitArray row, int rowOffset) throws NotFoundException {
|
||||
RXingResult decodeRow(int rowNumber, BitArray row, int rowOffset) throws NotFoundException {
|
||||
int[] extensionStartRange = UPCEANReader.findGuardPattern(row, rowOffset, false, EXTENSION_START_PATTERN);
|
||||
try {
|
||||
return fiveSupport.decodeRow(rowNumber, row, extensionStartRange);
|
||||
|
||||
@@ -22,10 +22,10 @@ import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.ReaderException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.ResultPointCallback;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.RXingResultPointCallback;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -126,7 +126,7 @@ public abstract class UPCEANReader extends OneDReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
public RXingResult decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, ChecksumException, FormatException {
|
||||
return decodeRow(rowNumber, row, findStartGuardPattern(row), hints);
|
||||
}
|
||||
@@ -140,23 +140,23 @@ public abstract class UPCEANReader extends OneDReader {
|
||||
* @param row encoding of the row of the barcode image
|
||||
* @param startGuardRange start/end column where the opening start pattern was found
|
||||
* @param hints optional hints that influence decoding
|
||||
* @return {@link Result} encapsulating the result of decoding a barcode in the row
|
||||
* @return {@link RXingResult} encapsulating the result of decoding a barcode in the row
|
||||
* @throws NotFoundException if no potential barcode is found
|
||||
* @throws ChecksumException if a potential barcode is found but does not pass its checksum
|
||||
* @throws FormatException if a potential barcode is found but format is invalid
|
||||
*/
|
||||
public Result decodeRow(int rowNumber,
|
||||
public RXingResult decodeRow(int rowNumber,
|
||||
BitArray row,
|
||||
int[] startGuardRange,
|
||||
Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, ChecksumException, FormatException {
|
||||
|
||||
ResultPointCallback resultPointCallback = hints == null ? null :
|
||||
(ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
|
||||
RXingResultPointCallback resultPointCallback = hints == null ? null :
|
||||
(RXingResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
|
||||
int symbologyIdentifier = 0;
|
||||
|
||||
if (resultPointCallback != null) {
|
||||
resultPointCallback.foundPossibleResultPoint(new ResultPoint(
|
||||
resultPointCallback.foundPossibleRXingResultPoint(new RXingResultPoint(
|
||||
(startGuardRange[0] + startGuardRange[1]) / 2.0f, rowNumber
|
||||
));
|
||||
}
|
||||
@@ -166,7 +166,7 @@ public abstract class UPCEANReader extends OneDReader {
|
||||
int endStart = decodeMiddle(row, startGuardRange, result);
|
||||
|
||||
if (resultPointCallback != null) {
|
||||
resultPointCallback.foundPossibleResultPoint(new ResultPoint(
|
||||
resultPointCallback.foundPossibleRXingResultPoint(new RXingResultPoint(
|
||||
endStart, rowNumber
|
||||
));
|
||||
}
|
||||
@@ -174,7 +174,7 @@ public abstract class UPCEANReader extends OneDReader {
|
||||
int[] endRange = decodeEnd(row, endStart);
|
||||
|
||||
if (resultPointCallback != null) {
|
||||
resultPointCallback.foundPossibleResultPoint(new ResultPoint(
|
||||
resultPointCallback.foundPossibleRXingResultPoint(new RXingResultPoint(
|
||||
(endRange[0] + endRange[1]) / 2.0f, rowNumber
|
||||
));
|
||||
}
|
||||
@@ -200,21 +200,21 @@ public abstract class UPCEANReader extends OneDReader {
|
||||
float left = (startGuardRange[1] + startGuardRange[0]) / 2.0f;
|
||||
float right = (endRange[1] + endRange[0]) / 2.0f;
|
||||
BarcodeFormat format = getBarcodeFormat();
|
||||
Result decodeResult = new Result(resultString,
|
||||
RXingResult decodeRXingResult = new RXingResult(resultString,
|
||||
null, // no natural byte representation for these barcodes
|
||||
new ResultPoint[]{
|
||||
new ResultPoint(left, rowNumber),
|
||||
new ResultPoint(right, rowNumber)},
|
||||
new RXingResultPoint[]{
|
||||
new RXingResultPoint(left, rowNumber),
|
||||
new RXingResultPoint(right, rowNumber)},
|
||||
format);
|
||||
|
||||
int extensionLength = 0;
|
||||
|
||||
try {
|
||||
Result extensionResult = extensionReader.decodeRow(rowNumber, row, endRange[1]);
|
||||
decodeResult.putMetadata(ResultMetadataType.UPC_EAN_EXTENSION, extensionResult.getText());
|
||||
decodeResult.putAllMetadata(extensionResult.getResultMetadata());
|
||||
decodeResult.addResultPoints(extensionResult.getResultPoints());
|
||||
extensionLength = extensionResult.getText().length();
|
||||
RXingResult extensionRXingResult = extensionReader.decodeRow(rowNumber, row, endRange[1]);
|
||||
decodeRXingResult.putMetadata(RXingResultMetadataType.UPC_EAN_EXTENSION, extensionRXingResult.getText());
|
||||
decodeRXingResult.putAllMetadata(extensionRXingResult.getRXingResultMetadata());
|
||||
decodeRXingResult.addRXingResultPoints(extensionRXingResult.getRXingResultPoints());
|
||||
extensionLength = extensionRXingResult.getText().length();
|
||||
} catch (ReaderException re) {
|
||||
// continue
|
||||
}
|
||||
@@ -237,16 +237,16 @@ public abstract class UPCEANReader extends OneDReader {
|
||||
if (format == BarcodeFormat.EAN_13 || format == BarcodeFormat.UPC_A) {
|
||||
String countryID = eanManSupport.lookupCountryIdentifier(resultString);
|
||||
if (countryID != null) {
|
||||
decodeResult.putMetadata(ResultMetadataType.POSSIBLE_COUNTRY, countryID);
|
||||
decodeRXingResult.putMetadata(RXingResultMetadataType.POSSIBLE_COUNTRY, countryID);
|
||||
}
|
||||
}
|
||||
if (format == BarcodeFormat.EAN_8) {
|
||||
symbologyIdentifier = 4;
|
||||
}
|
||||
|
||||
decodeResult.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]E" + symbologyIdentifier);
|
||||
decodeRXingResult.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]E" + symbologyIdentifier);
|
||||
|
||||
return decodeResult;
|
||||
return decodeRXingResult;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.zxing.oned.rss;
|
||||
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
|
||||
/**
|
||||
* Encapsulates an RSS barcode finder pattern, including its start/end position and row.
|
||||
@@ -25,14 +25,14 @@ public final class FinderPattern {
|
||||
|
||||
private final int value;
|
||||
private final int[] startEnd;
|
||||
private final ResultPoint[] resultPoints;
|
||||
private final RXingResultPoint[] resultPoints;
|
||||
|
||||
public FinderPattern(int value, int[] startEnd, int start, int end, int rowNumber) {
|
||||
this.value = value;
|
||||
this.startEnd = startEnd;
|
||||
this.resultPoints = new ResultPoint[] {
|
||||
new ResultPoint(start, rowNumber),
|
||||
new ResultPoint(end, rowNumber),
|
||||
this.resultPoints = new RXingResultPoint[] {
|
||||
new RXingResultPoint(start, rowNumber),
|
||||
new RXingResultPoint(end, rowNumber),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public final class FinderPattern {
|
||||
return startEnd;
|
||||
}
|
||||
|
||||
public ResultPoint[] getResultPoints() {
|
||||
public RXingResultPoint[] getRXingResultPoints() {
|
||||
return resultPoints;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ package com.google.zxing.oned.rss;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.ResultPointCallback;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.RXingResultPointCallback;
|
||||
import com.google.zxing.common.BitArray;
|
||||
import com.google.zxing.common.detector.MathUtils;
|
||||
|
||||
@@ -65,7 +65,7 @@ public final class RSS14Reader extends AbstractRSSReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber,
|
||||
public RXingResult decodeRow(int rowNumber,
|
||||
BitArray row,
|
||||
Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
Pair leftPair = decodePair(row, false, rowNumber, hints);
|
||||
@@ -78,7 +78,7 @@ public final class RSS14Reader extends AbstractRSSReader {
|
||||
if (left.getCount() > 1) {
|
||||
for (Pair right : possibleRightPairs) {
|
||||
if (right.getCount() > 1 && checkChecksum(left, right)) {
|
||||
return constructResult(left, right);
|
||||
return constructRXingResult(left, right);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ public final class RSS14Reader extends AbstractRSSReader {
|
||||
possibleRightPairs.clear();
|
||||
}
|
||||
|
||||
private static Result constructResult(Pair leftPair, Pair rightPair) {
|
||||
private static RXingResult constructRXingResult(Pair leftPair, Pair rightPair) {
|
||||
long symbolValue = 4537077L * leftPair.getValue() + rightPair.getValue();
|
||||
String text = String.valueOf(symbolValue);
|
||||
|
||||
@@ -130,14 +130,14 @@ public final class RSS14Reader extends AbstractRSSReader {
|
||||
}
|
||||
buffer.append(checkDigit);
|
||||
|
||||
ResultPoint[] leftPoints = leftPair.getFinderPattern().getResultPoints();
|
||||
ResultPoint[] rightPoints = rightPair.getFinderPattern().getResultPoints();
|
||||
Result result = new Result(
|
||||
RXingResultPoint[] leftPoints = leftPair.getFinderPattern().getRXingResultPoints();
|
||||
RXingResultPoint[] rightPoints = rightPair.getFinderPattern().getRXingResultPoints();
|
||||
RXingResult result = new RXingResult(
|
||||
buffer.toString(),
|
||||
null,
|
||||
new ResultPoint[] { leftPoints[0], leftPoints[1], rightPoints[0], rightPoints[1], },
|
||||
new RXingResultPoint[] { leftPoints[0], leftPoints[1], rightPoints[0], rightPoints[1], },
|
||||
BarcodeFormat.RSS_14);
|
||||
result.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]e0");
|
||||
result.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]e0");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -159,8 +159,8 @@ public final class RSS14Reader extends AbstractRSSReader {
|
||||
int[] startEnd = findFinderPattern(row, right);
|
||||
FinderPattern pattern = parseFoundFinderPattern(row, rowNumber, right, startEnd);
|
||||
|
||||
ResultPointCallback resultPointCallback = hints == null ? null :
|
||||
(ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
|
||||
RXingResultPointCallback resultPointCallback = hints == null ? null :
|
||||
(RXingResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
|
||||
|
||||
if (resultPointCallback != null) {
|
||||
startEnd = pattern.getStartEnd();
|
||||
@@ -169,7 +169,7 @@ public final class RSS14Reader extends AbstractRSSReader {
|
||||
// row is actually reversed
|
||||
center = row.getSize() - 1 - center;
|
||||
}
|
||||
resultPointCallback.foundPossibleResultPoint(new ResultPoint(center, rowNumber));
|
||||
resultPointCallback.foundPossibleRXingResultPoint(new RXingResultPoint(center, rowNumber));
|
||||
}
|
||||
|
||||
DataCharacter outside = decodeDataCharacter(row, pattern, true);
|
||||
|
||||
@@ -30,9 +30,9 @@ import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitArray;
|
||||
import com.google.zxing.common.detector.MathUtils;
|
||||
import com.google.zxing.oned.rss.AbstractRSSReader;
|
||||
@@ -123,7 +123,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
||||
private boolean startFromEven;
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber,
|
||||
public RXingResult decodeRow(int rowNumber,
|
||||
BitArray row,
|
||||
Map<DecodeHintType,?> hints) throws NotFoundException, FormatException {
|
||||
// Rows can start with even pattern in case in prev rows there where odd number of patters.
|
||||
@@ -131,14 +131,14 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
||||
this.pairs.clear();
|
||||
this.startFromEven = false;
|
||||
try {
|
||||
return constructResult(decodeRow2pairs(rowNumber, row));
|
||||
return constructRXingResult(decodeRow2pairs(rowNumber, row));
|
||||
} catch (NotFoundException e) {
|
||||
// OK
|
||||
}
|
||||
|
||||
this.pairs.clear();
|
||||
this.startFromEven = true;
|
||||
return constructResult(decodeRow2pairs(rowNumber, row));
|
||||
return constructRXingResult(decodeRow2pairs(rowNumber, row));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -348,22 +348,22 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
||||
}
|
||||
|
||||
// Not private for unit testing
|
||||
static Result constructResult(List<ExpandedPair> pairs) throws NotFoundException, FormatException {
|
||||
static RXingResult constructRXingResult(List<ExpandedPair> pairs) throws NotFoundException, FormatException {
|
||||
BitArray binary = BitArrayBuilder.buildBitArray(pairs);
|
||||
|
||||
AbstractExpandedDecoder decoder = AbstractExpandedDecoder.createDecoder(binary);
|
||||
String resultingString = decoder.parseInformation();
|
||||
|
||||
ResultPoint[] firstPoints = pairs.get(0).getFinderPattern().getResultPoints();
|
||||
ResultPoint[] lastPoints = pairs.get(pairs.size() - 1).getFinderPattern().getResultPoints();
|
||||
RXingResultPoint[] firstPoints = pairs.get(0).getFinderPattern().getRXingResultPoints();
|
||||
RXingResultPoint[] lastPoints = pairs.get(pairs.size() - 1).getFinderPattern().getRXingResultPoints();
|
||||
|
||||
Result result = new Result(
|
||||
RXingResult result = new RXingResult(
|
||||
resultingString,
|
||||
null,
|
||||
new ResultPoint[]{firstPoints[0], firstPoints[1], lastPoints[0], lastPoints[1]},
|
||||
new RXingResultPoint[]{firstPoints[0], firstPoints[1], lastPoints[0], lastPoints[1]},
|
||||
BarcodeFormat.RSS_EXPANDED
|
||||
);
|
||||
result.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]e0");
|
||||
result.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]e0");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,16 +30,16 @@ package com.google.zxing.oned.rss.expanded.decoders;
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
* @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
|
||||
*/
|
||||
final class BlockParsedResult {
|
||||
final class BlockParsedRXingResult {
|
||||
|
||||
private final DecodedInformation decodedInformation;
|
||||
private final boolean finished;
|
||||
|
||||
BlockParsedResult() {
|
||||
BlockParsedRXingResult() {
|
||||
this(null, false);
|
||||
}
|
||||
|
||||
BlockParsedResult(DecodedInformation information, boolean finished) {
|
||||
BlockParsedRXingResult(DecodedInformation information, boolean finished) {
|
||||
this.finished = finished;
|
||||
this.decodedInformation = information;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ final class GeneralAppIdDecoder {
|
||||
|
||||
private DecodedInformation parseBlocks() throws FormatException {
|
||||
boolean isFinished;
|
||||
BlockParsedResult result;
|
||||
BlockParsedRXingResult result;
|
||||
do {
|
||||
int initialPosition = current.getPosition();
|
||||
|
||||
@@ -158,7 +158,7 @@ final class GeneralAppIdDecoder {
|
||||
return result.getDecodedInformation();
|
||||
}
|
||||
|
||||
private BlockParsedResult parseNumericBlock() throws FormatException {
|
||||
private BlockParsedRXingResult parseNumericBlock() throws FormatException {
|
||||
while (isStillNumeric(current.getPosition())) {
|
||||
DecodedNumeric numeric = decodeNumeric(current.getPosition());
|
||||
current.setPosition(numeric.getNewPosition());
|
||||
@@ -170,13 +170,13 @@ final class GeneralAppIdDecoder {
|
||||
} else {
|
||||
information = new DecodedInformation(current.getPosition(), buffer.toString(), numeric.getSecondDigit());
|
||||
}
|
||||
return new BlockParsedResult(information, true);
|
||||
return new BlockParsedRXingResult(information, true);
|
||||
}
|
||||
buffer.append(numeric.getFirstDigit());
|
||||
|
||||
if (numeric.isSecondDigitFNC1()) {
|
||||
DecodedInformation information = new DecodedInformation(current.getPosition(), buffer.toString());
|
||||
return new BlockParsedResult(information, true);
|
||||
return new BlockParsedRXingResult(information, true);
|
||||
}
|
||||
buffer.append(numeric.getSecondDigit());
|
||||
}
|
||||
@@ -185,17 +185,17 @@ final class GeneralAppIdDecoder {
|
||||
current.setAlpha();
|
||||
current.incrementPosition(4);
|
||||
}
|
||||
return new BlockParsedResult();
|
||||
return new BlockParsedRXingResult();
|
||||
}
|
||||
|
||||
private BlockParsedResult parseIsoIec646Block() throws FormatException {
|
||||
private BlockParsedRXingResult parseIsoIec646Block() throws FormatException {
|
||||
while (isStillIsoIec646(current.getPosition())) {
|
||||
DecodedChar iso = decodeIsoIec646(current.getPosition());
|
||||
current.setPosition(iso.getNewPosition());
|
||||
|
||||
if (iso.isFNC1()) {
|
||||
DecodedInformation information = new DecodedInformation(current.getPosition(), buffer.toString());
|
||||
return new BlockParsedResult(information, true);
|
||||
return new BlockParsedRXingResult(information, true);
|
||||
}
|
||||
buffer.append(iso.getValue());
|
||||
}
|
||||
@@ -212,17 +212,17 @@ final class GeneralAppIdDecoder {
|
||||
|
||||
current.setAlpha();
|
||||
}
|
||||
return new BlockParsedResult();
|
||||
return new BlockParsedRXingResult();
|
||||
}
|
||||
|
||||
private BlockParsedResult parseAlphaBlock() {
|
||||
private BlockParsedRXingResult parseAlphaBlock() {
|
||||
while (isStillAlpha(current.getPosition())) {
|
||||
DecodedChar alpha = decodeAlphanumeric(current.getPosition());
|
||||
current.setPosition(alpha.getNewPosition());
|
||||
|
||||
if (alpha.isFNC1()) {
|
||||
DecodedInformation information = new DecodedInformation(current.getPosition(), buffer.toString());
|
||||
return new BlockParsedResult(information, true); //end of the char block
|
||||
return new BlockParsedRXingResult(information, true); //end of the char block
|
||||
}
|
||||
|
||||
buffer.append(alpha.getValue());
|
||||
@@ -240,7 +240,7 @@ final class GeneralAppIdDecoder {
|
||||
|
||||
current.setIsoIec646();
|
||||
}
|
||||
return new BlockParsedResult();
|
||||
return new BlockParsedRXingResult();
|
||||
}
|
||||
|
||||
private boolean isStillIsoIec646(int pos) {
|
||||
|
||||
@@ -23,14 +23,14 @@ import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Reader;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.common.DecoderResult;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.DecoderRXingResult;
|
||||
import com.google.zxing.multi.MultipleBarcodeReader;
|
||||
import com.google.zxing.pdf417.decoder.PDF417ScanningDecoder;
|
||||
import com.google.zxing.pdf417.detector.Detector;
|
||||
import com.google.zxing.pdf417.detector.PDF417DetectorResult;
|
||||
import com.google.zxing.pdf417.detector.PDF417DetectorRXingResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -43,7 +43,7 @@ import java.util.Map;
|
||||
*/
|
||||
public final class PDF417Reader implements Reader, MultipleBarcodeReader {
|
||||
|
||||
private static final Result[] EMPTY_RESULT_ARRAY = new Result[0];
|
||||
private static final RXingResult[] EMPTY_RESULT_ARRAY = new RXingResult[0];
|
||||
|
||||
/**
|
||||
* Locates and decodes a PDF417 code in an image.
|
||||
@@ -53,14 +53,14 @@ public final class PDF417Reader implements Reader, MultipleBarcodeReader {
|
||||
* @throws FormatException if a PDF417 cannot be decoded
|
||||
*/
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image) throws NotFoundException, FormatException, ChecksumException {
|
||||
public RXingResult decode(BinaryBitmap image) throws NotFoundException, FormatException, ChecksumException {
|
||||
return decode(image, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException, FormatException,
|
||||
public RXingResult decode(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException, FormatException,
|
||||
ChecksumException {
|
||||
Result[] result = decode(image, hints, false);
|
||||
RXingResult[] result = decode(image, hints, false);
|
||||
if (result.length == 0 || result[0] == null) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
@@ -68,12 +68,12 @@ public final class PDF417Reader implements Reader, MultipleBarcodeReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result[] decodeMultiple(BinaryBitmap image) throws NotFoundException {
|
||||
public RXingResult[] decodeMultiple(BinaryBitmap image) throws NotFoundException {
|
||||
return decodeMultiple(image, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result[] decodeMultiple(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
public RXingResult[] decodeMultiple(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
try {
|
||||
return decode(image, hints, true);
|
||||
} catch (FormatException | ChecksumException ignored) {
|
||||
@@ -81,41 +81,41 @@ public final class PDF417Reader implements Reader, MultipleBarcodeReader {
|
||||
}
|
||||
}
|
||||
|
||||
private static Result[] decode(BinaryBitmap image, Map<DecodeHintType, ?> hints, boolean multiple)
|
||||
private static RXingResult[] decode(BinaryBitmap image, Map<DecodeHintType, ?> hints, boolean multiple)
|
||||
throws NotFoundException, FormatException, ChecksumException {
|
||||
List<Result> results = new ArrayList<>();
|
||||
PDF417DetectorResult detectorResult = Detector.detect(image, hints, multiple);
|
||||
for (ResultPoint[] points : detectorResult.getPoints()) {
|
||||
DecoderResult decoderResult = PDF417ScanningDecoder.decode(detectorResult.getBits(), points[4], points[5],
|
||||
List<RXingResult> results = new ArrayList<>();
|
||||
PDF417DetectorRXingResult detectorRXingResult = Detector.detect(image, hints, multiple);
|
||||
for (RXingResultPoint[] points : detectorRXingResult.getPoints()) {
|
||||
DecoderRXingResult decoderRXingResult = PDF417ScanningDecoder.decode(detectorRXingResult.getBits(), points[4], points[5],
|
||||
points[6], points[7], getMinCodewordWidth(points), getMaxCodewordWidth(points));
|
||||
Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.PDF_417);
|
||||
result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult.getECLevel());
|
||||
PDF417ResultMetadata pdf417ResultMetadata = (PDF417ResultMetadata) decoderResult.getOther();
|
||||
if (pdf417ResultMetadata != null) {
|
||||
result.putMetadata(ResultMetadataType.PDF417_EXTRA_METADATA, pdf417ResultMetadata);
|
||||
RXingResult result = new RXingResult(decoderRXingResult.getText(), decoderRXingResult.getRawBytes(), points, BarcodeFormat.PDF_417);
|
||||
result.putMetadata(RXingResultMetadataType.ERROR_CORRECTION_LEVEL, decoderRXingResult.getECLevel());
|
||||
PDF417RXingResultMetadata pdf417RXingResultMetadata = (PDF417RXingResultMetadata) decoderRXingResult.getOther();
|
||||
if (pdf417RXingResultMetadata != null) {
|
||||
result.putMetadata(RXingResultMetadataType.PDF417_EXTRA_METADATA, pdf417RXingResultMetadata);
|
||||
}
|
||||
result.putMetadata(ResultMetadataType.ORIENTATION, detectorResult.getRotation());
|
||||
result.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]L" + decoderResult.getSymbologyModifier());
|
||||
result.putMetadata(RXingResultMetadataType.ORIENTATION, detectorRXingResult.getRotation());
|
||||
result.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]L" + decoderRXingResult.getSymbologyModifier());
|
||||
results.add(result);
|
||||
}
|
||||
return results.toArray(EMPTY_RESULT_ARRAY);
|
||||
}
|
||||
|
||||
private static int getMaxWidth(ResultPoint p1, ResultPoint p2) {
|
||||
private static int getMaxWidth(RXingResultPoint p1, RXingResultPoint p2) {
|
||||
if (p1 == null || p2 == null) {
|
||||
return 0;
|
||||
}
|
||||
return (int) Math.abs(p1.getX() - p2.getX());
|
||||
}
|
||||
|
||||
private static int getMinWidth(ResultPoint p1, ResultPoint p2) {
|
||||
private static int getMinWidth(RXingResultPoint p1, RXingResultPoint p2) {
|
||||
if (p1 == null || p2 == null) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
return (int) Math.abs(p1.getX() - p2.getX());
|
||||
}
|
||||
|
||||
private static int getMaxCodewordWidth(ResultPoint[] p) {
|
||||
private static int getMaxCodewordWidth(RXingResultPoint[] p) {
|
||||
return Math.max(
|
||||
Math.max(getMaxWidth(p[0], p[4]), getMaxWidth(p[6], p[2]) * PDF417Common.MODULES_IN_CODEWORD /
|
||||
PDF417Common.MODULES_IN_STOP_PATTERN),
|
||||
@@ -123,7 +123,7 @@ public final class PDF417Reader implements Reader, MultipleBarcodeReader {
|
||||
PDF417Common.MODULES_IN_STOP_PATTERN));
|
||||
}
|
||||
|
||||
private static int getMinCodewordWidth(ResultPoint[] p) {
|
||||
private static int getMinCodewordWidth(RXingResultPoint[] p) {
|
||||
return Math.min(
|
||||
Math.min(getMinWidth(p[0], p[4]), getMinWidth(p[6], p[2]) * PDF417Common.MODULES_IN_CODEWORD /
|
||||
PDF417Common.MODULES_IN_STOP_PATTERN),
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.google.zxing.pdf417;
|
||||
/**
|
||||
* @author Guenther Grau
|
||||
*/
|
||||
public final class PDF417ResultMetadata {
|
||||
public final class PDF417RXingResultMetadata {
|
||||
|
||||
private int segmentIndex;
|
||||
private String fileId;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.google.zxing.pdf417.decoder;
|
||||
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
|
||||
/**
|
||||
@@ -26,31 +26,31 @@ import com.google.zxing.common.BitMatrix;
|
||||
final class BoundingBox {
|
||||
|
||||
private final BitMatrix image;
|
||||
private final ResultPoint topLeft;
|
||||
private final ResultPoint bottomLeft;
|
||||
private final ResultPoint topRight;
|
||||
private final ResultPoint bottomRight;
|
||||
private final RXingResultPoint topLeft;
|
||||
private final RXingResultPoint bottomLeft;
|
||||
private final RXingResultPoint topRight;
|
||||
private final RXingResultPoint bottomRight;
|
||||
private final int minX;
|
||||
private final int maxX;
|
||||
private final int minY;
|
||||
private final int maxY;
|
||||
|
||||
BoundingBox(BitMatrix image,
|
||||
ResultPoint topLeft,
|
||||
ResultPoint bottomLeft,
|
||||
ResultPoint topRight,
|
||||
ResultPoint bottomRight) throws NotFoundException {
|
||||
RXingResultPoint topLeft,
|
||||
RXingResultPoint bottomLeft,
|
||||
RXingResultPoint topRight,
|
||||
RXingResultPoint bottomRight) throws NotFoundException {
|
||||
boolean leftUnspecified = topLeft == null || bottomLeft == null;
|
||||
boolean rightUnspecified = topRight == null || bottomRight == null;
|
||||
if (leftUnspecified && rightUnspecified) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
if (leftUnspecified) {
|
||||
topLeft = new ResultPoint(0, topRight.getY());
|
||||
bottomLeft = new ResultPoint(0, bottomRight.getY());
|
||||
topLeft = new RXingResultPoint(0, topRight.getY());
|
||||
bottomLeft = new RXingResultPoint(0, bottomRight.getY());
|
||||
} else if (rightUnspecified) {
|
||||
topRight = new ResultPoint(image.getWidth() - 1, topLeft.getY());
|
||||
bottomRight = new ResultPoint(image.getWidth() - 1, bottomLeft.getY());
|
||||
topRight = new RXingResultPoint(image.getWidth() - 1, topLeft.getY());
|
||||
bottomRight = new RXingResultPoint(image.getWidth() - 1, bottomLeft.getY());
|
||||
}
|
||||
this.image = image;
|
||||
this.topLeft = topLeft;
|
||||
@@ -86,18 +86,18 @@ final class BoundingBox {
|
||||
}
|
||||
|
||||
BoundingBox addMissingRows(int missingStartRows, int missingEndRows, boolean isLeft) throws NotFoundException {
|
||||
ResultPoint newTopLeft = topLeft;
|
||||
ResultPoint newBottomLeft = bottomLeft;
|
||||
ResultPoint newTopRight = topRight;
|
||||
ResultPoint newBottomRight = bottomRight;
|
||||
RXingResultPoint newTopLeft = topLeft;
|
||||
RXingResultPoint newBottomLeft = bottomLeft;
|
||||
RXingResultPoint newTopRight = topRight;
|
||||
RXingResultPoint newBottomRight = bottomRight;
|
||||
|
||||
if (missingStartRows > 0) {
|
||||
ResultPoint top = isLeft ? topLeft : topRight;
|
||||
RXingResultPoint top = isLeft ? topLeft : topRight;
|
||||
int newMinY = (int) top.getY() - missingStartRows;
|
||||
if (newMinY < 0) {
|
||||
newMinY = 0;
|
||||
}
|
||||
ResultPoint newTop = new ResultPoint(top.getX(), newMinY);
|
||||
RXingResultPoint newTop = new RXingResultPoint(top.getX(), newMinY);
|
||||
if (isLeft) {
|
||||
newTopLeft = newTop;
|
||||
} else {
|
||||
@@ -106,12 +106,12 @@ final class BoundingBox {
|
||||
}
|
||||
|
||||
if (missingEndRows > 0) {
|
||||
ResultPoint bottom = isLeft ? bottomLeft : bottomRight;
|
||||
RXingResultPoint bottom = isLeft ? bottomLeft : bottomRight;
|
||||
int newMaxY = (int) bottom.getY() + missingEndRows;
|
||||
if (newMaxY >= image.getHeight()) {
|
||||
newMaxY = image.getHeight() - 1;
|
||||
}
|
||||
ResultPoint newBottom = new ResultPoint(bottom.getX(), newMaxY);
|
||||
RXingResultPoint newBottom = new RXingResultPoint(bottom.getX(), newMaxY);
|
||||
if (isLeft) {
|
||||
newBottomLeft = newBottom;
|
||||
} else {
|
||||
@@ -138,19 +138,19 @@ final class BoundingBox {
|
||||
return maxY;
|
||||
}
|
||||
|
||||
ResultPoint getTopLeft() {
|
||||
RXingResultPoint getTopLeft() {
|
||||
return topLeft;
|
||||
}
|
||||
|
||||
ResultPoint getTopRight() {
|
||||
RXingResultPoint getTopRight() {
|
||||
return topRight;
|
||||
}
|
||||
|
||||
ResultPoint getBottomLeft() {
|
||||
RXingResultPoint getBottomLeft() {
|
||||
return bottomLeft;
|
||||
}
|
||||
|
||||
ResultPoint getBottomRight() {
|
||||
RXingResultPoint getBottomRight() {
|
||||
return bottomRight;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ package com.google.zxing.pdf417.decoder;
|
||||
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.common.ECIStringBuilder;
|
||||
import com.google.zxing.common.DecoderResult;
|
||||
import com.google.zxing.pdf417.PDF417ResultMetadata;
|
||||
import com.google.zxing.common.DecoderRXingResult;
|
||||
import com.google.zxing.pdf417.PDF417RXingResultMetadata;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
@@ -97,10 +97,10 @@ final class DecodedBitStreamParser {
|
||||
private DecodedBitStreamParser() {
|
||||
}
|
||||
|
||||
static DecoderResult decode(int[] codewords, String ecLevel) throws FormatException {
|
||||
static DecoderRXingResult decode(int[] codewords, String ecLevel) throws FormatException {
|
||||
ECIStringBuilder result = new ECIStringBuilder(codewords.length * 2);
|
||||
int codeIndex = textCompaction(codewords, 1, result);
|
||||
PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata();
|
||||
PDF417RXingResultMetadata resultMetadata = new PDF417RXingResultMetadata();
|
||||
while (codeIndex < codewords[0]) {
|
||||
int code = codewords[codeIndex++];
|
||||
switch (code) {
|
||||
@@ -147,13 +147,13 @@ final class DecodedBitStreamParser {
|
||||
if (result.isEmpty() && resultMetadata.getFileId() == null) {
|
||||
throw FormatException.getFormatInstance();
|
||||
}
|
||||
DecoderResult decoderResult = new DecoderResult(null, result.toString(), null, ecLevel);
|
||||
decoderResult.setOther(resultMetadata);
|
||||
return decoderResult;
|
||||
DecoderRXingResult decoderRXingResult = new DecoderRXingResult(null, result.toString(), null, ecLevel);
|
||||
decoderRXingResult.setOther(resultMetadata);
|
||||
return decoderRXingResult;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
static int decodeMacroBlock(int[] codewords, int codeIndex, PDF417ResultMetadata resultMetadata)
|
||||
static int decodeMacroBlock(int[] codewords, int codeIndex, PDF417RXingResultMetadata resultMetadata)
|
||||
throws FormatException {
|
||||
if (codeIndex + NUMBER_OF_SEQUENCE_CODEWORDS > codewords[0]) {
|
||||
// we must have at least two bytes left for the segment index
|
||||
@@ -681,7 +681,7 @@ final class DecodedBitStreamParser {
|
||||
1 x 900 power of 5 + 624 x 900 power of 4 + 434 x 900 power of 3 +
|
||||
632 x 900 power of 2 + 282 x 900 power of 1 + 200 x 900 power of 0 = 1000213298174000
|
||||
|
||||
Remove leading 1 => Result is 000213298174000
|
||||
Remove leading 1 => RXingResult is 000213298174000
|
||||
*/
|
||||
private static String decodeBase900toBase10(int[] codewords, int count) throws FormatException {
|
||||
BigInteger result = BigInteger.ZERO;
|
||||
|
||||
@@ -23,37 +23,37 @@ import java.util.Formatter;
|
||||
/**
|
||||
* @author Guenther Grau
|
||||
*/
|
||||
final class DetectionResult {
|
||||
final class DetectionRXingResult {
|
||||
|
||||
private static final int ADJUST_ROW_NUMBER_SKIP = 2;
|
||||
|
||||
private final BarcodeMetadata barcodeMetadata;
|
||||
private final DetectionResultColumn[] detectionResultColumns;
|
||||
private final DetectionRXingResultColumn[] detectionRXingResultColumns;
|
||||
private BoundingBox boundingBox;
|
||||
private final int barcodeColumnCount;
|
||||
|
||||
DetectionResult(BarcodeMetadata barcodeMetadata, BoundingBox boundingBox) {
|
||||
DetectionRXingResult(BarcodeMetadata barcodeMetadata, BoundingBox boundingBox) {
|
||||
this.barcodeMetadata = barcodeMetadata;
|
||||
this.barcodeColumnCount = barcodeMetadata.getColumnCount();
|
||||
this.boundingBox = boundingBox;
|
||||
detectionResultColumns = new DetectionResultColumn[barcodeColumnCount + 2];
|
||||
detectionRXingResultColumns = new DetectionRXingResultColumn[barcodeColumnCount + 2];
|
||||
}
|
||||
|
||||
DetectionResultColumn[] getDetectionResultColumns() {
|
||||
adjustIndicatorColumnRowNumbers(detectionResultColumns[0]);
|
||||
adjustIndicatorColumnRowNumbers(detectionResultColumns[barcodeColumnCount + 1]);
|
||||
DetectionRXingResultColumn[] getDetectionRXingResultColumns() {
|
||||
adjustIndicatorColumnRowNumbers(detectionRXingResultColumns[0]);
|
||||
adjustIndicatorColumnRowNumbers(detectionRXingResultColumns[barcodeColumnCount + 1]);
|
||||
int unadjustedCodewordCount = PDF417Common.MAX_CODEWORDS_IN_BARCODE;
|
||||
int previousUnadjustedCount;
|
||||
do {
|
||||
previousUnadjustedCount = unadjustedCodewordCount;
|
||||
unadjustedCodewordCount = adjustRowNumbers();
|
||||
} while (unadjustedCodewordCount > 0 && unadjustedCodewordCount < previousUnadjustedCount);
|
||||
return detectionResultColumns;
|
||||
return detectionRXingResultColumns;
|
||||
}
|
||||
|
||||
private void adjustIndicatorColumnRowNumbers(DetectionResultColumn detectionResultColumn) {
|
||||
if (detectionResultColumn != null) {
|
||||
((DetectionResultRowIndicatorColumn) detectionResultColumn)
|
||||
private void adjustIndicatorColumnRowNumbers(DetectionRXingResultColumn detectionRXingResultColumn) {
|
||||
if (detectionRXingResultColumn != null) {
|
||||
((DetectionRXingResultRowIndicatorColumn) detectionRXingResultColumn)
|
||||
.adjustCompleteIndicatorColumnRowNumbers(barcodeMetadata);
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ final class DetectionResult {
|
||||
return 0;
|
||||
}
|
||||
for (int barcodeColumn = 1; barcodeColumn < barcodeColumnCount + 1; barcodeColumn++) {
|
||||
Codeword[] codewords = detectionResultColumns[barcodeColumn].getCodewords();
|
||||
Codeword[] codewords = detectionRXingResultColumns[barcodeColumn].getCodewords();
|
||||
for (int codewordsRow = 0; codewordsRow < codewords.length; codewordsRow++) {
|
||||
if (codewords[codewordsRow] == null) {
|
||||
continue;
|
||||
@@ -95,23 +95,23 @@ final class DetectionResult {
|
||||
}
|
||||
|
||||
private void adjustRowNumbersFromBothRI() {
|
||||
if (detectionResultColumns[0] == null || detectionResultColumns[barcodeColumnCount + 1] == null) {
|
||||
if (detectionRXingResultColumns[0] == null || detectionRXingResultColumns[barcodeColumnCount + 1] == null) {
|
||||
return;
|
||||
}
|
||||
Codeword[] LRIcodewords = detectionResultColumns[0].getCodewords();
|
||||
Codeword[] RRIcodewords = detectionResultColumns[barcodeColumnCount + 1].getCodewords();
|
||||
Codeword[] LRIcodewords = detectionRXingResultColumns[0].getCodewords();
|
||||
Codeword[] RRIcodewords = detectionRXingResultColumns[barcodeColumnCount + 1].getCodewords();
|
||||
for (int codewordsRow = 0; codewordsRow < LRIcodewords.length; codewordsRow++) {
|
||||
if (LRIcodewords[codewordsRow] != null &&
|
||||
RRIcodewords[codewordsRow] != null &&
|
||||
LRIcodewords[codewordsRow].getRowNumber() == RRIcodewords[codewordsRow].getRowNumber()) {
|
||||
for (int barcodeColumn = 1; barcodeColumn <= barcodeColumnCount; barcodeColumn++) {
|
||||
Codeword codeword = detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow];
|
||||
Codeword codeword = detectionRXingResultColumns[barcodeColumn].getCodewords()[codewordsRow];
|
||||
if (codeword == null) {
|
||||
continue;
|
||||
}
|
||||
codeword.setRowNumber(LRIcodewords[codewordsRow].getRowNumber());
|
||||
if (!codeword.hasValidRowNumber()) {
|
||||
detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow] = null;
|
||||
detectionRXingResultColumns[barcodeColumn].getCodewords()[codewordsRow] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,11 +119,11 @@ final class DetectionResult {
|
||||
}
|
||||
|
||||
private int adjustRowNumbersFromRRI() {
|
||||
if (detectionResultColumns[barcodeColumnCount + 1] == null) {
|
||||
if (detectionRXingResultColumns[barcodeColumnCount + 1] == null) {
|
||||
return 0;
|
||||
}
|
||||
int unadjustedCount = 0;
|
||||
Codeword[] codewords = detectionResultColumns[barcodeColumnCount + 1].getCodewords();
|
||||
Codeword[] codewords = detectionRXingResultColumns[barcodeColumnCount + 1].getCodewords();
|
||||
for (int codewordsRow = 0; codewordsRow < codewords.length; codewordsRow++) {
|
||||
if (codewords[codewordsRow] == null) {
|
||||
continue;
|
||||
@@ -133,7 +133,7 @@ final class DetectionResult {
|
||||
for (int barcodeColumn = barcodeColumnCount + 1;
|
||||
barcodeColumn > 0 && invalidRowCounts < ADJUST_ROW_NUMBER_SKIP;
|
||||
barcodeColumn--) {
|
||||
Codeword codeword = detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow];
|
||||
Codeword codeword = detectionRXingResultColumns[barcodeColumn].getCodewords()[codewordsRow];
|
||||
if (codeword != null) {
|
||||
invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword);
|
||||
if (!codeword.hasValidRowNumber()) {
|
||||
@@ -146,11 +146,11 @@ final class DetectionResult {
|
||||
}
|
||||
|
||||
private int adjustRowNumbersFromLRI() {
|
||||
if (detectionResultColumns[0] == null) {
|
||||
if (detectionRXingResultColumns[0] == null) {
|
||||
return 0;
|
||||
}
|
||||
int unadjustedCount = 0;
|
||||
Codeword[] codewords = detectionResultColumns[0].getCodewords();
|
||||
Codeword[] codewords = detectionRXingResultColumns[0].getCodewords();
|
||||
for (int codewordsRow = 0; codewordsRow < codewords.length; codewordsRow++) {
|
||||
if (codewords[codewordsRow] == null) {
|
||||
continue;
|
||||
@@ -160,7 +160,7 @@ final class DetectionResult {
|
||||
for (int barcodeColumn = 1;
|
||||
barcodeColumn < barcodeColumnCount + 1 && invalidRowCounts < ADJUST_ROW_NUMBER_SKIP;
|
||||
barcodeColumn++) {
|
||||
Codeword codeword = detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow];
|
||||
Codeword codeword = detectionRXingResultColumns[barcodeColumn].getCodewords()[codewordsRow];
|
||||
if (codeword != null) {
|
||||
invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword);
|
||||
if (!codeword.hasValidRowNumber()) {
|
||||
@@ -189,10 +189,10 @@ final class DetectionResult {
|
||||
|
||||
private void adjustRowNumbers(int barcodeColumn, int codewordsRow, Codeword[] codewords) {
|
||||
Codeword codeword = codewords[codewordsRow];
|
||||
Codeword[] previousColumnCodewords = detectionResultColumns[barcodeColumn - 1].getCodewords();
|
||||
Codeword[] previousColumnCodewords = detectionRXingResultColumns[barcodeColumn - 1].getCodewords();
|
||||
Codeword[] nextColumnCodewords = previousColumnCodewords;
|
||||
if (detectionResultColumns[barcodeColumn + 1] != null) {
|
||||
nextColumnCodewords = detectionResultColumns[barcodeColumn + 1].getCodewords();
|
||||
if (detectionRXingResultColumns[barcodeColumn + 1] != null) {
|
||||
nextColumnCodewords = detectionRXingResultColumns[barcodeColumn + 1].getCodewords();
|
||||
}
|
||||
|
||||
Codeword[] otherCodewords = new Codeword[14];
|
||||
@@ -261,29 +261,29 @@ final class DetectionResult {
|
||||
return boundingBox;
|
||||
}
|
||||
|
||||
void setDetectionResultColumn(int barcodeColumn, DetectionResultColumn detectionResultColumn) {
|
||||
detectionResultColumns[barcodeColumn] = detectionResultColumn;
|
||||
void setDetectionRXingResultColumn(int barcodeColumn, DetectionRXingResultColumn detectionRXingResultColumn) {
|
||||
detectionRXingResultColumns[barcodeColumn] = detectionRXingResultColumn;
|
||||
}
|
||||
|
||||
DetectionResultColumn getDetectionResultColumn(int barcodeColumn) {
|
||||
return detectionResultColumns[barcodeColumn];
|
||||
DetectionRXingResultColumn getDetectionRXingResultColumn(int barcodeColumn) {
|
||||
return detectionRXingResultColumns[barcodeColumn];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
DetectionResultColumn rowIndicatorColumn = detectionResultColumns[0];
|
||||
DetectionRXingResultColumn rowIndicatorColumn = detectionRXingResultColumns[0];
|
||||
if (rowIndicatorColumn == null) {
|
||||
rowIndicatorColumn = detectionResultColumns[barcodeColumnCount + 1];
|
||||
rowIndicatorColumn = detectionRXingResultColumns[barcodeColumnCount + 1];
|
||||
}
|
||||
try (Formatter formatter = new Formatter()) {
|
||||
for (int codewordsRow = 0; codewordsRow < rowIndicatorColumn.getCodewords().length; codewordsRow++) {
|
||||
formatter.format("CW %3d:", codewordsRow);
|
||||
for (int barcodeColumn = 0; barcodeColumn < barcodeColumnCount + 2; barcodeColumn++) {
|
||||
if (detectionResultColumns[barcodeColumn] == null) {
|
||||
if (detectionRXingResultColumns[barcodeColumn] == null) {
|
||||
formatter.format(" | ");
|
||||
continue;
|
||||
}
|
||||
Codeword codeword = detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow];
|
||||
Codeword codeword = detectionRXingResultColumns[barcodeColumn].getCodewords()[codewordsRow];
|
||||
if (codeword == null) {
|
||||
formatter.format(" | ");
|
||||
continue;
|
||||
|
||||
@@ -21,14 +21,14 @@ import java.util.Formatter;
|
||||
/**
|
||||
* @author Guenther Grau
|
||||
*/
|
||||
class DetectionResultColumn {
|
||||
class DetectionRXingResultColumn {
|
||||
|
||||
private static final int MAX_NEARBY_DISTANCE = 5;
|
||||
|
||||
private final BoundingBox boundingBox;
|
||||
private final Codeword[] codewords;
|
||||
|
||||
DetectionResultColumn(BoundingBox boundingBox) {
|
||||
DetectionRXingResultColumn(BoundingBox boundingBox) {
|
||||
this.boundingBox = new BoundingBox(boundingBox);
|
||||
codewords = new Codeword[boundingBox.getMaxY() - boundingBox.getMinY() + 1];
|
||||
}
|
||||
|
||||
@@ -16,17 +16,17 @@
|
||||
|
||||
package com.google.zxing.pdf417.decoder;
|
||||
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.pdf417.PDF417Common;
|
||||
|
||||
/**
|
||||
* @author Guenther Grau
|
||||
*/
|
||||
final class DetectionResultRowIndicatorColumn extends DetectionResultColumn {
|
||||
final class DetectionRXingResultRowIndicatorColumn extends DetectionRXingResultColumn {
|
||||
|
||||
private final boolean isLeft;
|
||||
|
||||
DetectionResultRowIndicatorColumn(BoundingBox boundingBox, boolean isLeft) {
|
||||
DetectionRXingResultRowIndicatorColumn(BoundingBox boundingBox, boolean isLeft) {
|
||||
super(boundingBox);
|
||||
this.isLeft = isLeft;
|
||||
}
|
||||
@@ -48,8 +48,8 @@ final class DetectionResultRowIndicatorColumn extends DetectionResultColumn {
|
||||
setRowNumbers();
|
||||
removeIncorrectCodewords(codewords, barcodeMetadata);
|
||||
BoundingBox boundingBox = getBoundingBox();
|
||||
ResultPoint top = isLeft ? boundingBox.getTopLeft() : boundingBox.getTopRight();
|
||||
ResultPoint bottom = isLeft ? boundingBox.getBottomLeft() : boundingBox.getBottomRight();
|
||||
RXingResultPoint top = isLeft ? boundingBox.getTopLeft() : boundingBox.getTopRight();
|
||||
RXingResultPoint bottom = isLeft ? boundingBox.getBottomLeft() : boundingBox.getBottomRight();
|
||||
int firstRow = imageRowToCodewordIndex((int) top.getY());
|
||||
int lastRow = imageRowToCodewordIndex((int) bottom.getY());
|
||||
// We need to be careful using the average row height. Barcode could be skewed so that we have smaller and
|
||||
@@ -127,8 +127,8 @@ final class DetectionResultRowIndicatorColumn extends DetectionResultColumn {
|
||||
// use row height count to make detection of invalid row numbers more reliable
|
||||
private void adjustIncompleteIndicatorColumnRowNumbers(BarcodeMetadata barcodeMetadata) {
|
||||
BoundingBox boundingBox = getBoundingBox();
|
||||
ResultPoint top = isLeft ? boundingBox.getTopLeft() : boundingBox.getTopRight();
|
||||
ResultPoint bottom = isLeft ? boundingBox.getBottomLeft() : boundingBox.getBottomRight();
|
||||
RXingResultPoint top = isLeft ? boundingBox.getTopLeft() : boundingBox.getTopRight();
|
||||
RXingResultPoint bottom = isLeft ? boundingBox.getBottomLeft() : boundingBox.getBottomRight();
|
||||
int firstRow = imageRowToCodewordIndex((int) top.getY());
|
||||
int lastRow = imageRowToCodewordIndex((int) bottom.getY());
|
||||
//float averageRowHeight = (lastRow - firstRow) / (float) barcodeMetadata.getRowCount();
|
||||
|
||||
@@ -19,9 +19,9 @@ package com.google.zxing.pdf417.decoder;
|
||||
import com.google.zxing.ChecksumException;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.common.DecoderResult;
|
||||
import com.google.zxing.common.DecoderRXingResult;
|
||||
import com.google.zxing.common.detector.MathUtils;
|
||||
import com.google.zxing.pdf417.PDF417Common;
|
||||
import com.google.zxing.pdf417.decoder.ec.ErrorCorrection;
|
||||
@@ -49,18 +49,18 @@ public final class PDF417ScanningDecoder {
|
||||
// columns. That way width can be deducted from the pattern column.
|
||||
// This approach also allows to detect more details about the barcode, e.g. if a bar type (white or black) is wider
|
||||
// than it should be. This can happen if the scanner used a bad blackpoint.
|
||||
public static DecoderResult decode(BitMatrix image,
|
||||
ResultPoint imageTopLeft,
|
||||
ResultPoint imageBottomLeft,
|
||||
ResultPoint imageTopRight,
|
||||
ResultPoint imageBottomRight,
|
||||
public static DecoderRXingResult decode(BitMatrix image,
|
||||
RXingResultPoint imageTopLeft,
|
||||
RXingResultPoint imageBottomLeft,
|
||||
RXingResultPoint imageTopRight,
|
||||
RXingResultPoint imageBottomRight,
|
||||
int minCodewordWidth,
|
||||
int maxCodewordWidth)
|
||||
throws NotFoundException, FormatException, ChecksumException {
|
||||
BoundingBox boundingBox = new BoundingBox(image, imageTopLeft, imageBottomLeft, imageTopRight, imageBottomRight);
|
||||
DetectionResultRowIndicatorColumn leftRowIndicatorColumn = null;
|
||||
DetectionResultRowIndicatorColumn rightRowIndicatorColumn = null;
|
||||
DetectionResult detectionResult;
|
||||
DetectionRXingResultRowIndicatorColumn leftRowIndicatorColumn = null;
|
||||
DetectionRXingResultRowIndicatorColumn rightRowIndicatorColumn = null;
|
||||
DetectionRXingResult detectionRXingResult;
|
||||
for (boolean firstPass = true; ; firstPass = false) {
|
||||
if (imageTopLeft != null) {
|
||||
leftRowIndicatorColumn = getRowIndicatorColumn(image, boundingBox, imageTopLeft, true, minCodewordWidth,
|
||||
@@ -70,11 +70,11 @@ public final class PDF417ScanningDecoder {
|
||||
rightRowIndicatorColumn = getRowIndicatorColumn(image, boundingBox, imageTopRight, false, minCodewordWidth,
|
||||
maxCodewordWidth);
|
||||
}
|
||||
detectionResult = merge(leftRowIndicatorColumn, rightRowIndicatorColumn);
|
||||
if (detectionResult == null) {
|
||||
detectionRXingResult = merge(leftRowIndicatorColumn, rightRowIndicatorColumn);
|
||||
if (detectionRXingResult == null) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
BoundingBox resultBox = detectionResult.getBoundingBox();
|
||||
BoundingBox resultBox = detectionRXingResult.getBoundingBox();
|
||||
if (firstPass && resultBox != null &&
|
||||
(resultBox.getMinY() < boundingBox.getMinY() || resultBox.getMaxY() > boundingBox.getMaxY())) {
|
||||
boundingBox = resultBox;
|
||||
@@ -82,30 +82,30 @@ public final class PDF417ScanningDecoder {
|
||||
break;
|
||||
}
|
||||
}
|
||||
detectionResult.setBoundingBox(boundingBox);
|
||||
int maxBarcodeColumn = detectionResult.getBarcodeColumnCount() + 1;
|
||||
detectionResult.setDetectionResultColumn(0, leftRowIndicatorColumn);
|
||||
detectionResult.setDetectionResultColumn(maxBarcodeColumn, rightRowIndicatorColumn);
|
||||
detectionRXingResult.setBoundingBox(boundingBox);
|
||||
int maxBarcodeColumn = detectionRXingResult.getBarcodeColumnCount() + 1;
|
||||
detectionRXingResult.setDetectionRXingResultColumn(0, leftRowIndicatorColumn);
|
||||
detectionRXingResult.setDetectionRXingResultColumn(maxBarcodeColumn, rightRowIndicatorColumn);
|
||||
|
||||
boolean leftToRight = leftRowIndicatorColumn != null;
|
||||
for (int barcodeColumnCount = 1; barcodeColumnCount <= maxBarcodeColumn; barcodeColumnCount++) {
|
||||
int barcodeColumn = leftToRight ? barcodeColumnCount : maxBarcodeColumn - barcodeColumnCount;
|
||||
if (detectionResult.getDetectionResultColumn(barcodeColumn) != null) {
|
||||
if (detectionRXingResult.getDetectionRXingResultColumn(barcodeColumn) != null) {
|
||||
// This will be the case for the opposite row indicator column, which doesn't need to be decoded again.
|
||||
continue;
|
||||
}
|
||||
DetectionResultColumn detectionResultColumn;
|
||||
DetectionRXingResultColumn detectionRXingResultColumn;
|
||||
if (barcodeColumn == 0 || barcodeColumn == maxBarcodeColumn) {
|
||||
detectionResultColumn = new DetectionResultRowIndicatorColumn(boundingBox, barcodeColumn == 0);
|
||||
detectionRXingResultColumn = new DetectionRXingResultRowIndicatorColumn(boundingBox, barcodeColumn == 0);
|
||||
} else {
|
||||
detectionResultColumn = new DetectionResultColumn(boundingBox);
|
||||
detectionRXingResultColumn = new DetectionRXingResultColumn(boundingBox);
|
||||
}
|
||||
detectionResult.setDetectionResultColumn(barcodeColumn, detectionResultColumn);
|
||||
detectionRXingResult.setDetectionRXingResultColumn(barcodeColumn, detectionRXingResultColumn);
|
||||
int startColumn = -1;
|
||||
int previousStartColumn = startColumn;
|
||||
// TODO start at a row for which we know the start position, then detect upwards and downwards from there.
|
||||
for (int imageRow = boundingBox.getMinY(); imageRow <= boundingBox.getMaxY(); imageRow++) {
|
||||
startColumn = getStartColumn(detectionResult, barcodeColumn, imageRow, leftToRight);
|
||||
startColumn = getStartColumn(detectionRXingResult, barcodeColumn, imageRow, leftToRight);
|
||||
if (startColumn < 0 || startColumn > boundingBox.getMaxX()) {
|
||||
if (previousStartColumn == -1) {
|
||||
continue;
|
||||
@@ -115,18 +115,18 @@ public final class PDF417ScanningDecoder {
|
||||
Codeword codeword = detectCodeword(image, boundingBox.getMinX(), boundingBox.getMaxX(), leftToRight,
|
||||
startColumn, imageRow, minCodewordWidth, maxCodewordWidth);
|
||||
if (codeword != null) {
|
||||
detectionResultColumn.setCodeword(imageRow, codeword);
|
||||
detectionRXingResultColumn.setCodeword(imageRow, codeword);
|
||||
previousStartColumn = startColumn;
|
||||
minCodewordWidth = Math.min(minCodewordWidth, codeword.getWidth());
|
||||
maxCodewordWidth = Math.max(maxCodewordWidth, codeword.getWidth());
|
||||
}
|
||||
}
|
||||
}
|
||||
return createDecoderResult(detectionResult);
|
||||
return createDecoderRXingResult(detectionRXingResult);
|
||||
}
|
||||
|
||||
private static DetectionResult merge(DetectionResultRowIndicatorColumn leftRowIndicatorColumn,
|
||||
DetectionResultRowIndicatorColumn rightRowIndicatorColumn)
|
||||
private static DetectionRXingResult merge(DetectionRXingResultRowIndicatorColumn leftRowIndicatorColumn,
|
||||
DetectionRXingResultRowIndicatorColumn rightRowIndicatorColumn)
|
||||
throws NotFoundException {
|
||||
if (leftRowIndicatorColumn == null && rightRowIndicatorColumn == null) {
|
||||
return null;
|
||||
@@ -137,10 +137,10 @@ public final class PDF417ScanningDecoder {
|
||||
}
|
||||
BoundingBox boundingBox = BoundingBox.merge(adjustBoundingBox(leftRowIndicatorColumn),
|
||||
adjustBoundingBox(rightRowIndicatorColumn));
|
||||
return new DetectionResult(barcodeMetadata, boundingBox);
|
||||
return new DetectionRXingResult(barcodeMetadata, boundingBox);
|
||||
}
|
||||
|
||||
private static BoundingBox adjustBoundingBox(DetectionResultRowIndicatorColumn rowIndicatorColumn)
|
||||
private static BoundingBox adjustBoundingBox(DetectionRXingResultRowIndicatorColumn rowIndicatorColumn)
|
||||
throws NotFoundException {
|
||||
if (rowIndicatorColumn == null) {
|
||||
return null;
|
||||
@@ -183,8 +183,8 @@ public final class PDF417ScanningDecoder {
|
||||
return maxValue;
|
||||
}
|
||||
|
||||
private static BarcodeMetadata getBarcodeMetadata(DetectionResultRowIndicatorColumn leftRowIndicatorColumn,
|
||||
DetectionResultRowIndicatorColumn rightRowIndicatorColumn) {
|
||||
private static BarcodeMetadata getBarcodeMetadata(DetectionRXingResultRowIndicatorColumn leftRowIndicatorColumn,
|
||||
DetectionRXingResultRowIndicatorColumn rightRowIndicatorColumn) {
|
||||
BarcodeMetadata leftBarcodeMetadata;
|
||||
if (leftRowIndicatorColumn == null ||
|
||||
(leftBarcodeMetadata = leftRowIndicatorColumn.getBarcodeMetadata()) == null) {
|
||||
@@ -204,13 +204,13 @@ public final class PDF417ScanningDecoder {
|
||||
return leftBarcodeMetadata;
|
||||
}
|
||||
|
||||
private static DetectionResultRowIndicatorColumn getRowIndicatorColumn(BitMatrix image,
|
||||
private static DetectionRXingResultRowIndicatorColumn getRowIndicatorColumn(BitMatrix image,
|
||||
BoundingBox boundingBox,
|
||||
ResultPoint startPoint,
|
||||
RXingResultPoint startPoint,
|
||||
boolean leftToRight,
|
||||
int minCodewordWidth,
|
||||
int maxCodewordWidth) {
|
||||
DetectionResultRowIndicatorColumn rowIndicatorColumn = new DetectionResultRowIndicatorColumn(boundingBox,
|
||||
DetectionRXingResultRowIndicatorColumn rowIndicatorColumn = new DetectionRXingResultRowIndicatorColumn(boundingBox,
|
||||
leftToRight);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
int increment = i == 0 ? 1 : -1;
|
||||
@@ -232,13 +232,13 @@ public final class PDF417ScanningDecoder {
|
||||
return rowIndicatorColumn;
|
||||
}
|
||||
|
||||
private static void adjustCodewordCount(DetectionResult detectionResult, BarcodeValue[][] barcodeMatrix)
|
||||
private static void adjustCodewordCount(DetectionRXingResult detectionRXingResult, BarcodeValue[][] barcodeMatrix)
|
||||
throws NotFoundException {
|
||||
BarcodeValue barcodeMatrix01 = barcodeMatrix[0][1];
|
||||
int[] numberOfCodewords = barcodeMatrix01.getValue();
|
||||
int calculatedNumberOfCodewords = detectionResult.getBarcodeColumnCount() *
|
||||
detectionResult.getBarcodeRowCount() -
|
||||
getNumberOfECCodeWords(detectionResult.getBarcodeECLevel());
|
||||
int calculatedNumberOfCodewords = detectionRXingResult.getBarcodeColumnCount() *
|
||||
detectionRXingResult.getBarcodeRowCount() -
|
||||
getNumberOfECCodeWords(detectionRXingResult.getBarcodeECLevel());
|
||||
if (numberOfCodewords.length == 0) {
|
||||
if (calculatedNumberOfCodewords < 1 || calculatedNumberOfCodewords > PDF417Common.MAX_CODEWORDS_IN_BARCODE) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
@@ -252,18 +252,18 @@ public final class PDF417ScanningDecoder {
|
||||
}
|
||||
}
|
||||
|
||||
private static DecoderResult createDecoderResult(DetectionResult detectionResult) throws FormatException,
|
||||
private static DecoderRXingResult createDecoderRXingResult(DetectionRXingResult detectionRXingResult) throws FormatException,
|
||||
ChecksumException, NotFoundException {
|
||||
BarcodeValue[][] barcodeMatrix = createBarcodeMatrix(detectionResult);
|
||||
adjustCodewordCount(detectionResult, barcodeMatrix);
|
||||
BarcodeValue[][] barcodeMatrix = createBarcodeMatrix(detectionRXingResult);
|
||||
adjustCodewordCount(detectionRXingResult, barcodeMatrix);
|
||||
Collection<Integer> erasures = new ArrayList<>();
|
||||
int[] codewords = new int[detectionResult.getBarcodeRowCount() * detectionResult.getBarcodeColumnCount()];
|
||||
int[] codewords = new int[detectionRXingResult.getBarcodeRowCount() * detectionRXingResult.getBarcodeColumnCount()];
|
||||
List<int[]> ambiguousIndexValuesList = new ArrayList<>();
|
||||
Collection<Integer> ambiguousIndexesList = new ArrayList<>();
|
||||
for (int row = 0; row < detectionResult.getBarcodeRowCount(); row++) {
|
||||
for (int column = 0; column < detectionResult.getBarcodeColumnCount(); column++) {
|
||||
for (int row = 0; row < detectionRXingResult.getBarcodeRowCount(); row++) {
|
||||
for (int column = 0; column < detectionRXingResult.getBarcodeColumnCount(); column++) {
|
||||
int[] values = barcodeMatrix[row][column + 1].getValue();
|
||||
int codewordIndex = row * detectionResult.getBarcodeColumnCount() + column;
|
||||
int codewordIndex = row * detectionRXingResult.getBarcodeColumnCount() + column;
|
||||
if (values.length == 0) {
|
||||
erasures.add(codewordIndex);
|
||||
} else if (values.length == 1) {
|
||||
@@ -278,7 +278,7 @@ public final class PDF417ScanningDecoder {
|
||||
for (int i = 0; i < ambiguousIndexValues.length; i++) {
|
||||
ambiguousIndexValues[i] = ambiguousIndexValuesList.get(i);
|
||||
}
|
||||
return createDecoderResultFromAmbiguousValues(detectionResult.getBarcodeECLevel(), codewords,
|
||||
return createDecoderRXingResultFromAmbiguousValues(detectionRXingResult.getBarcodeECLevel(), codewords,
|
||||
PDF417Common.toIntArray(erasures), PDF417Common.toIntArray(ambiguousIndexesList), ambiguousIndexValues);
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ public final class PDF417ScanningDecoder {
|
||||
* @param ambiguousIndexValues two dimensional array that contains the ambiguous values. The first dimension must
|
||||
* be the same length as the ambiguousIndexes array
|
||||
*/
|
||||
private static DecoderResult createDecoderResultFromAmbiguousValues(int ecLevel,
|
||||
private static DecoderRXingResult createDecoderRXingResultFromAmbiguousValues(int ecLevel,
|
||||
int[] codewords,
|
||||
int[] erasureArray,
|
||||
int[] ambiguousIndexes,
|
||||
@@ -331,9 +331,9 @@ public final class PDF417ScanningDecoder {
|
||||
throw ChecksumException.getChecksumInstance();
|
||||
}
|
||||
|
||||
private static BarcodeValue[][] createBarcodeMatrix(DetectionResult detectionResult) {
|
||||
private static BarcodeValue[][] createBarcodeMatrix(DetectionRXingResult detectionRXingResult) {
|
||||
BarcodeValue[][] barcodeMatrix =
|
||||
new BarcodeValue[detectionResult.getBarcodeRowCount()][detectionResult.getBarcodeColumnCount() + 2];
|
||||
new BarcodeValue[detectionRXingResult.getBarcodeRowCount()][detectionRXingResult.getBarcodeColumnCount() + 2];
|
||||
for (int row = 0; row < barcodeMatrix.length; row++) {
|
||||
for (int column = 0; column < barcodeMatrix[row].length; column++) {
|
||||
barcodeMatrix[row][column] = new BarcodeValue();
|
||||
@@ -341,9 +341,9 @@ public final class PDF417ScanningDecoder {
|
||||
}
|
||||
|
||||
int column = 0;
|
||||
for (DetectionResultColumn detectionResultColumn : detectionResult.getDetectionResultColumns()) {
|
||||
if (detectionResultColumn != null) {
|
||||
for (Codeword codeword : detectionResultColumn.getCodewords()) {
|
||||
for (DetectionRXingResultColumn detectionRXingResultColumn : detectionRXingResult.getDetectionRXingResultColumns()) {
|
||||
if (detectionRXingResultColumn != null) {
|
||||
for (Codeword codeword : detectionRXingResultColumn.getCodewords()) {
|
||||
if (codeword != null) {
|
||||
int rowNumber = codeword.getRowNumber();
|
||||
if (rowNumber >= 0) {
|
||||
@@ -361,37 +361,37 @@ public final class PDF417ScanningDecoder {
|
||||
return barcodeMatrix;
|
||||
}
|
||||
|
||||
private static boolean isValidBarcodeColumn(DetectionResult detectionResult, int barcodeColumn) {
|
||||
return barcodeColumn >= 0 && barcodeColumn <= detectionResult.getBarcodeColumnCount() + 1;
|
||||
private static boolean isValidBarcodeColumn(DetectionRXingResult detectionRXingResult, int barcodeColumn) {
|
||||
return barcodeColumn >= 0 && barcodeColumn <= detectionRXingResult.getBarcodeColumnCount() + 1;
|
||||
}
|
||||
|
||||
private static int getStartColumn(DetectionResult detectionResult,
|
||||
private static int getStartColumn(DetectionRXingResult detectionRXingResult,
|
||||
int barcodeColumn,
|
||||
int imageRow,
|
||||
boolean leftToRight) {
|
||||
int offset = leftToRight ? 1 : -1;
|
||||
Codeword codeword = null;
|
||||
if (isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) {
|
||||
codeword = detectionResult.getDetectionResultColumn(barcodeColumn - offset).getCodeword(imageRow);
|
||||
if (isValidBarcodeColumn(detectionRXingResult, barcodeColumn - offset)) {
|
||||
codeword = detectionRXingResult.getDetectionRXingResultColumn(barcodeColumn - offset).getCodeword(imageRow);
|
||||
}
|
||||
if (codeword != null) {
|
||||
return leftToRight ? codeword.getEndX() : codeword.getStartX();
|
||||
}
|
||||
codeword = detectionResult.getDetectionResultColumn(barcodeColumn).getCodewordNearby(imageRow);
|
||||
codeword = detectionRXingResult.getDetectionRXingResultColumn(barcodeColumn).getCodewordNearby(imageRow);
|
||||
if (codeword != null) {
|
||||
return leftToRight ? codeword.getStartX() : codeword.getEndX();
|
||||
}
|
||||
if (isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) {
|
||||
codeword = detectionResult.getDetectionResultColumn(barcodeColumn - offset).getCodewordNearby(imageRow);
|
||||
if (isValidBarcodeColumn(detectionRXingResult, barcodeColumn - offset)) {
|
||||
codeword = detectionRXingResult.getDetectionRXingResultColumn(barcodeColumn - offset).getCodewordNearby(imageRow);
|
||||
}
|
||||
if (codeword != null) {
|
||||
return leftToRight ? codeword.getEndX() : codeword.getStartX();
|
||||
}
|
||||
int skippedColumns = 0;
|
||||
|
||||
while (isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) {
|
||||
while (isValidBarcodeColumn(detectionRXingResult, barcodeColumn - offset)) {
|
||||
barcodeColumn -= offset;
|
||||
for (Codeword previousRowCodeword : detectionResult.getDetectionResultColumn(barcodeColumn).getCodewords()) {
|
||||
for (Codeword previousRowCodeword : detectionRXingResult.getDetectionRXingResultColumn(barcodeColumn).getCodewords()) {
|
||||
if (previousRowCodeword != null) {
|
||||
return (leftToRight ? previousRowCodeword.getEndX() : previousRowCodeword.getStartX()) +
|
||||
offset *
|
||||
@@ -401,7 +401,7 @@ public final class PDF417ScanningDecoder {
|
||||
}
|
||||
skippedColumns++;
|
||||
}
|
||||
return leftToRight ? detectionResult.getBoundingBox().getMinX() : detectionResult.getBoundingBox().getMaxX();
|
||||
return leftToRight ? detectionRXingResult.getBoundingBox().getMinX() : detectionRXingResult.getBoundingBox().getMaxX();
|
||||
}
|
||||
|
||||
private static Codeword detectCodeword(BitMatrix image,
|
||||
@@ -523,7 +523,7 @@ public final class PDF417ScanningDecoder {
|
||||
codewordSize <= maxCodewordWidth + CODEWORD_SKEW_SIZE;
|
||||
}
|
||||
|
||||
private static DecoderResult decodeCodewords(int[] codewords, int ecLevel, int[] erasures) throws FormatException,
|
||||
private static DecoderRXingResult decodeCodewords(int[] codewords, int ecLevel, int[] erasures) throws FormatException,
|
||||
ChecksumException {
|
||||
if (codewords.length == 0) {
|
||||
throw FormatException.getFormatInstance();
|
||||
@@ -534,10 +534,10 @@ public final class PDF417ScanningDecoder {
|
||||
verifyCodewordCount(codewords, numECCodewords);
|
||||
|
||||
// Decode the codewords
|
||||
DecoderResult decoderResult = DecodedBitStreamParser.decode(codewords, String.valueOf(ecLevel));
|
||||
decoderResult.setErrorsCorrected(correctedErrorsCount);
|
||||
decoderResult.setErasures(erasures.length);
|
||||
return decoderResult;
|
||||
DecoderRXingResult decoderRXingResult = DecodedBitStreamParser.decode(codewords, String.valueOf(ecLevel));
|
||||
decoderRXingResult.setErrorsCorrected(correctedErrorsCount);
|
||||
decoderRXingResult.setErasures(erasures.length);
|
||||
return decoderRXingResult;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.google.zxing.pdf417.detector;
|
||||
import com.google.zxing.BinaryBitmap;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -69,10 +69,10 @@ public final class Detector {
|
||||
* @param hints optional hints to detector
|
||||
* @param multiple if true, then the image is searched for multiple codes. If false, then at most one code will
|
||||
* be found and returned
|
||||
* @return {@link PDF417DetectorResult} encapsulating results of detecting a PDF417 code
|
||||
* @return {@link PDF417DetectorRXingResult} encapsulating results of detecting a PDF417 code
|
||||
* @throws NotFoundException if no PDF417 Code can be found
|
||||
*/
|
||||
public static PDF417DetectorResult detect(BinaryBitmap image, Map<DecodeHintType,?> hints, boolean multiple)
|
||||
public static PDF417DetectorRXingResult detect(BinaryBitmap image, Map<DecodeHintType,?> hints, boolean multiple)
|
||||
throws NotFoundException {
|
||||
// TODO detection improvement, tryHarder could try several different luminance thresholds/blackpoints or even
|
||||
// different binarizers
|
||||
@@ -81,12 +81,12 @@ public final class Detector {
|
||||
BitMatrix originalMatrix = image.getBlackMatrix();
|
||||
for (int rotation : ROTATIONS) {
|
||||
BitMatrix bitMatrix = applyRotation(originalMatrix, rotation);
|
||||
List<ResultPoint[]> barcodeCoordinates = detect(multiple, bitMatrix);
|
||||
List<RXingResultPoint[]> barcodeCoordinates = detect(multiple, bitMatrix);
|
||||
if (!barcodeCoordinates.isEmpty()) {
|
||||
return new PDF417DetectorResult(bitMatrix, barcodeCoordinates, rotation);
|
||||
return new PDF417DetectorRXingResult(bitMatrix, barcodeCoordinates, rotation);
|
||||
}
|
||||
}
|
||||
return new PDF417DetectorResult(originalMatrix, new ArrayList<>(), 0);
|
||||
return new PDF417DetectorRXingResult(originalMatrix, new ArrayList<>(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,15 +110,15 @@ public final class Detector {
|
||||
* @param multiple if true, then the image is searched for multiple codes. If false, then at most one code will
|
||||
* be found and returned
|
||||
* @param bitMatrix bit matrix to detect barcodes in
|
||||
* @return List of ResultPoint arrays containing the coordinates of found barcodes
|
||||
* @return List of RXingResultPoint arrays containing the coordinates of found barcodes
|
||||
*/
|
||||
private static List<ResultPoint[]> detect(boolean multiple, BitMatrix bitMatrix) {
|
||||
List<ResultPoint[]> barcodeCoordinates = new ArrayList<>();
|
||||
private static List<RXingResultPoint[]> detect(boolean multiple, BitMatrix bitMatrix) {
|
||||
List<RXingResultPoint[]> barcodeCoordinates = new ArrayList<>();
|
||||
int row = 0;
|
||||
int column = 0;
|
||||
boolean foundBarcodeInRow = false;
|
||||
while (row < bitMatrix.getHeight()) {
|
||||
ResultPoint[] vertices = findVertices(bitMatrix, row, column);
|
||||
RXingResultPoint[] vertices = findVertices(bitMatrix, row, column);
|
||||
|
||||
if (vertices[0] == null && vertices[3] == null) {
|
||||
if (!foundBarcodeInRow) {
|
||||
@@ -129,7 +129,7 @@ public final class Detector {
|
||||
// below the lowest barcode we found so far.
|
||||
foundBarcodeInRow = false;
|
||||
column = 0;
|
||||
for (ResultPoint[] barcodeCoordinate : barcodeCoordinates) {
|
||||
for (RXingResultPoint[] barcodeCoordinate : barcodeCoordinates) {
|
||||
if (barcodeCoordinate[1] != null) {
|
||||
row = (int) Math.max(row, barcodeCoordinate[1].getY());
|
||||
}
|
||||
@@ -173,36 +173,36 @@ public final class Detector {
|
||||
* vertices[6] x, y top right codeword area
|
||||
* vertices[7] x, y bottom right codeword area
|
||||
*/
|
||||
private static ResultPoint[] findVertices(BitMatrix matrix, int startRow, int startColumn) {
|
||||
private static RXingResultPoint[] findVertices(BitMatrix matrix, int startRow, int startColumn) {
|
||||
int height = matrix.getHeight();
|
||||
int width = matrix.getWidth();
|
||||
|
||||
ResultPoint[] result = new ResultPoint[8];
|
||||
copyToResult(result, findRowsWithPattern(matrix, height, width, startRow, startColumn, START_PATTERN),
|
||||
RXingResultPoint[] result = new RXingResultPoint[8];
|
||||
copyToRXingResult(result, findRowsWithPattern(matrix, height, width, startRow, startColumn, START_PATTERN),
|
||||
INDEXES_START_PATTERN);
|
||||
|
||||
if (result[4] != null) {
|
||||
startColumn = (int) result[4].getX();
|
||||
startRow = (int) result[4].getY();
|
||||
}
|
||||
copyToResult(result, findRowsWithPattern(matrix, height, width, startRow, startColumn, STOP_PATTERN),
|
||||
copyToRXingResult(result, findRowsWithPattern(matrix, height, width, startRow, startColumn, STOP_PATTERN),
|
||||
INDEXES_STOP_PATTERN);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void copyToResult(ResultPoint[] result, ResultPoint[] tmpResult, int[] destinationIndexes) {
|
||||
private static void copyToRXingResult(RXingResultPoint[] result, RXingResultPoint[] tmpRXingResult, int[] destinationIndexes) {
|
||||
for (int i = 0; i < destinationIndexes.length; i++) {
|
||||
result[destinationIndexes[i]] = tmpResult[i];
|
||||
result[destinationIndexes[i]] = tmpRXingResult[i];
|
||||
}
|
||||
}
|
||||
|
||||
private static ResultPoint[] findRowsWithPattern(BitMatrix matrix,
|
||||
private static RXingResultPoint[] findRowsWithPattern(BitMatrix matrix,
|
||||
int height,
|
||||
int width,
|
||||
int startRow,
|
||||
int startColumn,
|
||||
int[] pattern) {
|
||||
ResultPoint[] result = new ResultPoint[4];
|
||||
RXingResultPoint[] result = new RXingResultPoint[4];
|
||||
boolean found = false;
|
||||
int[] counters = new int[pattern.length];
|
||||
for (; startRow < height; startRow += ROW_STEP) {
|
||||
@@ -217,8 +217,8 @@ public final class Detector {
|
||||
break;
|
||||
}
|
||||
}
|
||||
result[0] = new ResultPoint(loc[0], startRow);
|
||||
result[1] = new ResultPoint(loc[1], startRow);
|
||||
result[0] = new RXingResultPoint(loc[0], startRow);
|
||||
result[1] = new RXingResultPoint(loc[1], startRow);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@@ -248,8 +248,8 @@ public final class Detector {
|
||||
}
|
||||
}
|
||||
stopRow -= skippedRowCount + 1;
|
||||
result[2] = new ResultPoint(previousRowLoc[0], stopRow);
|
||||
result[3] = new ResultPoint(previousRowLoc[1], stopRow);
|
||||
result[2] = new RXingResultPoint(previousRowLoc[0], stopRow);
|
||||
result[3] = new RXingResultPoint(previousRowLoc[1], stopRow);
|
||||
}
|
||||
if (stopRow - startRow < BARCODE_MIN_HEIGHT) {
|
||||
Arrays.fill(result, null);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.zxing.pdf417.detector;
|
||||
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
|
||||
import java.util.List;
|
||||
@@ -24,19 +24,19 @@ import java.util.List;
|
||||
/**
|
||||
* @author Guenther Grau
|
||||
*/
|
||||
public final class PDF417DetectorResult {
|
||||
public final class PDF417DetectorRXingResult {
|
||||
|
||||
private final BitMatrix bits;
|
||||
private final List<ResultPoint[]> points;
|
||||
private final List<RXingResultPoint[]> points;
|
||||
private final int rotation;
|
||||
|
||||
public PDF417DetectorResult(BitMatrix bits, List<ResultPoint[]> points, int rotation) {
|
||||
public PDF417DetectorRXingResult(BitMatrix bits, List<RXingResultPoint[]> points, int rotation) {
|
||||
this.bits = bits;
|
||||
this.points = points;
|
||||
this.rotation = rotation;
|
||||
}
|
||||
|
||||
public PDF417DetectorResult(BitMatrix bits, List<ResultPoint[]> points) {
|
||||
public PDF417DetectorRXingResult(BitMatrix bits, List<RXingResultPoint[]> points) {
|
||||
this(bits, points, 0);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public final class PDF417DetectorResult {
|
||||
return bits;
|
||||
}
|
||||
|
||||
public List<ResultPoint[]> getPoints() {
|
||||
public List<RXingResultPoint[]> getPoints() {
|
||||
return points;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,12 +23,12 @@ import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Reader;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.common.DecoderResult;
|
||||
import com.google.zxing.common.DetectorResult;
|
||||
import com.google.zxing.common.DecoderRXingResult;
|
||||
import com.google.zxing.common.DetectorRXingResult;
|
||||
import com.google.zxing.qrcode.decoder.Decoder;
|
||||
import com.google.zxing.qrcode.decoder.QRCodeDecoderMetaData;
|
||||
import com.google.zxing.qrcode.detector.Detector;
|
||||
@@ -43,7 +43,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class QRCodeReader implements Reader {
|
||||
|
||||
private static final ResultPoint[] NO_POINTS = new ResultPoint[0];
|
||||
private static final RXingResultPoint[] NO_POINTS = new RXingResultPoint[0];
|
||||
|
||||
private final Decoder decoder = new Decoder();
|
||||
|
||||
@@ -60,46 +60,46 @@ public class QRCodeReader implements Reader {
|
||||
* @throws ChecksumException if error correction fails
|
||||
*/
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException {
|
||||
public RXingResult decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException {
|
||||
return decode(image, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
|
||||
public final RXingResult decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, ChecksumException, FormatException {
|
||||
DecoderResult decoderResult;
|
||||
ResultPoint[] points;
|
||||
DecoderRXingResult decoderRXingResult;
|
||||
RXingResultPoint[] points;
|
||||
if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) {
|
||||
BitMatrix bits = extractPureBits(image.getBlackMatrix());
|
||||
decoderResult = decoder.decode(bits, hints);
|
||||
decoderRXingResult = decoder.decode(bits, hints);
|
||||
points = NO_POINTS;
|
||||
} else {
|
||||
DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect(hints);
|
||||
decoderResult = decoder.decode(detectorResult.getBits(), hints);
|
||||
points = detectorResult.getPoints();
|
||||
DetectorRXingResult detectorRXingResult = new Detector(image.getBlackMatrix()).detect(hints);
|
||||
decoderRXingResult = decoder.decode(detectorRXingResult.getBits(), hints);
|
||||
points = detectorRXingResult.getPoints();
|
||||
}
|
||||
|
||||
// If the code was mirrored: swap the bottom-left and the top-right points.
|
||||
if (decoderResult.getOther() instanceof QRCodeDecoderMetaData) {
|
||||
((QRCodeDecoderMetaData) decoderResult.getOther()).applyMirroredCorrection(points);
|
||||
if (decoderRXingResult.getOther() instanceof QRCodeDecoderMetaData) {
|
||||
((QRCodeDecoderMetaData) decoderRXingResult.getOther()).applyMirroredCorrection(points);
|
||||
}
|
||||
|
||||
Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.QR_CODE);
|
||||
List<byte[]> byteSegments = decoderResult.getByteSegments();
|
||||
RXingResult result = new RXingResult(decoderRXingResult.getText(), decoderRXingResult.getRawBytes(), points, BarcodeFormat.QR_CODE);
|
||||
List<byte[]> byteSegments = decoderRXingResult.getByteSegments();
|
||||
if (byteSegments != null) {
|
||||
result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments);
|
||||
result.putMetadata(RXingResultMetadataType.BYTE_SEGMENTS, byteSegments);
|
||||
}
|
||||
String ecLevel = decoderResult.getECLevel();
|
||||
String ecLevel = decoderRXingResult.getECLevel();
|
||||
if (ecLevel != null) {
|
||||
result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
|
||||
result.putMetadata(RXingResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
|
||||
}
|
||||
if (decoderResult.hasStructuredAppend()) {
|
||||
result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE,
|
||||
decoderResult.getStructuredAppendSequenceNumber());
|
||||
result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_PARITY,
|
||||
decoderResult.getStructuredAppendParity());
|
||||
if (decoderRXingResult.hasStructuredAppend()) {
|
||||
result.putMetadata(RXingResultMetadataType.STRUCTURED_APPEND_SEQUENCE,
|
||||
decoderRXingResult.getStructuredAppendSequenceNumber());
|
||||
result.putMetadata(RXingResultMetadataType.STRUCTURED_APPEND_PARITY,
|
||||
decoderRXingResult.getStructuredAppendParity());
|
||||
}
|
||||
result.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]Q" + decoderResult.getSymbologyModifier());
|
||||
result.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]Q" + decoderRXingResult.getSymbologyModifier());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,12 +76,12 @@ public final class QRCodeWriter implements Writer {
|
||||
}
|
||||
|
||||
QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
|
||||
return renderResult(code, width, height, quietZone);
|
||||
return renderRXingResult(code, width, height, quietZone);
|
||||
}
|
||||
|
||||
// Note that the input matrix uses 0 == white, 1 == black, while the output matrix uses
|
||||
// 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).
|
||||
private static BitMatrix renderResult(QRCode code, int width, int height, int quietZone) {
|
||||
private static BitMatrix renderRXingResult(QRCode code, int width, int height, int quietZone) {
|
||||
ByteMatrix input = code.getMatrix();
|
||||
if (input == null) {
|
||||
throw new IllegalStateException();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user