Package org.krysalis.barcode4j.impl
Class AbstractBarcodeBean
java.lang.Object
org.krysalis.barcode4j.impl.AbstractBarcodeBean
- All Implemented Interfaces:
BarcodeGenerator
- Direct Known Subclasses:
CodabarBean,Code128Bean,Code39Bean,DataMatrixBean,HeightVariableBarcodeBean,Interleaved2Of5Bean,PDF417Bean,QRCodeBean,UPCEANBean
Base class for most barcode implementations.
- Version:
- $Id: AbstractBarcodeBean.java,v 1.7 2008-05-13 13:00:45 jmaerki Exp $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanTrue if quiet zone should be renderedprotected StringFont nameprotected doubleFont size in mmprotected doubleNet height of bars in mmprotected doubleWidth of narrow module in mmprotected HumanReadablePlacementPosition of human-readable textprotected Stringpattern to be applied over the human readable messageprotected doubleWidth of the quiet zone left and right of the barcode in mmprotected DoubleHeight of the vertical quiet zone above and below the barcode in mm -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncalcDimensions(String msg) Calculates the dimension of a barcode with the given message.voiddoQuietZone(boolean value) Controls whether a quiet zone should be included or not.abstract voidgenerateBarcode(CanvasProvider canvas, String msg) Generates a barcode using the given Canvas to render the barcode to its output format.doubleReturns the height of the bars.abstract doublegetBarWidth(int width) Returns the effective width of a bar with a given logical width.Returns the font name of the human-readable part.doubleReturns the font size of the human-readable part.doubleReturns the full height of the barcode.doubleReturns the height of the human-readable part.doubleReturns the width of the narrow module.Returns the placement of the human-readable part.returns the pattern to be applied over the human readable messagedoubledoubleReturns the vertical quiet zone.protected booleanIndicates whether the barcode height calculation should take a font descender into account.booleanIndicates whether a quiet zone is included.voidsetBarHeight(double height) Sets the height of the bars.voidsetFontName(String name) Sets the font name of the human-readable part.voidsetFontSize(double size) Sets the font size of the human-readable part.voidsetHeight(double height) Sets the full height of the barcode.voidsetModuleWidth(double width) Sets the width of the narrow module.voidsetMsgPosition(HumanReadablePlacement placement) Sets the placement of the human-readable part.voidsetPattern(String v) Sets the pattern to be applied over the human readable messagevoidsetQuietZone(double width) Sets the width of the quiet zone.voidsetVerticalQuietZone(double height) Sets the height of the vertical quiet zone.
-
Field Details
-
height
protected double heightNet height of bars in mm -
moduleWidth
protected double moduleWidthWidth of narrow module in mm -
msgPos
Position of human-readable text -
fontSize
protected double fontSizeFont size in mm -
fontName
Font name -
doQuietZone
protected boolean doQuietZoneTrue if quiet zone should be rendered -
quietZone
protected double quietZoneWidth of the quiet zone left and right of the barcode in mm -
quietZoneVertical
Height of the vertical quiet zone above and below the barcode in mm -
pattern
pattern to be applied over the human readable message
-
-
Constructor Details
-
AbstractBarcodeBean
public AbstractBarcodeBean()
-
-
Method Details
-
getPattern
returns the pattern to be applied over the human readable message- Returns:
- String
-
setPattern
Sets the pattern to be applied over the human readable message- Parameters:
v- String
-
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.- Returns:
- true if the implementation has to take font descenders into account
-
getHumanReadableHeight
public double getHumanReadableHeight()Returns the height of the human-readable part.- Returns:
- the height of the human-readable part (in mm)
-
getBarHeight
public double getBarHeight()Returns the height of the bars.- Returns:
- the height of the bars (in mm)
-
setBarHeight
public void setBarHeight(double height) Sets the height of the bars.- Parameters:
height- the height of the bars (in mm)
-
getHeight
public double getHeight()Returns the full height of the barcode.- Returns:
- the full height (in mm)
-
setHeight
public void setHeight(double height) Sets the full height of the barcode.- Parameters:
height- the full height (in mm)
-
getModuleWidth
public double getModuleWidth()Returns the width of the narrow module.- Returns:
- the width of the narrow module (in mm)
-
setModuleWidth
public void setModuleWidth(double width) Sets the width of the narrow module.- Parameters:
width- the width of the narrow module (in mm)
-
getBarWidth
public abstract double getBarWidth(int width) Returns the effective width of a bar with a given logical width.- Parameters:
width- the logical width (1=narrow, 2=wide)- Returns:
- the effective width of a bar (in mm)
-
hasQuietZone
public boolean hasQuietZone()Indicates whether a quiet zone is included.- Returns:
- true if a quiet zone is included
-
doQuietZone
public void doQuietZone(boolean value) Controls whether a quiet zone should be included or not.- Parameters:
value- true if a quiet zone should be included
-
getQuietZone
public double getQuietZone()- Returns:
- the width of the quiet zone (in mm)
-
setQuietZone
public void setQuietZone(double width) Sets the width of the quiet zone.- Parameters:
width- the width of the quiet zone (in mm)
-
getVerticalQuietZone
public double getVerticalQuietZone()Returns the vertical quiet zone. If no vertical quiet zone is set explicitely, the value ifgetQuietZone()is returned.- Returns:
- the height of the vertical quiet zone (in mm)
-
setVerticalQuietZone
public void setVerticalQuietZone(double height) Sets the height of the vertical quiet zone. If this value is not explicitely set the vertical quiet zone has the same width as the horizontal quiet zone.- Parameters:
height- the height of the vertical quiet zone (in mm)
-
getMsgPosition
Returns the placement of the human-readable part.- Returns:
- the placement of the human-readable part
-
setMsgPosition
Sets the placement of the human-readable part.- Parameters:
placement- the placement of the human-readable part
-
getFontSize
public double getFontSize()Returns the font size of the human-readable part.- Returns:
- the font size
-
setFontSize
public void setFontSize(double size) Sets the font size of the human-readable part.- Parameters:
size- the font size
-
getFontName
Returns the font name of the human-readable part.- Returns:
- the font name
-
setFontName
Sets the font name of the human-readable part.- Parameters:
name- the font name
-
generateBarcode
Generates a barcode using the given Canvas to render the barcode to its output format.- Specified by:
generateBarcodein interfaceBarcodeGenerator- 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- Parameters:
msg- message to use for calculation.- Returns:
- BarcodeDimension a BarcodeDimension object containing the barcode's dimensions
-