Class 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.
    The default parameters are:
     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)
    • Constructor Detail

      • Barcode128

        public Barcode128()
        Creates new Barcode128
    • 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:
        getBarcodeWidth in class Barcode
        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 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()
      • 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:

        barColor

        textColor

        Result

        null

        null

        bars and text painted with current fill color

        barColor

        null

        bars and text painted with barColor

        null

        textColor

        bars painted with current color
        text painted with textColor

        barColor

        textColor

        bars painted with barColor
        text painted with textColor

        Specified by:
        placeBarcode in class Barcode
        Parameters:
        i - the Image where the barcode will be placed
        barColor - the color of the bars. It can be -1
        textColor - the color of the text. It can be -1