Package totalcross.barcode
Class Barcode128
- java.lang.Object
-
- totalcross.barcode.Barcode
-
- totalcross.barcode.Barcode128
-
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:
- CODE128 - plain barcode 128.
- CODE128_UCC - support for UCC/EAN-128.
- CODE128_RAW - raw mode. The code attribute has the actual codes from 0 to 105 followed by '\uffff' and the human readable text.
x = 1f; font = new Font("Helvetica",Font.PLAIN,20)); textAlignment = ALIGN_CENTER; codeType = CODE128; transparent = true; shotText = true quietZone = true; quietZoneX = 10;This class is based on iText "A Free Java-PDF library by Bruno Lowagie and Paulo Soares" using the Mozilla Public License(MPL)
-
-
Field Summary
Fields Modifier and Type Field Description static charCODE_AB_TO_CThe charset code change.static charCODE_AC_TO_BThe charset code change.static charCODE_BC_TO_AThe charset code change.static charFNC1The code for UCC/EAN-128.static charSTART_AThe start code.static charSTART_BThe start code.static charSTART_CThe start code.-
Fields inherited from class totalcross.barcode.Barcode
ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, backgroundColor, barHeight, checksumText, CODABAR, code, CODE128, CODE128_RAW, CODE128_UCC, CODE93, codeType, EAN13, EAN8, extended, font, generateChecksum, guardBars, n, PLANET, POSTNET, quietZone, quietZoneX, showText, size, startStopText, SUPP2, SUPP5, textAlignment, transparent, TYPE_CODE128, TYPE_CODE93, TYPE_INTERLEAVED2OF5, UPCA, UPCE, x
-
-
Constructor Summary
Constructors Constructor Description Barcode128()Creates new Barcode128
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetBarcodeWidth()Gets the maximum width that the barcode will occupy.static byte[]getBarsCode128Raw(java.lang.String text)Generates the bars.static java.lang.StringgetRawText(java.lang.String text, boolean ucc)Converts the human readable text to the characters needed to create a barcode.voidplaceBarcode(Image i, int barColor, int textColor)Places the barcode in a BufferedImage.-
Methods inherited from class totalcross.barcode.Barcode
createImage, createImage, getBackgroundColor, getBarHeight, getCode, getCodeType, getFont, getFontName, getFontSize, getN, getQuietZoneX, getSize, getTextAlignment, getX, isChecksumText, isExtended, isGenerateChecksum, isGuardBars, isQuietZone, isShowText, isStartStopText, isTransparent, scale, setBackgroundColor, setBarHeight, setChecksumText, setCode, setCodeType, setExtended, setFont, setFontName, setFontSize, setFontStyle, setGenerateChecksum, setGuardBars, setN, setQuietZone, setQuietZoneX, setShowText, setSize, setStartStopText, setTextAlignment, setTransparent, setX
-
-
-
-
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
-
-
Method Detail
-
getBarcodeWidth
public int getBarcodeWidth()
Gets the maximum width that the barcode will occupy. The lower left corner is always (0, 0).- Specified by:
getBarcodeWidthin classBarcode- Returns:
- the size the barcode occupies.
-
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
-
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 convertucc-trueif it is an UCC/EAN-128. In this case the character FNC1 is added- Returns:
- the code ready to be fed to getBarsCode128Raw()
-
placeBarcode
public void placeBarcode(Image i, int barColor, int textColor)
Places the barcode in a BufferedImage. The The bars and text are written in the following colors:barColortextColorResult
nullnullbars and text painted with current fill color
barColornullbars and text painted with
barColornulltextColorbars painted with current color
text painted withtextColorbarColortextColorbars painted with
barColor
text painted withtextColor- Specified by:
placeBarcodein classBarcode- Parameters:
i- theImagewhere the barcode will be placedbarColor- the color of the bars. It can be-1textColor- the color of the text. It can be-1
-
-