Replace tabs with spaces ( part of accepting another big patch); fix one failing test due to typo

git-svn-id: https://zxing.googlecode.com/svn/trunk@1326 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2010-05-02 06:49:18 +00:00
parent 1109e2aecf
commit 816d6b81e0
21 changed files with 303 additions and 325 deletions

View file

@ -137,7 +137,7 @@ public final class IntentIntegrator {
CharSequence stringButtonYes,
CharSequence stringButtonNo) {
return initiateScan(activity,
return initiateScan(activity,
stringTitle,
stringMessage,
stringButtonYes,
@ -171,8 +171,8 @@ public final class IntentIntegrator {
// check which types of codes to scan for
if (stringDesiredBarcodeFormats != null) {
// set the desired barcode types
intentScan.putExtra("SCAN_FORMATS", stringDesiredBarcodeFormats);
// set the desired barcode types
intentScan.putExtra("SCAN_FORMATS", stringDesiredBarcodeFormats);
}
try {

View file

@ -588,8 +588,8 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
resultHandler.getDisplayContents().toString() + "&source=zxing";
handler.sendMessageDelayed(message, INTENT_RESULT_DURATION);
} else if (source == Source.ZXING_LINK) {
// Replace each occurrence of RETURN_CODE_PLACEHOLDER in the returnUrlTemplate
// with the scanned code. This allows both queries and REST-style URLs to work.
// Replace each occurrence of RETURN_CODE_PLACEHOLDER in the returnUrlTemplate
// with the scanned code. This allows both queries and REST-style URLs to work.
Message message = Message.obtain(handler, R.id.launch_product_query);
message.obj = returnUrlTemplate.replace(RETURN_CODE_PLACEHOLDER, resultHandler.getDisplayContents().toString());
handler.sendMessageDelayed(message, INTENT_RESULT_DURATION);

View file

@ -199,7 +199,7 @@ public final class SearchBookContentsActivity extends Activity {
for (int x = 0; x < count; x++) {
items.add(parseResult(results.getJSONObject(x)));
}
resultListView.setOnItemClickListener(new BrowseBookListener(this, items));
resultListView.setOnItemClickListener(new BrowseBookListener(this, items));
resultListView.setAdapter(new SearchBookContentsAdapter(this, items));
} else {
String searchable = json.optString("searchable");
@ -243,7 +243,7 @@ public final class SearchBookContentsActivity extends Activity {
return new SearchBookContentsResult(pageId, pageNumber, snippet, valid);
} catch (JSONException e) {
// Never seen in the wild, just being complete.
return new SearchBookContentsResult(getString(R.string.msg_sbc_no_page_returned), "", "", false);
return new SearchBookContentsResult(getString(R.string.msg_sbc_no_page_returned), "", "", false);
}
}
@ -267,7 +267,7 @@ public final class SearchBookContentsActivity extends Activity {
// website, we don't use LocaleManager to change the TLD.
URI uri;
if (isbn.startsWith("http://google.com/books?id=")) {
int equals = isbn.indexOf('=');
int equals = isbn.indexOf('=');
String volumeId = isbn.substring(equals + 1);
uri = new URI("http", null, "www.google.com", -1, "/books", "id=" + volumeId +
"&jscmd=SearchWithinVolume2&q=" + query, null);

View file

@ -30,8 +30,10 @@ final class SearchBookContentsResult {
private final String snippet;
private final boolean validSnippet;
SearchBookContentsResult(String pageId, String pageNumber, String snippet,
boolean validSnippet) {
SearchBookContentsResult(String pageId,
String pageNumber,
String snippet,
boolean validSnippet) {
this.pageId = pageId;
this.pageNumber = pageNumber;
this.snippet = snippet;

View file

@ -65,7 +65,7 @@ public final class URIResultHandler extends ResultHandler {
shareBySMS(uri);
break;
case 3:
searchBookContents(uri);
searchBookContents(uri);
break;
}
}

View file

@ -47,7 +47,7 @@ final class DecodedBitStreamParser {
private static final char[] C40_SHIFT2_SET_CHARS = {
'!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.',
'/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_'
};
};
/**
* See ISO 16022:2006, Annex C Table C.2
@ -122,54 +122,54 @@ final class DecodedBitStreamParser {
do {
int oneByte = bits.readBits(8);
if (oneByte == 0) {
throw FormatException.getFormatInstance();
} else if (oneByte <= 128) { // ASCII data (ASCII value + 1)
oneByte = upperShift ? (oneByte + 128) : oneByte;
upperShift = false;
result.append((char) (oneByte - 1));
return ASCII_ENCODE;
} else if (oneByte == 129) { // Pad
return PAD_ENCODE;
} else if (oneByte <= 229) { // 2-digit data 00-99 (Numeric Value + 130)
int value = oneByte - 130;
if (value < 10) { // padd with '0' for single digit values
result.append('0');
}
result.append(value);
} else if (oneByte == 230) { // Latch to C40 encodation
return C40_ENCODE;
} else if (oneByte == 231) { // Latch to Base 256 encodation
return BASE256_ENCODE;
} else if (oneByte == 232) { // FNC1
//throw ReaderException.getInstance();
throw FormatException.getFormatInstance();
} else if (oneByte <= 128) { // ASCII data (ASCII value + 1)
oneByte = upperShift ? (oneByte + 128) : oneByte;
upperShift = false;
result.append((char) (oneByte - 1));
return ASCII_ENCODE;
} else if (oneByte == 129) { // Pad
return PAD_ENCODE;
} else if (oneByte <= 229) { // 2-digit data 00-99 (Numeric Value + 130)
int value = oneByte - 130;
if (value < 10) { // padd with '0' for single digit values
result.append('0');
}
result.append(value);
} else if (oneByte == 230) { // Latch to C40 encodation
return C40_ENCODE;
} else if (oneByte == 231) { // Latch to Base 256 encodation
return BASE256_ENCODE;
} else if (oneByte == 232) { // FNC1
//throw ReaderException.getInstance();
// Ignore this symbol for now
} else if (oneByte == 233) { // Structured Append
//throw ReaderException.getInstance();
} else if (oneByte == 233) { // Structured Append
//throw ReaderException.getInstance();
// Ignore this symbol for now
} else if (oneByte == 234) { // Reader Programming
//throw ReaderException.getInstance();
} else if (oneByte == 234) { // Reader Programming
//throw ReaderException.getInstance();
// Ignore this symbol for now
} else if (oneByte == 235) { // Upper Shift (shift to Extended ASCII)
upperShift = true;
} else if (oneByte == 236) { // 05 Macro
} else if (oneByte == 235) { // Upper Shift (shift to Extended ASCII)
upperShift = true;
} else if (oneByte == 236) { // 05 Macro
result.append("[)>\u001E05\u001D");
resultTrailer.insert(0, "\u001E\u0004");
} else if (oneByte == 237) { // 06 Macro
result.append("[)>\u001E06\u001D");
result.append("[)>\u001E06\u001D");
resultTrailer.insert(0, "\u001E\u0004");
} else if (oneByte == 238) { // Latch to ANSI X12 encodation
return ANSIX12_ENCODE;
} else if (oneByte == 239) { // Latch to Text encodation
return TEXT_ENCODE;
} else if (oneByte == 240) { // Latch to EDIFACT encodation
return EDIFACT_ENCODE;
} else if (oneByte == 241) { // ECI Character
// TODO(bbrown): I think we need to support ECI
//throw ReaderException.getInstance();
} else if (oneByte == 238) { // Latch to ANSI X12 encodation
return ANSIX12_ENCODE;
} else if (oneByte == 239) { // Latch to Text encodation
return TEXT_ENCODE;
} else if (oneByte == 240) { // Latch to EDIFACT encodation
return EDIFACT_ENCODE;
} else if (oneByte == 241) { // ECI Character
// TODO(bbrown): I think we need to support ECI
//throw ReaderException.getInstance();
// Ignore this symbol for now
} else if (oneByte >= 242) { // Not to be used in ASCII encodation
throw FormatException.getFormatInstance();
}
} else if (oneByte >= 242) { // Not to be used in ASCII encodation
throw FormatException.getFormatInstance();
}
} while (bits.available() > 0);
return ASCII_ENCODE;
}

View file

@ -28,46 +28,46 @@ import com.google.zxing.common.BitMatrix;
*/
public final class Code128Writer extends UPCEANWriter {
public BitMatrix encode(String contents,
public BitMatrix encode(String contents,
BarcodeFormat format,
int width,
int height,
Hashtable hints) throws WriterException {
if (format != BarcodeFormat.CODE_128) {
throw new IllegalArgumentException("Can only encode CODE_128, but got " + format);
}
return super.encode(contents, format, width, height, hints);
}
if (format != BarcodeFormat.CODE_128) {
throw new IllegalArgumentException("Can only encode CODE_128, but got " + format);
}
return super.encode(contents, format, width, height, hints);
}
public byte[] encode(String contents) {
public byte[] encode(String contents) {
int length = contents.length();
if (length > 80) {
throw new IllegalArgumentException(
"Requested contents should be less than 80 digits long, but got " + length);
}
if (length > 80) {
throw new IllegalArgumentException(
"Requested contents should be less than 80 digits long, but got " + length);
}
int codeWidth = 11 + 11 + 13; //start plus check plus stop character
//get total code width for this barcode
for (int i = 0; i < length; i++) {
int codeWidth = 11 + 11 + 13; //start plus check plus stop character
//get total code width for this barcode
for (int i = 0; i < length; i++) {
int[] patterns = Code128Reader.CODE_PATTERNS[contents.charAt(i) - ' '];
for (int j = 0; j < patterns.length; j++) {
codeWidth += patterns[j];
}
}
byte[] result = new byte[codeWidth];
for (int j = 0; j < patterns.length; j++) {
codeWidth += patterns[j];
}
}
byte[] result = new byte[codeWidth];
int pos = appendPattern(result, 0, Code128Reader.CODE_PATTERNS[104], 1);
int check = 104;
//append next character to bytematrix
for(int i = 0; i < length; i++) {
//append next character to bytematrix
for(int i = 0; i < length; i++) {
check += (contents.charAt(i) - ' ') * (i + 1);
pos += appendPattern(result, pos, Code128Reader.CODE_PATTERNS[contents.charAt(i) - ' '],1);
}
//compute checksum and append it along with end character and quiet space
pos += appendPattern(result, pos, Code128Reader.CODE_PATTERNS[contents.charAt(i) - ' '],1);
}
//compute checksum and append it along with end character and quiet space
check %= 103;
pos += appendPattern(result,pos,Code128Reader.CODE_PATTERNS[check],1);
pos += appendPattern(result,pos,Code128Reader.CODE_PATTERNS[106],1);
pos += appendPattern(result,pos,Code128Reader.CODE_PATTERNS[check],1);
pos += appendPattern(result,pos,Code128Reader.CODE_PATTERNS[106],1);
return result;
}
return result;
}
}

View file

@ -28,52 +28,55 @@ import com.google.zxing.common.BitMatrix;
*/
public final class Code39Writer extends UPCEANWriter {
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height,
Hashtable hints) throws WriterException {
if (format != BarcodeFormat.CODE_39) {
throw new IllegalArgumentException("Can only encode CODE_39, but got " + format);
}
return super.encode(contents, format, width, height, hints);
}
public BitMatrix encode(String contents,
BarcodeFormat format,
int width,
int height,
Hashtable hints) throws WriterException {
if (format != BarcodeFormat.CODE_39) {
throw new IllegalArgumentException("Can only encode CODE_39, but got " + format);
}
return super.encode(contents, format, width, height, hints);
}
public byte[] encode(String contents) {
int length = contents.length();
if (length > 80) {
throw new IllegalArgumentException(
"Requested contents should be less than 80 digits long, but got " + length);
}
public byte[] encode(String contents) {
int length = contents.length();
if (length > 80) {
throw new IllegalArgumentException(
"Requested contents should be less than 80 digits long, but got " + length);
}
int[] widths = new int[9];
int codeWidth = 24 + 1 + length;
for (int i = 0; i < length; i++) {
int indexInString = Code39Reader.ALPHABET_STRING.indexOf(contents.charAt(i));
toIntArray(Code39Reader.CHARACTER_ENCODINGS[indexInString], widths);
for(int j = 0; j < widths.length; j++) {
codeWidth += widths[j];
}
}
byte[] result = new byte[codeWidth];
toIntArray(Code39Reader.CHARACTER_ENCODINGS[39], widths);
int pos = appendPattern(result, 0, widths, 1);
int[] narrowWhite = {1};
int[] widths = new int[9];
int codeWidth = 24 + 1 + length;
for (int i = 0; i < length; i++) {
int indexInString = Code39Reader.ALPHABET_STRING.indexOf(contents.charAt(i));
toIntArray(Code39Reader.CHARACTER_ENCODINGS[indexInString], widths);
for(int j = 0; j < widths.length; j++) {
codeWidth += widths[j];
}
}
byte[] result = new byte[codeWidth];
toIntArray(Code39Reader.CHARACTER_ENCODINGS[39], widths);
int pos = appendPattern(result, 0, widths, 1);
int[] narrowWhite = {1};
pos += appendPattern(result, pos, narrowWhite, 0);
//append next character to bytematrix
for(int i = length-1; i >= 0; i--) {
int indexInString = Code39Reader.ALPHABET_STRING.indexOf(contents.charAt(i));
toIntArray(Code39Reader.CHARACTER_ENCODINGS[indexInString], widths);
pos += appendPattern(result, pos, widths, 1);
pos += appendPattern(result, pos, narrowWhite, 0);
//append next character to bytematrix
for(int i = length-1; i >= 0; i--) {
int indexInString = Code39Reader.ALPHABET_STRING.indexOf(contents.charAt(i));
toIntArray(Code39Reader.CHARACTER_ENCODINGS[indexInString], widths);
pos += appendPattern(result, pos, widths, 1);
pos += appendPattern(result, pos, narrowWhite, 0);
}
toIntArray(Code39Reader.CHARACTER_ENCODINGS[39], widths);
pos += appendPattern(result, pos, widths, 1);
return result;
}
private static void toIntArray(int a, int[] toReturn) {
for (int i = 0; i < 9; i++) {
int temp = a & (1 << i);
toReturn[i] = (temp == 0) ? 1 : 2;
}
}
}
toIntArray(Code39Reader.CHARACTER_ENCODINGS[39], widths);
pos += appendPattern(result, pos, widths, 1);
return result;
}
private static void toIntArray(int a, int[] toReturn) {
for (int i = 0; i < 9; i++) {
int temp = a & (1 << i);
toReturn[i] = (temp == 0) ? 1 : 2;
}
}
}

View file

@ -340,9 +340,9 @@ public final class ITFReader extends OneDReader {
}
if (bestMatch >= 0) {
return bestMatch;
} else {
throw NotFoundException.getNotFoundInstance();
}
}
} else {
throw NotFoundException.getNotFoundInstance();
}
}
}

View file

@ -28,37 +28,41 @@ import com.google.zxing.common.BitMatrix;
*/
public final class ITFWriter extends UPCEANWriter {
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height,
Hashtable hints) throws WriterException {
if (format != BarcodeFormat.ITF) {
throw new IllegalArgumentException("Can only encode ITF, but got " + format);
}
return super.encode(contents, format, width, height, hints);
}
public BitMatrix encode(String contents,
BarcodeFormat format,
int width,
int height,
Hashtable hints) throws WriterException {
if (format != BarcodeFormat.ITF) {
throw new IllegalArgumentException("Can only encode ITF, but got " + format);
}
public byte[] encode(String contents) {
int length = contents.length();
if (length > 80) {
throw new IllegalArgumentException(
"Requested contents should be less than 80 digits long, but got " + length);
}
byte[] result = new byte[9 + 9 * length];
int[] start = {1, 1, 1, 1};
int pos = appendPattern(result, 0, start, 1);
for (int i = 0; i < length; i += 2) {
int one = Character.digit(contents.charAt(i), 10);
int two = Character.digit(contents.charAt(i+1), 10);
int[] encoding = new int[18];
for (int j = 0; j < 10; j += 2) {
encoding[j] = ITFReader.PATTERNS[one][j];
encoding[j + 1] = ITFReader.PATTERNS[two][j];
}
pos += appendPattern(result, pos, encoding, 1);
}
int[] end = {3, 1, 1};
pos += appendPattern(result, pos, end, 1);
return super.encode(contents, format, width, height, hints);
}
public byte[] encode(String contents) {
int length = contents.length();
if (length > 80) {
throw new IllegalArgumentException(
"Requested contents should be less than 80 digits long, but got " + length);
}
byte[] result = new byte[9 + 9 * length];
int[] start = {1, 1, 1, 1};
int pos = appendPattern(result, 0, start, 1);
for (int i = 0; i < length; i += 2) {
int one = Character.digit(contents.charAt(i), 10);
int two = Character.digit(contents.charAt(i+1), 10);
int[] encoding = new int[18];
for (int j = 0; j < 10; j += 2) {
encoding[j] = ITFReader.PATTERNS[one][j];
encoding[j + 1] = ITFReader.PATTERNS[two][j];
}
pos += appendPattern(result, pos, encoding, 1);
}
int[] end = {3, 1, 1};
pos += appendPattern(result, pos, end, 1);
return result;
}
return result;
}
}

View file

@ -446,7 +446,7 @@ final class DecodedBitStreamParser {
code == BEGIN_MACRO_PDF417_CONTROL_BLOCK ||
code == BEGIN_MACRO_PDF417_OPTIONAL_FIELD ||
code == MACRO_PDF417_TERMINATOR) {
codeIndex--;
codeIndex--;
end = true;
}
}

View file

@ -145,5 +145,6 @@ public final class Decoder {
}
}
return result;
}
}
}

View file

@ -202,11 +202,11 @@ public final class ParsedReaderResultTestCase extends TestCase {
"DTEND:20080505\r\nEND:VEVENT", "foo\n20080504\n20080505", ParsedResultType.CALENDAR);
// Start time only
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\nEND:VEVENT",
"foo\n20080504T123456Z", ParsedResultType.CALENDAR);
"foo\n20080504T123456Z\n20080504T123456Z", ParsedResultType.CALENDAR);
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456\r\nEND:VEVENT",
"foo\n20080504T123456", ParsedResultType.CALENDAR);
"foo\n20080504T123456\n20080504T123456", ParsedResultType.CALENDAR);
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504\r\nEND:VEVENT",
"foo\n20080504", ParsedResultType.CALENDAR);
"foo\n20080504\n20080504", ParsedResultType.CALENDAR);
doTestResult("BEGIN:VEVENT\r\nDTEND:20080505T\r\nEND:VEVENT",
"BEGIN:VEVENT\r\nDTEND:20080505T\r\nEND:VEVENT", ParsedResultType.TEXT);
// Make sure illegal entries without newlines don't crash

View file

@ -136,33 +136,33 @@ public final class EncoderTestCase extends TestCase {
{
BitArray bits = new BitArray();
Encoder.appendLengthInfo(1, // 1 letter (1/1).
1, // version 1.
Mode.NUMERIC,
bits);
1, // version 1.
Mode.NUMERIC,
bits);
assertEquals(" ........ .X", bits.toString()); // 10 bits.
}
{
BitArray bits = new BitArray();
Encoder.appendLengthInfo(2, // 2 letters (2/1).
10, // version 10.
Mode.ALPHANUMERIC,
bits);
10, // version 10.
Mode.ALPHANUMERIC,
bits);
assertEquals(" ........ .X.", bits.toString()); // 11 bits.
}
{
BitArray bits = new BitArray();
Encoder.appendLengthInfo(255, // 255 letter (255/1).
27, // version 27.
Mode.BYTE,
bits);
27, // version 27.
Mode.BYTE,
bits);
assertEquals(" ........ XXXXXXXX", bits.toString()); // 16 bits.
}
{
BitArray bits = new BitArray();
Encoder.appendLengthInfo(512, // 512 letters (1024/2).
40, // version 40.
Mode.KANJI,
bits);
40, // version 40.
Mode.KANJI,
bits);
assertEquals(" ..X..... ....", bits.toString()); // 12 bits.
}
}

View file

@ -54,27 +54,27 @@ public final class MatrixUtilTestCase extends TestCase {
{
// Version 1.
String expected =
" 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1\n" +
" 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" +
" 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" +
" 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" +
" 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" +
" 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" +
" 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" +
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" +
" 1 \n" +
" 0 \n" +
" 1 \n" +
" 0 \n" +
" 1 \n" +
" 0 0 0 0 0 0 0 0 1 \n" +
" 1 1 1 1 1 1 1 0 \n" +
" 1 0 0 0 0 0 1 0 \n" +
" 1 0 1 1 1 0 1 0 \n" +
" 1 0 1 1 1 0 1 0 \n" +
" 1 0 1 1 1 0 1 0 \n" +
" 1 0 0 0 0 0 1 0 \n" +
" 1 1 1 1 1 1 1 0 \n";
" 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1\n" +
" 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" +
" 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" +
" 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" +
" 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" +
" 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" +
" 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" +
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" +
" 1 \n" +
" 0 \n" +
" 1 \n" +
" 0 \n" +
" 1 \n" +
" 0 0 0 0 0 0 0 0 1 \n" +
" 1 1 1 1 1 1 1 0 \n" +
" 1 0 0 0 0 0 1 0 \n" +
" 1 0 1 1 1 0 1 0 \n" +
" 1 0 1 1 1 0 1 0 \n" +
" 1 0 1 1 1 0 1 0 \n" +
" 1 0 0 0 0 0 1 0 \n" +
" 1 1 1 1 1 1 1 0 \n";
ByteMatrix matrix = new ByteMatrix(21, 21);
MatrixUtil.clearMatrix(matrix);
MatrixUtil.embedBasicPatterns(1, matrix);
@ -84,31 +84,31 @@ public final class MatrixUtilTestCase extends TestCase {
// Version 2. Position adjustment pattern should apppear at right
// bottom corner.
String expected =
" 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1\n" +
" 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" +
" 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" +
" 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" +
" 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" +
" 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" +
" 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" +
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" +
" 1 \n" +
" 0 \n" +
" 1 \n" +
" 0 \n" +
" 1 \n" +
" 0 \n" +
" 1 \n" +
" 0 \n" +
" 1 1 1 1 1 1 \n" +
" 0 0 0 0 0 0 0 0 1 1 0 0 0 1 \n" +
" 1 1 1 1 1 1 1 0 1 0 1 0 1 \n" +
" 1 0 0 0 0 0 1 0 1 0 0 0 1 \n" +
" 1 0 1 1 1 0 1 0 1 1 1 1 1 \n" +
" 1 0 1 1 1 0 1 0 \n" +
" 1 0 1 1 1 0 1 0 \n" +
" 1 0 0 0 0 0 1 0 \n" +
" 1 1 1 1 1 1 1 0 \n";
" 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1\n" +
" 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" +
" 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" +
" 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" +
" 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" +
" 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" +
" 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" +
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" +
" 1 \n" +
" 0 \n" +
" 1 \n" +
" 0 \n" +
" 1 \n" +
" 0 \n" +
" 1 \n" +
" 0 \n" +
" 1 1 1 1 1 1 \n" +
" 0 0 0 0 0 0 0 0 1 1 0 0 0 1 \n" +
" 1 1 1 1 1 1 1 0 1 0 1 0 1 \n" +
" 1 0 0 0 0 0 1 0 1 0 0 0 1 \n" +
" 1 0 1 1 1 0 1 0 1 1 1 1 1 \n" +
" 1 0 1 1 1 0 1 0 \n" +
" 1 0 1 1 1 0 1 0 \n" +
" 1 0 0 0 0 0 1 0 \n" +
" 1 1 1 1 1 1 1 0 \n";
ByteMatrix matrix = new ByteMatrix(25, 25);
MatrixUtil.clearMatrix(matrix);
MatrixUtil.embedBasicPatterns(2, matrix);
@ -235,18 +235,18 @@ public final class MatrixUtilTestCase extends TestCase {
" 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0\n" +
" 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 1 0 0 1 0\n";
char[] bytes = {32, 65, 205, 69, 41, 220, 46, 128, 236,
42, 159, 74, 221, 244, 169, 239, 150, 138,
70, 237, 85, 224, 96, 74, 219 , 61};
42, 159, 74, 221, 244, 169, 239, 150, 138,
70, 237, 85, 224, 96, 74, 219 , 61};
BitArray bits = new BitArray();
for (char c: bytes) {
bits.appendBits(c, 8);
}
ByteMatrix matrix = new ByteMatrix(21, 21);
MatrixUtil.buildMatrix(bits,
ErrorCorrectionLevel.H,
1, // Version 1
3, // Mask pattern 3
matrix);
ErrorCorrectionLevel.H,
1, // Version 1
3, // Mask pattern 3
matrix);
}
public void testFindMSBSet() {
@ -290,8 +290,7 @@ public final class MatrixUtilTestCase extends TestCase {
public void testMakeTypeInfoInfoBits() throws WriterException {
// From Appendix C in JISX0510:2004 (p 65)
BitArray bits = new BitArray();
MatrixUtil.makeTypeInfoBits(ErrorCorrectionLevel.M,
5, bits);
MatrixUtil.makeTypeInfoBits(ErrorCorrectionLevel.M, 5, bits);
assertEquals(" X......X X..XXX.", bits.toString());
}
}

View file

@ -83,55 +83,55 @@ public final class QRCodeTestCase extends TestCase {
{
QRCode qrCode = new QRCode();
String expected =
"<<\n" +
" mode: null\n" +
" ecLevel: null\n" +
" version: -1\n" +
" matrixWidth: -1\n" +
" maskPattern: -1\n" +
" numTotalBytes: -1\n" +
" numDataBytes: -1\n" +
" numECBytes: -1\n" +
" numRSBlocks: -1\n" +
" matrix: null\n" +
">>\n";
"<<\n" +
" mode: null\n" +
" ecLevel: null\n" +
" version: -1\n" +
" matrixWidth: -1\n" +
" maskPattern: -1\n" +
" numTotalBytes: -1\n" +
" numDataBytes: -1\n" +
" numECBytes: -1\n" +
" numRSBlocks: -1\n" +
" matrix: null\n" +
">>\n";
assertEquals(expected, qrCode.toString());
}
{
String expected =
"<<\n" +
" mode: BYTE\n" +
" ecLevel: H\n" +
" version: 1\n" +
" matrixWidth: 21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1 0 1 0 1 0\n" +
" 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" +
" 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" +
" 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" +
" 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" +
">>\n";
QRCode qrCode = new QRCode();
qrCode.setMode(Mode.BYTE);
qrCode.setECLevel(ErrorCorrectionLevel.H);

View file

@ -1,7 +1,7 @@
raise "ZXing requires JRuby" unless defined?(JRuby)
require File.expand_path( File.dirname(__FILE__) + '/core.jar' ) # ZXing core classes
require File.expand_path( File.dirname(__FILE__) + '/javase.jar' ) # ZXing JavaSE classes
require File.expand_path( File.dirname(__FILE__) + '/core.jar' ) # ZXing core classes
require File.expand_path( File.dirname(__FILE__) + '/javase.jar' ) # ZXing JavaSE classes
require 'uri'

View file

@ -1,21 +1,16 @@
<module>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<!-- Inherit the default GWT style sheet. -->
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
<!-- Other module inherits -->
<inherits name='com.google.gwt.widgetideas.WidgetIdeas' />
<inherits name='com.google.gwt.libideas.LibIdeas' />
<inherits name='com.google.gwt.maps.GoogleMaps' />
<!-- Specify the app entry point class. -->
<entry-point class='com.google.zxing.web.generator.client.Generator'/>
<!-- Specify the application specific style sheet. -->
<stylesheet src='Generator.css' />
<stylesheet src='DatePickerDemo.css' />
<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjEOGGB_IEuss4QYUzB6Z0BRlY4xXjGBjgubjQXCS8Djm2jdpYBQn9f8dHtxpg30ararqd3GCyq_T4A' />
</module>

View file

@ -24,9 +24,7 @@ package com.google.zxing.web.generator.client;
* @author Yohann Coppel
*/
public class GeneratorException extends Exception {
private static final long serialVersionUID = 1L;
public GeneratorException(String message) {
super(message);
}
public GeneratorException(String message) {
super(message);
}
}

View file

@ -6,12 +6,10 @@ body {
font-family: Arial, sans-serif;
font-size: 11px;
}
#header {
background-color: #dde3e9;
border-bottom: 1px solid #f2f7fc;
}
#header h1 {
font-size: 15px;
font-weight: bold;
@ -19,23 +17,19 @@ body {
padding: 12px;
border-bottom: 1px solid #c8d0d9;
}
#header span {
font-weight: normal;
color: #5e6b75;
}
#footer {
width: 100%;
text-align:center;
padding-top: 12px;
}
#footer a {
text-decoration:none;
color: #5e6b75;
}
/****************************************/
#mainpanel {
width: 800px;
@ -43,7 +37,6 @@ body {
padding: 12px;
font-size: 11px;
}
#imageresult {
background-color: #dde3e9;
height: 350px;
@ -56,7 +49,6 @@ body {
display: table;
#position: relative;
}
#innerresult {
display: table-cell;
vertical-align: middle;
@ -64,20 +56,16 @@ body {
#position: absolute;
#top: 50%;
}
#innerresult img {
#position: relative;
#top: -50%;
}
#downloadText {
font-size: 11px;
}
#urlresult {
width: 350px;
}
.firstColumn {
width: 100px;
text-align: right;
@ -87,14 +75,12 @@ body {
font-weight: bold;
font-size: 11px;
}
.secondColumn {
width: 270px;
font-size: 11px;
color: #5e6b75;
font-weight: bold;
}
/*.inputfield,*/
.gwt-TextBox,
.gwt-TextArea {
@ -106,19 +92,15 @@ body {
color: #000;
font-weight: normal;
}
/*.inputfield:focus,*/
.gwt-TextBox:focus {
background-color: #fffbcc;
}
.required {
background: #ffffff url(required-field-bg.png) repeat-y;
}
.errorMessage {
padding-left: 110px;
font-size: 11px;
color: red;
}

View file

@ -1,40 +1,34 @@
/** CSS by Wain. */
body {
background-color: #e9eef3;
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-color: #e9eef3;
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
font-size: 12px;
}
td {
font-size: 14px;
}
#header {
background-color: #dde3e9;
border-bottom: 1px solid #f2f7fc;
background-color: #dde3e9;
border-bottom: 1px solid #f2f7fc;
}
#header h1 {
font-size: 15px;
font-weight: bold;
margin: 0;
padding: 12px;
border-bottom: 1px solid #c8d0d9;
font-size: 15px;
font-weight: bold;
margin: 0;
padding: 12px;
border-bottom: 1px solid #c8d0d9;
}
#header span {
font-weight: normal;
color: #5e6b75;
font-weight: normal;
color: #5e6b75;
}
#footer {
width: 100%;
width: 100%;
text-align:center;
padding-top: 12px;
}
#footer a {
text-decoration:none;
color: #5e6b75;