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

public abstract class AbstractBarcodeBean extends 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 Details

    • 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 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 Double quietZoneVertical
      Height of the vertical quiet zone above and below the barcode in mm
    • pattern

      protected String pattern
      pattern to be applied over the human readable message
  • Constructor Details

    • AbstractBarcodeBean

      public AbstractBarcodeBean()
  • Method Details

    • getPattern

      public String getPattern()
      returns the pattern to be applied over the human readable message
      Returns:
      String
    • setPattern

      public void setPattern(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)
    • 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 if getQuietZone() 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

      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 String getFontName()
      Returns the font name of the human-readable part.
      Returns:
      the font name
    • setFontName

      public void setFontName(String name)
      Sets the font name of the human-readable part.
      Parameters:
      name - the font name
    • generateBarcode

      public abstract void generateBarcode(CanvasProvider canvas, 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(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