com.java4less.rss
Class BarCode

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--com.java4less.rss.BarCode
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
RSS

public class BarCode
extends java.awt.Canvas

Class used to create EAN and UPC barcodes with or without 2D component. This is a canvas object where the barcode will be painted. Example of use:

   BarCode r=new BarCode();
   r.setSymbology(r.EAN128);
   r.setCode("0193812345678901");
   r.setHumanReadableCode("(01)93812345678901");
   // create a composite barcode
   r.setEAN128WithCCC(true);
   r.setSecondaryCode("10ABCD123456#4103898765432108");
   r.setSize(300,300);
   new ImageEncoder(r,"JPEG","c:\\barcode.jpg");
  

See Also:
Serialized Form

Field Summary
static int EAN128
           
static int EAN13
           
static int EAN8
           
 double H
          height of bars.
 int L
          Symbol lentgh as multiplier of X.
static int RSS14
           
static int RSSEXPANDED
           
static int RSSLIMITED
           
static int UPCA
           
static int UPCE
           
 
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
BarCode()
           
 
Method Summary
 void barHeight2D(int h)
          bar height of the 2D component
 java.awt.Color getBackColor()
          background color.
 java.awt.Color getBarColor()
          color of the bars.
 int getBarHeight()
          bar height in pixels.
 int getBarHeight2D()
          bar height of the 2D component
 java.lang.String getBarType()
          gets the symbology as String, valid values are EAN13, EAN8, UPCA, UPCE and EAN128
 int getCCCColumns()
          number of columns for the CC-C symbol when used with EAN128.
 java.lang.String getCode()
          text to be painted as barcode.
 boolean getEAN128WithCCC()
          if true the EAN128 will be linked to a CCC barcode, otherwise to a CC-A or CC-B
 boolean getEANUPCPrintFlag()
          print first digit of the encoded value
 java.awt.Color getFontColor()
          color of the human readable text.
 boolean getGuardBars()
          if true (default), guardbars in EAN and UPC codes will be longer than data bars.
 double getH()
          height of bars.
 java.lang.String getHumanReadableCode()
          human readable version of the text to be painted as barcode.
 int getLeftMargin()
          left margin of the barcode (also know as quite zone).
 java.lang.String getName()
          Returns name of the component
 boolean getProcessTilde()
          process ~ in code?
 int getRotate()
          rotation angle.
 java.lang.String getSecondaryCode()
          text to be painted as 2D component in the barcode.
 double getSupHeight()
          height of the supplement.
 java.lang.String getSuplement()
          supplement for EAN or UPC barcode
 int getSupSeparation()
          Separation in pixels between the barcode and the supplement
 int getSymbology()
          symbology to be used, EAN13, EAN8, UPCE, UPCA or EAN128
 java.awt.Font getTextFont()
          font of the text.
 int getTopMargin()
          top margin of the barcode (also know as quite zone).
 boolean getUPCEANSupplement2()
          2 digit supplement for EAN or UPC codes.
 boolean getUPCEANSupplement5()
          5 digit supplement for EAN or UPC codes.
 java.lang.String getUPCESytem()
          system to be used in UPCE.
 int getX()
          size in pixels of modules (narrow bars or spaces).
 void paint(java.awt.Graphics g2)
          paints the barcode and rotates it if necessary
 void setBackColor(java.awt.Color c)
          background color.
 void setBarColor(java.awt.Color c)
          color of the bars.
 void setBarHeight(int d)
          bar height in pixels.
 void setBarType(java.lang.String t)
          sets the symbology as String, valid values are EAN13, EAN8, UPCA, UPCE and EAN128
 void setCCCColumns(int c)
          number of columns for the CC-C symbol when used with EAN128.
 void setCode(java.lang.String c)
          text to be painted as barcode.
 void setEAN128WithCCC(boolean b)
          if true the EAN128 will be linked to a CCC barcode, otherwise to a CC-A or CC-B
 void setEANUPCPrintFlag(boolean b)
          print first digit of the encoded value
 void setFontColor(java.awt.Color c)
          color of the human readable text.
 void setGuardBars(boolean b)
          if true (default), guardbars in EAN and UPC codes will be longer than data bars.
 void setH(double d)
          height of bars.
 void setHumanReadableCode(java.lang.String c)
          human readable version of the text to be painted as barcode.
 void setLeftMargin(int d)
           
 void setProcessTilde(boolean pt)
          process ~ in code?
 void setRotate(int i)
          rotation angle.
 void setSecondaryCode(java.lang.String c)
          text to be painted as 2D component in the barcode.
 void setSupHeight(double d)
          height of the supplement.
 void setSuplement(java.lang.String c)
           
 void setSupSeparation(int d)
          Separation in pixels between the barcode and the supplement
 void setSymbology(int c)
          symbology to be used, EAN13, EAN8, UPCE, UPCA or EAN128
 void setTextFont(java.awt.Font f)
          font of the text.
 void setTopMargin(int d)
          top margin of the barcode (also know as quite zone).
 void setUPCEANSupplement2(boolean b)
          2 digit supplement for EAN or UPC codes.
 void setUPCEANSupplement5(boolean b)
          5 digit supplement for EAN or UPC codes.
 void setUPCESytem(java.lang.String d)
          system to be used in UPCE.
 void setX(int d)
           
 
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, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, dispatchEvent, doLayout, enable, enable, enableInputMethods, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, 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, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UPCA

public static final int UPCA
See Also:
Constant Field Values

EAN13

public static final int EAN13
See Also:
Constant Field Values

EAN8

public static final int EAN8
See Also:
Constant Field Values

UPCE

public static final int UPCE
See Also:
Constant Field Values

EAN128

public static final int EAN128
See Also:
Constant Field Values

RSS14

public static final int RSS14
See Also:
Constant Field Values

RSSLIMITED

public static final int RSSLIMITED
See Also:
Constant Field Values

RSSEXPANDED

public static final int RSSEXPANDED
See Also:
Constant Field Values

H

public double H
height of bars. This a multiplicator of X. The default is 0.45.


L

public int L
Symbol lentgh as multiplier of X. This is calculated by RBarcode and the user can read it.

Constructor Detail

BarCode

public BarCode()
Method Detail

getCCCColumns

public int getCCCColumns()
number of columns for the CC-C symbol when used with EAN128. The default value is 4.


setCCCColumns

public void setCCCColumns(int c)
number of columns for the CC-C symbol when used with EAN128. The default value is 4.


getEANUPCPrintFlag

public boolean getEANUPCPrintFlag()
print first digit of the encoded value


setEANUPCPrintFlag

public void setEANUPCPrintFlag(boolean b)
print first digit of the encoded value


getEAN128WithCCC

public boolean getEAN128WithCCC()
if true the EAN128 will be linked to a CCC barcode, otherwise to a CC-A or CC-B


setEAN128WithCCC

public void setEAN128WithCCC(boolean b)
if true the EAN128 will be linked to a CCC barcode, otherwise to a CC-A or CC-B


getBarHeight2D

public int getBarHeight2D()
bar height of the 2D component


barHeight2D

public void barHeight2D(int h)
bar height of the 2D component


getCode

public java.lang.String getCode()
text to be painted as barcode.


setCode

public void setCode(java.lang.String c)
text to be painted as barcode. Use the # character to include FNC1 characters in your string (only for EAN128)


getSecondaryCode

public java.lang.String getSecondaryCode()
text to be painted as 2D component in the barcode.


setSecondaryCode

public void setSecondaryCode(java.lang.String c)
text to be painted as 2D component in the barcode. Use the # character to include FNC1 characters in your string (only for EAN128)


getHumanReadableCode

public java.lang.String getHumanReadableCode()
human readable version of the text to be painted as barcode.


setHumanReadableCode

public void setHumanReadableCode(java.lang.String c)
human readable version of the text to be painted as barcode.


getSymbology

public int getSymbology()
symbology to be used, EAN13, EAN8, UPCE, UPCA or EAN128


setSymbology

public void setSymbology(int c)
symbology to be used, EAN13, EAN8, UPCE, UPCA or EAN128


getBarType

public java.lang.String getBarType()
gets the symbology as String, valid values are EAN13, EAN8, UPCA, UPCE and EAN128


setBarType

public void setBarType(java.lang.String t)
sets the symbology as String, valid values are EAN13, EAN8, UPCA, UPCE and EAN128


getLeftMargin

public int getLeftMargin()
left margin of the barcode (also know as quite zone).


setLeftMargin

public void setLeftMargin(int d)

getTopMargin

public int getTopMargin()
top margin of the barcode (also know as quite zone).


setTopMargin

public void setTopMargin(int d)
top margin of the barcode (also know as quite zone).


getSuplement

public java.lang.String getSuplement()
supplement for EAN or UPC barcode


setSuplement

public void setSuplement(java.lang.String c)

getGuardBars

public boolean getGuardBars()
if true (default), guardbars in EAN and UPC codes will be longer than data bars.


setGuardBars

public void setGuardBars(boolean b)
if true (default), guardbars in EAN and UPC codes will be longer than data bars.


getBackColor

public java.awt.Color getBackColor()
background color.


setBackColor

public void setBackColor(java.awt.Color c)
background color.


getBarHeight

public int getBarHeight()
bar height in pixels. If 0 it will be calculated using H.


setBarHeight

public void setBarHeight(int d)
bar height in pixels. If 0 it will be calculated using H.


getTextFont

public java.awt.Font getTextFont()
font of the text. Set it to NULL if you donot want to paint the text.


setTextFont

public void setTextFont(java.awt.Font f)
font of the text. Set it to NULL if you donot want to paint the text.


getFontColor

public java.awt.Color getFontColor()
color of the human readable text.


setFontColor

public void setFontColor(java.awt.Color c)
color of the human readable text.


getBarColor

public java.awt.Color getBarColor()
color of the bars.


setBarColor

public void setBarColor(java.awt.Color c)
color of the bars.


getUPCESytem

public java.lang.String getUPCESytem()
system to be used in UPCE. It can be "0" or "1". The default is "1".


setUPCESytem

public void setUPCESytem(java.lang.String d)
system to be used in UPCE. It can be "0" or "1". The default is "1".


getUPCEANSupplement2

public boolean getUPCEANSupplement2()
2 digit supplement for EAN or UPC codes.


setUPCEANSupplement2

public void setUPCEANSupplement2(boolean b)
2 digit supplement for EAN or UPC codes.


getUPCEANSupplement5

public boolean getUPCEANSupplement5()
5 digit supplement for EAN or UPC codes.


setUPCEANSupplement5

public void setUPCEANSupplement5(boolean b)
5 digit supplement for EAN or UPC codes.


getX

public int getX()
size in pixels of modules (narrow bars or spaces).

Overrides:
getX in class java.awt.Component

setX

public void setX(int d)

getH

public double getH()
height of bars. This a multiplicator of X. The default is 0.45.


setH

public void setH(double d)
height of bars. This a multiplicator of X. The default is 0.45.


getRotate

public int getRotate()
rotation angle. Valid values are 0 (default),90,180 and 270.


setRotate

public void setRotate(int i)
rotation angle. Valid values are 0 (default),90,180 and 270.


getSupSeparation

public int getSupSeparation()
Separation in pixels between the barcode and the supplement


setSupSeparation

public void setSupSeparation(int d)
Separation in pixels between the barcode and the supplement


getSupHeight

public double getSupHeight()
height of the supplement. This is a multiplicator of the height of the code. The default is 0.8 (80%).


setSupHeight

public void setSupHeight(double d)
height of the supplement. This is a multiplicator of the height of the code. The default is 0.8 (80%).


getName

public java.lang.String getName()
Returns name of the component

Overrides:
getName in class java.awt.Component

getProcessTilde

public boolean getProcessTilde()
process ~ in code?


setProcessTilde

public void setProcessTilde(boolean pt)
process ~ in code?


paint

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

Overrides:
paint in class java.awt.Canvas