mirror of
https://github.com/zxing/zxing.git
synced 2025-01-12 19:57:27 -08:00
More inspection stuff, mostly making things final that are not intended for extension
git-svn-id: https://zxing.googlecode.com/svn/trunk@2344 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
c73aac2f90
commit
d19176ec5f
|
@ -35,7 +35,7 @@ public abstract class Binarizer {
|
|||
this.source = source;
|
||||
}
|
||||
|
||||
public LuminanceSource getLuminanceSource() {
|
||||
public final LuminanceSource getLuminanceSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
|
@ -74,11 +74,11 @@ public abstract class Binarizer {
|
|||
*/
|
||||
public abstract Binarizer createBinarizer(LuminanceSource source);
|
||||
|
||||
public int getWidth() {
|
||||
public final int getWidth() {
|
||||
return source.getWidth();
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
public final int getHeight() {
|
||||
return source.getHeight();
|
||||
}
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ public abstract class LuminanceSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public final String toString() {
|
||||
byte[] row = new byte[width];
|
||||
StringBuilder result = new StringBuilder(height * (width + 1));
|
||||
for (int y = 0; y < height; y++) {
|
||||
|
|
|
@ -43,7 +43,7 @@ public class ResultPoint {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
public final boolean equals(Object other) {
|
||||
if (other instanceof ResultPoint) {
|
||||
ResultPoint otherPoint = (ResultPoint) other;
|
||||
return x == otherPoint.x && y == otherPoint.y;
|
||||
|
@ -52,12 +52,12 @@ public class ResultPoint {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
public final int hashCode() {
|
||||
return 31 * Float.floatToIntBits(x) + Float.floatToIntBits(y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public final String toString() {
|
||||
StringBuilder result = new StringBuilder(25);
|
||||
result.append('(');
|
||||
result.append(x);
|
||||
|
|
|
@ -37,14 +37,14 @@ public abstract class ParsedResult {
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
public ParsedResultType getType() {
|
||||
public final ParsedResultType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public abstract String getDisplayResult();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public final String toString() {
|
||||
return getDisplayResult();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,11 +35,11 @@ public class DetectorResult {
|
|||
this.points = points;
|
||||
}
|
||||
|
||||
public BitMatrix getBits() {
|
||||
public final BitMatrix getBits() {
|
||||
return bits;
|
||||
}
|
||||
|
||||
public ResultPoint[] getPoints() {
|
||||
public final ResultPoint[] getPoints() {
|
||||
return points;
|
||||
}
|
||||
|
||||
|
|
|
@ -429,7 +429,7 @@ public final class Detector {
|
|||
/**
|
||||
* Orders ResultPointsAndTransitions by number of transitions, ascending.
|
||||
*/
|
||||
private static class ResultPointsAndTransitionsComparator
|
||||
private static final class ResultPointsAndTransitionsComparator
|
||||
implements Comparator<ResultPointsAndTransitions>, Serializable {
|
||||
@Override
|
||||
public int compare(ResultPointsAndTransitions o1, ResultPointsAndTransitions o2) {
|
||||
|
|
|
@ -76,7 +76,7 @@ final class MultiFinderPatternFinder extends FinderPatternFinder {
|
|||
/**
|
||||
* A comparator that orders FinderPatterns by their estimated module size.
|
||||
*/
|
||||
private static class ModuleSizeComparator implements Comparator<FinderPattern>, Serializable {
|
||||
private static final class ModuleSizeComparator implements Comparator<FinderPattern>, Serializable {
|
||||
@Override
|
||||
public int compare(FinderPattern center1, FinderPattern center2) {
|
||||
float value = center2.getEstimatedModuleSize() - center1.getEstimatedModuleSize();
|
||||
|
|
|
@ -23,7 +23,7 @@ import com.google.zxing.common.BitMatrix;
|
|||
*
|
||||
* @author dsbnatut@gmail.com (Kazuki Nishiura)
|
||||
*/
|
||||
public class CodaBarWriter extends OneDimensionalCodeWriter {
|
||||
public final class CodaBarWriter extends OneDimensionalCodeWriter {
|
||||
|
||||
public CodaBarWriter() {
|
||||
// Super constructor requires the sum of the left and right margin length.
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.Map;
|
|||
*
|
||||
* @author qwandor@google.com (Andrew Walbran)
|
||||
*/
|
||||
public class UPCAWriter implements Writer {
|
||||
public final class UPCAWriter implements Writer {
|
||||
|
||||
private final EAN13Writer subWriter = new EAN13Writer();
|
||||
|
||||
|
|
|
@ -271,11 +271,11 @@ public abstract class UPCEANReader extends OneDReader {
|
|||
* @return start/end horizontal offset of guard pattern, as an array of two ints
|
||||
* @throws NotFoundException if pattern is not found
|
||||
*/
|
||||
static int[] findGuardPattern(BitArray row,
|
||||
int rowOffset,
|
||||
boolean whiteFirst,
|
||||
int[] pattern,
|
||||
int[] counters) throws NotFoundException {
|
||||
private static int[] findGuardPattern(BitArray row,
|
||||
int rowOffset,
|
||||
boolean whiteFirst,
|
||||
int[] pattern,
|
||||
int[] counters) throws NotFoundException {
|
||||
int patternLength = pattern.length;
|
||||
int width = row.getSize();
|
||||
boolean isWhite = whiteFirst;
|
||||
|
|
|
@ -43,27 +43,27 @@ public abstract class AbstractRSSReader extends OneDReader {
|
|||
evenCounts = new int[dataCharacterCounters.length / 2];
|
||||
}
|
||||
|
||||
protected int[] getDecodeFinderCounters() {
|
||||
protected final int[] getDecodeFinderCounters() {
|
||||
return decodeFinderCounters;
|
||||
}
|
||||
|
||||
protected int[] getDataCharacterCounters() {
|
||||
protected final int[] getDataCharacterCounters() {
|
||||
return dataCharacterCounters;
|
||||
}
|
||||
|
||||
protected float[] getOddRoundingErrors() {
|
||||
protected final float[] getOddRoundingErrors() {
|
||||
return oddRoundingErrors;
|
||||
}
|
||||
|
||||
protected float[] getEvenRoundingErrors() {
|
||||
protected final float[] getEvenRoundingErrors() {
|
||||
return evenRoundingErrors;
|
||||
}
|
||||
|
||||
protected int[] getOddCounts() {
|
||||
protected final int[] getOddCounts() {
|
||||
return oddCounts;
|
||||
}
|
||||
|
||||
protected int[] getEvenCounts() {
|
||||
protected final int[] getEvenCounts() {
|
||||
return evenCounts;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,11 @@ public class DataCharacter {
|
|||
this.checksumPortion = checksumPortion;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
public final int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public int getChecksumPortion() {
|
||||
public final int getChecksumPortion() {
|
||||
return checksumPortion;
|
||||
}
|
||||
|
||||
|
|
|
@ -353,23 +353,6 @@ public final class RSS14Reader extends AbstractRSSReader {
|
|||
return new FinderPattern(value, new int[] {firstElementStart, startEnd[1]}, start, end, rowNumber);
|
||||
}
|
||||
|
||||
/*
|
||||
private static int[] normalizeE2SEValues(int[] counters) {
|
||||
int p = 0;
|
||||
for (int i = 0; i < counters.length; i++) {
|
||||
p += counters[i];
|
||||
}
|
||||
int[] normalized = new int[counters.length - 2];
|
||||
for (int i = 0; i < normalized.length; i++) {
|
||||
int e = counters[i] + counters[i+1];
|
||||
float eRatio = (float) e / (float) p;
|
||||
float E = ((eRatio * 32.0f) + 1.0f) / 2.0f;
|
||||
normalized[i] = (int) E;
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
*/
|
||||
|
||||
private void adjustOddEvenCounts(boolean outsideChar, int numModules) throws NotFoundException {
|
||||
|
||||
int oddSum = count(getOddCounts());
|
||||
|
|
|
@ -369,9 +369,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
|||
|
||||
start = this.startEnd[0];
|
||||
|
||||
int firstElementStart = row.getNextUnset(this.startEnd[1] + 1);
|
||||
|
||||
end = firstElementStart;
|
||||
end = row.getNextUnset(this.startEnd[1] + 1);
|
||||
firstCounter = end - this.startEnd[1];
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ abstract class AI01decoder extends AbstractExpandedDecoder {
|
|||
super(information);
|
||||
}
|
||||
|
||||
protected void encodeCompressedGtin(StringBuilder buf, int currentPos) {
|
||||
protected final void encodeCompressedGtin(StringBuilder buf, int currentPos) {
|
||||
buf.append("(01)");
|
||||
int initialPosition = buf.length();
|
||||
buf.append('9');
|
||||
|
@ -48,7 +48,7 @@ abstract class AI01decoder extends AbstractExpandedDecoder {
|
|||
encodeCompressedGtinWithoutAI(buf, currentPos, initialPosition);
|
||||
}
|
||||
|
||||
protected void encodeCompressedGtinWithoutAI(StringBuilder buf, int currentPos, int initialBufferPosition) {
|
||||
protected final void encodeCompressedGtinWithoutAI(StringBuilder buf, int currentPos, int initialBufferPosition) {
|
||||
for(int i = 0; i < 4; ++i){
|
||||
int currentBlock = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos + 10 * i, 10);
|
||||
if (currentBlock / 100 == 0) {
|
||||
|
|
|
@ -37,7 +37,7 @@ abstract class AI01weightDecoder extends AI01decoder {
|
|||
super(information);
|
||||
}
|
||||
|
||||
protected void encodeCompressedWeight(StringBuilder buf, int currentPos, int weightSize) {
|
||||
protected final void encodeCompressedWeight(StringBuilder buf, int currentPos, int weightSize) {
|
||||
int originalWeightNumeric = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos, weightSize);
|
||||
addWeightCode(buf, originalWeightNumeric);
|
||||
|
||||
|
@ -54,5 +54,7 @@ abstract class AI01weightDecoder extends AI01decoder {
|
|||
}
|
||||
|
||||
protected abstract void addWeightCode(StringBuilder buf, int weight);
|
||||
|
||||
protected abstract int checkWeight(int weight);
|
||||
|
||||
}
|
||||
|
|
|
@ -43,11 +43,11 @@ public abstract class AbstractExpandedDecoder {
|
|||
this.generalDecoder = new GeneralAppIdDecoder(information);
|
||||
}
|
||||
|
||||
protected BitArray getInformation() {
|
||||
protected final BitArray getInformation() {
|
||||
return information;
|
||||
}
|
||||
|
||||
protected GeneralAppIdDecoder getGeneralDecoder() {
|
||||
protected final GeneralAppIdDecoder getGeneralDecoder() {
|
||||
return generalDecoder;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ abstract class DecodedObject {
|
|||
this.newPosition = newPosition;
|
||||
}
|
||||
|
||||
int getNewPosition() {
|
||||
final int getNewPosition() {
|
||||
return this.newPosition;
|
||||
}
|
||||
|
||||
|
|
|
@ -213,14 +213,8 @@ final class BitMatrixParser {
|
|||
// Left row indicator column
|
||||
int cw = getCodeword(symbol);
|
||||
if (ecLevel < 0) {
|
||||
switch (rowNumber % 3) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
leftColumnECData = cw;
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
if (rowNumber % 3 == 1) {
|
||||
leftColumnECData = cw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -234,18 +228,11 @@ final class BitMatrixParser {
|
|||
// Overwrite the last codeword i.e. Right Row Indicator
|
||||
--next;
|
||||
if (ecLevel < 0) {
|
||||
switch (rowNumber % 3) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
rightColumnECData = codewords[next];
|
||||
if (rightColumnECData == leftColumnECData
|
||||
&& leftColumnECData != 0) {
|
||||
ecLevel = ((rightColumnECData % 30) - rows % 3) / 3;
|
||||
}
|
||||
break;
|
||||
if (rowNumber % 3 == 2) {
|
||||
rightColumnECData = codewords[next];
|
||||
if (rightColumnECData == leftColumnECData && leftColumnECData != 0) {
|
||||
ecLevel = ((rightColumnECData % 30) - rows % 3) / 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
codewords[next] = 0;
|
||||
|
|
|
@ -506,7 +506,7 @@ final class PDF417 {
|
|||
0x107a4, 0x107a2, 0x10396, 0x107b6, 0x187d4, 0x187d2,
|
||||
0x10794, 0x10fb4, 0x10792, 0x10fb2, 0x1c7ea}};
|
||||
|
||||
public static final float PREFERRED_RATIO = 3.0f;
|
||||
private static final float PREFERRED_RATIO = 3.0f;
|
||||
private static final float DEFAULT_MODULE_WIDTH = 0.357f; //1px in mm
|
||||
private static final float HEIGHT = 2.0f; //mm
|
||||
|
||||
|
|
|
@ -156,7 +156,6 @@ final class PDF417HighLevelEncoder {
|
|||
|
||||
int len = msg.length();
|
||||
int p = 0;
|
||||
int encodingMode = TEXT_COMPACTION; //Default mode, see 4.4.2.1
|
||||
int textSubMode = SUBMODE_ALPHA;
|
||||
|
||||
// User selected encoding mode
|
||||
|
@ -164,16 +163,15 @@ final class PDF417HighLevelEncoder {
|
|||
encodeText(msg, p, len, sb, textSubMode);
|
||||
|
||||
} else if (compaction == Compaction.BYTE) {
|
||||
encodingMode = BYTE_COMPACTION;
|
||||
bytes = getBytesForMessage(msg);
|
||||
encodeBinary(bytes, p, bytes.length, encodingMode, sb);
|
||||
encodeBinary(bytes, p, bytes.length, BYTE_COMPACTION, sb);
|
||||
|
||||
} else if (compaction == Compaction.NUMERIC) {
|
||||
encodingMode = NUMERIC_COMPACTION;
|
||||
sb.append((char) LATCH_TO_NUMERIC);
|
||||
encodeNumeric(msg, p, len, sb);
|
||||
|
||||
} else {
|
||||
int encodingMode = TEXT_COMPACTION; //Default mode, see 4.4.2.1
|
||||
while (p < len) {
|
||||
int n = determineConsecutiveDigitCount(msg, p);
|
||||
if (n >= 13) {
|
||||
|
|
|
@ -82,7 +82,7 @@ abstract class DataMask {
|
|||
/**
|
||||
* 000: mask bits for which (x + y) mod 2 == 0
|
||||
*/
|
||||
private static class DataMask000 extends DataMask {
|
||||
private static final class DataMask000 extends DataMask {
|
||||
@Override
|
||||
boolean isMasked(int i, int j) {
|
||||
return ((i + j) & 0x01) == 0;
|
||||
|
@ -92,7 +92,7 @@ abstract class DataMask {
|
|||
/**
|
||||
* 001: mask bits for which x mod 2 == 0
|
||||
*/
|
||||
private static class DataMask001 extends DataMask {
|
||||
private static final class DataMask001 extends DataMask {
|
||||
@Override
|
||||
boolean isMasked(int i, int j) {
|
||||
return (i & 0x01) == 0;
|
||||
|
@ -102,7 +102,7 @@ abstract class DataMask {
|
|||
/**
|
||||
* 010: mask bits for which y mod 3 == 0
|
||||
*/
|
||||
private static class DataMask010 extends DataMask {
|
||||
private static final class DataMask010 extends DataMask {
|
||||
@Override
|
||||
boolean isMasked(int i, int j) {
|
||||
return j % 3 == 0;
|
||||
|
@ -112,7 +112,7 @@ abstract class DataMask {
|
|||
/**
|
||||
* 011: mask bits for which (x + y) mod 3 == 0
|
||||
*/
|
||||
private static class DataMask011 extends DataMask {
|
||||
private static final class DataMask011 extends DataMask {
|
||||
@Override
|
||||
boolean isMasked(int i, int j) {
|
||||
return (i + j) % 3 == 0;
|
||||
|
@ -122,7 +122,7 @@ abstract class DataMask {
|
|||
/**
|
||||
* 100: mask bits for which (x/2 + y/3) mod 2 == 0
|
||||
*/
|
||||
private static class DataMask100 extends DataMask {
|
||||
private static final class DataMask100 extends DataMask {
|
||||
@Override
|
||||
boolean isMasked(int i, int j) {
|
||||
return (((i >>> 1) + (j /3)) & 0x01) == 0;
|
||||
|
@ -132,7 +132,7 @@ abstract class DataMask {
|
|||
/**
|
||||
* 101: mask bits for which xy mod 2 + xy mod 3 == 0
|
||||
*/
|
||||
private static class DataMask101 extends DataMask {
|
||||
private static final class DataMask101 extends DataMask {
|
||||
@Override
|
||||
boolean isMasked(int i, int j) {
|
||||
int temp = i * j;
|
||||
|
@ -143,7 +143,7 @@ abstract class DataMask {
|
|||
/**
|
||||
* 110: mask bits for which (xy mod 2 + xy mod 3) mod 2 == 0
|
||||
*/
|
||||
private static class DataMask110 extends DataMask {
|
||||
private static final class DataMask110 extends DataMask {
|
||||
@Override
|
||||
boolean isMasked(int i, int j) {
|
||||
int temp = i * j;
|
||||
|
@ -154,7 +154,7 @@ abstract class DataMask {
|
|||
/**
|
||||
* 111: mask bits for which ((x+y)mod 2 + xy mod 3) mod 2 == 0
|
||||
*/
|
||||
private static class DataMask111 extends DataMask {
|
||||
private static final class DataMask111 extends DataMask {
|
||||
@Override
|
||||
boolean isMasked(int i, int j) {
|
||||
return ((((i + j) & 0x01) + ((i * j) % 3)) & 0x01) == 0;
|
||||
|
|
|
@ -45,11 +45,11 @@ public class Detector {
|
|||
this.image = image;
|
||||
}
|
||||
|
||||
protected BitMatrix getImage() {
|
||||
protected final BitMatrix getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
protected ResultPointCallback getResultPointCallback() {
|
||||
protected final ResultPointCallback getResultPointCallback() {
|
||||
return resultPointCallback;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class Detector {
|
|||
* @throws NotFoundException if QR Code cannot be found
|
||||
* @throws FormatException if a QR Code cannot be decoded
|
||||
*/
|
||||
public DetectorResult detect(Map<DecodeHintType,?> hints) throws NotFoundException, FormatException {
|
||||
public final DetectorResult detect(Map<DecodeHintType,?> hints) throws NotFoundException, FormatException {
|
||||
|
||||
resultPointCallback = hints == null ? null :
|
||||
(ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
|
||||
|
@ -82,7 +82,7 @@ public class Detector {
|
|||
return processFinderPatternInfo(info);
|
||||
}
|
||||
|
||||
protected DetectorResult processFinderPatternInfo(FinderPatternInfo info)
|
||||
protected final DetectorResult processFinderPatternInfo(FinderPatternInfo info)
|
||||
throws NotFoundException, FormatException {
|
||||
|
||||
FinderPattern topLeft = info.getTopLeft();
|
||||
|
@ -140,11 +140,11 @@ public class Detector {
|
|||
return new DetectorResult(bits, points);
|
||||
}
|
||||
|
||||
public static PerspectiveTransform createTransform(ResultPoint topLeft,
|
||||
ResultPoint topRight,
|
||||
ResultPoint bottomLeft,
|
||||
ResultPoint alignmentPattern,
|
||||
int dimension) {
|
||||
private static PerspectiveTransform createTransform(ResultPoint topLeft,
|
||||
ResultPoint topRight,
|
||||
ResultPoint bottomLeft,
|
||||
ResultPoint alignmentPattern,
|
||||
int dimension) {
|
||||
float dimMinusThree = (float) dimension - 3.5f;
|
||||
float bottomRightX;
|
||||
float bottomRightY;
|
||||
|
@ -194,10 +194,10 @@ public class Detector {
|
|||
* <p>Computes the dimension (number of modules on a size) of the QR Code based on the position
|
||||
* of the finder patterns and estimated module size.</p>
|
||||
*/
|
||||
protected static int computeDimension(ResultPoint topLeft,
|
||||
ResultPoint topRight,
|
||||
ResultPoint bottomLeft,
|
||||
float moduleSize) throws NotFoundException {
|
||||
private static int computeDimension(ResultPoint topLeft,
|
||||
ResultPoint topRight,
|
||||
ResultPoint bottomLeft,
|
||||
float moduleSize) throws NotFoundException {
|
||||
int tltrCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, topRight) / moduleSize);
|
||||
int tlblCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, bottomLeft) / moduleSize);
|
||||
int dimension = ((tltrCentersDimension + tlblCentersDimension) >> 1) + 7;
|
||||
|
@ -219,9 +219,9 @@ public class Detector {
|
|||
* <p>Computes an average estimated module size based on estimated derived from the positions
|
||||
* of the three finder patterns.</p>
|
||||
*/
|
||||
protected float calculateModuleSize(ResultPoint topLeft,
|
||||
ResultPoint topRight,
|
||||
ResultPoint bottomLeft) {
|
||||
protected final float calculateModuleSize(ResultPoint topLeft,
|
||||
ResultPoint topRight,
|
||||
ResultPoint bottomLeft) {
|
||||
// Take the average
|
||||
return (calculateModuleSizeOneWay(topLeft, topRight) +
|
||||
calculateModuleSizeOneWay(topLeft, bottomLeft)) / 2.0f;
|
||||
|
@ -364,10 +364,10 @@ public class Detector {
|
|||
* @return {@link AlignmentPattern} if found, or null otherwise
|
||||
* @throws NotFoundException if an unexpected error occurs during detection
|
||||
*/
|
||||
protected AlignmentPattern findAlignmentInRegion(float overallEstModuleSize,
|
||||
int estAlignmentX,
|
||||
int estAlignmentY,
|
||||
float allowanceFactor)
|
||||
protected final AlignmentPattern findAlignmentInRegion(float overallEstModuleSize,
|
||||
int estAlignmentX,
|
||||
int estAlignmentY,
|
||||
float allowanceFactor)
|
||||
throws NotFoundException {
|
||||
// Look for an alignment pattern (3 modules in size) around where it
|
||||
// should be
|
||||
|
|
|
@ -34,7 +34,7 @@ public final class FinderPattern extends ResultPoint {
|
|||
this(posX, posY, estimatedModuleSize, 1);
|
||||
}
|
||||
|
||||
FinderPattern(float posX, float posY, float estimatedModuleSize, int count) {
|
||||
private FinderPattern(float posX, float posY, float estimatedModuleSize, int count) {
|
||||
super(posX, posY);
|
||||
this.estimatedModuleSize = estimatedModuleSize;
|
||||
this.count = count;
|
||||
|
|
|
@ -66,15 +66,15 @@ public class FinderPatternFinder {
|
|||
this.resultPointCallback = resultPointCallback;
|
||||
}
|
||||
|
||||
protected BitMatrix getImage() {
|
||||
protected final BitMatrix getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
protected List<FinderPattern> getPossibleCenters() {
|
||||
protected final List<FinderPattern> getPossibleCenters() {
|
||||
return possibleCenters;
|
||||
}
|
||||
|
||||
FinderPatternInfo find(Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
final FinderPatternInfo find(Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
|
||||
int maxI = image.getHeight();
|
||||
int maxJ = image.getWidth();
|
||||
|
@ -390,7 +390,7 @@ public class FinderPatternFinder {
|
|||
* @param j end of possible finder pattern in row
|
||||
* @return true if a finder pattern candidate was found this time
|
||||
*/
|
||||
protected boolean handlePossibleCenter(int[] stateCount, int i, int j) {
|
||||
protected final boolean handlePossibleCenter(int[] stateCount, int i, int j) {
|
||||
int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] +
|
||||
stateCount[4];
|
||||
float centerJ = centerFromEnd(stateCount, j);
|
||||
|
|
|
@ -29,6 +29,8 @@ import java.awt.image.BufferedImage;
|
|||
*/
|
||||
public final class BufferedImageLuminanceSource extends LuminanceSource {
|
||||
|
||||
private static final double MINUS_45_IN_RADIANS = -0.7853981633974483; // Math.toRadians(-45.0)
|
||||
|
||||
private final BufferedImage image;
|
||||
private final int left;
|
||||
private final int top;
|
||||
|
@ -148,7 +150,7 @@ public final class BufferedImageLuminanceSource extends LuminanceSource {
|
|||
int oldCenterY = top + height / 2;
|
||||
|
||||
// Rotate 45 degrees counterclockwise.
|
||||
AffineTransform transform = AffineTransform.getRotateInstance(Math.toRadians(-45.0), oldCenterX, oldCenterY);
|
||||
AffineTransform transform = AffineTransform.getRotateInstance(MINUS_45_IN_RADIANS, oldCenterX, oldCenterY);
|
||||
|
||||
int sourceDimension = Math.max(image.getWidth(), image.getHeight());
|
||||
BufferedImage rotatedImage = new BufferedImage(sourceDimension, sourceDimension, BufferedImage.TYPE_BYTE_GRAY);
|
||||
|
|
|
@ -85,7 +85,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
|
|||
testResults = new ArrayList<TestResult>();
|
||||
}
|
||||
|
||||
protected void addTest(int mustPassCount, int tryHarderCount, float rotation) {
|
||||
protected final void addTest(int mustPassCount, int tryHarderCount, float rotation) {
|
||||
addTest(mustPassCount, tryHarderCount, 0, 0, rotation);
|
||||
}
|
||||
|
||||
|
@ -99,20 +99,20 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
|
|||
* reading the wrong contents using the try harder flag
|
||||
* @param rotation The rotation in degrees clockwise to use for this test.
|
||||
*/
|
||||
protected void addTest(int mustPassCount,
|
||||
int tryHarderCount,
|
||||
int maxMisreads,
|
||||
int maxTryHarderMisreads,
|
||||
float rotation) {
|
||||
protected final void addTest(int mustPassCount,
|
||||
int tryHarderCount,
|
||||
int maxMisreads,
|
||||
int maxTryHarderMisreads,
|
||||
float rotation) {
|
||||
testResults.add(new TestResult(mustPassCount, tryHarderCount, maxMisreads, maxTryHarderMisreads, rotation));
|
||||
}
|
||||
|
||||
protected File[] getImageFiles() {
|
||||
protected final File[] getImageFiles() {
|
||||
assertTrue("Please run from the 'core' directory", testBase.exists());
|
||||
return testBase.listFiles(IMAGE_NAME_FILTER);
|
||||
}
|
||||
|
||||
protected Reader getReader() {
|
||||
protected final Reader getReader() {
|
||||
return barcodeReader;
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
|
|||
testBlackBoxCountingResults(true);
|
||||
}
|
||||
|
||||
public SummaryResults testBlackBoxCountingResults(boolean assertOnFailure) throws IOException {
|
||||
public final SummaryResults testBlackBoxCountingResults(boolean assertOnFailure) throws IOException {
|
||||
assertFalse(testResults.isEmpty());
|
||||
|
||||
File[] imageFiles = getImageFiles();
|
||||
|
|
|
@ -42,7 +42,7 @@ import java.util.Map;
|
|||
*/
|
||||
public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxTestCase {
|
||||
|
||||
private static class TestResult {
|
||||
private static final class TestResult {
|
||||
private final int falsePositivesAllowed;
|
||||
private final float rotation;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.google.zxing.BarcodeFormat;
|
|||
import com.google.zxing.MultiFormatReader;
|
||||
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
||||
|
||||
public class RSSExpandedBlackBox2TestCase extends AbstractBlackBoxTestCase {
|
||||
public final class RSSExpandedBlackBox2TestCase extends AbstractBlackBoxTestCase {
|
||||
|
||||
public RSSExpandedBlackBox2TestCase() {
|
||||
super("test/data/blackbox/rssexpanded-2", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED);
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.junit.Test;
|
|||
/**
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
*/
|
||||
public class AI01_3103_DecoderTest extends AbstractDecoderTest {
|
||||
public final class AI01_3103_DecoderTest extends AbstractDecoderTest {
|
||||
|
||||
private static final String header = "..X..";
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.junit.Test;
|
|||
/**
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
*/
|
||||
public class AI01_3202_3203_DecoderTest extends AbstractDecoderTest {
|
||||
public final class AI01_3202_3203_DecoderTest extends AbstractDecoderTest {
|
||||
|
||||
private static final String header = "..X.X";
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.junit.Test;
|
|||
/**
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
*/
|
||||
public class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
|
||||
public final class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
|
||||
|
||||
private static final String header_310x_11 = "..XXX...";
|
||||
private static final String header_320x_11 = "..XXX..X";
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.junit.Test;
|
|||
/**
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
*/
|
||||
public class AnyAIDecoderTest extends AbstractDecoderTest {
|
||||
public final class AnyAIDecoderTest extends AbstractDecoderTest {
|
||||
|
||||
private static final String header = ".....";
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.junit.Test;
|
|||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
* @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
|
||||
*/
|
||||
public class FieldParserTest extends Assert {
|
||||
public final class FieldParserTest extends Assert {
|
||||
|
||||
private static void checkFields(String expected) throws NotFoundException {
|
||||
String field = expected.replace("(", "").replace(")","");
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.junit.Test;
|
|||
* @author satorux@google.com (Satoru Takabayashi) - creator
|
||||
* @author dswitkin@google.com (Daniel Switkin) - ported from C++
|
||||
*/
|
||||
public class BitVectorTestCase extends Assert {
|
||||
public final class BitVectorTestCase extends Assert {
|
||||
|
||||
private static long getUnsignedInt(BitArray v, int index) {
|
||||
long result = 0L;
|
||||
|
|
Loading…
Reference in a new issue