com.java4less.j4lqrcode
Class QRCode

java.lang.Object
  extended by com.java4less.j4lqrcode.QRCode

public class QRCode
extends java.lang.Object

This class creates QR Code symbols
Barcodes can be created with the following code:

QRCode barcode=new QRCode();
barcode.setCode("ABC");

You can paint the barcode using the QRCodeCanvas object or call the paint()
method which returns the barcode as an array of integers.


Field Summary
static int CORRECTION_LEVEL_H
           
static int CORRECTION_LEVEL_L
           
static int CORRECTION_LEVEL_M
           
static int CORRECTION_LEVEL_Q
           
static int ENC_ALPHA
           
static int ENC_AUTO
           
static int ENC_BYTE
           
static int ENC_KANJI
           
static int ENC_NUMERIC
           
static int FNC1_MODE_FIRST
           
static int FNC1_MODE_NO
           
static int FNC1_MODE_SECOND
           
 
Constructor Summary
QRCode()
           
 
Method Summary
 byte getApplicationIndicator()
          application indicator if Fnc1Mode is FNC1_MODE_SECOND
 boolean getAutoConfigurate()
          allow automatic selection of a larger configuration (than the preferred) if code is too large.
 java.lang.String getCode()
          text to be painted as barcode.
 int[] getCodeBinary()
          bytes to be painted as barcode.
 int getECI()
          Extended Channel Interpretation.
 int getEncoding()
           Encoding mode (default is AUTO).
 int getErrorCorrectionLevel()
           Error correction level.
 int getFnc1Mode()
          get FNC1 mode (FNC1_MODE_NO, FNC1_MODE_FIRST or FNC1_MODE_SECOND)
 java.lang.String getName()
          Returns "QRCode".
 int getPreferredVersion()
          use this configuration if possible.
 boolean getProcessTilde()
          process tilde.
 boolean getRedraw()
          Redraw symbol
 boolean getStructuredAppend()
          activate structured append
 int getStructuredAppendCounter()
          number of symbols in structured append (value 1 to 16)
 int getStructuredAppendIndex()
          current symbol in structured append (value 1 to 16)
 int[][] paint()
          paints the symbol and return array of pixels (0-white, 1-black)
 void setApplicationIndicator(byte b)
          application indicator if Fnc1Mode is FNC1_MODE_SECOND
 void setAutoConfigurate(boolean pt)
          allow automatic selection of a larger configuration (than the preferred) if code is too large.
 void setCode(int[] c)
          bytes to be painted as barcode.
 void setCode(java.lang.String c)
          text to be painted as barcode.
 void setECI(int v)
          Extended Channel Interpretation.
 void setEncoding(int d)
           Encoding mode (default is AUTO).
 void setErrorCorrectionLevel(int d)
           Error correction level.
 void setFnc1Mode(int mode)
          sets the FNC1 mode (FNC1_MODE_NO, FNC1_MODE_FIRST or FNC1_MODE_SECOND)
 void setPreferredVersion(int r)
          use this configuration if possible.
 void setProcessTilde(boolean pt)
          process tilde. if true (default) the tilde character (~) will be processed like this:

~~: will be replaced with ~
~dxxx: will be replaced by the character whose ascii code is xxx.
 void setRedraw(boolean b)
          Redraw symbol.
 void setStructuredAppend(boolean b)
          activate structured append
 void setStructuredAppendCounter(int i)
          number of symbols in structured append (value 1 to 16)
 void setStructuredAppendIndex(int i)
          current symbol in structured append (value 1 to 16)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENC_ALPHA

public static final int ENC_ALPHA
See Also:
Constant Field Values

ENC_BYTE

public static final int ENC_BYTE
See Also:
Constant Field Values

ENC_NUMERIC

public static final int ENC_NUMERIC
See Also:
Constant Field Values

ENC_KANJI

public static final int ENC_KANJI
See Also:
Constant Field Values

ENC_AUTO

public static final int ENC_AUTO
See Also:
Constant Field Values

FNC1_MODE_NO

public static final int FNC1_MODE_NO
See Also:
Constant Field Values

FNC1_MODE_FIRST

public static final int FNC1_MODE_FIRST
See Also:
Constant Field Values

FNC1_MODE_SECOND

public static final int FNC1_MODE_SECOND
See Also:
Constant Field Values

CORRECTION_LEVEL_L

public static int CORRECTION_LEVEL_L

CORRECTION_LEVEL_M

public static int CORRECTION_LEVEL_M

CORRECTION_LEVEL_Q

public static int CORRECTION_LEVEL_Q

CORRECTION_LEVEL_H

public static int CORRECTION_LEVEL_H
Constructor Detail

QRCode

public QRCode()
Method Detail

getPreferredVersion

public int getPreferredVersion()
use this configuration if possible. Valid values are 1 to 40.


setPreferredVersion

public void setPreferredVersion(int r)
use this configuration if possible. Valid values are 1 to 40.


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.


getECI

public int getECI()
Extended Channel Interpretation. The default value is -1 (disabled).


setECI

public void setECI(int v)
Extended Channel Interpretation. The default value is -1 (disabled).


getCodeBinary

public int[] getCodeBinary()
bytes to be painted as barcode.


setCode

public void setCode(int[] c)
bytes to be painted as barcode.


getEncoding

public int getEncoding()
 Encoding mode (default is AUTO). Valid values are:
      
  • AUTO: Automatic selecting of the encoding method.
  • ALPHA: encode alpahnumeric characters only (upper case letter plus 9 additional characters).
  • NUMERIC: encode alpahnumeric digits only.
  • BYTE: use this mode to encode binary data.
  • KANJI: encodes Kanji characters only.


setEncoding

public void setEncoding(int d)
 Encoding mode (default is AUTO). Valid values are:
      
  • AUTO: Automatic selecting of the encoding method.
  • ALPHA: encode alpahnumeric characters only (upper case letter plus 9 additional characters).
  • NUMERIC: encode alpahnumeric digits only.
  • BYTE: use this mode to encode binary data.
  • KANJI: encodes Kanji characters only.


getName

public java.lang.String getName()
Returns "QRCode".


getErrorCorrectionLevel

public int getErrorCorrectionLevel()
 Error correction level. Valid values are:
         
  • CORRECTION_LEVEL_L (default). About 7% recovery capacity.
  • CORRECTION_LEVEL_M: About 15% recovery capacity.
  • CORRECTION_LEVEL_Q: About 25% recovery capacity.
  • CORRECTION_LEVEL_H: About 30% recovery capacity.


setErrorCorrectionLevel

public void setErrorCorrectionLevel(int d)
 Error correction level. Valid values are:
         
  • CORRECTION_LEVEL_L (default). About 7% recovery capacity.
  • CORRECTION_LEVEL_M: About 15% recovery capacity.
  • CORRECTION_LEVEL_Q: About 25% recovery capacity.
  • CORRECTION_LEVEL_H: About 30% recovery capacity.


getProcessTilde

public boolean getProcessTilde()
process tilde.


setProcessTilde

public void setProcessTilde(boolean pt)
process tilde. if true (default) the tilde character (~) will be processed like this:

~~: will be replaced with ~
~dxxx: will be replaced by the character whose ascii code is xxx. For example ~d065 will be replaced with A.


getRedraw

public boolean getRedraw()
Redraw symbol


setRedraw

public void setRedraw(boolean b)
Redraw symbol. Set this property to true if you change any property of the barcode and you want to rebuild it.


getFnc1Mode

public int getFnc1Mode()
get FNC1 mode (FNC1_MODE_NO, FNC1_MODE_FIRST or FNC1_MODE_SECOND)


setFnc1Mode

public void setFnc1Mode(int mode)
sets the FNC1 mode (FNC1_MODE_NO, FNC1_MODE_FIRST or FNC1_MODE_SECOND)


getApplicationIndicator

public byte getApplicationIndicator()
application indicator if Fnc1Mode is FNC1_MODE_SECOND


setApplicationIndicator

public void setApplicationIndicator(byte b)
application indicator if Fnc1Mode is FNC1_MODE_SECOND


getAutoConfigurate

public boolean getAutoConfigurate()
allow automatic selection of a larger configuration (than the preferred) if code is too large.


setAutoConfigurate

public void setAutoConfigurate(boolean pt)
allow automatic selection of a larger configuration (than the preferred) if code is too large.


setStructuredAppend

public void setStructuredAppend(boolean b)
activate structured append


getStructuredAppend

public boolean getStructuredAppend()
activate structured append


setStructuredAppendCounter

public void setStructuredAppendCounter(int i)
number of symbols in structured append (value 1 to 16)


getStructuredAppendCounter

public int getStructuredAppendCounter()
number of symbols in structured append (value 1 to 16)


setStructuredAppendIndex

public void setStructuredAppendIndex(int i)
current symbol in structured append (value 1 to 16)


getStructuredAppendIndex

public int getStructuredAppendIndex()
current symbol in structured append (value 1 to 16)


paint

public int[][] paint()
paints the symbol and return array of pixels (0-white, 1-black)