public abstract class Barcode
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
ALIGN_CENTER
Center alignment
|
static int |
ALIGN_LEFT
Left alignment
|
static int |
ALIGN_RIGHT
Rigth alignment
|
protected int |
backgroundColor |
protected int |
barHeight
The height of the bars.
|
protected boolean |
checksumText
Shows the generated checksum in the the text.
|
static int |
CODABAR
A type of barcode
|
protected java.lang.String |
code
The code to generate.
|
static int |
CODE128
A type of barcode
|
static int |
CODE128_RAW
A type of barcode
|
static int |
CODE128_UCC
A type of barcode
|
static int |
CODE93
A type of barcode
|
protected int |
codeType
The code type.
|
static int |
EAN13
A type of barcode
|
static int |
EAN8
A type of barcode
|
protected boolean |
extended
Generates extended barcode 39.
|
protected Font |
font
The font to use in the text of the codebar
|
protected boolean |
generateChecksum
The optional checksum generation.
|
protected boolean |
guardBars
Show the guard bars for barcode EAN.
|
protected int |
n
The bar multiplier for wide bars or the distance between
bars for Postnet and Planet.
|
static int |
PLANET
A type of barcode
|
static int |
POSTNET
A type of barcode
|
protected boolean |
quietZone
The option to generate a starting and ending quiet zone
|
protected int |
quietZoneX
The width of the quiet zone expressed in multiples of x(the minimun width of the bar)
|
protected boolean |
showText
The property to show the text for barcode.
|
protected int |
size
The size of the text or the height of the shorter bar
in Postnet.
|
protected boolean |
startStopText
Show the start and stop character '*' in the text for
the barcode 39 or 'ABCD' for codabar.
|
static int |
SUPP2
A type of barcode
|
static int |
SUPP5
A type of barcode
|
protected int |
textAlignment
The text alignment.
|
protected boolean |
transparent |
static java.lang.String |
TYPE_CODE128 |
static java.lang.String |
TYPE_CODE93 |
static java.lang.String |
TYPE_INTERLEAVED2OF5 |
static int |
UPCA
A type of barcode
|
static int |
UPCE
A type of barcode
|
protected int |
x
The minimum bar width.
|
Constructor and Description |
---|
Barcode() |
Modifier and Type | Method and Description |
---|---|
static Image |
createImage(java.lang.String codeType,
java.lang.String codeValue,
int height)
Creates a image representing a codebar
using a codebar type and the codebar code
|
static Image |
createImage(java.lang.String codeType,
java.lang.String codeValue,
int barHeight,
java.lang.String fontName,
int fontSize,
boolean transparent,
int alignment,
boolean fontBold,
int newBarColor,
int newTextColor,
int x,
int n)
Creates a image representing a codebar
using a codebar type and the codebar code
|
int |
getBackgroundColor()
Gets the background color to use
|
protected abstract int |
getBarcodeWidth()
Gets the maximum width that the barcode will occupy.
|
int |
getBarHeight()
Gets the height of the bars.
|
java.lang.String |
getCode()
Gets the code to generate.
|
int |
getCodeType()
Gets the code type.
|
Font |
getFont()
Gets the font to use in the text of the barcode
|
java.lang.String |
getFontName()
Gets name of the font to use in the text of the barcode
Return null if no text is displayed
|
int |
getFontSize()
Gets size of the font to use in the text of the barcode
Return -1 if no text is displayed
|
int |
getN()
Gets the bar multiplier for wide bars.
|
int |
getQuietZoneX()
Get the width of the quiet zone
|
int |
getSize()
Gets the size of the text.
|
int |
getTextAlignment()
Gets the text alignment.
|
int |
getX()
Gets the minimum bar width.
|
boolean |
isChecksumText()
Gets the property to show the generated checksum in the the text.
|
boolean |
isExtended()
Gets the property to generate extended barcode 39.
|
boolean |
isGenerateChecksum()
Gets the optional checksum generation.
|
boolean |
isGuardBars()
Gets the property to show the guard bars for barcode EAN.
|
boolean |
isQuietZone()
Gets the property to show the quiet zone at start and end of the bars.
|
boolean |
isShowText()
Gets the property to show the text for barcode.
|
boolean |
isStartStopText()
Sets the property to show the start and stop character '*' in the text for
the barcode 39.
|
boolean |
isTransparent()
Get the tranaparent background property
|
abstract void |
placeBarcode(Image i,
int barColor,
int textColor)
Places the barcode in a BufferedImage.
|
int |
scale(int imageSize,
int totalSize,
int coordinate)
Scales a logical coordinate to fit a physical image coordinate
Example: Having the logical dimension 200, and the logical coordinate 20.5 we want
to scale the coordinate to a 300 pixel physical dimension.
|
void |
setBackgroundColor(int newBackgroundColor)
Set the backgroud color od the barcode
Default color is white
|
void |
setBarHeight(int barHeight)
Sets the height of the bars.
|
void |
setChecksumText(boolean checksumText)
Sets the property to show the generated checksum in the the text.
|
void |
setCode(java.lang.String code)
Sets the code to generate.
|
void |
setCodeType(int codeType)
Sets the code type.
|
void |
setExtended(boolean extended)
Sets the property to generate extended barcode 39.
|
void |
setFont(Font newFont)
Sets the font to use
null font prints no text.
|
void |
setFontName(java.lang.String newFontName)
Modifies the font name
|
void |
setFontSize(int newFontSize)
Modifies the font size
|
void |
setFontStyle(boolean bold)
Modifies the font style
|
void |
setGenerateChecksum(boolean generateChecksum)
Setter for property generateChecksum.
|
void |
setGuardBars(boolean guardBars)
Sets the property to show the guard bars for barcode EAN.
|
void |
setN(int n)
Sets the bar multiplier for wide bars.
|
void |
setQuietZone(boolean newQuietZone)
Enables/Disables quiet zone usage
|
void |
setQuietZoneX(int newQuietZoneX)
Set the width of the quiet zone
|
void |
setShowText(boolean newShowText)
Sets the property to show the text for barcode.
|
void |
setSize(int size)
Sets the size of the text.
|
void |
setStartStopText(boolean startStopText)
Gets the property to show the start and stop character '*' in the text for
the barcode 39.
|
void |
setTextAlignment(int textAlignment)
Sets the text alignment.
|
void |
setTransparent(boolean newTransparent)
Sets the tranaparent background property
Default tranparency is false
|
void |
setX(int x)
Sets the minimum bar width.
|
public static final int EAN13
public static final int EAN8
public static final int UPCA
public static final int UPCE
public static final int SUPP2
public static final int SUPP5
public static final int POSTNET
public static final int PLANET
public static final int CODE128
public static final int CODE128_UCC
public static final int CODABAR
public static final int CODE93
public static final int CODE128_RAW
protected int x
protected int n
protected int size
protected int barHeight
protected int textAlignment
CoderBar.ALIGN_LEFT
,
Codebar.ALIGN_CENTER
or Codebar.ALIGN_RIGHT
.protected boolean generateChecksum
protected boolean checksumText
protected boolean startStopText
protected boolean extended
protected java.lang.String code
protected boolean guardBars
protected int codeType
public static final int ALIGN_LEFT
public static final int ALIGN_RIGHT
public static final int ALIGN_CENTER
protected boolean quietZone
protected Font font
protected int quietZoneX
protected boolean showText
protected boolean transparent
protected int backgroundColor
public static final java.lang.String TYPE_CODE128
public static final java.lang.String TYPE_CODE93
public static final java.lang.String TYPE_INTERLEAVED2OF5
public static Image createImage(java.lang.String codeType, java.lang.String codeValue, int height) throws ImageException
codeType
- String Codebar type(Barcode.TYPE_CODE128 or Barcode.TYPE_CODE93 or Barcode.INTERLEAVED2OF5)codeValue
- String The code to representheight
- the Image's heightImageException
public static Image createImage(java.lang.String codeType, java.lang.String codeValue, int barHeight, java.lang.String fontName, int fontSize, boolean transparent, int alignment, boolean fontBold, int newBarColor, int newTextColor, int x, int n) throws java.lang.Exception
codeType
- String Codebar type(Barcode.TYPE_CODE128 or Barcode.TYPE_CODE93 or Barcode.INTERLEAVED2OF5)codeValue
- String The code to representbarHeight
- int The bar height in pixelsfontName
- String The name of the font to usefontSize
- int The size of the font to usetransparent
- boolean Use transparent backgroundalignment
- int Text alignment :use Barcode.ALIGN_CENTER, Barcode.ALIGN_LEFT, Barcode.ALIGN_RIGHTfontBold
- The style of the font to usenewBarColor
- Color Color to use in the barsnewTextColor
- Color Color to use in the textjava.lang.Exception
public int getBackgroundColor()
protected abstract int getBarcodeWidth()
public int getBarHeight()
public java.lang.String getCode()
public int getCodeType()
public Font getFont()
public java.lang.String getFontName()
public int getFontSize()
public int getN()
public int getQuietZoneX()
public int getSize()
public int getTextAlignment()
Barcode.ALIGN_LEFT
,
Barcode.ALIGN_CENTER
or Barcode.ALIGN_RIGHT
.public int getX()
public boolean isChecksumText()
public boolean isExtended()
public boolean isGenerateChecksum()
public boolean isGuardBars()
public boolean isQuietZone()
public boolean isShowText()
public boolean isStartStopText()
public boolean isTransparent()
public abstract void placeBarcode(Image i, int barColor, int textColor)
|
|
Result |
---|---|---|
|
|
bars and text painted with current fill color |
|
|
bars and text painted with |
|
|
bars painted with current color |
|
|
bars painted with |
i
- the BufferedImage
where the barcode will be placedbarColor
- the color of the bars. It can be null
textColor
- the color of the text. It can be null
public int scale(int imageSize, int totalSize, int coordinate)
imageSize
- The size of the imagetotalSize
- The logical sizecoordinate
- The logical coordinatepublic void setBackgroundColor(int newBackgroundColor)
newBackgroundColor
- Colorpublic void setBarHeight(int barHeight)
barHeight
- the height of the barspublic void setCode(java.lang.String code)
code
- the code to generatepublic void setCodeType(int codeType)
codeType
- the code typepublic void setChecksumText(boolean checksumText)
checksumText
- new value of property checksumTextpublic void setExtended(boolean extended)
extended
- new value of property extendedpublic void setFont(Font newFont)
newFont
- Fontpublic void setFontName(java.lang.String newFontName)
newFontName
- intpublic void setFontSize(int newFontSize)
newFontSize
- intpublic void setFontStyle(boolean bold)
public void setGenerateChecksum(boolean generateChecksum)
generateChecksum
- New value of property generateChecksum.public void setGuardBars(boolean guardBars)
guardBars
- new value of property guardBarspublic void setN(int n)
n
- the bar multiplier for wide barspublic void setQuietZone(boolean newQuietZone)
newQuietZone
- booleanpublic void setQuietZoneX(int newQuietZoneX)
newQuietZoneX
- intpublic void setShowText(boolean newShowText)
newShowText
- booleanpublic void setSize(int size)
size
- the size of the textpublic void setStartStopText(boolean startStopText)
startStopText
- new value of property startStopTextpublic void setTextAlignment(int textAlignment)
Element.ALIGN_LEFT
,
Element.ALIGN_CENTER
or Element.ALIGN_RIGHT
.textAlignment
- the text alignmentpublic void setTransparent(boolean newTransparent)
newTransparent
- booleanpublic void setX(int x)
x
- the minimum bar width