Skip to main content

RectangleQRFrameOptions Class

Contains options that customize a rectangular frame and associated text around a QR code.

Declaration

public class RectangleQRFrameOptions extends QRFrameOptions

Remarks

The following code snippet creates a QR Code barcode and customizes its encoding parameters:

import com.devexpress.drawing.*;
import com.devexpress.docs.barcode.*;
import com.devexpress.system.drawing.*;
import com.devexpress.docs.Padding;

import java.io.*;
import java.nio.file.*;

public class Main {
    public static void main(String[] args) throws Exception {

        byte[] logoBytes = Files.readAllBytes(Path.of("images/devexpress-logo.png"));

        try (DXImage logo = DXImage.fromStream(new ByteArrayInputStream(logoBytes))) {

            // Customize QR Code parameters.
            QRCodeOptions options = new QRCodeOptions();
            options.setErrorCorrectionLevel(QRCodeErrorCorrectionLevel.H);
            options.setCompactionMode(QRCodeCompactionMode.AUTO);
            options.setVersion(QRCodeVersion.VERSION_10);
            options.setIncludeQuietZone(true);
            options.setLogo(logo);
            options.setPadding(new Padding(10));
            options.setModuleSize(10);
            options.setShowText(false);

            // Customize QR Code frame parameters.
            RectangleQRFrameOptions frameOptions = new RectangleQRFrameOptions();
            frameOptions.setPadding(new Padding(10));
            frameOptions.setFrameColor(Color.getOrange());
            frameOptions.setFrameWidth(10);
            frameOptions.setText("DevExpress");
            frameOptions.setCornerRadius(10);
            frameOptions.setTextAlignment(QRFrameTextAlignment.CENTER);
            frameOptions.setTextColor(Color.getBlack());
            frameOptions.setTextPosition(QRFrameTextPosition.BOTTOM);

            options.setFrameOptions(frameOptions);

            Path outputDir = Path.of("output");
            Files.createDirectories(outputDir);

            try (FileOutputStream fileStream = new FileOutputStream(
                    outputDir.resolve("qrcode.png").toFile());
                    BarcodeGenerator barcodeGenerator = new BarcodeGenerator(options)) {
                        barcodeGenerator.export(
                                "https://www.devexpress.com",
                                fileStream,
                                DXImageFormat.getPng());
            }
        }
    }
}

Refer to the following help topic for additional information: QR Code.

Inherited Members

com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.memberwiseClone()
com.devexpress.system.JavaObject.toString()
java.lang.Object.finalize()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

Object
JavaObject
QRFrameOptions
RectangleQRFrameOptions

RectangleQRFrameOptions()

Initializes a new instance of the RectangleQRFrameOptions class.

Declaration

public RectangleQRFrameOptions()

Methods

getCornerRadius() Method

Returns rounded corners for the rectangular frame in pixels.

Declaration

public float getCornerRadius()

Returns

Type Description
float

The radius of the rounded corners in pixels.

getFrameColor() Method

Returns the color of the frame around a QR code.

Declaration

public Color getFrameColor()

Returns

Type Description
Color

The frame color.

getFrameWidth() Method

Returns the width of the frame around a QR code.

Declaration

public float getFrameWidth()

Returns

Type Description
float

The frame width.

getPadding() Method

Gets the offset between the frame and QR code.

Declaration

public Padding getPadding()

Returns

Type Description
Padding

The padding.

getText() Method

Returns the text displayed in the frame.

Declaration

public String getText()

Returns

Type Description
String

The text displayed in the frame.

getTextAlignment() Method

Returns the alignment of the text displayed in the frame.

Declaration

public QRFrameTextAlignment getTextAlignment()

Returns

Type Description
QRFrameTextAlignment

The text alignment.

getTextColor() Method

Returns the color of the text displayed in the frame.

Declaration

public Color getTextColor()

Returns

Type Description
Color

The text color.

getTextPosition() Method

Returns the position of the text displayed relative to the QR code.

Declaration

public QRFrameTextPosition getTextPosition()

Returns

Type Description
QRFrameTextPosition

The text position.

setCornerRadius(float value) Method

Specifies rounded corners for the rectangular frame in pixels.

Declaration

public void setCornerRadius(float value)

Parameters

Name Type Description
value float

The radius of the rounded corners in pixels.

setFrameColor(Color value) Method

Specifies the color of the frame around a QR code.

Declaration

public void setFrameColor(Color value)

Parameters

Name Type Description
value Color

The frame color.

setFrameWidth(float value) Method

Specifies the width of the frame around a QR code.

Declaration

public void setFrameWidth(float value)

Parameters

Name Type Description
value float

The frame width.

setPadding(Padding value) Method

Sets the offset between the frame and QR code.

Declaration

public void setPadding(Padding value)

Parameters

Name Type Description
value Padding

The padding.

setText(String value) Method

Specifies the text displayed in the frame.

Declaration

public void setText(String value)

Parameters

Name Type Description
value String

The text displayed in the frame.

setTextAlignment(QRFrameTextAlignment value) Method

Specifies the alignment of the text displayed in the frame.

Declaration

public void setTextAlignment(QRFrameTextAlignment value)

Parameters

Name Type Description
value QRFrameTextAlignment

The text alignment.

setTextColor(Color value) Method

Specifies the color of the text displayed in the frame.

Declaration

public void setTextColor(Color value)

Parameters

Name Type Description
value Color

The text color.

setTextPosition(QRFrameTextPosition value) Method

Specifies the position of the text displayed relative to the QR code.

Declaration

public void setTextPosition(QRFrameTextPosition value)

Parameters

Name Type Description
value QRFrameTextPosition

The text position.