Package adams.data.barcode.encode
Class UPCA
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,SizeOfHandler
,Serializable
public class UPCA extends AbstractBarcodeEncoder
Draws a UPCA barcode at a specified location and size.Digits must be 11 (checksum gets calculated) or 12 (incl. checksum)
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-x <int> (property: x) X position of the top-left corner. default: 1 minimum: 1
-y <int> (property: y) Y position of the top-left corner. default: 1 minimum: 1
-width <int> (property: width) Width of the barcode in pixels. default: 100 minimum: 1
-height <int> (property: height) Height of the barcode in pixels. default: 100 minimum: 1
-margin <int> (property: margin) White margin surrounding the barcode. default: 5 minimum: 0
-digits <java.lang.String> (property: digits) Digits to be encoded. default: 012345678905
- Author:
- lx51 (lx51 at students dot waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String
m_Digits
Digits to be encoded.-
Fields inherited from class adams.data.barcode.encode.AbstractBarcodeEncoder
m_Height, m_Margin, m_Width, m_X, m_Y
-
Fields inherited from class adams.flow.transformer.draw.AbstractDrawOperation
m_Owner
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description UPCA()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
defineOptions()
Adds options to the internal list of options.String
digitsTipText()
Returns the tip text for this property.protected BufferedImageContainer
doEncode(String payload, BufferedImageContainer cont, MessageCollection errors)
Encodes the supplied payload.String
getDigits()
Returns the digits to be encoded in the QR code.protected String
getPayload()
Returns the payload to use for generating the barcode.String
globalInfo()
Returns a string describing the object.protected String
isValid(String payload)
Checks the given 12 digit code.void
setDigits(String value)
Sets the digits to be encoded in the QR code.-
Methods inherited from class adams.data.barcode.encode.AbstractBarcodeEncoder
check, doDraw, encode, encode, getHeight, getMargin, getWidth, getX, getY, heightTipText, marginTipText, newImage, setHeight, setMargin, setWidth, setX, setY, widthTipText, xTipText, yTipText
-
Methods inherited from class adams.flow.transformer.draw.AbstractDrawOperation
draw, getOwner, getQuickInfo, setOwner
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_Digits
protected String m_Digits
Digits to be encoded.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractBarcodeEncoder
-
getDigits
public String getDigits()
Returns the digits to be encoded in the QR code.- Returns:
- the digits
-
isValid
protected String isValid(String payload)
Checks the given 12 digit code. See also Universal Product Code.- Specified by:
isValid
in classAbstractBarcodeEncoder
- Parameters:
payload
- the code to check- Returns:
- null if valid, otherwise error message
-
setDigits
public void setDigits(String value)
Sets the digits to be encoded in the QR code.- Parameters:
value
- the digits
-
digitsTipText
public String digitsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getPayload
protected String getPayload()
Returns the payload to use for generating the barcode.- Specified by:
getPayload
in classAbstractBarcodeEncoder
- Returns:
- the payload
-
doEncode
protected BufferedImageContainer doEncode(String payload, BufferedImageContainer cont, MessageCollection errors)
Encodes the supplied payload.- Specified by:
doEncode
in classAbstractBarcodeEncoder
- Parameters:
payload
- the payload to encodecont
- the container to add the barcode; creates a new one if nullerrors
- for collecting error messages- Returns:
- the updated/generated container, null if failed to generate
-
-