com.jrefinery.report.ext.barcode
Class Barcode

java.lang.Object
  |
  +--com.jrefinery.report.ext.barcode.Barcode
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
Barcode128, Barcode39, BarcodeEAN, BarcodeEANSUPP, BarcodeInter25, BarcodePostnet

public abstract class Barcode
extends java.lang.Object
implements java.lang.Cloneable

Base class containing properties and methods commom to all barcode types.

Author:
Paulo Soares (psoares@consiste.pt)

Field Summary
static com.jrefinery.report.targets.FontDefinition DEFAULT_FONT
          A type of barcode
 
Constructor Summary
Barcode()
           
 
Method Summary
 java.lang.Object clone()
           
abstract  java.awt.Image createImageWithBarcode(java.awt.Color barColor, java.awt.Color textColor)
          Creates an Image with the barcode.
abstract  java.awt.geom.Dimension2D getBarcodeSize()
          Gets the maximum area that the barcode and the text, if any, will occupy.
 float getBarHeight()
          Gets the height of the bars.
 float getBaseline()
          Gets the text baseline.
 java.lang.String getCode()
          Gets the code to generate.
 com.jrefinery.report.targets.FontDefinition getFont()
          Gets the text font.
protected  float getFontAscent(java.awt.Font font)
           
protected  float getFontDescent(java.awt.Font font)
           
 float getMinWidth()
          Gets the minimum bar width.
 com.jrefinery.report.ElementAlignment getTextAlignment()
          Gets the text alignment.
 boolean isDisplayChecksumText()
          Gets the property to show the generated checksum in the the text.
 boolean isGenerateChecksum()
          Gets the optional checksum generation.
 void setBarHeight(float barHeight)
          Sets the height of the bars.
 void setBaseline(float baseline)
          Sets the text baseline.
 void setCode(java.lang.String code)
          Sets the code to generate.
 void setDisplayChecksumText(boolean checksumText)
          Sets the property to show the generated checksum in the the text.
 void setFont(com.jrefinery.report.targets.FontDefinition font)
          Sets the text font.
 void setGenerateChecksum(boolean generateChecksum)
          Setter for property generateChecksum.
 void setMinWidth(float minWidth)
          Sets the minimum bar width.
 void setTextAlignment(com.jrefinery.report.ElementAlignment textAlignment)
          Sets the text alignment.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FONT

public static final com.jrefinery.report.targets.FontDefinition DEFAULT_FONT
A type of barcode

Constructor Detail

Barcode

public Barcode()
Method Detail

getMinWidth

public float getMinWidth()
Gets the minimum bar width.

Returns:
the minimum bar width

setMinWidth

public void setMinWidth(float minWidth)
Sets the minimum bar width.

Parameters:
minWidth - the minimum bar width

getFont

public com.jrefinery.report.targets.FontDefinition getFont()
Gets the text font. null if no text.

Returns:
the text font. null if no text

setFont

public void setFont(com.jrefinery.report.targets.FontDefinition font)
Sets the text font. null if no text.

Parameters:
font - the text font. null if no text

getBaseline

public float getBaseline()
Gets the text baseline. If positive, the text distance under the bars. If zero or negative, the text distance above the bars.

Returns:
the baseline.

setBaseline

public void setBaseline(float baseline)
Sets the text baseline. If positive, the text distance under the bars. If zero or negative, the text distance above the bars.

Parameters:
baseline - the baseline.

getBarHeight

public float getBarHeight()
Gets the height of the bars.

Returns:
the height of the bars

setBarHeight

public void setBarHeight(float barHeight)
Sets the height of the bars.

Parameters:
barHeight - the height of the bars

getTextAlignment

public com.jrefinery.report.ElementAlignment getTextAlignment()
Gets the text alignment. Can be Element.ALIGN_LEFT, Element.ALIGN_CENTER or Element.ALIGN_RIGHT.

Returns:
the text alignment

setTextAlignment

public void setTextAlignment(com.jrefinery.report.ElementAlignment textAlignment)
Sets the text alignment. Can be Element.ALIGN_LEFT, Element.ALIGN_CENTER or Element.ALIGN_RIGHT.

Parameters:
textAlignment - the text alignment

isGenerateChecksum

public boolean isGenerateChecksum()
Gets the optional checksum generation.

Returns:
the optional checksum generation

setGenerateChecksum

public void setGenerateChecksum(boolean generateChecksum)
Setter for property generateChecksum.

Parameters:
generateChecksum - New value of property generateChecksum.

isDisplayChecksumText

public boolean isDisplayChecksumText()
Gets the property to show the generated checksum in the the text.

Returns:
value of property checksumText

setDisplayChecksumText

public void setDisplayChecksumText(boolean checksumText)
Sets the property to show the generated checksum in the the text.

Parameters:
checksumText - new value of property checksumText

getCode

public java.lang.String getCode()
Gets the code to generate.

Returns:
the code to generate

setCode

public void setCode(java.lang.String code)
Sets the code to generate.

Parameters:
code - the code to generate

getBarcodeSize

public abstract java.awt.geom.Dimension2D getBarcodeSize()
Gets the maximum area that the barcode and the text, if any, will occupy.

Returns:
the size the barcode occupies.

createImageWithBarcode

public abstract java.awt.Image createImageWithBarcode(java.awt.Color barColor,
                                                      java.awt.Color textColor)
Creates an Image with the barcode.

Parameters:
barColor - the color of the bars. It can be null
textColor - the color of the text. It can be null
Returns:
the Image

getFontDescent

protected float getFontDescent(java.awt.Font font)

getFontAscent

protected float getFontAscent(java.awt.Font font)

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
java.lang.CloneNotSupportedException