com.jrefinery.report.ext.barcode
Class BarcodeEAN

java.lang.Object
  |
  +--com.jrefinery.report.ext.barcode.Barcode
        |
        +--com.jrefinery.report.ext.barcode.BarcodeEAN
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
BarcodeEAN13, BarcodeEAN8, BarcodeSUPP2, BarcodeSUPP5, BarcodeUPCE

public abstract class BarcodeEAN
extends Barcode

Generates barcodes in several formats: EAN13, EAN8, UPCA, UPCE, supplemental 2 and 5. The default parameters are:

x = 0.8f;
font = BaseFont.createFont("Helvetica", "winansi", false);
size = 8;
baseline = size;
barHeight = size * 3;
guardBars = true;
codeType = EAN13;
code = "";
 

Author:
Paulo Soares (psoares@consiste.pt)

Field Summary
protected static byte[][] BARS
          The basic bar widths.
protected static int EVEN
          Marker for even parity.
protected static int[] GUARD_EMPTY
          The bar positions that are guard bars.
protected static int ODD
          Marker for odd parity.
 
Fields inherited from class com.jrefinery.report.ext.barcode.Barcode
DEFAULT_FONT
 
Constructor Summary
BarcodeEAN()
          Creates new BarcodeEAN
 
Method Summary
protected static int calculateEANParity(java.lang.String code)
          Calculates the EAN parity character.
 java.awt.Image createImageWithBarcode(java.awt.Color barColor, java.awt.Color textColor)
          Creates an Image with the barcode.
protected abstract  void drawCode(java.awt.Graphics2D g2, float keepBarX, float textStartY)
           
 java.awt.geom.Dimension2D getBarcodeSize()
          Gets the maximum area that the barcode and the text, if any, will occupy.
protected abstract  byte[] getBars()
           
protected abstract  int[] getGuardBarPositions()
           
protected abstract  float getWidth()
           
 boolean isGuardBars()
          Gets the property to show the guard bars for barcode EAN.
protected  boolean isTextBased()
           
 void setGuardBars(boolean guardBars)
          Sets the property to show the guard bars for barcode EAN.
 
Methods inherited from class com.jrefinery.report.ext.barcode.Barcode
clone, getBarHeight, getBaseline, getCode, getFont, getFontAscent, getFontDescent, getMinWidth, getTextAlignment, isDisplayChecksumText, isGenerateChecksum, setBarHeight, setBaseline, setCode, setDisplayChecksumText, setFont, setGenerateChecksum, setMinWidth, setTextAlignment
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GUARD_EMPTY

protected static int[] GUARD_EMPTY
The bar positions that are guard bars.


BARS

protected static byte[][] BARS
The basic bar widths.


ODD

protected static final int ODD
Marker for odd parity.

See Also:
Constant Field Values

EVEN

protected static final int EVEN
Marker for even parity.

See Also:
Constant Field Values
Constructor Detail

BarcodeEAN

public BarcodeEAN()
Creates new BarcodeEAN

Method Detail

getBars

protected abstract byte[] getBars()

isGuardBars

public boolean isGuardBars()
Gets the property to show the guard bars for barcode EAN.

Returns:
value of property guardBars

setGuardBars

public void setGuardBars(boolean guardBars)
Sets the property to show the guard bars for barcode EAN.

Parameters:
guardBars - new value of property guardBars

calculateEANParity

protected static int calculateEANParity(java.lang.String code)
Calculates the EAN parity character.

Parameters:
code - the code
Returns:
the parity character

getWidth

protected abstract float getWidth()

getBarcodeSize

public java.awt.geom.Dimension2D getBarcodeSize()
Gets the maximum area that the barcode and the text, if any, will occupy. The lower left corner is always (0, 0).

Specified by:
getBarcodeSize in class Barcode
Returns:
the size the barcode occupies.

isTextBased

protected boolean isTextBased()

getGuardBarPositions

protected abstract int[] getGuardBarPositions()

drawCode

protected abstract void drawCode(java.awt.Graphics2D g2,
                                 float keepBarX,
                                 float textStartY)

createImageWithBarcode

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

Specified by:
createImageWithBarcode in class 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