com.idautomation.datamatrix
Class DataMatrix

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Canvas
          extended bycom.idautomation.datamatrix.DataMatrix
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class DataMatrix
extends java.awt.Canvas
implements java.io.Serializable

This is the main DataMatrix class that generates the DataMatrix barcode image.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 boolean autoSize
          If true, will automatically size the control canvas to fit the barcode at design or runtime; Default =True.
 java.awt.Color backColor
          Background color.
 java.awt.Color barColor
          Color of the modules.
protected  int barHeightPixels
           
static int C104X104
           
static int C10X10
           
static int C120X120
           
static int C12X12
           
static int C12X26
           
static int C12X36
           
static int C132X132
           
static int C144X144
           
static int C14X14
           
static int C16X16
           
static int C16X36
           
static int C16X48
           
static int C18X18
           
static int C20X20
           
static int C22X22
           
static int C24X24
           
static int C26X26
           
static int C32X32
           
static int C36X36
           
static int C40X40
           
static int C44X44
           
static int C48X48
           
static int C52X52
           
static int C64X64
           
static int C72X72
           
static int C80X80
           
static int C88X88
           
static int C8X18
           
static int C8X32
           
static int C96X96
           
 java.lang.String code
          Data to be encoded in a Data Matrix symbol.
protected  int currentX
          Current position of painting cursor.
protected  int currentY
           
protected static int d1
           
static int E_ASCII
           
static int E_AUTO
           
static int E_BASE256
           
static int E_C40
           
static int E_NONE
           
static int E_TEXT
           
 int encoding
          The encoding mode; valid values are E_ASCII (default), E_C40, E_TEXT or E_BASE256.
 int height
          Initial preferred height property of the bean
 double leftMarginCM
          The left margin of the barcode (also know as quiet zone); The default is .06 CM.
protected  int leftMarginPixels
           
 double marginCM
          Margin of the Barcode (also know as quiet zone).
 double N
          multiple value for width bars - should be 2.
protected  double narrowBarCM
           
protected  int narrowBarPixels
           
 int pHeight
          The preferred height of the barcode image in pixels after barcode is generated.
 int preferredFormat
          The preferred format represented by a number; valid values are from 0 (10X10) to 23 (144X144) and from 24 (8X18) to 29 (16X48); The default value is -1 which sets this to automatic; this is also documented in the user manual.
 boolean processTilde
          If true, ("Y") the tilde (~) will be processed as explained in the Data Matrix user guide.
 int pWidth
          The preferred width of the barcode image in pixels after barcode is generated.
 boolean reBuild
           
 int resolution
          The resolution used to create the X dimension and other measurements in pixels; Default is 38 Pixels Per CM which is about 96 DPI.
 int rotate
          Rotation angle; valid values are 0 (default), 90, 180 & 270.
 double topMarginCM
          The top margin of the barcode (also know as quiet zone); The default is .06 CM.
protected  int topMarginPixels
           
 int width
          Initial preferred width property of the bean
protected  double widthBarCM
           
protected  int widthBarPixels
           
 double X
          The size in CM of modules, default is .06; usually adjustable in increments of .03CM because (X * resolution) is used to convert to pixels; use setPixelsPerCM to change; if X * resolution = < 1, X will be set to one pixel.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DataMatrix()
           
 
Method Summary
protected  void addBar(java.awt.Graphics g, int w, boolean black, int bartopmargin)
          Adds a module to the data matrix symbol at the currentX position.
protected  void calculateSizes()
          Converts size in CM to pixels
 boolean getAutoSize()
          Gets the autoSize property.
 java.awt.Color getBackground()
          Gets the backColor property.
 java.lang.String getDataToEncode()
          Gets the code property.
 int getEncodingMode()
          Gets the encoding property.
 java.awt.Color getForeground()
          Gets the barColor property.
 double getLeftMarginCM()
          Gets the leftMarginCM property.
 double getMarginCM()
          Gets the marginCM property.
 java.awt.Dimension getMinimumSize()
          Gets the minimum size in pixels of the barcode image generated.
 int getPixelsPerCM()
          Gets the resolution property.
 int getPreferredFormat()
          Gets the preferredFormat property.
 java.awt.Dimension getPreferredSize()
          Gets the size in pixels of the Preferred barcode image generated.
 boolean getProcessTilde()
          Gets the processTilde property.
 int getRotationAngle()
          Gets the rotate property.
 double getTopMarginCM()
          Gets the topMarginCM property.
 double getXDimensionCM()
          Gets the X property.
 void paint(java.awt.Graphics g2)
          Paints the barcode and rotates it if necessary
protected  void paintBasis(java.awt.Graphics g)
           
protected  void paintChar(java.awt.Graphics g, java.lang.String patternColor, java.lang.String patternBars)
          Paints a character
protected  void paintChar2(java.awt.Graphics g, java.lang.String patternColor, java.lang.String patternBars, int bartopmargin)
          Paints a character
protected  java.awt.Image rotate(java.awt.Image im, int angle, int maxw, int maxh)
          Rotates an image
 void setAutoSize(boolean newVal)
          Sets the autoSize property.
 void setBackground(java.awt.Color newColor)
          Sets the backColor property.
 void setDataToEncode(java.lang.String newCode)
          Sets the code property.
 void setEncodingMode(int newMode)
          Sets the encoding property.
 void setForeground(java.awt.Color newColor)
          Sets the barColor property.
 void setImageSize(int imgWidth, int imgHeight)
          Sets the size of the generated image, if used then autoSize is set to false.
 void setLeftMarginCM(double newMargin)
          Sets the leftMarginCM property.
 void setMarginCM(double newMargin)
          Sets the marginCM property.
 void setPixelsPerCM(int newRes)
          Sets the resolution property.
 void setPreferredFormat(int newFormat)
          Sets the preferredFormat property.
 void setProcessTilde(boolean newVal)
          Sets the processTilde property.
 void setRotationAngle(int newRotate)
          Sets the rotate property.
 void setTopMarginCM(double newMargin)
          Sets the topMarginCM property.
 void setXDimensionCM(double newX)
          Sets the X property.
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, update
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

code

public java.lang.String code
Data to be encoded in a Data Matrix symbol.

See Also:
setDataToEncode(String newCode), getDataToEncode(), User Manual

d1

protected static final int d1
See Also:
Constant Field Values

marginCM

public double marginCM
Margin of the Barcode (also know as quiet zone). The default is .06 CM

See Also:
setMarginCM(double newMargin), getMarginCM(), User Manual

topMarginCM

public double topMarginCM
The top margin of the barcode (also know as quiet zone); The default is .06 CM.

See Also:
setTopMarginCM(double newMargin), getTopMarginCM(), User Manual

leftMarginCM

public double leftMarginCM
The left margin of the barcode (also know as quiet zone); The default is .06 CM.

See Also:
setLeftMarginCM(double newMargin), getLeftMarginCM(), User Manual

leftMarginPixels

protected int leftMarginPixels

topMarginPixels

protected int topMarginPixels

backColor

public java.awt.Color backColor
Background color.

See Also:
setBackground(Color newColor), getBackground(), User Manual

narrowBarPixels

protected int narrowBarPixels

widthBarPixels

protected int widthBarPixels

narrowBarCM

protected double narrowBarCM

widthBarCM

protected double widthBarCM

resolution

public int resolution
The resolution used to create the X dimension and other measurements in pixels; Default is 38 Pixels Per CM which is about 96 DPI. 96 DPI is the resolution of the web browser; this setting works best when using the servlet. Enter 118 to create a 300 DPI image.

See Also:
setPixelsPerCM(int newRes), getPixelsPerCM(), User Manual

barHeightPixels

protected int barHeightPixels

N

public double N
multiple value for width bars - should be 2.


X

public double X
The size in CM of modules, default is .06; usually adjustable in increments of .03CM because (X * resolution) is used to convert to pixels; use setPixelsPerCM to change; if X * resolution = < 1, X will be set to one pixel.

See Also:
setXDimensionCM(double newX), getXDimensionCM(), User Manual

width

public int width
Initial preferred width property of the bean


height

public int height
Initial preferred height property of the bean


pWidth

public int pWidth
The preferred width of the barcode image in pixels after barcode is generated.

See Also:
getPreferredSize(), User Manual

pHeight

public int pHeight
The preferred height of the barcode image in pixels after barcode is generated.

See Also:
getPreferredSize(), User Manual

autoSize

public boolean autoSize
If true, will automatically size the control canvas to fit the barcode at design or runtime; Default =True.

See Also:
setAutoSize(boolean newVal), getAutoSize(), User Manual

barColor

public java.awt.Color barColor
Color of the modules.

See Also:
setForeground(Color newColor), getForeground(), User Manual

rotate

public int rotate
Rotation angle; valid values are 0 (default), 90, 180 & 270.

See Also:
setRotationAngle(int newRotate), getRotationAngle(), User Manual

currentX

protected int currentX
Current position of painting cursor.


currentY

protected int currentY

processTilde

public boolean processTilde
If true, ("Y") the tilde (~) will be processed as explained in the Data Matrix user guide. If not, it will be treated as a normal character; Default =False.

See Also:
setProcessTilde(boolean newVal), getProcessTilde(), User Manual

E_AUTO

public static int E_AUTO

E_ASCII

public static int E_ASCII

E_C40

public static int E_C40

E_TEXT

public static int E_TEXT

E_BASE256

public static int E_BASE256

E_NONE

public static int E_NONE

encoding

public int encoding
The encoding mode; valid values are E_ASCII (default), E_C40, E_TEXT or E_BASE256.

See Also:
setEncodingMode(int newMode), getEncodingMode(), User Manual

reBuild

public boolean reBuild

preferredFormat

public int preferredFormat
The preferred format represented by a number; valid values are from 0 (10X10) to 23 (144X144) and from 24 (8X18) to 29 (16X48); The default value is -1 which sets this to automatic; this is also documented in the user manual.

See Also:
setPreferredFormat(int newFormat), getPreferredFormat(), User Manual

C10X10

public static final int C10X10
See Also:
Constant Field Values

C12X12

public static final int C12X12
See Also:
Constant Field Values

C14X14

public static final int C14X14
See Also:
Constant Field Values

C16X16

public static final int C16X16
See Also:
Constant Field Values

C18X18

public static final int C18X18
See Also:
Constant Field Values

C20X20

public static final int C20X20
See Also:
Constant Field Values

C22X22

public static final int C22X22
See Also:
Constant Field Values

C24X24

public static final int C24X24
See Also:
Constant Field Values

C26X26

public static final int C26X26
See Also:
Constant Field Values

C32X32

public static final int C32X32
See Also:
Constant Field Values

C36X36

public static final int C36X36
See Also:
Constant Field Values

C40X40

public static final int C40X40
See Also:
Constant Field Values

C44X44

public static final int C44X44
See Also:
Constant Field Values

C48X48

public static final int C48X48
See Also:
Constant Field Values

C52X52

public static final int C52X52
See Also:
Constant Field Values

C64X64

public static final int C64X64
See Also:
Constant Field Values

C72X72

public static final int C72X72
See Also:
Constant Field Values

C80X80

public static final int C80X80
See Also:
Constant Field Values

C88X88

public static final int C88X88
See Also:
Constant Field Values

C96X96

public static final int C96X96
See Also:
Constant Field Values

C104X104

public static final int C104X104
See Also:
Constant Field Values

C120X120

public static final int C120X120
See Also:
Constant Field Values

C132X132

public static final int C132X132
See Also:
Constant Field Values

C144X144

public static final int C144X144
See Also:
Constant Field Values

C8X18

public static final int C8X18
See Also:
Constant Field Values

C8X32

public static final int C8X32
See Also:
Constant Field Values

C12X26

public static final int C12X26
See Also:
Constant Field Values

C12X36

public static final int C12X36
See Also:
Constant Field Values

C16X36

public static final int C16X36
See Also:
Constant Field Values

C16X48

public static final int C16X48
See Also:
Constant Field Values
Constructor Detail

DataMatrix

public DataMatrix()
Method Detail

setDataToEncode

public void setDataToEncode(java.lang.String newCode)
Sets the code property.

Parameters:
newCode - the new value for the code variable.
See Also:
code, User Manual

getDataToEncode

public java.lang.String getDataToEncode()
Gets the code property.

Returns:
the current value of the code variable.
See Also:
code, User Manual

setMarginCM

public void setMarginCM(double newMargin)
Sets the marginCM property.

Parameters:
newMargin - the new value for the marginCM variable.
See Also:
marginCM, User Manual

getMarginCM

public double getMarginCM()
Gets the marginCM property.

Returns:
the current value of the marginCM variable.
See Also:
marginCM, User Manual

setTopMarginCM

public void setTopMarginCM(double newMargin)
Sets the topMarginCM property.

Parameters:
newMargin - the new value for the topMarginCM variable.
See Also:
topMarginCM, User Manual

getTopMarginCM

public double getTopMarginCM()
Gets the topMarginCM property.

Returns:
the current value of the topMarginCM variable.
See Also:
topMarginCM, User Manual

setLeftMarginCM

public void setLeftMarginCM(double newMargin)
Sets the leftMarginCM property.

Parameters:
newMargin - the new value for the leftMarginCM variable.
See Also:
leftMarginCM, User Manual

getLeftMarginCM

public double getLeftMarginCM()
Gets the leftMarginCM property.

Returns:
the current value of the leftMarginCM variable.
See Also:
leftMarginCM, User Manual

setBackground

public void setBackground(java.awt.Color newColor)
Sets the backColor property.

Parameters:
newColor - the new value for the backColor variable.
See Also:
backColor, User Manual

getBackground

public java.awt.Color getBackground()
Gets the backColor property.

Returns:
the current value of the backColor variable.
See Also:
backColor, User Manual

setPixelsPerCM

public void setPixelsPerCM(int newRes)
Sets the resolution property.

Parameters:
newRes - the new value for the resolution variable.
See Also:
resolution, User Manual

getPixelsPerCM

public int getPixelsPerCM()
Gets the resolution property.

Returns:
the current value of the resolution variable.
See Also:
resolution, User Manual

setXDimensionCM

public void setXDimensionCM(double newX)
Sets the X property.

Parameters:
newX - the new value for the X variable.
See Also:
X, User Manual

getXDimensionCM

public double getXDimensionCM()
Gets the X property.

Returns:
the current value of the X variable.
See Also:
X, User Manual

setAutoSize

public void setAutoSize(boolean newVal)
Sets the autoSize property.

Parameters:
newVal - the new value for the autoSize variable.
See Also:
autoSize, User Manual

getAutoSize

public boolean getAutoSize()
Gets the autoSize property.

Returns:
the current value of the autoSize variable.
See Also:
autoSize, User Manual

setImageSize

public void setImageSize(int imgWidth,
                         int imgHeight)
Sets the size of the generated image, if used then autoSize is set to false.

See Also:
User Manual

getPreferredSize

public java.awt.Dimension getPreferredSize()
Gets the size in pixels of the Preferred barcode image generated.

Returns:
Dimension(pWidth,pHeight)
See Also:
pWidth, pHeight, User Manual

getMinimumSize

public java.awt.Dimension getMinimumSize()
Gets the minimum size in pixels of the barcode image generated.

Returns:
Dimension(8,8)
See Also:
User Manual

setForeground

public void setForeground(java.awt.Color newColor)
Sets the barColor property.

Parameters:
newColor - the new value for the barColor variable.
See Also:
barColor, User Manual

getForeground

public java.awt.Color getForeground()
Gets the barColor property.

Returns:
the current value of the barColor variable.
See Also:
barColor, User Manual

setRotationAngle

public void setRotationAngle(int newRotate)
Sets the rotate property.

Parameters:
newRotate - the new value for the rotate variable.
See Also:
rotate, User Manual

getRotationAngle

public int getRotationAngle()
Gets the rotate property.

Returns:
the current value of the rotate variable.
See Also:
rotate, User Manual

setProcessTilde

public void setProcessTilde(boolean newVal)
Sets the processTilde property.

Parameters:
newVal - the new value for the processTilde variable.
See Also:
processTilde, User Manual

getProcessTilde

public boolean getProcessTilde()
Gets the processTilde property.

Returns:
the current value of the processTilde variable.
See Also:
processTilde, User Manual

setEncodingMode

public void setEncodingMode(int newMode)
Sets the encoding property.

Parameters:
newMode - the new value for the encoding variable.
See Also:
encoding, User Manual

getEncodingMode

public int getEncodingMode()
Gets the encoding property.

Returns:
the current value of the encoding variable.
See Also:
encoding, User Manual

setPreferredFormat

public void setPreferredFormat(int newFormat)
Sets the preferredFormat property.

Parameters:
newFormat - the new value for the preferredFormat variable.
See Also:
preferredFormat, User Manual

getPreferredFormat

public int getPreferredFormat()
Gets the preferredFormat property.

Returns:
the current value of the preferredFormat variable.
See Also:
preferredFormat, User Manual

paintBasis

protected void paintBasis(java.awt.Graphics g)

addBar

protected void addBar(java.awt.Graphics g,
                      int w,
                      boolean black,
                      int bartopmargin)
Adds a module to the data matrix symbol at the currentX position.


paintChar

protected void paintChar(java.awt.Graphics g,
                         java.lang.String patternColor,
                         java.lang.String patternBars)
Paints a character


paintChar2

protected void paintChar2(java.awt.Graphics g,
                          java.lang.String patternColor,
                          java.lang.String patternBars,
                          int bartopmargin)
Paints a character


calculateSizes

protected void calculateSizes()
Converts size in CM to pixels


paint

public void paint(java.awt.Graphics g2)
Paints the barcode and rotates it if necessary


rotate

protected java.awt.Image rotate(java.awt.Image im,
                                int angle,
                                int maxw,
                                int maxh)
Rotates an image