From c9d3eae171f32180b70d1cbbe1b662f0bc06f223 Mon Sep 17 00:00:00 2001 From: dswitkin Date: Thu, 21 May 2009 15:36:51 +0000 Subject: [PATCH] Cleaned up some code to fit in 100 columns. git-svn-id: https://zxing.googlecode.com/svn/trunk@942 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- .../com/google/zxing/MultiFormatReader.java | 22 +++++++-------- core/src/com/google/zxing/Result.java | 7 ++--- .../common/BaseMonochromeBitmapSource.java | 3 ++- .../zxing/common/BlackPointEstimator.java | 3 +-- .../google/zxing/common/CharacterSetECI.java | 6 +++-- .../zxing/common/DefaultGridSampler.java | 4 +-- core/src/com/google/zxing/common/ECI.java | 4 +-- .../com/google/zxing/common/GridSampler.java | 27 ++++++++++--------- .../zxing/common/PerspectiveTransform.java | 6 ++--- 9 files changed, 43 insertions(+), 39 deletions(-) diff --git a/core/src/com/google/zxing/MultiFormatReader.java b/core/src/com/google/zxing/MultiFormatReader.java index 2677c3aa8..872195f31 100644 --- a/core/src/com/google/zxing/MultiFormatReader.java +++ b/core/src/com/google/zxing/MultiFormatReader.java @@ -90,25 +90,25 @@ public final class MultiFormatReader implements Reader { this.hints = hints; boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); - Vector possibleFormats = hints == null ? null : (Vector) hints.get(DecodeHintType.POSSIBLE_FORMATS); + Vector formats = hints == null ? null : (Vector) hints.get(DecodeHintType.POSSIBLE_FORMATS); readers = new Vector(); - if (possibleFormats != null) { + if (formats != null) { boolean addOneDReader = - possibleFormats.contains(BarcodeFormat.UPC_A) || - possibleFormats.contains(BarcodeFormat.UPC_E) || - possibleFormats.contains(BarcodeFormat.EAN_13) || - possibleFormats.contains(BarcodeFormat.EAN_8) || - possibleFormats.contains(BarcodeFormat.CODE_39) || - possibleFormats.contains(BarcodeFormat.CODE_128) || - possibleFormats.contains(BarcodeFormat.ITF); + formats.contains(BarcodeFormat.UPC_A) || + formats.contains(BarcodeFormat.UPC_E) || + formats.contains(BarcodeFormat.EAN_13) || + formats.contains(BarcodeFormat.EAN_8) || + formats.contains(BarcodeFormat.CODE_39) || + formats.contains(BarcodeFormat.CODE_128) || + formats.contains(BarcodeFormat.ITF); // Put 1D readers upfront in "normal" mode if (addOneDReader && !tryHarder) { readers.addElement(new MultiFormatOneDReader(hints)); } - if (possibleFormats.contains(BarcodeFormat.QR_CODE)) { + if (formats.contains(BarcodeFormat.QR_CODE)) { readers.addElement(new QRCodeReader()); } - if (possibleFormats.contains(BarcodeFormat.DATAMATRIX)) { + if (formats.contains(BarcodeFormat.DATAMATRIX)) { readers.addElement(new DataMatrixReader()); } // At end in "try harder" mode diff --git a/core/src/com/google/zxing/Result.java b/core/src/com/google/zxing/Result.java index 8a798f078..01dd5811f 100644 --- a/core/src/com/google/zxing/Result.java +++ b/core/src/com/google/zxing/Result.java @@ -69,15 +69,16 @@ public final class Result { } /** - * @return {@link BarcodeFormat} representing the format of the barcode that was recognized and decoded + * @return {@link BarcodeFormat} representing the format of the barcode that was decoded */ public BarcodeFormat getBarcodeFormat() { return format; } /** - * @return {@link Hashtable} mapping {@link ResultMetadataType} keys to values. May be null. - * This contains optional metadata about what was detected about the barcode, like orientation. + * @return {@link Hashtable} mapping {@link ResultMetadataType} keys to values. May be + * null. This contains optional metadata about what was detected about the barcode, + * like orientation. */ public Hashtable getResultMetadata() { return resultMetadata; diff --git a/core/src/com/google/zxing/common/BaseMonochromeBitmapSource.java b/core/src/com/google/zxing/common/BaseMonochromeBitmapSource.java index 35c3f2642..0120391be 100644 --- a/core/src/com/google/zxing/common/BaseMonochromeBitmapSource.java +++ b/core/src/com/google/zxing/common/BaseMonochromeBitmapSource.java @@ -110,7 +110,8 @@ public abstract class BaseMonochromeBitmapSource implements MonochromeBitmapSour return column; } - public void estimateBlackPoint(BlackPointEstimationMethod method, int argument) throws ReaderException { + public void estimateBlackPoint(BlackPointEstimationMethod method, int argument) + throws ReaderException { if (!method.equals(lastMethod) || argument != lastArgument) { int width = getWidth(); int height = getHeight(); diff --git a/core/src/com/google/zxing/common/BlackPointEstimator.java b/core/src/com/google/zxing/common/BlackPointEstimator.java index 2b683c239..9f218dd02 100644 --- a/core/src/com/google/zxing/common/BlackPointEstimator.java +++ b/core/src/com/google/zxing/common/BlackPointEstimator.java @@ -42,10 +42,9 @@ public final class BlackPointEstimator { * @param histogram an array of counts of luminance values * @return index within argument of bucket corresponding to brightest values which should be * considered "black" - * @throws ReaderException if "black" and "white" appear to be very close in luminance in the image + * @throws ReaderException if "black" and "white" appear to be very close in luminance */ public static int estimate(int[] histogram) throws ReaderException{ - int numBuckets = histogram.length; int maxBucketCount = 0; // Find tallest peak in histogram diff --git a/core/src/com/google/zxing/common/CharacterSetECI.java b/core/src/com/google/zxing/common/CharacterSetECI.java index a0d1f0f79..dbb9144db 100644 --- a/core/src/com/google/zxing/common/CharacterSetECI.java +++ b/core/src/com/google/zxing/common/CharacterSetECI.java @@ -81,7 +81,8 @@ public final class CharacterSetECI extends ECI { /** * @param value character set ECI value - * @return {@link CharacterSetECI} representing ECI of given value, or null if it is legal but unsupported + * @return {@link CharacterSetECI} representing ECI of given value, or null if it is legal but + * unsupported * @throws IllegalArgumentException if ECI value is invalid */ public static CharacterSetECI getCharacterSetECIByValue(int value) { @@ -96,7 +97,8 @@ public final class CharacterSetECI extends ECI { /** * @param name character set ECI encoding name - * @return {@link CharacterSetECI} representing ECI for character encoding, or null if it is legal but unsupported + * @return {@link CharacterSetECI} representing ECI for character encoding, or null if it is legal + * but unsupported */ public static CharacterSetECI getCharacterSetECIByName(String name) { if (NAME_TO_ECI == null) { diff --git a/core/src/com/google/zxing/common/DefaultGridSampler.java b/core/src/com/google/zxing/common/DefaultGridSampler.java index 9932f6325..d0bcd95cd 100644 --- a/core/src/com/google/zxing/common/DefaultGridSampler.java +++ b/core/src/com/google/zxing/common/DefaultGridSampler.java @@ -64,8 +64,8 @@ public final class DefaultGridSampler extends GridSampler { // transform gets "twisted" such that it maps a straight line of points to a set of points // whose endpoints are in bounds, but others are not. There is probably some mathematical // way to detect this about the transformation that I don't know yet. - // This results in an ugly runtime exception despite our clever checks above -- can't have that. - // We could check each point's coordinates but that feels duplicative. We settle for + // This results in an ugly runtime exception despite our clever checks above -- can't have + // that. We could check each point's coordinates but that feels duplicative. We settle for // catching and wrapping ArrayIndexOutOfBoundsException. throw ReaderException.getInstance(); } diff --git a/core/src/com/google/zxing/common/ECI.java b/core/src/com/google/zxing/common/ECI.java index dbb9556b5..9d725dbc3 100644 --- a/core/src/com/google/zxing/common/ECI.java +++ b/core/src/com/google/zxing/common/ECI.java @@ -17,8 +17,8 @@ package com.google.zxing.common; /** - * Superclass of classes encapsulating types ECIs, according to "Extended Channel Interpretations" 5.3 - * of ISO 18004. + * Superclass of classes encapsulating types ECIs, according to "Extended Channel Interpretations" + * 5.3 of ISO 18004. * * @author Sean Owen */ diff --git a/core/src/com/google/zxing/common/GridSampler.java b/core/src/com/google/zxing/common/GridSampler.java index 2d0b81d4d..4cf27763c 100644 --- a/core/src/com/google/zxing/common/GridSampler.java +++ b/core/src/com/google/zxing/common/GridSampler.java @@ -65,27 +65,27 @@ public abstract class GridSampler { } /** - *

Samples an image for a square matrix of bits of the given dimension. This is used to extract the - * black/white modules of a 2D barcode like a QR Code found in an image. Because this barcode may be - * rotated or perspective-distorted, the caller supplies four points in the source image that define - * known points in the barcode, so that the image may be sampled appropriately.

+ *

Samples an image for a square matrix of bits of the given dimension. This is used to extract + * the black/white modules of a 2D barcode like a QR Code found in an image. Because this barcode + * may be rotated or perspective-distorted, the caller supplies four points in the source image + * that define known points in the barcode, so that the image may be sampled appropriately.

* *

The last eight "from" parameters are four X/Y coordinate pairs of locations of points in * the image that define some significant points in the image to be sample. For example, * these may be the location of finder pattern in a QR Code.

* *

The first eight "to" parameters are four X/Y coordinate pairs measured in the destination - * {@link BitMatrix}, from the top left, where the known points in the image given by the "from" parameters - * map to.

+ * {@link BitMatrix}, from the top left, where the known points in the image given by the "from" + * parameters map to.

* *

These 16 parameters define the transformation needed to sample the image.

* * @param image image to sample * @param dimension width/height of {@link BitMatrix} to sample from iamge * @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 by - * the given points is invalid or results in sampling outside the image boundaries + * defined by the "from" parameters + * @throws ReaderException if image can't be sampled, for example, if the transformation defined + * by the given points is invalid or results in sampling outside the image boundaries */ public abstract BitMatrix sampleGrid(MonochromeBitmapSource image, int dimension, @@ -102,9 +102,9 @@ public abstract class GridSampler { *

Checks a set of points that have been transformed to sample points on an image against * the image's dimensions to see if the point are even within the image.

* - *

This method will actually "nudge" the endpoints back onto the image if they are found to be barely - * (less than 1 pixel) off the image. This accounts for imperfect detection of finder patterns in an image - * where the QR Code runs all the way to the image border.

+ *

This method will actually "nudge" the endpoints back onto the image if they are found to be + * barely (less than 1 pixel) off the image. This accounts for imperfect detection of finder + * patterns in an image where the QR Code runs all the way to the image border.

* *

For efficiency, the method will check points from either end of the line until one is found * to be within the image. Because the set of points are assumed to be linear, this is valid.

@@ -113,7 +113,8 @@ public abstract class GridSampler { * @param points actual points in x1,y1,...,xn,yn form * @throws ReaderException if an endpoint is lies outside the image boundaries */ - protected static void checkAndNudgePoints(MonochromeBitmapSource image, float[] points) throws ReaderException { + protected static void checkAndNudgePoints(MonochromeBitmapSource image, float[] points) + throws ReaderException { int width = image.getWidth(); int height = image.getHeight(); // Check and nudge points from start until we see some that are OK: diff --git a/core/src/com/google/zxing/common/PerspectiveTransform.java b/core/src/com/google/zxing/common/PerspectiveTransform.java index 5ff6f09dd..b79e4adcf 100644 --- a/core/src/com/google/zxing/common/PerspectiveTransform.java +++ b/core/src/com/google/zxing/common/PerspectiveTransform.java @@ -17,9 +17,9 @@ package com.google.zxing.common; /** - *

This class implements a perspective transform in two dimensions. Given four source and four destination - * points, it will compute the transformation implied between them. The code is based directly upon section - * 3.4.2 of George Wolberg's "Digital Image Warping"; see pages 54-56.

+ *

This class implements a perspective transform in two dimensions. Given four source and four + * destination points, it will compute the transformation implied between them. The code is based + * directly upon section 3.4.2 of George Wolberg's "Digital Image Warping"; see pages 54-56.

* * @author Sean Owen */