barcode4j 2.1.0

org.krysalis.barcode4j.impl
Class AbstractBarcodeBean

java.lang.Object
  extended by org.krysalis.barcode4j.impl.AbstractBarcodeBean
All Implemented Interfaces:
BarcodeGenerator
Direct Known Subclasses:
CodabarBean, Code128Bean, Code39Bean, DataMatrixBean, HeightVariableBarcodeBean, Interleaved2Of5Bean, PDF417Bean, QRCodeBean, UPCEANBean

public abstract class AbstractBarcodeBean
extends java.lang.Object
implements BarcodeGenerator

Base class for most barcode implementations.

Version:
$Id: AbstractBarcodeBean.java,v 1.7 2008/05/13 13:00:45 jmaerki Exp $

Field Summary
protected  boolean doQuietZone
          True if quiet zone should be rendered
protected  java.lang.String fontName
          Font name
protected  double fontSize
          Font size in mm
protected  double height
          Net height of bars in mm
protected  double moduleWidth
          Width of narrow module in mm
protected  HumanReadablePlacement msgPos
          Position of human-readable text
protected  java.lang.String pattern
          pattern to be applied over the human readable message
protected  double quietZone
          Width of the quiet zone left and right of the barcode in mm
protected  java.lang.Double quietZoneVertical
          Height of the vertical quiet zone above and below the barcode in mm
 
Constructor Summary
AbstractBarcodeBean()
           
 
Method Summary
 BarcodeDimension calcDimensions(java.lang.String msg)
          Calculates the dimension of a barcode with the given message.
 void doQuietZone(boolean value)
          Controls whether a quiet zone should be included or not.
abstract  void generateBarcode(CanvasProvider canvas, java.lang.String msg)
          Generates a barcode using the given Canvas to render the barcode to its output format.
 double getBarHeight()
          Returns the height of the bars.
abstract  double getBarWidth(int width)
          Returns the effective width of a bar with a given logical width.
 java.lang.String getFontName()
          Returns the font name of the human-readable part.
 double getFontSize()
          Returns the font size of the human-readable part.
 double getHeight()
          Returns the full height of the barcode.
 double getHumanReadableHeight()
          Returns the height of the human-readable part.
 double getModuleWidth()
          Returns the width of the narrow module.
 HumanReadablePlacement getMsgPosition()
          Returns the placement of the human-readable part.
 java.lang.String getPattern()
          returns the pattern to be applied over the human readable message
 double getQuietZone()
           
 double getVerticalQuietZone()
          Returns the vertical quiet zone.
protected  boolean hasFontDescender()
          Indicates whether the barcode height calculation should take a font descender into account.
 boolean hasQuietZone()
          Indicates whether a quiet zone is included.
 void setBarHeight(double height)
          Sets the height of the bars.
 void setFontName(java.lang.String name)
          Sets the font name of the human-readable part.
 void setFontSize(double size)
          Sets the font size of the human-readable part.
 void setHeight(double height)
          Sets the full height of the barcode.
 void setModuleWidth(double width)
          Sets the width of the narrow module.
 void setMsgPosition(HumanReadablePlacement placement)
          Sets the placement of the human-readable part.
 void setPattern(java.lang.String v)
          Sets the pattern to be applied over the human readable message
 void setQuietZone(double width)
          Sets the width of the quiet zone.
 void setVerticalQuietZone(double height)
          Sets the height of the vertical quiet zone.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

height

protected double height
Net height of bars in mm


moduleWidth

protected double moduleWidth
Width of narrow module in mm


msgPos

protected HumanReadablePlacement msgPos
Position of human-readable text


fontSize

protected double fontSize
Font size in mm


fontName

protected java.lang.String fontName
Font name


doQuietZone

protected boolean doQuietZone
True if quiet zone should be rendered


quietZone

protected double quietZone
Width of the quiet zone left and right of the barcode in mm


quietZoneVertical

protected java.lang.Double quietZoneVertical
Height of the vertical quiet zone above and below the barcode in mm


pattern

protected java.lang.String pattern
pattern to be applied over the human readable message

Constructor Detail

AbstractBarcodeBean

public AbstractBarcodeBean()
Method Detail

getPattern

public java.lang.String getPattern()
returns the pattern to be applied over the human readable message

Returns:
String

setPattern

public void setPattern(java.lang.String v)
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)

getHeight

public double getHeight()
Returns the full height of the barcode.

Returns:
the full height (in mm)

setBarHeight

public void setBarHeight(double height)
Sets the height of the bars.

Parameters:
height - the height of the bars (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)

getVerticalQuietZone

public double getVerticalQuietZone()
Returns the vertical quiet zone. If no vertical quiet zone is set explicitely, the value if getQuietZone() is returned.

Returns:
the height of the vertical 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)

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

public HumanReadablePlacement getMsgPosition()
Returns the placement of the human-readable part.

Returns:
the placement of the human-readable part

setMsgPosition

public void setMsgPosition(HumanReadablePlacement placement)
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

public java.lang.String getFontName()
Returns the font name of the human-readable part.

Returns:
the font name

setFontName

public void setFontName(java.lang.String name)
Sets the font name of the human-readable part.

Parameters:
name - the font name

generateBarcode

public abstract void generateBarcode(CanvasProvider canvas,
                                     java.lang.String msg)
Generates a barcode using the given Canvas to render the barcode to its output format.

Specified by:
generateBarcode in interface BarcodeGenerator
Parameters:
canvas - CanvasProvider that the barcode is to be rendered on.
msg - message to encode

calcDimensions

public BarcodeDimension calcDimensions(java.lang.String msg)
Calculates the dimension of a barcode with the given message. The dimensions are dependant on the configuration of the barcode generator.

Specified by:
calcDimensions in interface BarcodeGenerator
Parameters:
msg - message to use for calculation.
Returns:
BarcodeDimension a BarcodeDimension object containing the barcode's dimensions

barcode4j 2.1.0

Copyright © 2000-2010 Jeremias Maerki. All rights reserved.