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:
srowen 2012-07-07 20:41:00 +00:00
parent c73aac2f90
commit d19176ec5f
35 changed files with 100 additions and 130 deletions

View file

@ -35,7 +35,7 @@ public abstract class Binarizer {
this.source = source; this.source = source;
} }
public LuminanceSource getLuminanceSource() { public final LuminanceSource getLuminanceSource() {
return source; return source;
} }
@ -74,11 +74,11 @@ public abstract class Binarizer {
*/ */
public abstract Binarizer createBinarizer(LuminanceSource source); public abstract Binarizer createBinarizer(LuminanceSource source);
public int getWidth() { public final int getWidth() {
return source.getWidth(); return source.getWidth();
} }
public int getHeight() { public final int getHeight() {
return source.getHeight(); return source.getHeight();
} }

View file

@ -122,7 +122,7 @@ public abstract class LuminanceSource {
} }
@Override @Override
public String toString() { public final String toString() {
byte[] row = new byte[width]; byte[] row = new byte[width];
StringBuilder result = new StringBuilder(height * (width + 1)); StringBuilder result = new StringBuilder(height * (width + 1));
for (int y = 0; y < height; y++) { for (int y = 0; y < height; y++) {

View file

@ -43,7 +43,7 @@ public class ResultPoint {
} }
@Override @Override
public boolean equals(Object other) { public final boolean equals(Object other) {
if (other instanceof ResultPoint) { if (other instanceof ResultPoint) {
ResultPoint otherPoint = (ResultPoint) other; ResultPoint otherPoint = (ResultPoint) other;
return x == otherPoint.x && y == otherPoint.y; return x == otherPoint.x && y == otherPoint.y;
@ -52,12 +52,12 @@ public class ResultPoint {
} }
@Override @Override
public int hashCode() { public final int hashCode() {
return 31 * Float.floatToIntBits(x) + Float.floatToIntBits(y); return 31 * Float.floatToIntBits(x) + Float.floatToIntBits(y);
} }
@Override @Override
public String toString() { public final String toString() {
StringBuilder result = new StringBuilder(25); StringBuilder result = new StringBuilder(25);
result.append('('); result.append('(');
result.append(x); result.append(x);

View file

@ -37,14 +37,14 @@ public abstract class ParsedResult {
this.type = type; this.type = type;
} }
public ParsedResultType getType() { public final ParsedResultType getType() {
return type; return type;
} }
public abstract String getDisplayResult(); public abstract String getDisplayResult();
@Override @Override
public String toString() { public final String toString() {
return getDisplayResult(); return getDisplayResult();
} }

View file

@ -35,11 +35,11 @@ public class DetectorResult {
this.points = points; this.points = points;
} }
public BitMatrix getBits() { public final BitMatrix getBits() {
return bits; return bits;
} }
public ResultPoint[] getPoints() { public final ResultPoint[] getPoints() {
return points; return points;
} }

View file

@ -429,7 +429,7 @@ public final class Detector {
/** /**
* Orders ResultPointsAndTransitions by number of transitions, ascending. * Orders ResultPointsAndTransitions by number of transitions, ascending.
*/ */
private static class ResultPointsAndTransitionsComparator private static final class ResultPointsAndTransitionsComparator
implements Comparator<ResultPointsAndTransitions>, Serializable { implements Comparator<ResultPointsAndTransitions>, Serializable {
@Override @Override
public int compare(ResultPointsAndTransitions o1, ResultPointsAndTransitions o2) { public int compare(ResultPointsAndTransitions o1, ResultPointsAndTransitions o2) {

View file

@ -76,7 +76,7 @@ final class MultiFinderPatternFinder extends FinderPatternFinder {
/** /**
* A comparator that orders FinderPatterns by their estimated module size. * 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 @Override
public int compare(FinderPattern center1, FinderPattern center2) { public int compare(FinderPattern center1, FinderPattern center2) {
float value = center2.getEstimatedModuleSize() - center1.getEstimatedModuleSize(); float value = center2.getEstimatedModuleSize() - center1.getEstimatedModuleSize();

View file

@ -23,7 +23,7 @@ import com.google.zxing.common.BitMatrix;
* *
* @author dsbnatut@gmail.com (Kazuki Nishiura) * @author dsbnatut@gmail.com (Kazuki Nishiura)
*/ */
public class CodaBarWriter extends OneDimensionalCodeWriter { public final class CodaBarWriter extends OneDimensionalCodeWriter {
public CodaBarWriter() { public CodaBarWriter() {
// Super constructor requires the sum of the left and right margin length. // Super constructor requires the sum of the left and right margin length.

View file

@ -29,7 +29,7 @@ import java.util.Map;
* *
* @author qwandor@google.com (Andrew Walbran) * @author qwandor@google.com (Andrew Walbran)
*/ */
public class UPCAWriter implements Writer { public final class UPCAWriter implements Writer {
private final EAN13Writer subWriter = new EAN13Writer(); private final EAN13Writer subWriter = new EAN13Writer();

View file

@ -271,11 +271,11 @@ public abstract class UPCEANReader extends OneDReader {
* @return start/end horizontal offset of guard pattern, as an array of two ints * @return start/end horizontal offset of guard pattern, as an array of two ints
* @throws NotFoundException if pattern is not found * @throws NotFoundException if pattern is not found
*/ */
static int[] findGuardPattern(BitArray row, private static int[] findGuardPattern(BitArray row,
int rowOffset, int rowOffset,
boolean whiteFirst, boolean whiteFirst,
int[] pattern, int[] pattern,
int[] counters) throws NotFoundException { int[] counters) throws NotFoundException {
int patternLength = pattern.length; int patternLength = pattern.length;
int width = row.getSize(); int width = row.getSize();
boolean isWhite = whiteFirst; boolean isWhite = whiteFirst;

View file

@ -43,27 +43,27 @@ public abstract class AbstractRSSReader extends OneDReader {
evenCounts = new int[dataCharacterCounters.length / 2]; evenCounts = new int[dataCharacterCounters.length / 2];
} }
protected int[] getDecodeFinderCounters() { protected final int[] getDecodeFinderCounters() {
return decodeFinderCounters; return decodeFinderCounters;
} }
protected int[] getDataCharacterCounters() { protected final int[] getDataCharacterCounters() {
return dataCharacterCounters; return dataCharacterCounters;
} }
protected float[] getOddRoundingErrors() { protected final float[] getOddRoundingErrors() {
return oddRoundingErrors; return oddRoundingErrors;
} }
protected float[] getEvenRoundingErrors() { protected final float[] getEvenRoundingErrors() {
return evenRoundingErrors; return evenRoundingErrors;
} }
protected int[] getOddCounts() { protected final int[] getOddCounts() {
return oddCounts; return oddCounts;
} }
protected int[] getEvenCounts() { protected final int[] getEvenCounts() {
return evenCounts; return evenCounts;
} }

View file

@ -26,11 +26,11 @@ public class DataCharacter {
this.checksumPortion = checksumPortion; this.checksumPortion = checksumPortion;
} }
public int getValue() { public final int getValue() {
return value; return value;
} }
public int getChecksumPortion() { public final int getChecksumPortion() {
return checksumPortion; return checksumPortion;
} }

View file

@ -353,23 +353,6 @@ public final class RSS14Reader extends AbstractRSSReader {
return new FinderPattern(value, new int[] {firstElementStart, startEnd[1]}, start, end, rowNumber); 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 { private void adjustOddEvenCounts(boolean outsideChar, int numModules) throws NotFoundException {
int oddSum = count(getOddCounts()); int oddSum = count(getOddCounts());

View file

@ -369,9 +369,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
start = this.startEnd[0]; start = this.startEnd[0];
int firstElementStart = row.getNextUnset(this.startEnd[1] + 1); end = row.getNextUnset(this.startEnd[1] + 1);
end = firstElementStart;
firstCounter = end - this.startEnd[1]; firstCounter = end - this.startEnd[1];
} }

View file

@ -40,7 +40,7 @@ abstract class AI01decoder extends AbstractExpandedDecoder {
super(information); super(information);
} }
protected void encodeCompressedGtin(StringBuilder buf, int currentPos) { protected final void encodeCompressedGtin(StringBuilder buf, int currentPos) {
buf.append("(01)"); buf.append("(01)");
int initialPosition = buf.length(); int initialPosition = buf.length();
buf.append('9'); buf.append('9');
@ -48,7 +48,7 @@ abstract class AI01decoder extends AbstractExpandedDecoder {
encodeCompressedGtinWithoutAI(buf, currentPos, initialPosition); 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){ for(int i = 0; i < 4; ++i){
int currentBlock = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos + 10 * i, 10); int currentBlock = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos + 10 * i, 10);
if (currentBlock / 100 == 0) { if (currentBlock / 100 == 0) {

View file

@ -37,7 +37,7 @@ abstract class AI01weightDecoder extends AI01decoder {
super(information); 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); int originalWeightNumeric = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos, weightSize);
addWeightCode(buf, originalWeightNumeric); addWeightCode(buf, originalWeightNumeric);
@ -54,5 +54,7 @@ abstract class AI01weightDecoder extends AI01decoder {
} }
protected abstract void addWeightCode(StringBuilder buf, int weight); protected abstract void addWeightCode(StringBuilder buf, int weight);
protected abstract int checkWeight(int weight); protected abstract int checkWeight(int weight);
} }

View file

@ -43,11 +43,11 @@ public abstract class AbstractExpandedDecoder {
this.generalDecoder = new GeneralAppIdDecoder(information); this.generalDecoder = new GeneralAppIdDecoder(information);
} }
protected BitArray getInformation() { protected final BitArray getInformation() {
return information; return information;
} }
protected GeneralAppIdDecoder getGeneralDecoder() { protected final GeneralAppIdDecoder getGeneralDecoder() {
return generalDecoder; return generalDecoder;
} }

View file

@ -37,7 +37,7 @@ abstract class DecodedObject {
this.newPosition = newPosition; this.newPosition = newPosition;
} }
int getNewPosition() { final int getNewPosition() {
return this.newPosition; return this.newPosition;
} }

View file

@ -213,14 +213,8 @@ final class BitMatrixParser {
// Left row indicator column // Left row indicator column
int cw = getCodeword(symbol); int cw = getCodeword(symbol);
if (ecLevel < 0) { if (ecLevel < 0) {
switch (rowNumber % 3) { if (rowNumber % 3 == 1) {
case 0: leftColumnECData = cw;
break;
case 1:
leftColumnECData = cw;
break;
case 2:
break;
} }
} }
} }
@ -234,18 +228,11 @@ final class BitMatrixParser {
// Overwrite the last codeword i.e. Right Row Indicator // Overwrite the last codeword i.e. Right Row Indicator
--next; --next;
if (ecLevel < 0) { if (ecLevel < 0) {
switch (rowNumber % 3) { if (rowNumber % 3 == 2) {
case 0: rightColumnECData = codewords[next];
break; if (rightColumnECData == leftColumnECData && leftColumnECData != 0) {
case 1: ecLevel = ((rightColumnECData % 30) - rows % 3) / 3;
break; }
case 2:
rightColumnECData = codewords[next];
if (rightColumnECData == leftColumnECData
&& leftColumnECData != 0) {
ecLevel = ((rightColumnECData % 30) - rows % 3) / 3;
}
break;
} }
} }
codewords[next] = 0; codewords[next] = 0;

View file

@ -506,7 +506,7 @@ final class PDF417 {
0x107a4, 0x107a2, 0x10396, 0x107b6, 0x187d4, 0x187d2, 0x107a4, 0x107a2, 0x10396, 0x107b6, 0x187d4, 0x187d2,
0x10794, 0x10fb4, 0x10792, 0x10fb2, 0x1c7ea}}; 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 DEFAULT_MODULE_WIDTH = 0.357f; //1px in mm
private static final float HEIGHT = 2.0f; //mm private static final float HEIGHT = 2.0f; //mm

View file

@ -156,7 +156,6 @@ final class PDF417HighLevelEncoder {
int len = msg.length(); int len = msg.length();
int p = 0; int p = 0;
int encodingMode = TEXT_COMPACTION; //Default mode, see 4.4.2.1
int textSubMode = SUBMODE_ALPHA; int textSubMode = SUBMODE_ALPHA;
// User selected encoding mode // User selected encoding mode
@ -164,16 +163,15 @@ final class PDF417HighLevelEncoder {
encodeText(msg, p, len, sb, textSubMode); encodeText(msg, p, len, sb, textSubMode);
} else if (compaction == Compaction.BYTE) { } else if (compaction == Compaction.BYTE) {
encodingMode = BYTE_COMPACTION;
bytes = getBytesForMessage(msg); bytes = getBytesForMessage(msg);
encodeBinary(bytes, p, bytes.length, encodingMode, sb); encodeBinary(bytes, p, bytes.length, BYTE_COMPACTION, sb);
} else if (compaction == Compaction.NUMERIC) { } else if (compaction == Compaction.NUMERIC) {
encodingMode = NUMERIC_COMPACTION;
sb.append((char) LATCH_TO_NUMERIC); sb.append((char) LATCH_TO_NUMERIC);
encodeNumeric(msg, p, len, sb); encodeNumeric(msg, p, len, sb);
} else { } else {
int encodingMode = TEXT_COMPACTION; //Default mode, see 4.4.2.1
while (p < len) { while (p < len) {
int n = determineConsecutiveDigitCount(msg, p); int n = determineConsecutiveDigitCount(msg, p);
if (n >= 13) { if (n >= 13) {

View file

@ -82,7 +82,7 @@ abstract class DataMask {
/** /**
* 000: mask bits for which (x + y) mod 2 == 0 * 000: mask bits for which (x + y) mod 2 == 0
*/ */
private static class DataMask000 extends DataMask { private static final class DataMask000 extends DataMask {
@Override @Override
boolean isMasked(int i, int j) { boolean isMasked(int i, int j) {
return ((i + j) & 0x01) == 0; return ((i + j) & 0x01) == 0;
@ -92,7 +92,7 @@ abstract class DataMask {
/** /**
* 001: mask bits for which x mod 2 == 0 * 001: mask bits for which x mod 2 == 0
*/ */
private static class DataMask001 extends DataMask { private static final class DataMask001 extends DataMask {
@Override @Override
boolean isMasked(int i, int j) { boolean isMasked(int i, int j) {
return (i & 0x01) == 0; return (i & 0x01) == 0;
@ -102,7 +102,7 @@ abstract class DataMask {
/** /**
* 010: mask bits for which y mod 3 == 0 * 010: mask bits for which y mod 3 == 0
*/ */
private static class DataMask010 extends DataMask { private static final class DataMask010 extends DataMask {
@Override @Override
boolean isMasked(int i, int j) { boolean isMasked(int i, int j) {
return j % 3 == 0; return j % 3 == 0;
@ -112,7 +112,7 @@ abstract class DataMask {
/** /**
* 011: mask bits for which (x + y) mod 3 == 0 * 011: mask bits for which (x + y) mod 3 == 0
*/ */
private static class DataMask011 extends DataMask { private static final class DataMask011 extends DataMask {
@Override @Override
boolean isMasked(int i, int j) { boolean isMasked(int i, int j) {
return (i + j) % 3 == 0; return (i + j) % 3 == 0;
@ -122,7 +122,7 @@ abstract class DataMask {
/** /**
* 100: mask bits for which (x/2 + y/3) mod 2 == 0 * 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 @Override
boolean isMasked(int i, int j) { boolean isMasked(int i, int j) {
return (((i >>> 1) + (j /3)) & 0x01) == 0; 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 * 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 @Override
boolean isMasked(int i, int j) { boolean isMasked(int i, int j) {
int temp = i * 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 * 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 @Override
boolean isMasked(int i, int j) { boolean isMasked(int i, int j) {
int temp = i * 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 * 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 @Override
boolean isMasked(int i, int j) { boolean isMasked(int i, int j) {
return ((((i + j) & 0x01) + ((i * j) % 3)) & 0x01) == 0; return ((((i + j) & 0x01) + ((i * j) % 3)) & 0x01) == 0;

View file

@ -45,11 +45,11 @@ public class Detector {
this.image = image; this.image = image;
} }
protected BitMatrix getImage() { protected final BitMatrix getImage() {
return image; return image;
} }
protected ResultPointCallback getResultPointCallback() { protected final ResultPointCallback getResultPointCallback() {
return resultPointCallback; return resultPointCallback;
} }
@ -71,7 +71,7 @@ public class Detector {
* @throws NotFoundException if QR Code cannot be found * @throws NotFoundException if QR Code cannot be found
* @throws FormatException if a QR Code cannot be decoded * @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 == null ? null :
(ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
@ -82,7 +82,7 @@ public class Detector {
return processFinderPatternInfo(info); return processFinderPatternInfo(info);
} }
protected DetectorResult processFinderPatternInfo(FinderPatternInfo info) protected final DetectorResult processFinderPatternInfo(FinderPatternInfo info)
throws NotFoundException, FormatException { throws NotFoundException, FormatException {
FinderPattern topLeft = info.getTopLeft(); FinderPattern topLeft = info.getTopLeft();
@ -140,11 +140,11 @@ public class Detector {
return new DetectorResult(bits, points); return new DetectorResult(bits, points);
} }
public static PerspectiveTransform createTransform(ResultPoint topLeft, private static PerspectiveTransform createTransform(ResultPoint topLeft,
ResultPoint topRight, ResultPoint topRight,
ResultPoint bottomLeft, ResultPoint bottomLeft,
ResultPoint alignmentPattern, ResultPoint alignmentPattern,
int dimension) { int dimension) {
float dimMinusThree = (float) dimension - 3.5f; float dimMinusThree = (float) dimension - 3.5f;
float bottomRightX; float bottomRightX;
float bottomRightY; 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 * <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> * of the finder patterns and estimated module size.</p>
*/ */
protected static int computeDimension(ResultPoint topLeft, private static int computeDimension(ResultPoint topLeft,
ResultPoint topRight, ResultPoint topRight,
ResultPoint bottomLeft, ResultPoint bottomLeft,
float moduleSize) throws NotFoundException { float moduleSize) throws NotFoundException {
int tltrCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, topRight) / moduleSize); int tltrCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, topRight) / moduleSize);
int tlblCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, bottomLeft) / moduleSize); int tlblCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, bottomLeft) / moduleSize);
int dimension = ((tltrCentersDimension + tlblCentersDimension) >> 1) + 7; 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 * <p>Computes an average estimated module size based on estimated derived from the positions
* of the three finder patterns.</p> * of the three finder patterns.</p>
*/ */
protected float calculateModuleSize(ResultPoint topLeft, protected final float calculateModuleSize(ResultPoint topLeft,
ResultPoint topRight, ResultPoint topRight,
ResultPoint bottomLeft) { ResultPoint bottomLeft) {
// Take the average // Take the average
return (calculateModuleSizeOneWay(topLeft, topRight) + return (calculateModuleSizeOneWay(topLeft, topRight) +
calculateModuleSizeOneWay(topLeft, bottomLeft)) / 2.0f; calculateModuleSizeOneWay(topLeft, bottomLeft)) / 2.0f;
@ -364,10 +364,10 @@ public class Detector {
* @return {@link AlignmentPattern} if found, or null otherwise * @return {@link AlignmentPattern} if found, or null otherwise
* @throws NotFoundException if an unexpected error occurs during detection * @throws NotFoundException if an unexpected error occurs during detection
*/ */
protected AlignmentPattern findAlignmentInRegion(float overallEstModuleSize, protected final AlignmentPattern findAlignmentInRegion(float overallEstModuleSize,
int estAlignmentX, int estAlignmentX,
int estAlignmentY, int estAlignmentY,
float allowanceFactor) float allowanceFactor)
throws NotFoundException { throws NotFoundException {
// Look for an alignment pattern (3 modules in size) around where it // Look for an alignment pattern (3 modules in size) around where it
// should be // should be

View file

@ -34,7 +34,7 @@ public final class FinderPattern extends ResultPoint {
this(posX, posY, estimatedModuleSize, 1); 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); super(posX, posY);
this.estimatedModuleSize = estimatedModuleSize; this.estimatedModuleSize = estimatedModuleSize;
this.count = count; this.count = count;

View file

@ -66,15 +66,15 @@ public class FinderPatternFinder {
this.resultPointCallback = resultPointCallback; this.resultPointCallback = resultPointCallback;
} }
protected BitMatrix getImage() { protected final BitMatrix getImage() {
return image; return image;
} }
protected List<FinderPattern> getPossibleCenters() { protected final List<FinderPattern> getPossibleCenters() {
return possibleCenters; 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); boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
int maxI = image.getHeight(); int maxI = image.getHeight();
int maxJ = image.getWidth(); int maxJ = image.getWidth();
@ -390,7 +390,7 @@ public class FinderPatternFinder {
* @param j end of possible finder pattern in row * @param j end of possible finder pattern in row
* @return true if a finder pattern candidate was found this time * @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] + int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] +
stateCount[4]; stateCount[4];
float centerJ = centerFromEnd(stateCount, j); float centerJ = centerFromEnd(stateCount, j);

View file

@ -29,6 +29,8 @@ import java.awt.image.BufferedImage;
*/ */
public final class BufferedImageLuminanceSource extends LuminanceSource { 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 BufferedImage image;
private final int left; private final int left;
private final int top; private final int top;
@ -148,7 +150,7 @@ public final class BufferedImageLuminanceSource extends LuminanceSource {
int oldCenterY = top + height / 2; int oldCenterY = top + height / 2;
// Rotate 45 degrees counterclockwise. // 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()); int sourceDimension = Math.max(image.getWidth(), image.getHeight());
BufferedImage rotatedImage = new BufferedImage(sourceDimension, sourceDimension, BufferedImage.TYPE_BYTE_GRAY); BufferedImage rotatedImage = new BufferedImage(sourceDimension, sourceDimension, BufferedImage.TYPE_BYTE_GRAY);

View file

@ -85,7 +85,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
testResults = new ArrayList<TestResult>(); 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); 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 * reading the wrong contents using the try harder flag
* @param rotation The rotation in degrees clockwise to use for this test. * @param rotation The rotation in degrees clockwise to use for this test.
*/ */
protected void addTest(int mustPassCount, protected final void addTest(int mustPassCount,
int tryHarderCount, int tryHarderCount,
int maxMisreads, int maxMisreads,
int maxTryHarderMisreads, int maxTryHarderMisreads,
float rotation) { float rotation) {
testResults.add(new TestResult(mustPassCount, tryHarderCount, maxMisreads, maxTryHarderMisreads, 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()); assertTrue("Please run from the 'core' directory", testBase.exists());
return testBase.listFiles(IMAGE_NAME_FILTER); return testBase.listFiles(IMAGE_NAME_FILTER);
} }
protected Reader getReader() { protected final Reader getReader() {
return barcodeReader; return barcodeReader;
} }
@ -123,7 +123,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
testBlackBoxCountingResults(true); testBlackBoxCountingResults(true);
} }
public SummaryResults testBlackBoxCountingResults(boolean assertOnFailure) throws IOException { public final SummaryResults testBlackBoxCountingResults(boolean assertOnFailure) throws IOException {
assertFalse(testResults.isEmpty()); assertFalse(testResults.isEmpty());
File[] imageFiles = getImageFiles(); File[] imageFiles = getImageFiles();

View file

@ -42,7 +42,7 @@ import java.util.Map;
*/ */
public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxTestCase { public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxTestCase {
private static class TestResult { private static final class TestResult {
private final int falsePositivesAllowed; private final int falsePositivesAllowed;
private final float rotation; private final float rotation;

View file

@ -30,7 +30,7 @@ import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatReader; import com.google.zxing.MultiFormatReader;
import com.google.zxing.common.AbstractBlackBoxTestCase; import com.google.zxing.common.AbstractBlackBoxTestCase;
public class RSSExpandedBlackBox2TestCase extends AbstractBlackBoxTestCase { public final class RSSExpandedBlackBox2TestCase extends AbstractBlackBoxTestCase {
public RSSExpandedBlackBox2TestCase() { public RSSExpandedBlackBox2TestCase() {
super("test/data/blackbox/rssexpanded-2", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED); super("test/data/blackbox/rssexpanded-2", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED);

View file

@ -32,7 +32,7 @@ import org.junit.Test;
/** /**
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) * @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.."; private static final String header = "..X..";

View file

@ -31,7 +31,7 @@ import org.junit.Test;
/** /**
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) * @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"; private static final String header = "..X.X";

View file

@ -31,7 +31,7 @@ import org.junit.Test;
/** /**
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) * @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_310x_11 = "..XXX...";
private static final String header_320x_11 = "..XXX..X"; private static final String header_320x_11 = "..XXX..X";

View file

@ -31,7 +31,7 @@ import org.junit.Test;
/** /**
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) * @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 = "....."; private static final String header = ".....";

View file

@ -34,7 +34,7 @@ import org.junit.Test;
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
* @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@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 { private static void checkFields(String expected) throws NotFoundException {
String field = expected.replace("(", "").replace(")",""); String field = expected.replace("(", "").replace(")","");

View file

@ -24,7 +24,7 @@ import org.junit.Test;
* @author satorux@google.com (Satoru Takabayashi) - creator * @author satorux@google.com (Satoru Takabayashi) - creator
* @author dswitkin@google.com (Daniel Switkin) - ported from C++ * @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) { private static long getUnsignedInt(BitArray v, int index) {
long result = 0L; long result = 0L;