Class DefaultBarcodeCreator

  • All Implemented Interfaces:
    BarcodeCreator

    public class DefaultBarcodeCreator
    extends Object
    implements BarcodeCreator
    A bean implementing the BarcodeCreator interface using the ZXing library.
    Author:
    Martin Lindström (martin@idsec.se), Henrik Bengtsson (extern.henrik.bengtsson@digg.se), Henric Norlander (extern.henric.norlander@digg.se)
    • Field Detail

      • DEFAULT_TYPE

        public static final Barcode.BarcodeType DEFAULT_TYPE
        The default barcode type for this implementation is QR.
      • DEFAULT_IMAGE_FORMAT

        public static final Barcode.ImageFormat DEFAULT_IMAGE_FORMAT
        The default image format to use when creating barcodes.
      • DEFAULT_WIDTH_AND_HEIGHT

        public static final int DEFAULT_WIDTH_AND_HEIGHT
        The default width and height to be used for the created barcodes.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultBarcodeCreator

        public DefaultBarcodeCreator()
    • Method Detail

      • create

        public Barcode create​(String contents,
                              Charset characterSet)
                       throws BarcodeException
        Creates a barcode containing the supplied contents which is a string of the given character set.
        Specified by:
        create in interface BarcodeCreator
        Parameters:
        contents - the contents
        characterSet - the character set
        Returns:
        a Barcode
        Throws:
        BarcodeException - for creation errors
      • setType

        public void setType​(Barcode.BarcodeType type)
        Sets the type of barcodes to create.

        is the default.

        Parameters:
        type - barcode type
      • setImageFormat

        public void setImageFormat​(Barcode.ImageFormat imageFormat)
        Sets the image format for barcodes created.

        is the default.

        Parameters:
        imageFormat - the image format
      • setWidthAndHeight

        public void setWidthAndHeight​(int widthAndHeight)
        Sets the width and height (in pixels) to use for creating barcodes.

        300 is the default.

        If 0 is supplied the smallest possible size will be choosen for the generated code.

        Parameters:
        widthAndHeight - the width/height