mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Spell checker fixes, narrowed scope / made less visible where possible. Little stuff
git-svn-id: https://zxing.googlecode.com/svn/trunk@1053 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
eef79f730b
commit
5b041daad0
|
@ -41,8 +41,8 @@ public final class PreferencesActivity extends PreferenceActivity
|
|||
|
||||
static final String KEY_HELP_VERSION_SHOWN = "preferences_help_version_shown";
|
||||
|
||||
CheckBoxPreference decode1D;
|
||||
CheckBoxPreference decodeQR;
|
||||
private CheckBoxPreference decode1D;
|
||||
private CheckBoxPreference decodeQR;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle icicle) {
|
||||
|
|
|
@ -38,7 +38,7 @@ public abstract class LuminanceSource {
|
|||
/**
|
||||
* Fetches one row of luminance data from the underlying platform's bitmap. Values range from
|
||||
* 0 (black) to 255 (white). Because Java does not have an unsigned byte type, callers will have
|
||||
* to bitwise and with 0xff for each value. It is preferrable for implementations of this method
|
||||
* to bitwise and with 0xff for each value. It is preferable for implementations of this method
|
||||
* to only fetch this row rather than the whole image, since no 2D Readers may be installed and
|
||||
* getMatrix() may never be called.
|
||||
*
|
||||
|
|
|
@ -46,7 +46,8 @@ public interface Reader {
|
|||
* hints, each possibly associated to some data, which may help the implementation decode.
|
||||
*
|
||||
* @param image image of barcode to decode
|
||||
* @param hints passed as a {@link java.util.Hashtable} from {@link com.google.zxing.DecodeHintType} to aribtrary data. The
|
||||
* @param hints passed as a {@link java.util.Hashtable} from {@link com.google.zxing.DecodeHintType}
|
||||
* to arbitrary data. The
|
||||
* meaning of the data depends upon the hint type. The implementation may or may not do
|
||||
* anything with these hints.
|
||||
* @return String which the barcode encodes
|
||||
|
|
|
@ -117,7 +117,7 @@ public class ResultPoint {
|
|||
/**
|
||||
* Returns the z component of the cross product between vectors BC and BA.
|
||||
*/
|
||||
public static float crossProductZ(ResultPoint pointA, ResultPoint pointB, ResultPoint pointC) {
|
||||
private static float crossProductZ(ResultPoint pointA, ResultPoint pointB, ResultPoint pointC) {
|
||||
float bX = pointB.x;
|
||||
float bY = pointB.y;
|
||||
return ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX));
|
||||
|
|
|
@ -19,7 +19,7 @@ package com.google.zxing.client.result;
|
|||
import com.google.zxing.Result;
|
||||
|
||||
/**
|
||||
* Parses a "geo:" URI result, which specifices a location on the surface of
|
||||
* Parses a "geo:" URI result, which specifies a location on the surface of
|
||||
* the Earth as well as an optional altitude above the surface. See
|
||||
* <a href="http://tools.ietf.org/html/draft-mayrhofer-geo-uri-00">
|
||||
* http://tools.ietf.org/html/draft-mayrhofer-geo-uri-00</a>.
|
||||
|
|
|
@ -21,7 +21,7 @@ import com.google.zxing.Result;
|
|||
import com.google.zxing.oned.UPCEReader;
|
||||
|
||||
/**
|
||||
* Parses strings of digits that repesent a UPC code.
|
||||
* Parses strings of digits that represent a UPC code.
|
||||
*
|
||||
* @author dswitkin@google.com (Daniel Switkin)
|
||||
*/
|
||||
|
|
|
@ -117,7 +117,7 @@ public abstract class ResultParser {
|
|||
return escaped;
|
||||
}
|
||||
|
||||
static String urlDecode(String escaped) {
|
||||
private static String urlDecode(String escaped) {
|
||||
|
||||
// No we can't use java.net.URLDecoder here. JavaME doesn't have it.
|
||||
if (escaped == null) {
|
||||
|
|
|
@ -75,7 +75,7 @@ public abstract class GridSampler {
|
|||
* <p>These 16 parameters define the transformation needed to sample the image.</p>
|
||||
*
|
||||
* @param image image to sample
|
||||
* @param dimension width/height of {@link BitMatrix} to sample from iamge
|
||||
* @param dimension width/height of {@link BitMatrix} to sample from image
|
||||
* @return {@link BitMatrix} representing a grid of points sampled from the image within a region
|
||||
* defined by the "from" parameters
|
||||
* @throws ReaderException if image can't be sampled, for example, if the transformation defined
|
||||
|
|
|
@ -77,7 +77,7 @@ public final class LocalBlockBinarizer extends Binarizer {
|
|||
|
||||
// For each 8x8 block in the image, calculate the average black point using a 5x5 grid
|
||||
// of the blocks around it. Also handles the corner cases, but will ignore up to 7 pixels
|
||||
// on the right edge and 7 pixels at the bottom of the image if the overall dimsions are not
|
||||
// on the right edge and 7 pixels at the bottom of the image if the overall dimensions are not
|
||||
// multiples of eight. In practice, leaving those pixels white does not seem to be a problem.
|
||||
private static void calculateThresholdForBlock(byte[] luminances, int subWidth, int subHeight,
|
||||
int stride, int[][] blackPoints, BitMatrix matrix) {
|
||||
|
|
|
@ -149,7 +149,7 @@ public final class MonochromeRectangleDetector {
|
|||
* be part of a Data Matrix barcode.
|
||||
*
|
||||
* @param fixedDimension if scanning horizontally, this is the row (the fixed vertical location)
|
||||
* where we are scanning. If scanning vertically it's the colummn, the fixed horizontal location
|
||||
* where we are scanning. If scanning vertically it's the column, the fixed horizontal location
|
||||
* @param maxWhiteRun largest run of white pixels that can still be considered part of the
|
||||
* barcode region
|
||||
* @param minDim minimum pixel location, horizontally or vertically, to consider
|
||||
|
|
|
@ -170,7 +170,7 @@ final class BitMatrixParser {
|
|||
}
|
||||
|
||||
/**
|
||||
* <p>Reads the 8 bits of the standard utah shaped pattern.</p>
|
||||
* <p>Reads the 8 bits of the standard Utah-shaped pattern.</p>
|
||||
*
|
||||
* <p>See ISO 16022:2006, 5.8.1 Figure 6</p>
|
||||
*
|
||||
|
|
|
@ -160,7 +160,7 @@ public abstract class AbstractUPCEANReader extends AbstractOneDReader implements
|
|||
* @return true iff string of digits passes the UPC/EAN checksum algorithm
|
||||
* @throws ReaderException if the string does not contain only digits
|
||||
*/
|
||||
public static boolean checkStandardUPCEANChecksum(String s) throws ReaderException {
|
||||
private static boolean checkStandardUPCEANChecksum(String s) throws ReaderException {
|
||||
int length = s.length();
|
||||
if (length == 0) {
|
||||
return false;
|
||||
|
|
|
@ -51,7 +51,7 @@ public abstract class AbstractUPCEANWriter implements UPCEANWriter {
|
|||
}
|
||||
|
||||
/** @return a byte array of horizontal pixels (0 = white, 1 = black) */
|
||||
protected static ByteMatrix renderResult(byte[] code, int width, int height) {
|
||||
private static ByteMatrix renderResult(byte[] code, int width, int height) {
|
||||
int inputWidth = code.length;
|
||||
// Add quiet zone on both sides
|
||||
int fullWidth = inputWidth + (AbstractUPCEANReader.START_END_PATTERN.length << 1);
|
||||
|
|
|
@ -123,7 +123,7 @@ public final class ITFReader extends AbstractOneDReader {
|
|||
* @param resultString {@link StringBuffer} to append decoded chars to
|
||||
* @throws ReaderException if decoding could not complete successfully
|
||||
*/
|
||||
static void decodeMiddle(BitArray row, int payloadStart, int payloadEnd,
|
||||
private static void decodeMiddle(BitArray row, int payloadStart, int payloadEnd,
|
||||
StringBuffer resultString) throws ReaderException {
|
||||
|
||||
// Digits are interleaved in pairs - 5 black lines for one digit, and the
|
||||
|
@ -256,8 +256,8 @@ public final class ITFReader extends AbstractOneDReader {
|
|||
// ref: http://www.barcode-1.net/i25code.html
|
||||
validateQuietZone(row, endPattern[0]);
|
||||
|
||||
// Now recalc the indicies of where the 'endblock' starts & stops to
|
||||
// accomodate
|
||||
// Now recalculate the indices of where the 'endblock' starts & stops to
|
||||
// accommodate
|
||||
// the reversed nature of the search
|
||||
int temp = endPattern[0];
|
||||
endPattern[0] = row.getSize() - endPattern[1];
|
||||
|
@ -265,7 +265,7 @@ public final class ITFReader extends AbstractOneDReader {
|
|||
|
||||
return endPattern;
|
||||
} finally {
|
||||
// Put the row back the righ way.
|
||||
// Put the row back the right way.
|
||||
row.reverse();
|
||||
}
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ public final class ITFReader extends AbstractOneDReader {
|
|||
* ints
|
||||
* @throws ReaderException if pattern is not found
|
||||
*/
|
||||
static int[] findGuardPattern(BitArray row, int rowOffset, int[] pattern) throws ReaderException {
|
||||
private static int[] findGuardPattern(BitArray row, int rowOffset, int[] pattern) throws ReaderException {
|
||||
|
||||
// TODO: This is very similar to implementation in AbstractUPCEANReader. Consider if they can be
|
||||
// merged to a single method.
|
||||
|
|
|
@ -109,7 +109,7 @@ final class DecodedBitStreamParser {
|
|||
break;
|
||||
}
|
||||
default: {
|
||||
// Default to text compaction. During testing numberous barcodes
|
||||
// Default to text compaction. During testing numerous barcodes
|
||||
// appeared to be missing the starting mode. In these cases defaulting
|
||||
// to text compaction seems to work.
|
||||
codeIndex--;
|
||||
|
@ -143,10 +143,9 @@ final class DecodedBitStreamParser {
|
|||
int[] byteCompactionData = new int[codewords[0] << 1];
|
||||
|
||||
int index = 0;
|
||||
int code = 0;
|
||||
boolean end = false;
|
||||
while ((codeIndex < codewords[0]) && !end) {
|
||||
code = codewords[codeIndex++];
|
||||
int code = codewords[codeIndex++];
|
||||
if (code < TEXT_COMPACTION_MODE_LATCH) {
|
||||
textCompactionData[index] = code / 30;
|
||||
textCompactionData[index + 1] = code % 30;
|
||||
|
@ -341,10 +340,9 @@ final class DecodedBitStreamParser {
|
|||
long value = 0;
|
||||
char[] decodedData = new char[6];
|
||||
int[] byteCompactedCodewords = new int[6];
|
||||
int code = 0;
|
||||
boolean end = false;
|
||||
while ((codeIndex < codewords[0]) && !end) {
|
||||
code = codewords[codeIndex++];
|
||||
int code = codewords[codeIndex++];
|
||||
if (code < TEXT_COMPACTION_MODE_LATCH) {
|
||||
byteCompactedCodewords[count] = code;
|
||||
count++;
|
||||
|
@ -386,10 +384,9 @@ final class DecodedBitStreamParser {
|
|||
// is an integer multiple of 6
|
||||
int count = 0;
|
||||
long value = 0;
|
||||
int code = 0;
|
||||
boolean end = false;
|
||||
while ((codeIndex < codewords[0]) && !end) {
|
||||
code = codewords[codeIndex++];
|
||||
int code = codewords[codeIndex++];
|
||||
if (code < TEXT_COMPACTION_MODE_LATCH) {
|
||||
count += 1;
|
||||
// Base 900
|
||||
|
@ -515,9 +512,8 @@ final class DecodedBitStreamParser {
|
|||
*/
|
||||
private static String decodeBase900toBase10(int[] codewords, int count) {
|
||||
StringBuffer accum = null;
|
||||
StringBuffer value = null;
|
||||
for (int i = 0; i < count; i++) {
|
||||
value = multiply(EXP900[count - i - 1], codewords[i]);
|
||||
StringBuffer value = multiply(EXP900[count - i - 1], codewords[i]);
|
||||
if (accum == null) {
|
||||
// First time in accum=0
|
||||
accum = value;
|
||||
|
@ -526,7 +522,7 @@ final class DecodedBitStreamParser {
|
|||
}
|
||||
}
|
||||
String result = null;
|
||||
// Remove leading '1' which was inserted to preserce
|
||||
// Remove leading '1' which was inserted to preserve
|
||||
// leading zeros
|
||||
for (int i = 0; i < accum.length(); i++) {
|
||||
if (accum.charAt(i) == '1') {
|
||||
|
|
|
@ -93,7 +93,7 @@ public final class Decoder {
|
|||
* @return an index to the first data codeword.
|
||||
* @throws ReaderException
|
||||
*/
|
||||
private static int verifyCodewordCount(int[] codewords, int numECCodewords) throws ReaderException {
|
||||
private static void verifyCodewordCount(int[] codewords, int numECCodewords) throws ReaderException {
|
||||
if (codewords.length < 4) {
|
||||
// Codeword array size should be at least 4 allowing for
|
||||
// Count CW, At least one Data CW, Error Correction CW, Error Correction CW
|
||||
|
@ -114,7 +114,6 @@ public final class Decoder {
|
|||
throw ReaderException.getInstance();
|
||||
}
|
||||
}
|
||||
return 1; // Index to first data codeword
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -128,7 +128,7 @@ 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) throws ReaderException {
|
||||
private static ResultPoint[] findVertices(BitMatrix matrix) {
|
||||
int height = matrix.getHeight();
|
||||
int width = matrix.getWidth();
|
||||
int halfWidth = width >> 1;
|
||||
|
@ -136,10 +136,9 @@ public final class Detector {
|
|||
ResultPoint[] result = new ResultPoint[8];
|
||||
boolean found = false;
|
||||
|
||||
int[] loc = null;
|
||||
// Top Left
|
||||
for (int i = 0; i < height; i++) {
|
||||
loc = findGuardPattern(matrix, 0, i, halfWidth, false, START_PATTERN);
|
||||
int[] loc = findGuardPattern(matrix, 0, i, halfWidth, false, START_PATTERN);
|
||||
if (loc != null) {
|
||||
result[0] = new ResultPoint(loc[0], i);
|
||||
result[4] = new ResultPoint(loc[1], i);
|
||||
|
@ -151,7 +150,7 @@ public final class Detector {
|
|||
if (found) { // Found the Top Left vertex
|
||||
found = false;
|
||||
for (int i = height - 1; i > 0; i--) {
|
||||
loc = findGuardPattern(matrix, 0, i, halfWidth, false, START_PATTERN);
|
||||
int[] loc = findGuardPattern(matrix, 0, i, halfWidth, false, START_PATTERN);
|
||||
if (loc != null) {
|
||||
result[1] = new ResultPoint(loc[0], i);
|
||||
result[5] = new ResultPoint(loc[1], i);
|
||||
|
@ -164,7 +163,7 @@ public final class Detector {
|
|||
if (found) { // Found the Bottom Left vertex
|
||||
found = false;
|
||||
for (int i = 0; i < height; i++) {
|
||||
loc = findGuardPattern(matrix, halfWidth, i, halfWidth, false, STOP_PATTERN);
|
||||
int[] loc = findGuardPattern(matrix, halfWidth, i, halfWidth, false, STOP_PATTERN);
|
||||
if (loc != null) {
|
||||
result[2] = new ResultPoint(loc[1], i);
|
||||
result[6] = new ResultPoint(loc[0], i);
|
||||
|
@ -177,7 +176,7 @@ public final class Detector {
|
|||
if (found) { // Found the Top right vertex
|
||||
found = false;
|
||||
for (int i = height - 1; i > 0; i--) {
|
||||
loc = findGuardPattern(matrix, halfWidth, i, halfWidth, false, STOP_PATTERN);
|
||||
int[] loc = findGuardPattern(matrix, halfWidth, i, halfWidth, false, STOP_PATTERN);
|
||||
if (loc != null) {
|
||||
result[3] = new ResultPoint(loc[1], i);
|
||||
result[7] = new ResultPoint(loc[0], i);
|
||||
|
@ -208,7 +207,7 @@ public final class Detector {
|
|||
* vertices[6] x, y top right codeword area
|
||||
* vertices[7] x, y bottom right codeword area
|
||||
*/
|
||||
private static ResultPoint[] findVertices180(BitMatrix matrix) throws ReaderException {
|
||||
private static ResultPoint[] findVertices180(BitMatrix matrix) {
|
||||
int height = matrix.getHeight();
|
||||
int width = matrix.getWidth();
|
||||
int halfWidth = width >> 1;
|
||||
|
@ -216,10 +215,9 @@ public final class Detector {
|
|||
ResultPoint[] result = new ResultPoint[8];
|
||||
boolean found = false;
|
||||
|
||||
int[] loc = null;
|
||||
// Top Left
|
||||
for (int i = height - 1; i > 0; i--) {
|
||||
loc = findGuardPattern(matrix, halfWidth, i, halfWidth, true, START_PATTERN_REVERSE);
|
||||
int[] loc = findGuardPattern(matrix, halfWidth, i, halfWidth, true, START_PATTERN_REVERSE);
|
||||
if (loc != null) {
|
||||
result[0] = new ResultPoint(loc[1], i);
|
||||
result[4] = new ResultPoint(loc[0], i);
|
||||
|
@ -231,7 +229,7 @@ public final class Detector {
|
|||
if (found) { // Found the Top Left vertex
|
||||
found = false;
|
||||
for (int i = 0; i < height; i++) {
|
||||
loc = findGuardPattern(matrix, halfWidth, i, halfWidth, true, START_PATTERN_REVERSE);
|
||||
int[] loc = findGuardPattern(matrix, halfWidth, i, halfWidth, true, START_PATTERN_REVERSE);
|
||||
if (loc != null) {
|
||||
result[1] = new ResultPoint(loc[1], i);
|
||||
result[5] = new ResultPoint(loc[0], i);
|
||||
|
@ -244,7 +242,7 @@ public final class Detector {
|
|||
if (found) { // Found the Bottom Left vertex
|
||||
found = false;
|
||||
for (int i = height - 1; i > 0; i--) {
|
||||
loc = findGuardPattern(matrix, 0, i, halfWidth, false, STOP_PATTERN_REVERSE);
|
||||
int[] loc = findGuardPattern(matrix, 0, i, halfWidth, false, STOP_PATTERN_REVERSE);
|
||||
if (loc != null) {
|
||||
result[2] = new ResultPoint(loc[0], i);
|
||||
result[6] = new ResultPoint(loc[1], i);
|
||||
|
@ -257,7 +255,7 @@ public final class Detector {
|
|||
if (found) { // Found the Top Right vertex
|
||||
found = false;
|
||||
for (int i = 0; i < height; i++) {
|
||||
loc = findGuardPattern(matrix, 0, i, halfWidth, false, STOP_PATTERN_REVERSE);
|
||||
int[] loc = findGuardPattern(matrix, 0, i, halfWidth, false, STOP_PATTERN_REVERSE);
|
||||
if (loc != null) {
|
||||
result[3] = new ResultPoint(loc[0], i);
|
||||
result[7] = new ResultPoint(loc[1], i);
|
||||
|
@ -414,7 +412,7 @@ public final class Detector {
|
|||
* being searched for as a pattern
|
||||
* @return start/end horizontal offset of guard pattern, as an array of two ints.
|
||||
*/
|
||||
static int[] findGuardPattern(BitMatrix matrix, int column, int row, int width,
|
||||
private static int[] findGuardPattern(BitMatrix matrix, int column, int row, int width,
|
||||
boolean whiteFirst, int[] pattern) {
|
||||
int patternLength = pattern.length;
|
||||
// TODO: Find a way to cache this array, as this method is called hundreds of times
|
||||
|
@ -465,7 +463,7 @@ public final class Detector {
|
|||
* variance between counters and patterns equals the pattern length,
|
||||
* higher values mean even more variance
|
||||
*/
|
||||
public static int patternMatchVariance(int[] counters, int[] pattern, int maxIndividualVariance) {
|
||||
private static int patternMatchVariance(int[] counters, int[] pattern, int maxIndividualVariance) {
|
||||
int numCounters = counters.length;
|
||||
int total = 0;
|
||||
int patternLength = 0;
|
||||
|
|
|
@ -83,7 +83,7 @@ public final class QRCodeWriter implements Writer {
|
|||
int outputHeight = Math.max(height, qrHeight);
|
||||
|
||||
int multiple = Math.min(outputWidth / qrWidth, outputHeight / qrHeight);
|
||||
// Padding includes both the quiet zone and the extra white pixels to accomodate the requested
|
||||
// Padding includes both the quiet zone and the extra white pixels to accommodate the requested
|
||||
// dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.
|
||||
// If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will
|
||||
// handle all the padding from 100x100 (the actual QR) up to 200x160.
|
||||
|
|
|
@ -319,7 +319,7 @@ public class Detector {
|
|||
* @param overallEstModuleSize estimated module size so far
|
||||
* @param estAlignmentX x coordinate of center of area probably containing alignment pattern
|
||||
* @param estAlignmentY y coordinate of above
|
||||
* @param allowanceFactor number of pixels in all directons to search from the center
|
||||
* @param allowanceFactor number of pixels in all directions to search from the center
|
||||
* @return {@link AlignmentPattern} if found, or null otherwise
|
||||
* @throws ReaderException if an unexpected error occurs during detection
|
||||
*/
|
||||
|
|
|
@ -558,7 +558,7 @@ public final class Encoder {
|
|||
}
|
||||
}
|
||||
|
||||
static void appendECI(CharacterSetECI eci, BitVector bits) {
|
||||
private static void appendECI(CharacterSetECI eci, BitVector bits) {
|
||||
bits.appendBits(Mode.ECI.getBits(), 4);
|
||||
// This is correct for values up to 127, which is all we need now.
|
||||
bits.appendBits(eci.getValue(), 8);
|
||||
|
|
Loading…
Reference in a new issue