Java 类com.google.zxing.datamatrix.encoder.SymbolShapeHint 实例源码

项目:Camel    文件:BarcodeDataFormat.java   
/**
 * Sets hints optimized for different barcode types.
 */
protected final void optimizeHints() {
    // clear hints for re-optimization
    this.writerHintMap.clear();
    this.readerHintMap.clear();

    // writer hints
    String format = this.params.getFormat().toString();

    // only for QR code. AZTEC uses zxing's default error correction 33%.
    if (format.equals(BarcodeFormat.QR_CODE.toString())) {
        this.writerHintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
    }

    if (format.equals(BarcodeFormat.DATA_MATRIX.toString())) {
        this.writerHintMap.put(EncodeHintType.DATA_MATRIX_SHAPE, SymbolShapeHint.FORCE_SQUARE);
    }

    // reader hints
    this.readerHintMap.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
}
项目:boohee_v5.6    文件:DataMatrixWriter.java   
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height,
                        Map<EncodeHintType, ?> hints) {
    if (contents.isEmpty()) {
        throw new IllegalArgumentException("Found empty contents");
    } else if (format != BarcodeFormat.DATA_MATRIX) {
        throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format);
    } else if (width < 0 || height < 0) {
        throw new IllegalArgumentException("Requested dimensions are too small: " + width +
                'x' + height);
    } else {
        SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
        Dimension minSize = null;
        Dimension maxSize = null;
        if (hints != null) {
            SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType
                    .DATA_MATRIX_SHAPE);
            if (requestedShape != null) {
                shape = requestedShape;
            }
            Dimension requestedMinSize = (Dimension) hints.get(EncodeHintType.MIN_SIZE);
            if (requestedMinSize != null) {
                minSize = requestedMinSize;
            }
            Dimension requestedMaxSize = (Dimension) hints.get(EncodeHintType.MAX_SIZE);
            if (requestedMaxSize != null) {
                maxSize = requestedMaxSize;
            }
        }
        String encoded = HighLevelEncoder.encodeHighLevel(contents, shape, minSize, maxSize);
        SymbolInfo symbolInfo = SymbolInfo.lookup(encoded.length(), shape, minSize, maxSize,
                true);
        DefaultPlacement placement = new DefaultPlacement(ErrorCorrection.encodeECC200
                (encoded, symbolInfo), symbolInfo.getSymbolDataWidth(), symbolInfo
                .getSymbolDataHeight());
        placement.place();
        return encodeLowLevel(placement, symbolInfo);
    }
}
项目:ZXing-Orient    文件:DataMatrixWriter.java   
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {

  if (contents.isEmpty()) {
    throw new IllegalArgumentException("Found empty contents");
  }

  if (format != BarcodeFormat.DATA_MATRIX) {
    throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format);
  }

  if (width < 0 || height < 0) {
    throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
  }

  // Try to get force shape & min / max size
  SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
  Dimension minSize = null;
  Dimension maxSize = null;
  if (hints != null) {
    SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE);
    if (requestedShape != null) {
      shape = requestedShape;
    }
    Dimension requestedMinSize = (Dimension) hints.get(EncodeHintType.MIN_SIZE);
    if (requestedMinSize != null) {
      minSize = requestedMinSize;
    }
    Dimension requestedMaxSize = (Dimension) hints.get(EncodeHintType.MAX_SIZE);
    if (requestedMaxSize != null) {
      maxSize = requestedMaxSize;
    }
  }


  //1. step: Data encodation
  String encoded = HighLevelEncoder.encodeHighLevel(contents, shape, minSize, maxSize);

  SymbolInfo symbolInfo = SymbolInfo.lookup(encoded.length(), shape, minSize, maxSize, true);

  //2. step: ECC generation
  String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo);

  //3. step: Module placement in Matrix
  DefaultPlacement placement =
      new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(), symbolInfo.getSymbolDataHeight());
  placement.place();

  //4. step: low-level encoding
  return encodeLowLevel(placement, symbolInfo);
}
项目:zxing-bsplus    文件:DataMatrixWriterTestCase.java   
@Test
public void testDataMatrixImageWriter() {

  Map<EncodeHintType,Object> hints = new EnumMap<>(EncodeHintType.class);
  hints.put(EncodeHintType.DATA_MATRIX_SHAPE, SymbolShapeHint.FORCE_SQUARE);

  int bigEnough = 64;
  DataMatrixWriter writer = new DataMatrixWriter();
  BitMatrix matrix = writer.encode("Hello Google", BarcodeFormat.DATA_MATRIX, bigEnough, bigEnough, hints);
  assertNotNull(matrix);
  assertTrue(bigEnough >= matrix.getWidth());
  assertTrue(bigEnough >= matrix.getHeight());
}
项目:zxing-bsplus    文件:DataMatrixWriterTestCase.java   
@Test
public void testDataMatrixWriter() {

  Map<EncodeHintType,Object> hints = new EnumMap<>(EncodeHintType.class);
  hints.put(EncodeHintType.DATA_MATRIX_SHAPE, SymbolShapeHint.FORCE_SQUARE);

  int bigEnough = 14;
  DataMatrixWriter writer = new DataMatrixWriter();
  BitMatrix matrix = writer.encode("Hello Me", BarcodeFormat.DATA_MATRIX, bigEnough, bigEnough, hints);
  assertNotNull(matrix);
  assertEquals(bigEnough, matrix.getWidth());
  assertEquals(bigEnough, matrix.getHeight());
}
项目:ZxingCore    文件:DataMatrixWriterTestCase.java   
@Test
public void testDataMatrixImageWriter() {

  Map<EncodeHintType,Object> hints = new EnumMap<EncodeHintType,Object>(EncodeHintType.class);
  hints.put(EncodeHintType.DATA_MATRIX_SHAPE, SymbolShapeHint.FORCE_SQUARE);

  int bigEnough = 64;
  DataMatrixWriter writer = new DataMatrixWriter();
  BitMatrix matrix = writer.encode("Hello Google", BarcodeFormat.DATA_MATRIX, bigEnough, bigEnough, hints);
  assertNotNull(matrix);
  assertTrue(bigEnough >= matrix.getWidth());
  assertTrue(bigEnough >= matrix.getHeight());
}
项目:ZxingCore    文件:DataMatrixWriterTestCase.java   
@Test
public void testDataMatrixWriter() {

  Map<EncodeHintType,Object> hints = new EnumMap<EncodeHintType,Object>(EncodeHintType.class);
  hints.put(EncodeHintType.DATA_MATRIX_SHAPE, SymbolShapeHint.FORCE_SQUARE);

  int bigEnough = 14;
  DataMatrixWriter writer = new DataMatrixWriter();
  BitMatrix matrix = writer.encode("Hello Me", BarcodeFormat.DATA_MATRIX, bigEnough, bigEnough, hints);
  assertNotNull(matrix);
  assertEquals(bigEnough, matrix.getWidth());
  assertEquals(bigEnough, matrix.getHeight());
}
项目:weex-3d-map    文件:DataMatrixWriter.java   
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {

  if (contents.isEmpty()) {
    throw new IllegalArgumentException("Found empty contents");
  }

  if (format != BarcodeFormat.DATA_MATRIX) {
    throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format);
  }

  if (width < 0 || height < 0) {
    throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
  }

  // Try to get force shape & min / max size
  SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
  Dimension minSize = null;
  Dimension maxSize = null;
  if (hints != null) {
    SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE);
    if (requestedShape != null) {
      shape = requestedShape;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMinSize = (Dimension) hints.get(EncodeHintType.MIN_SIZE);
    if (requestedMinSize != null) {
      minSize = requestedMinSize;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMaxSize = (Dimension) hints.get(EncodeHintType.MAX_SIZE);
    if (requestedMaxSize != null) {
      maxSize = requestedMaxSize;
    }
  }


  //1. step: Data encodation
  String encoded = HighLevelEncoder.encodeHighLevel(contents, shape, minSize, maxSize);

  SymbolInfo symbolInfo = SymbolInfo.lookup(encoded.length(), shape, minSize, maxSize, true);

  //2. step: ECC generation
  String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo);

  //3. step: Module placement in Matrix
  DefaultPlacement placement =
      new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(), symbolInfo.getSymbolDataHeight());
  placement.place();

  //4. step: low-level encoding
  return encodeLowLevel(placement, symbolInfo);
}
项目:PortraitZXing    文件:DataMatrixWriter.java   
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {

  if (contents.isEmpty()) {
    throw new IllegalArgumentException("Found empty contents");
  }

  if (format != BarcodeFormat.DATA_MATRIX) {
    throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format);
  }

  if (width < 0 || height < 0) {
    throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
  }

  // Try to get force shape & min / max size
  SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
  Dimension minSize = null;
  Dimension maxSize = null;
  if (hints != null) {
    SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE);
    if (requestedShape != null) {
      shape = requestedShape;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMinSize = (Dimension) hints.get(EncodeHintType.MIN_SIZE);
    if (requestedMinSize != null) {
      minSize = requestedMinSize;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMaxSize = (Dimension) hints.get(EncodeHintType.MAX_SIZE);
    if (requestedMaxSize != null) {
      maxSize = requestedMaxSize;
    }
  }


  //1. step: Data encodation
  String encoded = HighLevelEncoder.encodeHighLevel(contents, shape, minSize, maxSize);

  SymbolInfo symbolInfo = SymbolInfo.lookup(encoded.length(), shape, minSize, maxSize, true);

  //2. step: ECC generation
  String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo);

  //3. step: Module placement in Matrix
  DefaultPlacement placement =
      new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(), symbolInfo.getSymbolDataHeight());
  placement.place();

  //4. step: low-level encoding
  return encodeLowLevel(placement, symbolInfo);
}
项目:PortraitZXing    文件:DataMatrixWriter.java   
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {

  if (contents.isEmpty()) {
    throw new IllegalArgumentException("Found empty contents");
  }

  if (format != BarcodeFormat.DATA_MATRIX) {
    throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format);
  }

  if (width < 0 || height < 0) {
    throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
  }

  // Try to get force shape & min / max size
  SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
  Dimension minSize = null;
  Dimension maxSize = null;
  if (hints != null) {
    SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE);
    if (requestedShape != null) {
      shape = requestedShape;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMinSize = (Dimension) hints.get(EncodeHintType.MIN_SIZE);
    if (requestedMinSize != null) {
      minSize = requestedMinSize;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMaxSize = (Dimension) hints.get(EncodeHintType.MAX_SIZE);
    if (requestedMaxSize != null) {
      maxSize = requestedMaxSize;
    }
  }


  //1. step: Data encodation
  String encoded = HighLevelEncoder.encodeHighLevel(contents, shape, minSize, maxSize);

  SymbolInfo symbolInfo = SymbolInfo.lookup(encoded.length(), shape, minSize, maxSize, true);

  //2. step: ECC generation
  String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo);

  //3. step: Module placement in Matrix
  DefaultPlacement placement =
      new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(), symbolInfo.getSymbolDataHeight());
  placement.place();

  //4. step: low-level encoding
  return encodeLowLevel(placement, symbolInfo);
}
项目:event-app    文件:DataMatrixWriter.java   
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {

  if (contents.isEmpty()) {
    throw new IllegalArgumentException("Found empty contents");
  }

  if (format != BarcodeFormat.DATA_MATRIX) {
    throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format);
  }

  if (width < 0 || height < 0) {
    throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
  }

  // Try to get force shape & min / max size
  SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
  Dimension minSize = null;
  Dimension maxSize = null;
  if (hints != null) {
    SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE);
    if (requestedShape != null) {
      shape = requestedShape;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMinSize = (Dimension) hints.get(EncodeHintType.MIN_SIZE);
    if (requestedMinSize != null) {
      minSize = requestedMinSize;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMaxSize = (Dimension) hints.get(EncodeHintType.MAX_SIZE);
    if (requestedMaxSize != null) {
      maxSize = requestedMaxSize;
    }
  }


  //1. step: Data encodation
  String encoded = HighLevelEncoder.encodeHighLevel(contents, shape, minSize, maxSize);

  SymbolInfo symbolInfo = SymbolInfo.lookup(encoded.length(), shape, minSize, maxSize, true);

  //2. step: ECC generation
  String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo);

  //3. step: Module placement in Matrix
  DefaultPlacement placement =
      new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(), symbolInfo.getSymbolDataHeight());
  placement.place();

  //4. step: low-level encoding
  return encodeLowLevel(placement, symbolInfo);
}
项目:weex-analyzer-android    文件:DataMatrixWriter.java   
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {

  if (contents.isEmpty()) {
    throw new IllegalArgumentException("Found empty contents");
  }

  if (format != BarcodeFormat.DATA_MATRIX) {
    throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format);
  }

  if (width < 0 || height < 0) {
    throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
  }

  // Try to get force shape & min / max size
  SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
  Dimension minSize = null;
  Dimension maxSize = null;
  if (hints != null) {
    SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE);
    if (requestedShape != null) {
      shape = requestedShape;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMinSize = (Dimension) hints.get(EncodeHintType.MIN_SIZE);
    if (requestedMinSize != null) {
      minSize = requestedMinSize;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMaxSize = (Dimension) hints.get(EncodeHintType.MAX_SIZE);
    if (requestedMaxSize != null) {
      maxSize = requestedMaxSize;
    }
  }


  //1. step: Data encodation
  String encoded = HighLevelEncoder.encodeHighLevel(contents, shape, minSize, maxSize);

  SymbolInfo symbolInfo = SymbolInfo.lookup(encoded.length(), shape, minSize, maxSize, true);

  //2. step: ECC generation
  String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo);

  //3. step: Module placement in Matrix
  DefaultPlacement placement =
      new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(), symbolInfo.getSymbolDataHeight());
  placement.place();

  //4. step: low-level encoding
  return encodeLowLevel(placement, symbolInfo);
}
项目:weex-3d-map    文件:DataMatrixWriter.java   
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {

  if (contents.isEmpty()) {
    throw new IllegalArgumentException("Found empty contents");
  }

  if (format != BarcodeFormat.DATA_MATRIX) {
    throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format);
  }

  if (width < 0 || height < 0) {
    throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
  }

  // Try to get force shape & min / max size
  SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
  Dimension minSize = null;
  Dimension maxSize = null;
  if (hints != null) {
    SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE);
    if (requestedShape != null) {
      shape = requestedShape;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMinSize = (Dimension) hints.get(EncodeHintType.MIN_SIZE);
    if (requestedMinSize != null) {
      minSize = requestedMinSize;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMaxSize = (Dimension) hints.get(EncodeHintType.MAX_SIZE);
    if (requestedMaxSize != null) {
      maxSize = requestedMaxSize;
    }
  }


  //1. step: Data encodation
  String encoded = HighLevelEncoder.encodeHighLevel(contents, shape, minSize, maxSize);

  SymbolInfo symbolInfo = SymbolInfo.lookup(encoded.length(), shape, minSize, maxSize, true);

  //2. step: ECC generation
  String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo);

  //3. step: Module placement in Matrix
  DefaultPlacement placement =
      new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(), symbolInfo.getSymbolDataHeight());
  placement.place();

  //4. step: low-level encoding
  return encodeLowLevel(placement, symbolInfo);
}
项目:Weex-TestDemo    文件:DataMatrixWriter.java   
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {

  if (contents.isEmpty()) {
    throw new IllegalArgumentException("Found empty contents");
  }

  if (format != BarcodeFormat.DATA_MATRIX) {
    throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format);
  }

  if (width < 0 || height < 0) {
    throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
  }

  // Try to get force shape & min / max size
  SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
  Dimension minSize = null;
  Dimension maxSize = null;
  if (hints != null) {
    SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE);
    if (requestedShape != null) {
      shape = requestedShape;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMinSize = (Dimension) hints.get(EncodeHintType.MIN_SIZE);
    if (requestedMinSize != null) {
      minSize = requestedMinSize;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMaxSize = (Dimension) hints.get(EncodeHintType.MAX_SIZE);
    if (requestedMaxSize != null) {
      maxSize = requestedMaxSize;
    }
  }


  //1. step: Data encodation
  String encoded = HighLevelEncoder.encodeHighLevel(contents, shape, minSize, maxSize);

  SymbolInfo symbolInfo = SymbolInfo.lookup(encoded.length(), shape, minSize, maxSize, true);

  //2. step: ECC generation
  String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo);

  //3. step: Module placement in Matrix
  DefaultPlacement placement =
      new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(), symbolInfo.getSymbolDataHeight());
  placement.place();

  //4. step: low-level encoding
  return encodeLowLevel(placement, symbolInfo);
}
项目:Cardstore    文件:DataMatrixWriter.java   
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {

  if (contents.isEmpty()) {
    throw new IllegalArgumentException("Found empty contents");
  }

  if (format != BarcodeFormat.DATA_MATRIX) {
    throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format);
  }

  if (width < 0 || height < 0) {
    throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
  }

  // Try to get force shape & min / max size
  SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
  Dimension minSize = null;
  Dimension maxSize = null;
  if (hints != null) {
    SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE);
    if (requestedShape != null) {
      shape = requestedShape;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMinSize = (Dimension) hints.get(EncodeHintType.MIN_SIZE);
    if (requestedMinSize != null) {
      minSize = requestedMinSize;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMaxSize = (Dimension) hints.get(EncodeHintType.MAX_SIZE);
    if (requestedMaxSize != null) {
      maxSize = requestedMaxSize;
    }
  }


  //1. step: Data encodation
  String encoded = HighLevelEncoder.encodeHighLevel(contents, shape, minSize, maxSize);

  SymbolInfo symbolInfo = SymbolInfo.lookup(encoded.length(), shape, minSize, maxSize, true);

  //2. step: ECC generation
  String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo);

  //3. step: Module placement in Matrix
  DefaultPlacement placement =
      new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(), symbolInfo.getSymbolDataHeight());
  placement.place();

  //4. step: low-level encoding
  return encodeLowLevel(placement, symbolInfo);
}
项目:QrScan_Demo    文件:DataMatrixWriter.java   
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {

  if (contents.isEmpty()) {
    throw new IllegalArgumentException("Found empty contents");
  }

  if (format != BarcodeFormat.DATA_MATRIX) {
    throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format);
  }

  if (width < 0 || height < 0) {
    throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
  }

  // Try to get force shape & min / max size
  SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
  Dimension minSize = null;
  Dimension maxSize = null;
  if (hints != null) {
    SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE);
    if (requestedShape != null) {
      shape = requestedShape;
    }
    Dimension requestedMinSize = (Dimension) hints.get(EncodeHintType.MIN_SIZE);
    if (requestedMinSize != null) {
      minSize = requestedMinSize;
    }
    Dimension requestedMaxSize = (Dimension) hints.get(EncodeHintType.MAX_SIZE);
    if (requestedMaxSize != null) {
      maxSize = requestedMaxSize;
    }
  }


  //1. step: Data encodation
  String encoded = HighLevelEncoder.encodeHighLevel(contents, shape, minSize, maxSize);

  SymbolInfo symbolInfo = SymbolInfo.lookup(encoded.length(), shape, minSize, maxSize, true);

  //2. step: ECC generation
  String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo);

  //3. step: Module placement in Matrix
  DefaultPlacement placement =
      new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(), symbolInfo.getSymbolDataHeight());
  placement.place();

  //4. step: low-level encoding
  return encodeLowLevel(placement, symbolInfo);
}
项目:weex    文件:DataMatrixWriter.java   
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {

  if (contents.isEmpty()) {
    throw new IllegalArgumentException("Found empty contents");
  }

  if (format != BarcodeFormat.DATA_MATRIX) {
    throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format);
  }

  if (width < 0 || height < 0) {
    throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
  }

  // Try to get force shape & min / max size
  SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
  Dimension minSize = null;
  Dimension maxSize = null;
  if (hints != null) {
    SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE);
    if (requestedShape != null) {
      shape = requestedShape;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMinSize = (Dimension) hints.get(EncodeHintType.MIN_SIZE);
    if (requestedMinSize != null) {
      minSize = requestedMinSize;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMaxSize = (Dimension) hints.get(EncodeHintType.MAX_SIZE);
    if (requestedMaxSize != null) {
      maxSize = requestedMaxSize;
    }
  }


  //1. step: Data encodation
  String encoded = HighLevelEncoder.encodeHighLevel(contents, shape, minSize, maxSize);

  SymbolInfo symbolInfo = SymbolInfo.lookup(encoded.length(), shape, minSize, maxSize, true);

  //2. step: ECC generation
  String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo);

  //3. step: Module placement in Matrix
  DefaultPlacement placement =
      new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(), symbolInfo.getSymbolDataHeight());
  placement.place();

  //4. step: low-level encoding
  return encodeLowLevel(placement, symbolInfo);
}
项目:TrueTone    文件:DataMatrixWriter.java   
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType, ?> hints) {

    if (contents.isEmpty()) {
        throw new IllegalArgumentException("Found empty contents");
    }

    if (format != BarcodeFormat.DATA_MATRIX) {
        throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format);
    }

    if (width < 0 || height < 0) {
        throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
    }

    // Try to get force shape & min / max size
    SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
    Dimension minSize = new Dimension(width, height);
    Dimension maxSize = null;
    if (hints != null) {
        SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE);
        if (requestedShape != null) {
            shape = requestedShape;
        }
        @SuppressWarnings("deprecated")
        Dimension requestedMinSize = (Dimension) hints.get(EncodeHintType.MIN_SIZE);
        if (requestedMinSize != null) {
            minSize = requestedMinSize;
        }
        @SuppressWarnings("deprecated")
        Dimension requestedMaxSize = (Dimension) hints.get(EncodeHintType.MAX_SIZE);
        if (requestedMaxSize != null) {
            maxSize = requestedMaxSize;
        }
    }


    //1. step: Data encodation
    String encoded = HighLevelEncoder.encodeHighLevel(contents, shape, minSize, maxSize);

    SymbolInfo symbolInfo = SymbolInfo.lookup(encoded.length(), shape, minSize, maxSize, true);

    //2. step: ECC generation
    String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo);

    //3. step: Module placement in Matrix
    DefaultPlacement placement =
            new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(), symbolInfo.getSymbolDataHeight());
    placement.place();

    //4. step: low-level encoding
    return encodeLowLevel(placement, symbolInfo);
}
项目:Discounty    文件:DataMatrixWriter.java   
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType, ?> hints) {

    if (contents.length() == 0) {
        throw new IllegalArgumentException("Found empty contents");
    }

    if (format != BarcodeFormat.DATA_MATRIX) {
        throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format);
    }

    if (width < 0 || height < 0) {
        throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
    }

    // Try to get force shape & min / max size
    SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
    Dimension minSize = null;
    Dimension maxSize = null;
    if (hints != null) {
        SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE);
        if (requestedShape != null) {
            shape = requestedShape;
        }
        Dimension requestedMinSize = (Dimension) hints.get(EncodeHintType.MIN_SIZE);
        if (requestedMinSize != null) {
            minSize = requestedMinSize;
        }
        Dimension requestedMaxSize = (Dimension) hints.get(EncodeHintType.MAX_SIZE);
        if (requestedMaxSize != null) {
            maxSize = requestedMaxSize;
        }
    }


    //1. step: Data encodation
    String encoded = HighLevelEncoder.encodeHighLevel(contents, shape, minSize, maxSize);

    SymbolInfo symbolInfo = SymbolInfo.lookup(encoded.length(), shape, minSize, maxSize, true);

    //2. step: ECC generation
    String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo);

    //3. step: Module placement in Matrix
    DefaultPlacement placement =
            new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(), symbolInfo.getSymbolDataHeight());
    placement.place();

    //4. step: low-level encoding
    return encodeLowLevel(placement, symbolInfo);
}
项目:bushido-android-app    文件:DataMatrixWriter.java   
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {

  if (contents.isEmpty()) {
    throw new IllegalArgumentException("Found empty contents");
  }

  if (format != BarcodeFormat.DATA_MATRIX) {
    throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format);
  }

  if (width < 0 || height < 0) {
    throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
  }

  // Try to get force shape & min / max size
  SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
  Dimension minSize = new Dimension(width, height);
  Dimension maxSize = null;
  if (hints != null) {
    SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE);
    if (requestedShape != null) {
      shape = requestedShape;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMinSize = (Dimension) hints.get(EncodeHintType.MIN_SIZE);
    if (requestedMinSize != null) {
      minSize = requestedMinSize;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMaxSize = (Dimension) hints.get(EncodeHintType.MAX_SIZE);
    if (requestedMaxSize != null) {
      maxSize = requestedMaxSize;
    }
  }


  //1. step: Data encodation
  String encoded = HighLevelEncoder.encodeHighLevel(contents, shape, minSize, maxSize);

  SymbolInfo symbolInfo = SymbolInfo.lookup(encoded.length(), shape, minSize, maxSize, true);

  //2. step: ECC generation
  String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo);

  //3. step: Module placement in Matrix
  DefaultPlacement placement =
      new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(), symbolInfo.getSymbolDataHeight());
  placement.place();

  //4. step: low-level encoding
  return encodeLowLevel(placement, symbolInfo);
}
项目:Android-Birdcopy-Application    文件:DataMatrixWriter.java   
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {

  if (contents.isEmpty()) {
    throw new IllegalArgumentException("Found empty contents");
  }

  if (format != BarcodeFormat.DATA_MATRIX) {
    throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format);
  }

  if (width < 0 || height < 0) {
    throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
  }

  // Try to get force shape & min / max size
  SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
  Dimension minSize = null;
  Dimension maxSize = null;
  if (hints != null) {
    SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE);
    if (requestedShape != null) {
      shape = requestedShape;
    }
    Dimension requestedMinSize = (Dimension) hints.get(EncodeHintType.MIN_SIZE);
    if (requestedMinSize != null) {
      minSize = requestedMinSize;
    }
    Dimension requestedMaxSize = (Dimension) hints.get(EncodeHintType.MAX_SIZE);
    if (requestedMaxSize != null) {
      maxSize = requestedMaxSize;
    }
  }


  //1. step: Data encodation
  String encoded = HighLevelEncoder.encodeHighLevel(contents, shape, minSize, maxSize);

  SymbolInfo symbolInfo = SymbolInfo.lookup(encoded.length(), shape, minSize, maxSize, true);

  //2. step: ECC generation
  String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo);

  //3. step: Module placement in Matrix
  DefaultPlacement placement =
      new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(), symbolInfo.getSymbolDataHeight());
  placement.place();

  //4. step: low-level encoding
  return encodeLowLevel(placement, symbolInfo);
}
项目:RipplePower    文件:DataMatrixWriter.java   
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height,
        Map<EncodeHintType, ?> hints) {

    if (contents.isEmpty()) {
        throw new IllegalArgumentException("Found empty contents");
    }

    if (format != BarcodeFormat.DATA_MATRIX) {
        throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format);
    }

    if (width < 0 || height < 0) {
        throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
    }

    // Try to get force shape & min / max size
    SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
    Dimension minSize = null;
    Dimension maxSize = null;
    if (hints != null) {
        SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE);
        if (requestedShape != null) {
            shape = requestedShape;
        }
        Dimension requestedMinSize = (Dimension) hints.get(EncodeHintType.MIN_SIZE);
        if (requestedMinSize != null) {
            minSize = requestedMinSize;
        }
        Dimension requestedMaxSize = (Dimension) hints.get(EncodeHintType.MAX_SIZE);
        if (requestedMaxSize != null) {
            maxSize = requestedMaxSize;
        }
    }

    // 1. step: Data encodation
    String encoded = HighLevelEncoder.encodeHighLevel(contents, shape, minSize, maxSize);

    SymbolInfo symbolInfo = SymbolInfo.lookup(encoded.length(), shape, minSize, maxSize, true);

    // 2. step: ECC generation
    String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo);

    // 3. step: Module placement in Matrix
    DefaultPlacement placement = new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(),
            symbolInfo.getSymbolDataHeight());
    placement.place();

    // 4. step: low-level encoding
    return encodeLowLevel(placement, symbolInfo);
}
项目:zxing-bsplus    文件:DataMatrixWriter.java   
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {

  if (contents.isEmpty()) {
    throw new IllegalArgumentException("Found empty contents");
  }

  if (format != BarcodeFormat.DATA_MATRIX) {
    throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format);
  }

  if (width < 0 || height < 0) {
    throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
  }

  // Try to get force shape & min / max size
  SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
  Dimension minSize = null;
  Dimension maxSize = null;
  if (hints != null) {
    SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE);
    if (requestedShape != null) {
      shape = requestedShape;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMinSize = (Dimension) hints.get(EncodeHintType.MIN_SIZE);
    if (requestedMinSize != null) {
      minSize = requestedMinSize;
    }
    @SuppressWarnings("deprecation")
    Dimension requestedMaxSize = (Dimension) hints.get(EncodeHintType.MAX_SIZE);
    if (requestedMaxSize != null) {
      maxSize = requestedMaxSize;
    }
  }


  //1. step: Data encodation
  String encoded = HighLevelEncoder.encodeHighLevel(contents, shape, minSize, maxSize);

  SymbolInfo symbolInfo = SymbolInfo.lookup(encoded.length(), shape, minSize, maxSize, true);

  //2. step: ECC generation
  String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo);

  //3. step: Module placement in Matrix
  DefaultPlacement placement =
      new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(), symbolInfo.getSymbolDataHeight());
  placement.place();

  //4. step: low-level encoding
  return encodeLowLevel(placement, symbolInfo);
}
项目:brigen-base    文件:ZxingBuilderImpl.java   
@Override
public SymbolShapeHint dataMatrixShape() {
    return dataMatrixShape;
}
项目:ZxingCore    文件:DataMatrixWriter.java   
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {

  if (contents.length() == 0) {
    throw new IllegalArgumentException("Found empty contents");
  }

  if (format != BarcodeFormat.DATA_MATRIX) {
    throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format);
  }

  if (width < 0 || height < 0) {
    throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
  }

  // Try to get force shape & min / max size
  SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
  Dimension minSize = null;
  Dimension maxSize = null;
  if (hints != null) {
    SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE);
    if (requestedShape != null) {
      shape = requestedShape;
    }
    Dimension requestedMinSize = (Dimension) hints.get(EncodeHintType.MIN_SIZE);
    if (requestedMinSize != null) {
      minSize = requestedMinSize;
    }
    Dimension requestedMaxSize = (Dimension) hints.get(EncodeHintType.MAX_SIZE);
    if (requestedMaxSize != null) {
      maxSize = requestedMaxSize;
    }
  }


  //1. step: Data encodation
  String encoded = HighLevelEncoder.encodeHighLevel(contents, shape, minSize, maxSize);

  SymbolInfo symbolInfo = SymbolInfo.lookup(encoded.length(), shape, minSize, maxSize, true);

  //2. step: ECC generation
  String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo);

  //3. step: Module placement in Matrix
  DefaultPlacement placement =
      new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(), symbolInfo.getSymbolDataHeight());
  placement.place();

  //4. step: low-level encoding
  return encodeLowLevel(placement, symbolInfo);
}