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,- Code93Writer,- ITFWriter,- UPCEANWriter
Encapsulates functionality and implementation that is common to one-dimensional barcodes.
- Author:
- dsbnatut@gmail.com (Kazuki Nishiura)
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected static intappendPattern(boolean[] target, int pos, int[] pattern, boolean startColor) protected static voidcheckNumeric(String contents) abstract boolean[]Encode the contents to boolean array expression of one-dimensional barcode.final BitMatrixencode(String contents, BarcodeFormat format, int width, int height) Encode a barcode using the default settings.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.intprotected Collection<BarcodeFormat>
- 
Constructor Details- 
OneDimensionalCodeWriterpublic OneDimensionalCodeWriter()
 
- 
- 
Method Details- 
encodeEncode 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)
 
- 
encodeCan be overwritten if the encode requires to read the hints map. Otherwise it defaults toencode.- Parameters:
- contents- barcode contents to encode
- hints- encoding hints
- Returns:
- a boolean[]of horizontal pixels (false = white, true = black)
 
- 
encodeDescription copied from interface:WriterEncode a barcode using the default settings.
- 
encodepublic BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType, ?> hints) 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 interface- Writer
- Parameters:
- 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
- Returns:
- BitMatrixrepresenting encoded barcode image
 
- 
getSupportedWriteFormats
- 
checkNumeric- Parameters:
- contents- string to check for numeric characters
- Throws:
- IllegalArgumentException- if input contains characters other than digits 0-9.
 
- 
appendPatternprotected static int appendPattern(boolean[] target, int pos, int[] pattern, boolean startColor) - Parameters:
- 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
- Returns:
- the number of elements added to target.
 
- 
getDefaultMarginpublic int getDefaultMargin()
 
-