Package se.digg.dgc.encoding.impl
Class DefaultBarcodeCreator
- java.lang.Object
-
- se.digg.dgc.encoding.impl.DefaultBarcodeCreator
-
- All Implemented Interfaces:
BarcodeCreator
public class DefaultBarcodeCreator extends Object implements BarcodeCreator
A bean implementing theBarcodeCreatorinterface 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 Summary
Fields Modifier and Type Field Description static Barcode.ImageFormatDEFAULT_IMAGE_FORMATThe default image format to use when creating barcodes.static Barcode.BarcodeTypeDEFAULT_TYPEThe default barcode type for this implementation is QR.static intDEFAULT_WIDTH_AND_HEIGHTThe default width and height to be used for the created barcodes.
-
Constructor Summary
Constructors Constructor Description DefaultBarcodeCreator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Barcodecreate(String contents)Creates a barcode containing the supplied contents.Barcodecreate(String contents, Charset characterSet)Creates a barcode containing the supplied contents which is a string of the given character set.voidsetImageFormat(Barcode.ImageFormat imageFormat)Sets the image format for barcodes created.voidsetType(Barcode.BarcodeType type)Sets the type of barcodes to create.voidsetWidthAndHeight(int widthAndHeight)Sets the width and height (in pixels) to use for creating barcodes.
-
-
-
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
-
-
Method Detail
-
create
public Barcode create(String contents) throws BarcodeException
Creates a barcode containing the supplied contents.- Specified by:
createin interfaceBarcodeCreator- Parameters:
contents- the contents- Returns:
- a Barcode
- Throws:
BarcodeException- for creation errors
-
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:
createin interfaceBarcodeCreator- Parameters:
contents- the contentscharacterSet- 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
-
-