From 346de1b561a5eb4ebb0b52d814aa169d9730b0ed Mon Sep 17 00:00:00 2001 From: srowen Date: Thu, 5 Apr 2012 17:41:28 +0000 Subject: [PATCH] Minor inspection stuff git-svn-id: https://zxing.googlecode.com/svn/trunk@2247 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- .../client/android/encode/ContactEncoder.java | 16 ++-- .../com/google/zxing/MultiFormatWriter.java | 2 +- .../com/google/zxing/aztec/AztecReader.java | 3 +- .../google/zxing/aztec/detector/Detector.java | 2 +- .../client/result/VCardResultParser.java | 4 +- .../google/zxing/common/HybridBinarizer.java | 16 ++-- .../decoder/DecodedBitStreamParser.java | 4 +- .../zxing/datamatrix/detector/Detector.java | 88 +++++++++---------- .../maxicode/decoder/BitMatrixParser.java | 2 - .../com/google/zxing/oned/Code128Reader.java | 10 +-- .../com/google/zxing/oned/Code39Reader.java | 9 +- core/src/com/google/zxing/oned/ITFWriter.java | 2 +- .../decoder/DecodedBitStreamParser.java | 2 - .../zxing/pdf417/decoder/ec/ModulusGF.java | 2 +- .../decoder/DecodedBitStreamParser.java | 10 +-- .../com/google/zxing/qrcode/decoder/Mode.java | 2 +- .../zxing/qrcode/detector/Detector.java | 6 +- .../qrcode/detector/FinderPatternFinder.java | 4 +- .../google/zxing/qrcode/encoder/Encoder.java | 4 +- .../zxing/qrcode/encoder/MatrixUtil.java | 6 +- 20 files changed, 90 insertions(+), 104 deletions(-) diff --git a/android/src/com/google/zxing/client/android/encode/ContactEncoder.java b/android/src/com/google/zxing/client/android/encode/ContactEncoder.java index 3875f1a4b..f55ddd547 100644 --- a/android/src/com/google/zxing/client/android/encode/ContactEncoder.java +++ b/android/src/com/google/zxing/client/android/encode/ContactEncoder.java @@ -78,16 +78,14 @@ abstract class ContactEncoder { Collection uniques = new HashSet(2); for (String value : values) { String trimmed = trim(value); - if (trimmed != null) { - if (!uniques.contains(trimmed)) { - newContents.append(prefix).append(':').append(fieldFormatter.format(trimmed)).append(terminator); - String display = formatter == null ? trimmed : formatter.format(trimmed); - newDisplayContents.append(display).append('\n'); - if (++count == max) { - break; - } - uniques.add(trimmed); + if (trimmed != null && !uniques.contains(trimmed)) { + newContents.append(prefix).append(':').append(fieldFormatter.format(trimmed)).append(terminator); + String display = formatter == null ? trimmed : formatter.format(trimmed); + newDisplayContents.append(display).append('\n'); + if (++count == max) { + break; } + uniques.add(trimmed); } } } diff --git a/core/src/com/google/zxing/MultiFormatWriter.java b/core/src/com/google/zxing/MultiFormatWriter.java index 64bbb9d03..c400b27ce 100644 --- a/core/src/com/google/zxing/MultiFormatWriter.java +++ b/core/src/com/google/zxing/MultiFormatWriter.java @@ -78,7 +78,7 @@ public final class MultiFormatWriter implements Writer { writer = new PDF417Writer(); break; case CODABAR: - writer = new CodaBarWriter(); + writer = new CodaBarWriter(); break; default: throw new IllegalArgumentException("No encoder available for format " + format); diff --git a/core/src/com/google/zxing/aztec/AztecReader.java b/core/src/com/google/zxing/aztec/AztecReader.java index 50959404a..fd7b44538 100644 --- a/core/src/com/google/zxing/aztec/AztecReader.java +++ b/core/src/com/google/zxing/aztec/AztecReader.java @@ -18,7 +18,6 @@ package com.google.zxing.aztec; import com.google.zxing.BarcodeFormat; import com.google.zxing.BinaryBitmap; -import com.google.zxing.ChecksumException; import com.google.zxing.DecodeHintType; import com.google.zxing.FormatException; import com.google.zxing.NotFoundException; @@ -47,7 +46,7 @@ public final class AztecReader implements Reader { * @return a String representing the content encoded by the Data Matrix code * @throws NotFoundException if a Data Matrix code cannot be found * @throws FormatException if a Data Matrix code cannot be decoded - * @throws ChecksumException if error correction fails + * @throws com.google.zxing.ChecksumException if error correction fails */ @Override public Result decode(BinaryBitmap image) throws NotFoundException, FormatException { diff --git a/core/src/com/google/zxing/aztec/detector/Detector.java b/core/src/com/google/zxing/aztec/detector/Detector.java index a65490cd0..f48ca8df1 100644 --- a/core/src/com/google/zxing/aztec/detector/Detector.java +++ b/core/src/com/google/zxing/aztec/detector/Detector.java @@ -598,7 +598,7 @@ public final class Detector { return new Point(x,y); } - private static class Point { + private static final class Point { public final int x; public final int y; diff --git a/core/src/com/google/zxing/client/result/VCardResultParser.java b/core/src/com/google/zxing/client/result/VCardResultParser.java index 7af6184f1..62def8b7a 100644 --- a/core/src/com/google/zxing/client/result/VCardResultParser.java +++ b/core/src/com/google/zxing/client/result/VCardResultParser.java @@ -207,9 +207,7 @@ public final class VCardResultParser extends ResultParser { case '=': if (i < length - 2) { char nextChar = value.charAt(i+1); - if (nextChar == '\r' || nextChar == '\n') { - // Ignore, it's just a continuation symbol - } else { + if (nextChar != '\r' && nextChar != '\n') { char nextNextChar = value.charAt(i+2); int firstDigit = parseHexDigit(nextChar); int secondDigit = parseHexDigit(nextNextChar); diff --git a/core/src/com/google/zxing/common/HybridBinarizer.java b/core/src/com/google/zxing/common/HybridBinarizer.java index 6b1343f10..18fcc94ea 100644 --- a/core/src/com/google/zxing/common/HybridBinarizer.java +++ b/core/src/com/google/zxing/common/HybridBinarizer.java @@ -168,14 +168,14 @@ public final class HybridBinarizer extends GlobalHistogramBinarizer { } } // short-circuit min/max tests once dynamic range is met - if (max - min > MIN_DYNAMIC_RANGE) { - // finish the rest of the rows quickly - for (yy++, offset += width; yy < BLOCK_SIZE; yy++, offset += width) { - for (int xx = 0; xx < BLOCK_SIZE; xx++) { - sum += luminances[offset + xx] & 0xFF; - } - } - } + if (max - min > MIN_DYNAMIC_RANGE) { + // finish the rest of the rows quickly + for (yy++, offset += width; yy < BLOCK_SIZE; yy++, offset += width) { + for (int xx = 0; xx < BLOCK_SIZE; xx++) { + sum += luminances[offset + xx] & 0xFF; + } + } + } } // The default estimate is the average of the values in the block. diff --git a/core/src/com/google/zxing/datamatrix/decoder/DecodedBitStreamParser.java b/core/src/com/google/zxing/datamatrix/decoder/DecodedBitStreamParser.java index ff601cedd..a92fb29d7 100644 --- a/core/src/com/google/zxing/datamatrix/decoder/DecodedBitStreamParser.java +++ b/core/src/com/google/zxing/datamatrix/decoder/DecodedBitStreamParser.java @@ -174,9 +174,7 @@ final class DecodedBitStreamParser { // Ignore this symbol for now } else if (oneByte >= 242) { // Not to be used in ASCII encodation // ... but work around encoders that end with 254, latch back to ASCII - if (oneByte == 254 && bits.available() == 0) { - // Ignore - } else { + if (oneByte != 254 || bits.available() != 0) { throw FormatException.getFormatInstance(); } } diff --git a/core/src/com/google/zxing/datamatrix/detector/Detector.java b/core/src/com/google/zxing/datamatrix/detector/Detector.java index 140173deb..e862bf780 100644 --- a/core/src/com/google/zxing/datamatrix/detector/Detector.java +++ b/core/src/com/google/zxing/datamatrix/detector/Detector.java @@ -159,8 +159,8 @@ public final class Detector { // than twice the other, it's certainly rectangular, but to cut a bit more slack we accept it as // rectangular if the bigger side is at least 7/4 times the other: if (4 * dimensionTop >= 7 * dimensionRight || 4 * dimensionRight >= 7 * dimensionTop) { - // The matrix is rectangular - + // The matrix is rectangular + correctedTopRight = correctTopRightRectangular(bottomLeft, bottomRight, topLeft, topRight, dimensionTop, dimensionRight); if (correctedTopRight == null){ @@ -183,9 +183,9 @@ public final class Detector { bits = sampleGrid(image, topLeft, bottomLeft, bottomRight, correctedTopRight, dimensionTop, dimensionRight); } else { - // The matrix is square + // The matrix is square - int dimension = Math.min(dimensionRight, dimensionTop); + int dimension = Math.min(dimensionRight, dimensionTop); // correct top right point to match the white module correctedTopRight = correctTopRight(bottomLeft, bottomRight, topLeft, topRight, dimension); if (correctedTopRight == null){ @@ -222,20 +222,20 @@ public final class Detector { ResultPoint topRight, int dimensionTop, int dimensionRight) { - - float corr = distance(bottomLeft, bottomRight) / (float)dimensionTop; - int norm = distance(topLeft, topRight); - float cos = (topRight.getX() - topLeft.getX()) / norm; - float sin = (topRight.getY() - topLeft.getY()) / norm; - - ResultPoint c1 = new ResultPoint(topRight.getX()+corr*cos, topRight.getY()+corr*sin); - - corr = distance(bottomLeft, topLeft) / (float)dimensionRight; - norm = distance(bottomRight, topRight); - cos = (topRight.getX() - bottomRight.getX()) / norm; - sin = (topRight.getY() - bottomRight.getY()) / norm; - - ResultPoint c2 = new ResultPoint(topRight.getX()+corr*cos, topRight.getY()+corr*sin); + + float corr = distance(bottomLeft, bottomRight) / (float)dimensionTop; + int norm = distance(topLeft, topRight); + float cos = (topRight.getX() - topLeft.getX()) / norm; + float sin = (topRight.getY() - topLeft.getY()) / norm; + + ResultPoint c1 = new ResultPoint(topRight.getX()+corr*cos, topRight.getY()+corr*sin); + + corr = distance(bottomLeft, topLeft) / (float)dimensionRight; + norm = distance(bottomRight, topRight); + cos = (topRight.getX() - bottomRight.getX()) / norm; + sin = (topRight.getY() - bottomRight.getY()) / norm; + + ResultPoint c2 = new ResultPoint(topRight.getX()+corr*cos, topRight.getY()+corr*sin); if (!isValid(c1)) { if (isValid(c2)) { @@ -248,15 +248,15 @@ public final class Detector { } int l1 = Math.abs(dimensionTop - transitionsBetween(topLeft, c1).getTransitions()) + - Math.abs(dimensionRight - transitionsBetween(bottomRight, c1).getTransitions()); - int l2 = Math.abs(dimensionTop - transitionsBetween(topLeft, c2).getTransitions()) + - Math.abs(dimensionRight - transitionsBetween(bottomRight, c2).getTransitions()); - - if (l1 <= l2){ - return c1; - } - - return c2; + Math.abs(dimensionRight - transitionsBetween(bottomRight, c1).getTransitions()); + int l2 = Math.abs(dimensionTop - transitionsBetween(topLeft, c2).getTransitions()) + + Math.abs(dimensionRight - transitionsBetween(bottomRight, c2).getTransitions()); + + if (l1 <= l2){ + return c1; + } + + return c2; } /** @@ -268,20 +268,20 @@ public final class Detector { ResultPoint topLeft, ResultPoint topRight, int dimension) { - - float corr = distance(bottomLeft, bottomRight) / (float) dimension; - int norm = distance(topLeft, topRight); - float cos = (topRight.getX() - topLeft.getX()) / norm; - float sin = (topRight.getY() - topLeft.getY()) / norm; - - ResultPoint c1 = new ResultPoint(topRight.getX() + corr * cos, topRight.getY() + corr * sin); - - corr = distance(bottomLeft, topLeft) / (float) dimension; - norm = distance(bottomRight, topRight); - cos = (topRight.getX() - bottomRight.getX()) / norm; - sin = (topRight.getY() - bottomRight.getY()) / norm; - - ResultPoint c2 = new ResultPoint(topRight.getX() + corr * cos, topRight.getY() + corr * sin); + + float corr = distance(bottomLeft, bottomRight) / (float) dimension; + int norm = distance(topLeft, topRight); + float cos = (topRight.getX() - topLeft.getX()) / norm; + float sin = (topRight.getY() - topLeft.getY()) / norm; + + ResultPoint c1 = new ResultPoint(topRight.getX() + corr * cos, topRight.getY() + corr * sin); + + corr = distance(bottomLeft, topLeft) / (float) dimension; + norm = distance(bottomRight, topRight); + cos = (topRight.getX() - bottomRight.getX()) / norm; + sin = (topRight.getY() - bottomRight.getY()) / norm; + + ResultPoint c2 = new ResultPoint(topRight.getX() + corr * cos, topRight.getY() + corr * sin); if (!isValid(c1)) { if (isValid(c2)) { @@ -295,14 +295,14 @@ public final class Detector { int l1 = Math.abs(transitionsBetween(topLeft, c1).getTransitions() - transitionsBetween(bottomRight, c1).getTransitions()); - int l2 = Math.abs(transitionsBetween(topLeft, c2).getTransitions() - + int l2 = Math.abs(transitionsBetween(topLeft, c2).getTransitions() - transitionsBetween(bottomRight, c2).getTransitions()); return l1 <= l2 ? c1 : c2; } private boolean isValid(ResultPoint p) { - return p.getX() >= 0 && p.getX() < image.getWidth() && p.getY() > 0 && p.getY() < image.getHeight(); + return p.getX() >= 0 && p.getX() < image.getWidth() && p.getY() > 0 && p.getY() < image.getHeight(); } /** @@ -406,7 +406,7 @@ public final class Detector { /** * Simply encapsulates two points and a number of transitions between them. */ - private static class ResultPointsAndTransitions { + private static final class ResultPointsAndTransitions { private final ResultPoint from; private final ResultPoint to; diff --git a/core/src/com/google/zxing/maxicode/decoder/BitMatrixParser.java b/core/src/com/google/zxing/maxicode/decoder/BitMatrixParser.java index c14e639fe..be18a7e2a 100644 --- a/core/src/com/google/zxing/maxicode/decoder/BitMatrixParser.java +++ b/core/src/com/google/zxing/maxicode/decoder/BitMatrixParser.java @@ -16,7 +16,6 @@ package com.google.zxing.maxicode.decoder; -import com.google.zxing.FormatException; import com.google.zxing.common.BitMatrix; /** @@ -65,7 +64,6 @@ final class BitMatrixParser { /** * @param bitMatrix {@link BitMatrix} to parse - * @throws FormatException if height is not 33 or width is not 30 */ BitMatrixParser(BitMatrix bitMatrix) { this.bitMatrix = bitMatrix; diff --git a/core/src/com/google/zxing/oned/Code128Reader.java b/core/src/com/google/zxing/oned/Code128Reader.java index bf1b62f95..07db7c77e 100644 --- a/core/src/com/google/zxing/oned/Code128Reader.java +++ b/core/src/com/google/zxing/oned/Code128Reader.java @@ -191,12 +191,10 @@ public final class Code128Reader extends OneDReader { bestMatch = startCode; } } - if (bestMatch >= 0) { - // Look for whitespace before start pattern, >= 50% of width of start pattern - if (row.isRange(Math.max(0, patternStart - (i - patternStart) / 2), patternStart, - false)) { - return new int[]{patternStart, i, bestMatch}; - } + // Look for whitespace before start pattern, >= 50% of width of start pattern + if (bestMatch >= 0 && + row.isRange(Math.max(0, patternStart - (i - patternStart) / 2), patternStart, false)) { + return new int[]{patternStart, i, bestMatch}; } patternStart += counters[0] + counters[1]; System.arraycopy(counters, 2, counters, 0, patternLength - 2); diff --git a/core/src/com/google/zxing/oned/Code39Reader.java b/core/src/com/google/zxing/oned/Code39Reader.java index c73643578..4b0fdede3 100644 --- a/core/src/com/google/zxing/oned/Code39Reader.java +++ b/core/src/com/google/zxing/oned/Code39Reader.java @@ -184,11 +184,10 @@ public final class Code39Reader extends OneDReader { counters[counterPosition]++; } else { if (counterPosition == patternLength - 1) { - if (toNarrowWidePattern(counters) == ASTERISK_ENCODING) { - // Look for whitespace before start pattern, >= 50% of width of start pattern - if (row.isRange(Math.max(0, patternStart - ((i - patternStart) >> 1)), patternStart, false)) { - return new int[]{patternStart, i}; - } + // Look for whitespace before start pattern, >= 50% of width of start pattern + if (toNarrowWidePattern(counters) == ASTERISK_ENCODING && + row.isRange(Math.max(0, patternStart - ((i - patternStart) >> 1)), patternStart, false)) { + return new int[]{patternStart, i}; } patternStart += counters[0] + counters[1]; System.arraycopy(counters, 2, counters, 0, patternLength - 2); diff --git a/core/src/com/google/zxing/oned/ITFWriter.java b/core/src/com/google/zxing/oned/ITFWriter.java index be8f51268..c44e1fc6b 100644 --- a/core/src/com/google/zxing/oned/ITFWriter.java +++ b/core/src/com/google/zxing/oned/ITFWriter.java @@ -67,7 +67,7 @@ public final class ITFWriter extends UPCEANWriter { pos += appendPattern(result, pos, encoding, 1); } int[] end = {3, 1, 1}; - pos += appendPattern(result, pos, end, 1); + appendPattern(result, pos, end, 1); return result; } diff --git a/core/src/com/google/zxing/pdf417/decoder/DecodedBitStreamParser.java b/core/src/com/google/zxing/pdf417/decoder/DecodedBitStreamParser.java index e35c4859f..451762c0d 100644 --- a/core/src/com/google/zxing/pdf417/decoder/DecodedBitStreamParser.java +++ b/core/src/com/google/zxing/pdf417/decoder/DecodedBitStreamParser.java @@ -316,8 +316,6 @@ final class DecodedBitStreamParser { ch = ' '; } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { subMode = Mode.ALPHA; - } else { - // is this even possible? } } break; diff --git a/core/src/com/google/zxing/pdf417/decoder/ec/ModulusGF.java b/core/src/com/google/zxing/pdf417/decoder/ec/ModulusGF.java index bddd5d20e..46a21087a 100644 --- a/core/src/com/google/zxing/pdf417/decoder/ec/ModulusGF.java +++ b/core/src/com/google/zxing/pdf417/decoder/ec/ModulusGF.java @@ -33,7 +33,7 @@ public final class ModulusGF { private final int modulus; public ModulusGF(int modulus, int generator) { - this.modulus = modulus; + this.modulus = modulus; expTable = new int[modulus]; logTable = new int[modulus]; int x = 1; diff --git a/core/src/com/google/zxing/qrcode/decoder/DecodedBitStreamParser.java b/core/src/com/google/zxing/qrcode/decoder/DecodedBitStreamParser.java index c7d747aa9..b045eb00c 100644 --- a/core/src/com/google/zxing/qrcode/decoder/DecodedBitStreamParser.java +++ b/core/src/com/google/zxing/qrcode/decoder/DecodedBitStreamParser.java @@ -93,11 +93,11 @@ final class DecodedBitStreamParser { } else { // First handle Hanzi mode which does not start with character count if (mode == Mode.HANZI) { - //chinese mode contains a sub set indicator right after mode indicator - int subset = bits.readBits(4); - int countHanzi = bits.readBits(mode.getCharacterCountBits(version)); - if (subset == GB2312_SUBSET) { - decodeHanziSegment(bits, result, countHanzi); + //chinese mode contains a sub set indicator right after mode indicator + int subset = bits.readBits(4); + int countHanzi = bits.readBits(mode.getCharacterCountBits(version)); + if (subset == GB2312_SUBSET) { + decodeHanziSegment(bits, result, countHanzi); } } else { // "Normal" QR code modes: diff --git a/core/src/com/google/zxing/qrcode/decoder/Mode.java b/core/src/com/google/zxing/qrcode/decoder/Mode.java index 5ba28a949..b7e9ab3a9 100644 --- a/core/src/com/google/zxing/qrcode/decoder/Mode.java +++ b/core/src/com/google/zxing/qrcode/decoder/Mode.java @@ -70,7 +70,7 @@ public enum Mode { case 0x9: return FNC1_SECOND_POSITION; case 0xD: - // 0xD is defined in GBT 18284-2000, may not be supported in foreign country + // 0xD is defined in GBT 18284-2000, may not be supported in foreign country return HANZI; default: throw new IllegalArgumentException(); diff --git a/core/src/com/google/zxing/qrcode/detector/Detector.java b/core/src/com/google/zxing/qrcode/detector/Detector.java index d59a9b877..e4e38933f 100644 --- a/core/src/com/google/zxing/qrcode/detector/Detector.java +++ b/core/src/com/google/zxing/qrcode/detector/Detector.java @@ -152,12 +152,14 @@ public class Detector { if (alignmentPattern != null) { bottomRightX = alignmentPattern.getX(); bottomRightY = alignmentPattern.getY(); - sourceBottomRightX = sourceBottomRightY = dimMinusThree - 3.0f; + sourceBottomRightX = dimMinusThree - 3.0f; + sourceBottomRightY = sourceBottomRightX; } else { // Don't have an alignment pattern, just make up the bottom-right point bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX(); bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY(); - sourceBottomRightX = sourceBottomRightY = dimMinusThree; + sourceBottomRightX = dimMinusThree; + sourceBottomRightY = dimMinusThree; } return PerspectiveTransform.quadrilateralToQuadrilateral( diff --git a/core/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java b/core/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java index 479dc3ec8..01d189a39 100755 --- a/core/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java +++ b/core/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java @@ -549,7 +549,7 @@ public class FinderPatternFinder { /** *

Orders by furthest from average

*/ - private static class FurthestFromAverageComparator implements Comparator, Serializable { + private static final class FurthestFromAverageComparator implements Comparator, Serializable { private final float average; private FurthestFromAverageComparator(float f) { average = f; @@ -565,7 +565,7 @@ public class FinderPatternFinder { /** *

Orders by {@link FinderPattern#getCount()}, descending.

*/ - private static class CenterComparator implements Comparator, Serializable { + private static final class CenterComparator implements Comparator, Serializable { private final float average; private CenterComparator(float f) { average = f; diff --git a/core/src/com/google/zxing/qrcode/encoder/Encoder.java b/core/src/com/google/zxing/qrcode/encoder/Encoder.java index 99d80e9ff..85d1529e6 100644 --- a/core/src/com/google/zxing/qrcode/encoder/Encoder.java +++ b/core/src/com/google/zxing/qrcode/encoder/Encoder.java @@ -542,7 +542,7 @@ public final class Encoder { try { bytes = content.getBytes(encoding); } catch (UnsupportedEncodingException uee) { - throw new WriterException(uee.toString()); + throw new WriterException(uee); } for (byte b : bytes) { bits.appendBits(b, 8); @@ -554,7 +554,7 @@ public final class Encoder { try { bytes = content.getBytes("Shift_JIS"); } catch (UnsupportedEncodingException uee) { - throw new WriterException(uee.toString()); + throw new WriterException(uee); } int length = bytes.length; for (int i = 0; i < length; i += 2) { diff --git a/core/src/com/google/zxing/qrcode/encoder/MatrixUtil.java b/core/src/com/google/zxing/qrcode/encoder/MatrixUtil.java index 26d095f99..9f9d06e77 100644 --- a/core/src/com/google/zxing/qrcode/encoder/MatrixUtil.java +++ b/core/src/com/google/zxing/qrcode/encoder/MatrixUtil.java @@ -255,10 +255,8 @@ final class MatrixUtil { } // Skip masking if mask_pattern is -1. - if (maskPattern != -1) { - if (MaskUtil.getDataMaskBit(maskPattern, xx, y)) { - bit = !bit; - } + if (maskPattern != -1 && MaskUtil.getDataMaskBit(maskPattern, xx, y)) { + bit = !bit; } matrix.set(xx, y, bit); }