com.jrefinery.report.ext.barcode
Class Barcode128

java.lang.Object
  |
  +--com.jrefinery.report.ext.barcode.Barcode
        |
        +--com.jrefinery.report.ext.barcode.Barcode128
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
Barcode128Raw

public class Barcode128
extends Barcode

Implements the code 128 and UCC/EAN-128. Other symbologies are allowed in raw mode.

The code types allowed are:

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;
 

Author:
Paulo Soares (psoares@consiste.pt)

Field Summary
static char CODE_AB_TO_C
          The charset code change.
static char CODE_AC_TO_B
          The charset code change.
static char CODE_BC_TO_A
          The charset code change.
static char FNC1
          The code for UCC/EAN-128.
static char START_A
          The start code.
static char START_B
          The start code.
static char START_C
          The start code.
 
Fields inherited from class com.jrefinery.report.ext.barcode.Barcode
DEFAULT_FONT
 
Constructor Summary
Barcode128()
          Creates new Barcode128
 
Method Summary
 java.awt.Image createImageWithBarcode(java.awt.Color barColor, java.awt.Color textColor)
          Creates an Image with the barcode.
 java.awt.geom.Dimension2D getBarcodeSize()
          Gets the maximum area that the barcode and the text, if any, will occupy.
static byte[] getBarsCode128Raw(java.lang.String text)
          Generates the bars.
 java.lang.String getRawText()
           
static java.lang.String getRawText(java.lang.String text, boolean ucc)
          Converts the human readable text to the characters needed to create a barcode.
 java.lang.String getStrippedCode()
           
 boolean isUccCode()
           
 void setUccCode(boolean ucc)
           
 
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

CODE_AB_TO_C

public static final char CODE_AB_TO_C
The charset code change.

See Also:
Constant Field Values

CODE_AC_TO_B

public static final char CODE_AC_TO_B
The charset code change.

See Also:
Constant Field Values

CODE_BC_TO_A

public static final char CODE_BC_TO_A
The charset code change.

See Also:
Constant Field Values

FNC1

public static final char FNC1
The code for UCC/EAN-128.

See Also:
Constant Field Values

START_A

public static final char START_A
The start code.

See Also:
Constant Field Values

START_B

public static final char START_B
The start code.

See Also:
Constant Field Values

START_C

public static final char START_C
The start code.

See Also:
Constant Field Values
Constructor Detail

Barcode128

public Barcode128()
Creates new Barcode128

Method Detail

isUccCode

public boolean isUccCode()

setUccCode

public void setUccCode(boolean ucc)

getRawText

public static java.lang.String getRawText(java.lang.String text,
                                          boolean ucc)
Converts the human readable text to the characters needed to create a barcode. Some optimization is done to get the shortest code.

Parameters:
text - the text to convert
ucc - true if it is an UCC/EAN-128. In this case the character FNC1 is added
Returns:
the code ready to be fed to getBarsCode128Raw()

getBarsCode128Raw

public static byte[] getBarsCode128Raw(java.lang.String text)
Generates the bars. The input has the actual barcodes, not the human readable text.

Parameters:
text - the barcode
Returns:
the bars

getStrippedCode

public java.lang.String getStrippedCode()

getRawText

public java.lang.String getRawText()

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.

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