public class PNGCanvas extends AbstractCanvas
PNGs are not an optimal file format for QR bills. Vector formats such a SVG or PDF are of better quality and use far less processing power to generate.
MM_TO_PT| Constructor and Description |
|---|
PNGCanvas(int resolution)
Creates a new instance
It is recommended to use at least 144 dpi for
a readable result.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRectangle(double x,
double y,
double width,
double height)
Adds a rectangle to the path
|
void |
close() |
void |
fillPath(int color)
Fills the current path and ends it
|
byte[] |
getResult()
Returns the generated graphics as a byte array
After this method was called, the page is no longer valid.
|
void |
lineTo(double x,
double y)
Adds a line segment to the open path from the previous point to the speicifed position.
|
void |
moveTo(double x,
double y)
Moves the current point of the open path to the specified position.
|
void |
putText(java.lang.String text,
double x,
double y,
int fontSize,
boolean isBold)
Adds text to the graphics.
|
void |
setTransformation(double translateX,
double translateY,
double scale)
Sets a translation and a scale factor for the subsequent operations
Before a new translation is applied, the coordinate system is
reset to it's original state after page setup (see
setupPage). |
void |
setupPage(double width,
double height)
Sets up the page
The page (and graphics context) is not valid until
this method has been called.
|
void |
startPath()
Starts a path that can be filled or stroked
|
void |
strokePath(double strokeWidth,
int color)
Strokes the current path and ends it
|
putMultilineText, putTextLinespublic PNGCanvas(int resolution)
It is recommended to use at least 144 dpi for a readable result.
resolution - resolution of the result (in dpi)public void setupPage(double width,
double height)
CanvasThe page (and graphics context) is not valid until this method has been called.
width - width of page (in mm)height - height of page (in mm)public void setTransformation(double translateX,
double translateY,
double scale)
Canvas
Before a new translation is applied, the coordinate system is
reset to it's original state after page setup (see setupPage).
translateX - translation in x direction (in mm)translateY - translation in y direction (in mm)scale - scale fator (1.0 = no scaling)public void putText(java.lang.String text,
double x,
double y,
int fontSize,
boolean isBold)
CanvasThe text position refers to the left most point on the text's baseline.
text - the textx - x position of the text's start (in mm)y - y position of the text's top (in mm)fontSize - the font size (in pt)isBold - indicates if the text is in bold or regular weightpublic void startPath()
Canvaspublic void moveTo(double x,
double y)
Canvasx - x-coordinate of positiony - y-coordinate of positionpublic void lineTo(double x,
double y)
Canvasx - x-coordinate of positiony - y-coordinate of positionpublic void addRectangle(double x,
double y,
double width,
double height)
Canvasx - the rectangle's left position (in mm)y - the rectangle's top position (in mm)width - the rectangle's width (in mm)height - rectangle's height (in mm)public void fillPath(int color)
Canvascolor - the fill color (expressed similar to HTML, e.g. 0xffffff for white)public void strokePath(double strokeWidth,
int color)
CanvasstrokeWidth - the stroke width (in pt)color - the stroke color (expressed similar to HTML, e.g. 0xffffff for white)public byte[] getResult()
throws java.io.IOException
CanvasAfter this method was called, the page is no longer valid.
java.io.IOException - thrown if the graphics cannot be generatedpublic void close()