类com.google.zxing.datamatrix.encoder.HighLevelEncoder源码实例Demo

下面列出了怎么用com.google.zxing.datamatrix.encoder.HighLevelEncoder的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: 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);
}
 

@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);
}
 
源代码3 项目: 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);
}
 

@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);
}
 
源代码5 项目: 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);
}
 
 类所在包
 类方法
 同包方法