public class Java2DCanvasProvider extends AbstractCanvasProvider
bardim| Constructor and Description |
|---|
Java2DCanvasProvider(Graphics2D g2d,
int orientation)
Creates a new Java2DCanvasProvider.
|
| Modifier and Type | Method and Description |
|---|---|
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(String text,
double x1,
double x2,
double y1,
String fontName,
double fontSize,
TextAlignment textAlign)
Draws text.
|
void |
establishDimensions(BarcodeDimension dim)
Sets the dimensions of the barcode.
|
Graphics2D |
getGraphics2D()
Returns the Graphics2D in use.
|
void |
setGraphics2D(Graphics2D g2d)
Sets the Graphics2D instance to paint on
|
deviceCenteredText, deviceJustifiedText, getDimensions, getOrientationpublic Java2DCanvasProvider(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 onorientation - Orientation must be 0, 90, 180, 270, -90, -180 or -270BarcodeDimension.normalizeOrientation(int)public void setGraphics2D(Graphics2D g2d)
g2d - the Graphics2D instancepublic Graphics2D getGraphics2D()
public void establishDimensions(BarcodeDimension dim)
establishDimensions in interface CanvasProviderestablishDimensions in class AbstractCanvasProviderdim - 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(String text, double x1, double x2, double y1, 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 alignmentCopyright © 2003–2023. All rights reserved.