|
barcode4j 2.1.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.krysalis.barcode4j.output.AbstractCanvasProvider org.krysalis.barcode4j.output.java2d.Java2DCanvasProvider
public class Java2DCanvasProvider
CanvasProvider implementation that renders to Java2D (AWT).
Field Summary |
---|
Fields inherited from class org.krysalis.barcode4j.output.AbstractCanvasProvider |
---|
bardim |
Constructor Summary | |
---|---|
Java2DCanvasProvider(java.awt.Graphics2D g2d,
int orientation)
Creates a new Java2DCanvasProvider. |
Method Summary | |
---|---|
void |
deviceDrawRect(double x,
double y,
double w,
double h)
|
void |
deviceFillRect(double x,
double y,
double w,
double h)
Paints a filled rectangle. |
void |
deviceText(java.lang.String text,
double x1,
double x2,
double y1,
java.lang.String fontName,
double fontSize,
TextAlignment textAlign)
Draws text. |
void |
establishDimensions(BarcodeDimension dim)
Sets the dimensions of the barcode. |
java.awt.Graphics2D |
getGraphics2D()
Returns the Graphics2D in use. |
void |
setGraphics2D(java.awt.Graphics2D g2d)
Sets the Graphics2D instance to paint on |
Methods inherited from class org.krysalis.barcode4j.output.AbstractCanvasProvider |
---|
deviceCenteredText, deviceJustifiedText, getDimensions, getOrientation |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Java2DCanvasProvider(java.awt.Graphics2D g2d, int orientation)
This class internally operates with millimeters (mm) as units. This means you have to apply the necessary transformation before rendering a barcode to obtain the expected size. See the source code for BitmapBuilder.java for an example.
To improve the quality of text output it is recommended that fractional
font metrics be enabled on the Graphics2D object passed in:
g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
g2d
- Graphics2D object to paint onMethod Detail |
---|
public void setGraphics2D(java.awt.Graphics2D g2d)
g2d
- the Graphics2D instancepublic java.awt.Graphics2D getGraphics2D()
public void establishDimensions(BarcodeDimension dim)
establishDimensions
in interface CanvasProvider
establishDimensions
in class AbstractCanvasProvider
dim
- the dimensions of the barcodepublic void deviceFillRect(double x, double y, double w, double h)
x
- x coordinate of the upper left cornery
- y coordinate of the upper left cornerw
- the widthh
- the heightpublic void deviceDrawRect(double x, double y, double w, double h)
public void deviceText(java.lang.String text, double x1, double x2, double y1, java.lang.String fontName, double fontSize, TextAlignment textAlign)
text
- the text to drawx1
- the left boundaryx2
- the right boundaryy1
- the y coordinatefontName
- the name of the fontfontSize
- the size of the fonttextAlign
- the text alignment
|
barcode4j 2.1.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |