Class QRCodeHandler
java.lang.Object
org.primefaces.application.resource.BaseDynamicContentHandler
org.primefaces.application.resource.QRCodeHandler
- All Implemented Interfaces:
DynamicContentHandler
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected io.nayuki.qrcodegen.QrCode.Ecc
getErrorCorrection
(String value) void
handle
(javax.faces.context.FacesContext context) protected BufferedImage
toImage
(io.nayuki.qrcodegen.QrCode qr, int scale, int border) protected BufferedImage
toImage
(io.nayuki.qrcodegen.QrCode qr, int scale, int border, int lightColor, int darkColor) Returns a raster image depicting the specified QR Code, with the specified module scale, border modules, and module colors.protected String
toSvgString
(io.nayuki.qrcodegen.QrCode qr, int border, String lightColor, String darkColor) Returns a string of SVG code for an image depicting the specified QR Code, with the specified number of border modules.Methods inherited from class org.primefaces.application.resource.BaseDynamicContentHandler
handleCache
-
Constructor Details
-
QRCodeHandler
public QRCodeHandler()
-
-
Method Details
-
handle
- Throws:
IOException
-
getErrorCorrection
-
toImage
-
toImage
protected BufferedImage toImage(io.nayuki.qrcodegen.QrCode qr, int scale, int border, int lightColor, int darkColor) Returns a raster image depicting the specified QR Code, with the specified module scale, border modules, and module colors.For example, scale=10 and border=4 means to pad the QR Code with 4 light border modules on all four sides, and use 10×10 pixels to represent each module.
- Parameters:
qr
- the QR Code to render (notnull
)scale
- the side length (measured in pixels, must be positive) of each moduleborder
- the number of border modules to add, which must be non-negativelightColor
- the color to use for light modules, in 0xRRGGBB formatdarkColor
- the color to use for dark modules, in 0xRRGGBB format- Returns:
- a new image representing the QR Code, with padding and scaling
- Throws:
NullPointerException
- if the QR Code isnull
IllegalArgumentException
- if the scale or border is out of range, or if {scale, border, size} cause the image dimensions to exceed Integer.MAX_VALUE
-
toSvgString
protected String toSvgString(io.nayuki.qrcodegen.QrCode qr, int border, String lightColor, String darkColor) Returns a string of SVG code for an image depicting the specified QR Code, with the specified number of border modules. The string always uses Unix newlines (\n), regardless of the platform.- Parameters:
qr
- the QR Code to render (notnull
)border
- the number of border modules to add, which must be non-negativelightColor
- the color to use for light modules, in any format supported by CSS, notnull
darkColor
- the color to use for dark modules, in any format supported by CSS, notnull
- Returns:
- a string representing the QR Code as an SVG XML document
- Throws:
NullPointerException
- if any object isnull
IllegalArgumentException
- if the border is negative
-