public abstract class OneDimensionalCodeWriter extends Objectimplements Writer
Encapsulates functionality and implementation that is common to one-dimensional barcodes.
| Constructor and Description |
|---|
OneDimensionalCodeWriter()
|
| Modifier and Type | Method and Description |
|---|---|
protected static int |
appendPattern(boolean[] target, int pos, int[] pattern, boolean startColor)
|
abstract boolean[] |
encode(String
Encode the contents to boolean array expression of one-dimensional barcode.
|
BitMatrix |
encode(String
Encode a barcode using the default settings.
|
BitMatrix |
encode(String
Encode the contents following specified format.
|
int |
getDefaultMargin()
|
public final BitMatrixencode(String contents, BarcodeFormat format, int width, int height) throws WriterException
Writer
encode in interface
Writer
contents - The contents to encode in the barcode
format - The barcode format to generate
width - The preferred width in pixels
height - The preferred height in pixels
BitMatrix representing encoded barcode image
WriterException - if contents cannot be encoded legally in a format
public BitMatrixencode(String contents, BarcodeFormat format, int width, int height, Map <EncodeHintType ,?> hints) throws WriterException
width and
height are required size. This method may return bigger size
BitMatrix when specified size is too small. The user can set both
width and
height to zero to get minimum size barcode. If negative value is set to
width or
height,
IllegalArgumentException is thrown.
encode in interface
Writer
contents - The contents to encode in the barcode
format - The barcode format to generate
width - The preferred width in pixels
height - The preferred height in pixels
hints - Additional parameters to supply to the encoder
BitMatrix representing encoded barcode image
WriterException - if contents cannot be encoded legally in a format
protected static int appendPattern(boolean[] target,
int pos,
int[] pattern,
boolean startColor)
target - encode black/white pattern into this array
pos - position to start encoding at in
target
pattern - lengths of black/white runs to encode
startColor - starting color - false for white, true for black
public int getDefaultMargin()
public abstract boolean[] encode(Stringcontents)
contents - barcode contents to encode
boolean[] of horizontal pixels (false = white, true = black)