Package com.google.zxing.oned
Class OneDimensionalCodeWriter
- java.lang.Object
-
- com.google.zxing.oned.OneDimensionalCodeWriter
-
- All Implemented Interfaces:
Writer
- Direct Known Subclasses:
CodaBarWriter,Code128Writer,Code39Writer,ITFWriter,UPCEANWriter
public abstract class OneDimensionalCodeWriter extends java.lang.Object implements Writer
Encapsulates functionality and implementation that is common to one-dimensional barcodes.
-
-
Constructor Summary
Constructors Constructor Description OneDimensionalCodeWriter()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static intappendPattern(boolean[] target, int pos, int[] pattern, boolean startColor)abstract boolean[]encode(java.lang.String contents)Encode the contents to boolean array expression of one-dimensional barcode.BitMatrixencode(java.lang.String contents, BarcodeFormat format, int width, int height)Encode a barcode using the default settings.BitMatrixencode(java.lang.String contents, BarcodeFormat format, int width, int height, java.util.Map<EncodeHintType,?> hints)Encode the contents following specified format.intgetDefaultMargin()
-
-
-
Method Detail
-
encode
public final BitMatrix encode(java.lang.String contents, BarcodeFormat format, int width, int height) throws WriterException
Description copied from interface:WriterEncode a barcode using the default settings.- Specified by:
encodein interfaceWriter- Parameters:
contents- The contents to encode in the barcodeformat- The barcode format to generatewidth- The preferred width in pixelsheight- The preferred height in pixels- Returns:
BitMatrixrepresenting encoded barcode image- Throws:
WriterException- if contents cannot be encoded legally in a format
-
encode
public BitMatrix encode(java.lang.String contents, BarcodeFormat format, int width, int height, java.util.Map<EncodeHintType,?> hints) throws WriterException
Encode the contents following specified format.widthandheightare required size. This method may return bigger sizeBitMatrixwhen specified size is too small. The user can set bothwidthandheightto zero to get minimum size barcode. If negative value is set towidthorheight,IllegalArgumentExceptionis thrown.- Specified by:
encodein interfaceWriter- Parameters:
contents- The contents to encode in the barcodeformat- The barcode format to generatewidth- The preferred width in pixelsheight- The preferred height in pixelshints- Additional parameters to supply to the encoder- Returns:
BitMatrixrepresenting encoded barcode image- Throws:
WriterException- if contents cannot be encoded legally in a format
-
appendPattern
protected static int appendPattern(boolean[] target, int pos, int[] pattern, boolean startColor)- Parameters:
target- encode black/white pattern into this arraypos- position to start encoding at intargetpattern- lengths of black/white runs to encodestartColor- starting color - false for white, true for black- Returns:
- the number of elements added to target.
-
getDefaultMargin
public int getDefaultMargin()
-
encode
public abstract boolean[] encode(java.lang.String contents)
Encode the contents to boolean array expression of one-dimensional barcode. Start code and end code should be included in result, and side margins should not be included.- Parameters:
contents- barcode contents to encode- Returns:
- a
boolean[]of horizontal pixels (false = white, true = black)
-
-