com.tecit.jni.barcode
Class TBarCode

java.lang.Object
  extended by com.tecit.jni.barcode.TBarCode

public class TBarCode
extends java.lang.Object

The class TBarCode implements the interface to the native TBarCode DLL.

Example:

 // create the TBarCode instance
 TBarCode tbc = TBarCode.create();
 ...
 tbc.setBarcodeType (BarcodeType.xxx);
 ...
 tbc.setText ("......");
 ...
 // set the properties you need
 ...
 tbc.saveImage (...);
 ...
 // close the TBarCode instance (included the allocated resources)
 tbc.dispose();
 // invalidate the variable in order to avoid a false use of it!
 tbc = null;
 


Method Summary
 boolean areEscapeSequencesTranslated()
          Determines whether escape sequences in the input data are translated.
static TBarCode create()
          Create a new TBarCode object.
 void dispose()
          Dispose this TBarCode object.
protected  void finalize()
           
 int getBarcodeType()
          Get the bar code type.
 double getBarWidthReductionFactor()
          Get the bar width reduction factor.
 int getCheckDigitMethod()
          Get the check digit method.
 int getColorMode()
          Returns the color mode
 byte[] getData()
          Get the bar code data (as byte array).
static int getDefaultQuality(int nType)
          Calculate the default quality for given image type.
 double getDpi()
          The resolution of the generated bar code images (in DPI)
 int getDrawMode()
          Get the draw mode.
 int getFontHeight()
          Gets the font size [points] for human readable text
 java.lang.String getFontName()
          Gets the font name for human readable text
 double getModuleWidth()
          Get the width/height of the modules in the Data Matrix Symbol.
 int getNotchHeight()
          Gets the additional length of the synchronization bars (notches).
 int getScreenResolution()
          Get the screen resolution in DPI (dots per inch).
 java.lang.String getText()
          Get the bar code text (as string).
 int getTextAlignment()
          Get the text alignment.
 int getTextDistance()
          Get the text distance.
 boolean hasTransparentBackground()
          Test if the background is transparent
 boolean isDisplayTextShown()
          Determines whether the display text (= human readable text) is shown.
 boolean isOptimalResolution()
          Determines whether optimal resolution is set.
 boolean isTextShownAbove()
          Determines whether the display text is shown above the bar code.
 void licenseMe(License license)
          Licenses TBarCode with the license data provided by TEC-IT.
 void licenseMe(java.lang.String sLicensee, int nKind, int nLicenses, java.lang.String sLicenseKey, int nProduct)
          Licenses TBarCode with the license data provided by TEC-IT.
 java.io.InputStream saveImage(int nType, int nHeight, int nWidth, int nQual)
          Generate and return the Data Matrix code as input stream.
 void saveImage(java.lang.String sFileName, int nType, int nHeight, int nWidth, int nQual)
          Generate and save the Data Matrix code into the given file.
 void setBarcodeType(int nType)
          Set a new bar code type.
 void setBarWidthReductionFactor(double dFactor)
          Set a new bar width reduction factor.
 void setCheckDigitMethod(int nMethod)
          Set a new check digit method.
 void setColorMode(int nValue)
          Sets the color mode
 void setData(byte[] abData)
          Set the bar code data.
 void setDpi(double dRes)
          Set the resolution of the generated bar code images (in DPI)
 void setDrawMethod(int nMode)
          Set a new draw method.
 void setFont(java.lang.String name, int nSize, boolean bSubstituteEPS)
          Sets the font for human readable text
 void setModuleWidth(double dModuleWidth)
          Set a new module width.
 void setNotchHeight(int nHeight)
          Sets the additional length of the synchronization bars (notches).
 void setOptimalResolution(boolean bSet)
          Determine whether to draw with optimal resolution.
 void setShowDisplayText(boolean bShow)
          Determines whether the display text (= human readable text) is shown.
 void setShowTextAbove(boolean bAbove)
          Determines whether the display text is shown above the bar code.
 void setText(java.lang.String sData)
          Set the bar code text.
 void setTextAlignment(int nAlign)
          Set a new text alignment.
 void setTextDistance(int nDistance)
          Set a new text distance.
 void setTranslateEscapeSequences(boolean bTranslate)
          Determines whether escape sequences in the input data are translated.
 void setTransparentBackground(boolean bTrasparent)
          Sets the background as transparent The default setting is to fill the background with background color
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static TBarCode create()
                       throws TBarCodeException
Create a new TBarCode object.

The method create calls the constructor and the native Initialization method.

Returns:
the new TBarCode object.
Throws:
TBarCodeException

dispose

public void dispose()
             throws TBarCodeException
Dispose this TBarCode object.

The method dispose should be called as soon as this object is not needed anymore.

Throws:
TBarCodeException

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

licenseMe

public void licenseMe(License license)
Licenses TBarCode with the license data provided by TEC-IT.

Any demo-mode restrictions are removed.
You receive the license data from TEC-IT Datenverarbeitung GmbH after you have ordered a license.


licenseMe

public void licenseMe(java.lang.String sLicensee,
                      int nKind,
                      int nLicenses,
                      java.lang.String sLicenseKey,
                      int nProduct)
Licenses TBarCode with the license data provided by TEC-IT.

Any demo-mode restrictions are removed.
You receive the license data from TEC-IT Datenverarbeitung GmbH after you have ordered a license. You have to call the function licenseMe to obtain a readable bar code.

Parameters:
sLicensee - the name of the licensee.
nKind - the type of the license. (please use the constants specified in class LicenseKind)
nLicenses - the number of licenses.
sLicenseKey - the license key.
nProduct - the product variant (1D or 2D) ==> to be able to use DataMatrix 2D is required here.

getText

public java.lang.String getText()
Get the bar code text (as string).

Returns:
the bar code text.

setText

public void setText(java.lang.String sData)
             throws TBarCodeException
Set the bar code text.

One of the methods setData or setText must be called at least once before bar code generation.

Parameters:
sData - the new bar code text (as string).
Throws:
TBarCodeException

getData

public byte[] getData()
Get the bar code data (as byte array).

Returns:
the bar code data.

setData

public void setData(byte[] abData)
             throws TBarCodeException
Set the bar code data.

One of the methods setData or setText must be called at least once before bar code generation.

Parameters:
abData - the new bar code data (as byte array).
Throws:
TBarCodeException

getBarcodeType

public int getBarcodeType()
                   throws TBarCodeException
Get the bar code type. (please use the constants specified in class BarCodeType)

Returns:
the current bar code type.
Throws:
TBarCodeException

setBarcodeType

public void setBarcodeType(int nType)
                    throws TBarCodeException
Set a new bar code type.

This method must be called at least once before bar code generation.

Parameters:
nType - the new bar code type. (please use the constants specified in class BarCodeType).
Throws:
TBarCodeException

getCheckDigitMethod

public int getCheckDigitMethod()
                        throws TBarCodeException
Get the check digit method. (please use the constants specified in class CheckDigitMethod)

Returns:
the current check digit method.
Throws:
TBarCodeException

setCheckDigitMethod

public void setCheckDigitMethod(int nMethod)
                         throws TBarCodeException
Set a new check digit method.

Parameters:
nMethod - the new check digit method. (please use the constants specified in class CheckDigitMethod).
Throws:
TBarCodeException

areEscapeSequencesTranslated

public boolean areEscapeSequencesTranslated()
                                     throws TBarCodeException
Determines whether escape sequences in the input data are translated.

If the translation of escape-sequences is switched off, all characters are encoded "as-is". If turned on, escape-sequences are translated into the corresponding code words.

Returns:
true if escape sequences are translated, false otherwise.
Throws:
TBarCodeException

setTranslateEscapeSequences

public void setTranslateEscapeSequences(boolean bTranslate)
                                 throws TBarCodeException
Determines whether escape sequences in the input data are translated.

If the translation of escape-sequences is switched off, all characters are encoded "as-is". If turned on, escape-sequences are translated into the corresponding code words.

Default value = false.

Parameters:
bTranslate - translate escape sequences (true) or leave them untranslated ( false).
Throws:
TBarCodeException

isDisplayTextShown

public boolean isDisplayTextShown()
                           throws TBarCodeException
Determines whether the display text (= human readable text) is shown.

This settings has no effect if the bar code type does not support the display text feature (e.g. 2D codes like Data Matrix, PDF417,...).

Returns:
true if the display text is shown, false otherwise.
Throws:
TBarCodeException

setShowDisplayText

public void setShowDisplayText(boolean bShow)
                        throws TBarCodeException
Determines whether the display text (= human readable text) is shown.

This settings has no effect if the bar code type does not support the display text feature (e.g. 2D codes like Data Matrix, PDF417,...).

Default value = true.

Parameters:
bShow - show (true) or hide (false) the display text.
Throws:
TBarCodeException

isTextShownAbove

public boolean isTextShownAbove()
                         throws TBarCodeException
Determines whether the display text is shown above the bar code.

This settings has only effect if the display text is shown.

Returns:
true if the display text is shown above the bar code, false otherwise.
Throws:
TBarCodeException

setShowTextAbove

public void setShowTextAbove(boolean bAbove)
                      throws TBarCodeException
Determines whether the display text is shown above the bar code.

This settings has only effect if the display text is shown.

Default value = false.

Parameters:
bAbove - show the display text above (true) or below (false) the bar code.
Throws:
TBarCodeException

getTextAlignment

public int getTextAlignment()
                     throws TBarCodeException
Get the text alignment. (please use the constants specified in class TextAlignment )

This settings has only effect if the display text is shown.

Returns:
the current text alignment.
Throws:
TBarCodeException

setTextAlignment

public void setTextAlignment(int nAlign)
                      throws TBarCodeException
Set a new text alignment.

This settings has only effect if the display text is shown.

Parameters:
nAlign - the new alignment. (please use the constants specified in class TextAlignment).
Throws:
TBarCodeException

getTextDistance

public int getTextDistance()
                    throws TBarCodeException
Get the text distance.

The text distance is the distance between the display text and the bar code.

Returns:
the text distance in 1/1000 mm.
Throws:
TBarCodeException

setTextDistance

public void setTextDistance(int nDistance)
                     throws TBarCodeException
Set a new text distance.

The text distance is the distance between the display text and the bar code.

Default value = 0.

Parameters:
nDistance - the new text distance in 1/1000 mm.
Throws:
TBarCodeException

getBarWidthReductionFactor

public double getBarWidthReductionFactor()
                                  throws TBarCodeException
Get the bar width reduction factor.

Returns:
the currently used bar width reduction factor.
Throws:
TBarCodeException

setBarWidthReductionFactor

public void setBarWidthReductionFactor(double dFactor)
                                throws TBarCodeException
Set a new bar width reduction factor.

By changing the bar width reduction factor the user is able to reduce the width of the bar code modules (= dots in the matrix) by a given factor. Bar width reduction can be useful for printers with a reduced precision (e.g. ink-jet printers).

Default value = 0.

Parameters:
dFactor - the new bar width reduction factor (in percent of the module width).
Throws:
TBarCodeException

getModuleWidth

public double getModuleWidth()
                      throws TBarCodeException
Get the width/height of the modules in the Data Matrix Symbol.

Returns:
the current module width in 1/1000 mm.
Throws:
TBarCodeException

setModuleWidth

public void setModuleWidth(double dModuleWidth)
                    throws TBarCodeException
Set a new module width.

A module is a single dot (or space) in the matrix of a Data Matrix symbol. The nModuleWidth specifies the width (and so also the height) of a module in 1/1000 mm.

Parameters:
dModuleWidth - the width/height of a module in 1/1000 mm.
Throws:
TBarCodeException

isOptimalResolution

public boolean isOptimalResolution()
                            throws TBarCodeException
Determines whether optimal resolution is set.

If Optimal Resolution is set, the module width is rounded down to the next whole-numbered pixel width.

Default value = false.

Returns:
true if Optimal Resolution is currently set, false otherwise.
Throws:
TBarCodeException

setOptimalResolution

public void setOptimalResolution(boolean bSet)
                          throws TBarCodeException
Determine whether to draw with optimal resolution.

If Optimal Resolution is set, the module width is rounded down to the next whole-numbered pixel width.

Default value = false.

Parameters:
bSet - enter (true) or leave (false) the optimal resolution mode.
Throws:
TBarCodeException

getScreenResolution

public final int getScreenResolution()
                              throws TBarCodeException
Get the screen resolution in DPI (dots per inch).

Returns:
The screen resolution
Throws:
TBarCodeException

setDpi

public final void setDpi(double dRes)
Set the resolution of the generated bar code images (in DPI)

Default value = <screen resolution>.

Parameters:
dRes - the resolution (in DPI) to set

getDpi

public final double getDpi()
The resolution of the generated bar code images (in DPI)

Returns:
the resolution (in DPI)

getDrawMode

public int getDrawMode()
                throws TBarCodeException
Get the draw mode. (please use the constants specified in class DrawMode)

Returns:
the current draw mode.
Throws:
TBarCodeException

setDrawMethod

public void setDrawMethod(int nMode)
                   throws TBarCodeException
Set a new draw method.

Parameters:
nMode - the new draw mode. (please use the constants specified in class DrawMode).
Throws:
TBarCodeException - generic exception

setFont

public void setFont(java.lang.String name,
                    int nSize,
                    boolean bSubstituteEPS)
             throws TBarCodeException
Sets the font for human readable text

Parameters:
name -
nSize - the font size [points]
bSubstituteEPS - flag to substitute Windows font-names with Postscript-compatible fonts
  • true: Substitute font-names enabled
  • false: Do not substitute font-names
Throws:
TBarCodeException - generic exception

getFontHeight

public int getFontHeight()
                  throws TBarCodeException
Gets the font size [points] for human readable text

Throws:
TBarCodeException - generic exception

getFontName

public java.lang.String getFontName()
                             throws TBarCodeException
Gets the font name for human readable text

Throws:
TBarCodeException - generic exception

setTransparentBackground

public void setTransparentBackground(boolean bTrasparent)
                              throws TBarCodeException
Sets the background as transparent The default setting is to fill the background with background color

Parameters:
bTrasparent - true to set transparent, otherwise false
Throws:
TBarCodeException - generic exception

hasTransparentBackground

public boolean hasTransparentBackground()
                                 throws TBarCodeException
Test if the background is transparent

Throws:
TBarCodeException - generic exception

setColorMode

public void setColorMode(int nValue)
                  throws TBarCodeException
Sets the color mode

Parameters:
nValue - a constant value contained by ColorMode class
Throws:
TBarCodeException - generic exception

getColorMode

public int getColorMode()
                 throws TBarCodeException
Returns the color mode

Returns:
a constant value contained by ColorMode class
Throws:
TBarCodeException - generic exception

setNotchHeight

public void setNotchHeight(int nHeight)
                    throws TBarCodeException
Sets the additional length of the synchronization bars (notches). The term notch describes the synchronization bars used in some symbologies (like EAN, UPC, JAN, ...).
These notches are a little bit longer than normal bars. The original length of these
synchronization bars is determined by TBarCode automatically.
Use this function to specify an additional length of these bars.

Parameters:
nHeight - Additional notch height [1/1000 mm]. Negative values are allowed (-1 ... reset to default).
Throws:
TBarCodeException - generic exception

getNotchHeight

public int getNotchHeight()
                   throws TBarCodeException
Gets the additional length of the synchronization bars (notches).

Returns:
additional notch height [1/1000 mm]. Negative values are allowed (-1 ... reset to default).
Throws:
TBarCodeException - generic exception

getDefaultQuality

public static int getDefaultQuality(int nType)
Calculate the default quality for given image type.

Parameters:
nType - the image type. (please use the constants specified in class ImageType)
Returns:
the default quality for given image type
See Also:
ImageQuality

saveImage

public void saveImage(java.lang.String sFileName,
                      int nType,
                      int nHeight,
                      int nWidth,
                      int nQual)
               throws TBarCodeException
Generate and save the Data Matrix code into the given file.

One of the methods setData or setText has to be called before calling saveImage.

Parameters:
sFileName - the image file name.
nType - the image type. (please use the constants specified in class ImageType)
nHeight - the image height in pixels.
nWidth - the image width in pixels.
nQual - the quality of the image. (please use the constants specified in class ImageQuality)
Throws:
TBarCodeException - generic exception
See Also:
ImageType

saveImage

public java.io.InputStream saveImage(int nType,
                                     int nHeight,
                                     int nWidth,
                                     int nQual)
                              throws TBarCodeException
Generate and return the Data Matrix code as input stream.

The stream object has to be closed by the user.

One of the methods setData or setText has to be called before calling saveImage.

Parameters:
nType - the image type. (please use the constants specified in class ImageType)
nHeight - the image height in pixels.
nWidth - the image width in pixels.
nQual - the quality of the image. (please use the constants specified in class ImageQuality)
Returns:
the generated bar code as input stream
Throws:
TBarCodeException - generic exception
See Also:
ImageType