public class TBarCode
extends java.lang.Object
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;
Modifier and Type | Method and Description |
---|---|
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
|
public static TBarCode create() throws TBarCodeException
TBarCode
object.
The method create
calls the constructor and the native Initialization method.
TBarCode
object.TBarCodeException
public void dispose() throws TBarCodeException
this
TBarCode
object.
The method dispose
should be called as soon as this
object is
not needed anymore.
TBarCodeException
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public void licenseMe(License license)
Any demo-mode restrictions are removed.
You receive the license data from TEC-IT Datenverarbeitung GmbH after you have ordered a license.public void licenseMe(java.lang.String sLicensee, int nKind, int nLicenses, java.lang.String sLicenseKey, int nProduct)
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 functionlicenseMe
to obtain a readable bar code.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.public java.lang.String getText()
public void setText(java.lang.String sData) throws TBarCodeException
One of the methods setData
or setText
must be called at least once
before bar code generation.
sData
- the new bar code text (as string).TBarCodeException
public byte[] getData()
public void setData(byte[] abData) throws TBarCodeException
One of the methods setData
or setText
must be called at least once
before bar code generation.
abData
- the new bar code data (as byte array).TBarCodeException
public int getBarcodeType() throws TBarCodeException
BarCodeType
)TBarCodeException
public void setBarcodeType(int nType) throws TBarCodeException
This method must be called at least once before bar code generation.
nType
- the new bar code type. (please use the constants specified in class
BarCodeType
).TBarCodeException
public int getCheckDigitMethod() throws TBarCodeException
CheckDigitMethod
)TBarCodeException
public void setCheckDigitMethod(int nMethod) throws TBarCodeException
nMethod
- the new check digit method. (please use the constants specified in class
CheckDigitMethod
).TBarCodeException
public boolean areEscapeSequencesTranslated() throws TBarCodeException
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.
TBarCodeException
public void setTranslateEscapeSequences(boolean bTranslate) throws TBarCodeException
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
.
bTranslate
- translate escape sequences (true
) or leave them untranslated (
false
).TBarCodeException
public boolean isDisplayTextShown() throws TBarCodeException
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,...).
TBarCodeException
public void setShowDisplayText(boolean bShow) throws TBarCodeException
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
.
bShow
- show (true
) or hide (false
) the display text.TBarCodeException
public boolean isTextShownAbove() throws TBarCodeException
This settings has only effect if the display text is shown.
TBarCodeException
public void setShowTextAbove(boolean bAbove) throws TBarCodeException
This settings has only effect if the display text is shown.
Default value = false
.
bAbove
- show the display text above (true
) or below (false
) the bar
code.TBarCodeException
public int getTextAlignment() throws TBarCodeException
TextAlignment
)
This settings has only effect if the display text is shown.
TBarCodeException
public void setTextAlignment(int nAlign) throws TBarCodeException
This settings has only effect if the display text is shown.
nAlign
- the new alignment. (please use the constants specified in class
TextAlignment
).TBarCodeException
public int getTextDistance() throws TBarCodeException
The text distance is the distance between the display text and the bar code.
TBarCodeException
public void setTextDistance(int nDistance) throws TBarCodeException
The text distance is the distance between the display text and the bar code.
Default value = 0
.
nDistance
- the new text distance in 1/1000 mm.TBarCodeException
public double getBarWidthReductionFactor() throws TBarCodeException
TBarCodeException
public void setBarWidthReductionFactor(double dFactor) throws TBarCodeException
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.
dFactor
- the new bar width reduction factor (in percent of the module width).TBarCodeException
public double getModuleWidth() throws TBarCodeException
TBarCodeException
public void setModuleWidth(double dModuleWidth) throws TBarCodeException
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.
dModuleWidth
- the width/height of a module in 1/1000 mm.TBarCodeException
public boolean isOptimalResolution() throws TBarCodeException
If Optimal Resolution is set, the module width is rounded down to the next whole-numbered pixel width.
Default value = false
.
TBarCodeException
public void setOptimalResolution(boolean bSet) throws TBarCodeException
If Optimal Resolution is set, the module width is rounded down to the next whole-numbered pixel width.
Default value = false
.
bSet
- enter (true
) or leave (false
) the optimal resolution mode.TBarCodeException
public final int getScreenResolution() throws TBarCodeException
TBarCodeException
public final void setDpi(double dRes)
Default value = <screen resolution>.
dRes
- the resolution (in DPI) to setpublic final double getDpi()
public int getDrawMode() throws TBarCodeException
DrawMode
)TBarCodeException
public void setDrawMethod(int nMode) throws TBarCodeException
nMode
- the new draw mode. (please use the constants specified in class DrawMode
).TBarCodeException
- generic exceptionpublic void setFont(java.lang.String name, int nSize, boolean bSubstituteEPS) throws TBarCodeException
name
- nSize
- the font size [points]bSubstituteEPS
- flag to substitute Windows font-names with Postscript-compatible fonts
true
: Substitute font-names enabledfalse
: Do not substitute font-namesTBarCodeException
- generic exceptionpublic int getFontHeight() throws TBarCodeException
TBarCodeException
- generic exceptionpublic java.lang.String getFontName() throws TBarCodeException
TBarCodeException
- generic exceptionpublic void setTransparentBackground(boolean bTrasparent) throws TBarCodeException
bTrasparent
- true
to set transparent, otherwise false
TBarCodeException
- generic exceptionpublic boolean hasTransparentBackground() throws TBarCodeException
TBarCodeException
- generic exceptionpublic void setColorMode(int nValue) throws TBarCodeException
nValue
- a constant value contained by ColorMode
classTBarCodeException
- generic exceptionpublic int getColorMode() throws TBarCodeException
ColorMode
classTBarCodeException
- generic exceptionpublic void setNotchHeight(int nHeight) throws TBarCodeException
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.nHeight
- Additional notch height [1/1000 mm]. Negative values are allowed (-1 ... reset to default).TBarCodeException
- generic exceptionpublic int getNotchHeight() throws TBarCodeException
TBarCodeException
- generic exceptionpublic static int getDefaultQuality(int nType)
nType
- the image type. (please use the constants specified in class ImageType
)ImageQuality
public void saveImage(java.lang.String sFileName, int nType, int nHeight, int nWidth, int nQual) throws TBarCodeException
One of the methods setData
or setText
has to be called before calling
saveImage
.
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
)TBarCodeException
- generic exceptionImageType
public java.io.InputStream saveImage(int nType, int nHeight, int nWidth, int nQual) throws TBarCodeException
The stream object has to be closed by the user.
One of the methods setData
or setText
has to be called before calling
saveImage
.
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
)TBarCodeException
- generic exceptionImageType