Class Code128Bean
java.lang.Object
org.krysalis.barcode4j.impl.AbstractBarcodeBean
org.krysalis.barcode4j.impl.code128.Code128Bean
- All Implemented Interfaces:
BarcodeGenerator
- Direct Known Subclasses:
EAN128Bean
This class is an implementation of the Code 128 barcode.
- Version:
- $Id: Code128Bean.java,v 1.9 2009-02-18 16:09:04 jmaerki Exp $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intDefault codeset.protected static final doubleThe default module width for Code 128.Fields inherited from class org.krysalis.barcode4j.impl.AbstractBarcodeBean
doQuietZone, fontName, fontSize, height, moduleWidth, msgPos, pattern, quietZone, quietZoneVertical -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncalcDimensions(String msg) Calculates the dimension of a barcode with the given message.voidgenerateBarcode(CanvasProvider canvas, String msg) Generates a barcode using the given Canvas to render the barcode to its output format.doublegetBarWidth(int width) Returns the effective width of a bar with a given logical width.intReturns the codeset to be used.protected booleanIndicates whether the barcode height calculation should take a font descender into account.voidsetCodeset(int codeset) Sets the codesets to use.Methods inherited from class org.krysalis.barcode4j.impl.AbstractBarcodeBean
doQuietZone, getBarHeight, getFontName, getFontSize, getHeight, getHumanReadableHeight, getModuleWidth, getMsgPosition, getPattern, getQuietZone, getVerticalQuietZone, hasQuietZone, setBarHeight, setFontName, setFontSize, setHeight, setModuleWidth, setMsgPosition, setPattern, setQuietZone, setVerticalQuietZone
-
Field Details
-
DEFAULT_MODULE_WIDTH
protected static final double DEFAULT_MODULE_WIDTHThe default module width for Code 128.- See Also:
-
DEFAULT_CODESET
protected static final int DEFAULT_CODESETDefault codeset.- See Also:
-
-
Constructor Details
-
Code128Bean
public Code128Bean()Create a new instance.
-
-
Method Details
-
getCodeset
public int getCodeset()Returns the codeset to be used.- Returns:
- the codeset (see
Code128Constants.CODESET_*)
-
setCodeset
public void setCodeset(int codeset) Sets the codesets to use. This can be used to restrict the Code 128 codesets if an application requires that.- Parameters:
codeset- the codesets to use (seeCode128Constants.CODESET_*)
-
hasFontDescender
protected boolean hasFontDescender()Indicates whether the barcode height calculation should take a font descender into account. This is necessary for barcodes that support lower-case characters like Code128.- Overrides:
hasFontDescenderin classAbstractBarcodeBean- Returns:
- true if the implementation has to take font descenders into account
-
getBarWidth
public double getBarWidth(int width) Returns the effective width of a bar with a given logical width.- Specified by:
getBarWidthin classAbstractBarcodeBean- Parameters:
width- the logical width (1=narrow, 2=wide)- Returns:
- the effective width of a bar (in mm)
-
generateBarcode
Generates a barcode using the given Canvas to render the barcode to its output format.- Specified by:
generateBarcodein interfaceBarcodeGenerator- Specified by:
generateBarcodein classAbstractBarcodeBean- Parameters:
canvas- CanvasProvider that the barcode is to be rendered on.msg- message to encode
-
calcDimensions
Calculates the dimension of a barcode with the given message. The dimensions are dependant on the configuration of the barcode generator.- Specified by:
calcDimensionsin interfaceBarcodeGenerator- Overrides:
calcDimensionsin classAbstractBarcodeBean- Parameters:
msg- message to use for calculation.- Returns:
- BarcodeDimension a BarcodeDimension object containing the barcode's dimensions
-