public abstract class OneDimensionalCodeWriter extends Object implements 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) |
protected static void |
checkNumeric(String contents) |
abstract boolean[] |
encode(String contents)
Encode the contents to boolean array expression of one-dimensional barcode.
|
BitMatrix |
encode(String contents,
BarcodeFormat format,
int width,
int height)
Encode a barcode using the default settings.
|
BitMatrix |
encode(String contents,
BarcodeFormat format,
int width,
int height,
Map<EncodeHintType,?> hints)
Encode the contents following specified format.
|
boolean[] |
encode(String contents,
Map<EncodeHintType,?> hints)
Can be overwritten if the encode requires to read the hints map.
|
int |
getDefaultMargin() |
protected Collection<BarcodeFormat> |
getSupportedWriteFormats() |
public abstract boolean[] encode(String contents)
contents
- barcode contents to encodeboolean[]
of horizontal pixels (false = white, true = black)public boolean[] encode(String contents, Map<EncodeHintType,?> hints)
encode
.contents
- barcode contents to encodehints
- encoding hintsboolean[]
of horizontal pixels (false = white, true = black)public final BitMatrix encode(String contents, BarcodeFormat format, int width, int height)
Writer
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints)
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 barcodeformat
- The barcode format to generatewidth
- The preferred width in pixelsheight
- The preferred height in pixelshints
- Additional parameters to supply to the encoderBitMatrix
representing encoded barcode imageprotected Collection<BarcodeFormat> getSupportedWriteFormats()
protected static void checkNumeric(String contents)
contents
- string to check for numeric charactersIllegalArgumentException
- if input contains characters other than digits 0-9.protected static int appendPattern(boolean[] target, int pos, int[] pattern, boolean startColor)
target
- encode black/white pattern into this arraypos
- position to start encoding at in target
pattern
- lengths of black/white runs to encodestartColor
- starting color - false for white, true for blackpublic int getDefaultMargin()
Copyright © 2007–2024. All rights reserved.