|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jbars.Barcode
Base class containing properties and methods commom to all barcode types. This class is based on iText "A Free Java-PDF library by Bruno Lowagie and Paulo Soares" using the Mozilla Public License(MPL)
Field Summary | |
static int |
ALIGN_CENTER
Center alignment |
static int |
ALIGN_LEFT
Left alignment |
static int |
ALIGN_RIGHT
Rigth alignment |
protected java.awt.Color |
backgroundColor
|
protected float |
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 java.awt.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 float |
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) |
static double |
ROTATE_0
|
static double |
ROTATE_180
|
static double |
ROTATE_270
|
static double |
ROTATE_90
|
protected boolean |
showText
The property to show the text for barcode. |
protected float |
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 float |
x
The minimum bar width. |
Constructor Summary | |
Barcode()
|
Method Summary | |
static java.awt.Image |
createImage(java.lang.String codeType,
java.lang.String codeValue)
Creates a image representing a codebar using a codebar type and the codebar code |
static java.awt.Image |
createImage(java.lang.String codeType,
java.lang.String codeValue,
float barHeight,
java.lang.String fontName,
int fontSize,
boolean transparent,
int alignment,
int fontStyle,
java.awt.Color newBarColor,
java.awt.Color newTextColor,
int orientacion)
Creates a image representing a codebar using a codebar type and the codebar code |
byte[] |
createPNG(int y,
java.awt.Color barColor,
java.awt.Color textColor)
Creates a PNG image data that represents the barcode. |
byte[] |
createPNG(int y,
java.awt.Color barColor,
java.awt.Color textColor,
double angle)
Creates a PNG image data that represents the barcode. |
byte[] |
createPNG(int y,
java.awt.Color barColor,
java.awt.Color textColor,
int colorspace)
Creates a PNG image data that represents the barcode. |
byte[] |
createPNG(int y,
java.awt.Color barColor,
java.awt.Color textColor,
int colorspace,
double angle)
Creates a PNG image data that represents the barcode. |
byte[] |
createPNG(int x,
int y,
int colorspace,
java.awt.Color barColor,
java.awt.Color textColor)
Creates a PNG image data that represents the barcode. |
byte[] |
createPNG(int x,
int y,
int colorspace,
java.awt.Color barColor,
java.awt.Color textColor,
double angle)
Creates a PNG image data that represents the barcode,and rotates the image. |
protected byte[] |
encodePNG(java.awt.image.BufferedImage image)
Encodes an image into a PNG according to the barcode parameters |
java.awt.Color |
getBackgroundColor()
Gets the background color to use |
protected abstract float |
getBarcodeWidth()
Gets the maximum width that the barcode will occupy. |
float |
getBarHeight()
Gets the height of the bars. |
java.lang.String |
getCode()
Gets the code to generate. |
int |
getCodeType()
Gets the code type. |
java.awt.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 |
getFontStyle()
Gets style of the font to use in the text of the barcode Return -1 if no text is displayed |
float |
getN()
Gets the bar multiplier for wide bars. |
int |
getQuietZoneX()
Get the width of the quiet zone |
float |
getSize()
Gets the size of the text. |
int |
getTextAlignment()
Gets the text alignment. |
float |
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(java.awt.image.BufferedImage i,
java.awt.Color barColor,
java.awt.Color textColor)
Places the barcode in a BufferedImage. |
int |
scale(int imageSize,
float totalSize,
float coordinate)
Scales a logical coordinate to fit a physical image corrdinate 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(java.awt.Color newBackgroundColor)
Set the backgroud color od the barcode Default color is white |
void |
setBarHeight(float 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(java.awt.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(int newFontStyle)
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(float 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(float 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(float x)
Sets the minimum bar width. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
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 CODE128_RAW
public static final int CODABAR
public static final int CODE93
protected float x
protected float n
protected float size
protected float 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 java.awt.Font font
protected int quietZoneX
protected boolean showText
protected boolean transparent
protected java.awt.Color backgroundColor
public static final double ROTATE_90
public static final double ROTATE_180
public static final double ROTATE_270
public static final double ROTATE_0
public static final java.lang.String TYPE_CODE128
public static final java.lang.String TYPE_CODE93
public static final java.lang.String TYPE_INTERLEAVED2OF5
Constructor Detail |
public Barcode()
Method Detail |
public static java.awt.Image createImage(java.lang.String codeType, java.lang.String codeValue)
codeType
- String Codebar type(Barcode.TYPE_CODE128 or Barcode.TYPE_CODE93 or Barcode.INTERLEAVED2OF5)codeValue
- String The code to representpublic static java.awt.Image createImage(java.lang.String codeType, java.lang.String codeValue, float barHeight, java.lang.String fontName, int fontSize, boolean transparent, int alignment, int fontStyle, java.awt.Color newBarColor, java.awt.Color newTextColor, int orientacion)
codeType
- String Codebar type(Barcode.TYPE_CODE128 or Barcode.TYPE_CODE93 or Barcode.INTERLEAVED2OF5)codeValue
- String The code to representbarHeight
- float 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_RIGHTfontStyle
- int The style of the font to use: BOLD, ITALIC OR PLAINorientacion
- int rotation angle of the image in radians: 0,PI/2, PI or (3/2)*PIpublic byte[] createPNG(int y, java.awt.Color barColor, java.awt.Color textColor, double angle) throws java.lang.Exception
y
- The x size of the imagebarColor
- Color to use for the barstextColor
- Color to use for the textangle
- Rotation angle in radians
java.lang.Exception
public byte[] createPNG(int y, java.awt.Color barColor, java.awt.Color textColor)
y
- The x size of the imagebarColor
- Color to use for the barstextColor
- Color to use for the text
public byte[] createPNG(int x, int y, int colorspace, java.awt.Color barColor, java.awt.Color textColor)
x
- The x size of the imagey
- The x size of the imagecolorspace
- The type of colorspace to use
public byte[] createPNG(int x, int y, int colorspace, java.awt.Color barColor, java.awt.Color textColor, double angle) throws java.lang.Exception
x
- The x size of the imagey
- The x size of the imageangle
- Rotation angle in radians
java.lang.Exception
public byte[] createPNG(int y, java.awt.Color barColor, java.awt.Color textColor, int colorspace)
y
- The x size of the imagebarColor
- Color to use for the barstextColor
- Color to use for the text
public byte[] createPNG(int y, java.awt.Color barColor, java.awt.Color textColor, int colorspace, double angle) throws java.lang.Exception
y
- The x size of the imagebarColor
- Color to use for the barstextColor
- Color to use for the textangle
- Rotation angle in radians
java.lang.Exception
protected byte[] encodePNG(java.awt.image.BufferedImage image)
image
- java.awt.image.BufferedImage The image to encode
public java.awt.Color getBackgroundColor()
protected abstract float getBarcodeWidth()
public float getBarHeight()
public java.lang.String getCode()
public int getCodeType()
public java.awt.Font getFont()
public java.lang.String getFontName()
public int getFontSize()
public int getFontStyle()
public float getN()
public int getQuietZoneX()
public float getSize()
public int getTextAlignment()
Barcode.ALIGN_LEFT
,
Barcode.ALIGN_CENTER
or Barcode.ALIGN_RIGHT
.
public float 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(java.awt.image.BufferedImage i, java.awt.Color barColor, java.awt.Color textColor)
|
|
Result |
---|---|---|
|
|
bars and text painted with current fill color |
|
|
bars and text painted with |
|
|
bars painted with current color |
|
|
bars painted with |
barColor
- the color of the bars. It can be null
textColor
- the color of the text. It can be null
public int scale(int imageSize, float totalSize, float coordinate)
imageSize
- The size of the imagetotalSize
- The logical sizecoordinate
- The logical coordinate
public void setBackgroundColor(java.awt.Color newBackgroundColor)
newBackgroundColor
- java.awt.Colorpublic void setBarHeight(float 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(java.awt.Font newFont)
newFont
- java.awt.Fontpublic void setFontName(java.lang.String newFontName)
public void setFontSize(int newFontSize)
newFontSize
- intpublic void setFontStyle(int newFontStyle)
public void setGenerateChecksum(boolean generateChecksum)
generateChecksum
- New value of property generateChecksum.public void setGuardBars(boolean guardBars)
guardBars
- new value of property guardBarspublic void setN(float 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(float 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(float x)
x
- the minimum bar width
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |