com.lowagie.text.pdf
Class BarcodeEAN128

java.lang.Object
  extended bycom.lowagie.text.pdf.Barcode
      extended bycom.lowagie.text.pdf.Barcode128
          extended bycom.lowagie.text.pdf.BarcodeEAN128

public class BarcodeEAN128
extends Barcode128

Implements the UCC/EAN-128 in C mode with multiple parts in code.

The code is numeric only (which is correct in C) with FNC1 char to separate data if the Application Identifier supports variable data. The default parameters are:

 x = 0.8f;
 font = BaseFont.createFont("Helvetica", "winansi", false);
 size = 8;
 baseline = size;
 barHeight = size * 3;
 textAlignment = Element.ALIGN_CENTER;
 codeType = CODE128_UCC; (not used)
 

Author:
Emmanuel Hugonnet (emmanuel.hugonnet.at.illicom.com), Olivier Albrecht (albrecht.at.illicom.com)

Nested Class Summary
static class BarcodeEAN128.IdentifierEAN
           
 
Field Summary
private  StringBuffer bCode
           
private  int checksum
           
static IntHashtable codesB
           
private  String codeText
           
static HashMap ids
           
private  int ponderation
           
 
Fields inherited from class com.lowagie.text.pdf.Barcode128
BARS, BARS_STOP, CODE_A, CODE_AB_TO_C, CODE_AC_TO_B, CODE_BC_TO_A, CODE_C, DEL, FNC1, FNC1_INDEX, FNC2, FNC3, FNC4, SHIFT, START_A, START_B, START_C, STARTA, STARTB, STARTC
 
Fields inherited from class com.lowagie.text.pdf.Barcode
barHeight, baseline, checksumText, CODABAR, code, CODE128, CODE128_RAW, CODE128_UCC, codeType, EAN13, EAN8, extended, font, generateChecksum, guardBars, inkSpreading, n, PLANET, POSTNET, size, startStopText, SUPP2, SUPP5, textAlignment, UPCA, UPCE, x
 
Constructor Summary
BarcodeEAN128()
          Creates a new instance of BarcodeEAN128
 
Method Summary
 Rectangle getBarcodeSize()
          Gets the maximum area that the barcode and the text, if any, will occupy.
 Rectangle getBarcodeSize(float fullWidth)
          Gets the maximum area that the barcode and the text, if any, will occupy.
private  byte[] getBarsArray(LinkedList barres)
          Put the bytes describing the bars of the barcode in a single array.
protected  byte[] getBarsCode(String bloc)
          Compute the bars corresponding to a bloc of data.
 byte[] getBarsEAN128(String text)
          DOCUMENT ME!
protected  String getBloc(String texte, int index)
          Find the next bloc of data to be encoded.
 Rectangle placeBarcode(PdfContentByte cb, Color barColor, Color textColor)
          Places the barcode in a PdfContentByte.
 
Methods inherited from class com.lowagie.text.pdf.Barcode128
createAwtImage, getBarsCode128Raw, getPackedRawDigits, getRawText, isNextDigits
 
Methods inherited from class com.lowagie.text.pdf.Barcode
createImageWithBarcode, createTemplateWithBarcode, getBarHeight, getBaseline, getCode, getCodeType, getFont, getInkSpreading, getN, getSize, getTextAlignment, getX, isChecksumText, isExtended, isGenerateChecksum, isGuardBars, isStartStopText, setBarHeight, setBaseline, setChecksumText, setCode, setCodeType, setExtended, setFont, setGenerateChecksum, setGuardBars, setInkSpreading, setN, setSize, setStartStopText, setTextAlignment, setX
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ids

public static HashMap ids

codesB

public static IntHashtable codesB

codeText

private String codeText

bCode

private StringBuffer bCode

checksum

private int checksum

ponderation

private int ponderation
Constructor Detail

BarcodeEAN128

public BarcodeEAN128()
Creates a new instance of BarcodeEAN128

Throws:
ExceptionConverter - when the conversion is not possible.
Method Detail

getBarcodeSize

public Rectangle getBarcodeSize(float fullWidth)
Gets the maximum area that the barcode and the text, if any, will occupy. The lower left corner is always (0, 0).

Returns:
the size the barcode occupies.

getBarsEAN128

public byte[] getBarsEAN128(String text)
DOCUMENT ME!

Parameters:
text - DOCUMENT ME!
Returns:
DOCUMENT ME!

placeBarcode

public Rectangle placeBarcode(PdfContentByte cb,
                              Color barColor,
                              Color textColor)
Places the barcode in a PdfContentByte. The barcode is always placed at coodinates (0, 0). Use the translation matrix to move it elsewhere.

The bars and text are written in the following colors:

Overrides:
placeBarcode in class Barcode128
Parameters:
cb - the PdfContentByte where the barcode will be placed
barColor - the color of the bars. It can be null
textColor - the color of the text. It can be null
Returns:
the dimensions the barcode occupies

getBarsCode

protected byte[] getBarsCode(String bloc)
Compute the bars corresponding to a bloc of data.

Parameters:
bloc - : A bloc of data with its A.I. and its separator if there's one.
Returns:
the bars of the bloc

getBloc

protected String getBloc(String texte,
                         int index)
Find the next bloc of data to be encoded. The bloc is found by its A.I. and then computed by its length or with FNC1 as separator.

Parameters:
texte - the Data to be encoded.
index - the Index where the bloc starts.
Returns:
DOCUMENT ME!

getBarsArray

private byte[] getBarsArray(LinkedList barres)
Put the bytes describing the bars of the barcode in a single array.

Parameters:
barres - The list of bars which compose the barcode.
Returns:
a byte array which describes all the bars in the barcode.

getBarcodeSize

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

Overrides:
getBarcodeSize in class Barcode128
Returns:
the size the barcode occupies.