Back to Zxing

Class OneDimensionalCodeWriter

docs/apidocs/com/google/zxing/oned/OneDimensionalCodeWriter.html

latest6.1 KB
Original Source

Package com.google.zxing.oned

Class OneDimensionalCodeWriter

java.lang.Object com.google.zxing.oned.OneDimensionalCodeWriter

All Implemented Interfaces:WriterDirect Known Subclasses:CodaBarWriter, Code128Writer, Code39Writer, Code93Writer, ITFWriter, UPCEANWriter


public abstract class OneDimensionalCodeWriterextends Object implements Writer

Encapsulates functionality and implementation that is common to one-dimensional barcodes.

Author:[email protected] (Kazuki Nishiura)

Constructor Summary

Constructors

Constructor

Description

OneDimensionalCodeWriter()

Method Summary

All MethodsStatic MethodsInstance MethodsAbstract MethodsConcrete Methods

Modifier and Type

Method

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.

final 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()

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

OneDimensionalCodeWriter

public OneDimensionalCodeWriter()

Method Details

encode

public abstract boolean[] encode(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 encodeReturns:a boolean[] of horizontal pixels (false = white, true = black)

encode

public boolean[] encode(String contents, Map<EncodeHintType,?> hints)

Can be overwritten if the encode requires to read the hints map. Otherwise it defaults to encode. Parameters:contents - barcode contents to encodehints - encoding hintsReturns:a boolean[] of horizontal pixels (false = white, true = black)

encode

public final BitMatrix encode(String contents, BarcodeFormat format, int width, int height)

Description copied from interface: Writer

Encode a barcode using the default settings. Specified by:encode in interface WriterParameters:contents - The contents to encode in the barcodeformat - The barcode format to generatewidth - The preferred width in pixelsheight - The preferred height in pixelsReturns:BitMatrix representing encoded barcode image

encode

public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints)

Encode the contents following specified format. 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. Specified by:encode in interface WriterParameters: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 encoderReturns:BitMatrix representing encoded barcode image

getSupportedWriteFormats

protected Collection<BarcodeFormat> getSupportedWriteFormats()

checkNumeric

protected static void checkNumeric(String contents) Parameters:contents - string to check for numeric charactersThrows:IllegalArgumentException - if input contains characters other than digits 0-9.

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 in target``pattern - lengths of black/white runs to encodestartColor - starting color - false for white, true for blackReturns:the number of elements added to target.

getDefaultMargin

public int getDefaultMargin()