Skip to main content

OrientedRectangle Class

An oriented rectangle with location, size, rotation, skew, and pivot data.

Declaration

public final class OrientedRectangle extends Struct<OrientedRectangle>

Remarks

The following code snippet highlights all occurrences of “external PDF Viewer“:

import com.devexpress.docs.pdf.*;

import java.nio.file.*;
import java.nio.channels.*;
import java.util.List;

public class Main {
    public static void main(String[] args) throws Exception {
        try (FileChannel channel = FileChannel.open(Path.of("Document.pdf"));
                PdfDocument pdfDocument = new PdfDocument(channel)) {

            // Search for text.
            for (TextSearchInfo result : pdfDocument.findText("external PDF Viewer")) {
                for (TextMatchInfo match : result.getMatches()) {

                    List<OrientedRectangle> bounds =
                        match.getMatchFragments().stream()
                                .map(fragment -> fragment.getRectangle())
                                .toList();

                    TextMarkupAnnotation annotation = new TextMarkupAnnotation(bounds);

                    annotation.setType(TextMarkupAnnotationType.HIGHLIGHT);
                    annotation.setColor(PdfColor.getYellow());
                    annotation.setTitle("John Smith");
                    annotation.setContent("Review this section.");

                    pdfDocument.getPages()
                            .get(result.getPageIndex())
                            .getAnnotations()
                            .add(annotation);
                }
            }

            // Save the document.
            try (WritableByteChannel summaryChannel =
                    FileChannel.open(
                        Path.of("Result.pdf"),
                        StandardOpenOption.CREATE,
                        StandardOpenOption.WRITE,
                        StandardOpenOption.TRUNCATE_EXISTING)) {

                pdfDocument.save(summaryChannel);
            }
        }
    }
}

Inherited Members

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

Inheritance

Object
com.devexpress.system.Struct
OrientedRectangle

Constructors

OrientedRectangle() Constructor

Initializes a new oriented rectangle with default values.

Declaration

public OrientedRectangle()

OrientedRectangle(float x, float y, float width, float height, double angleDegrees) Constructor

Initializes a new oriented rectangle with the specified coordinates, size, and rotation angle.

Declaration

public OrientedRectangle(float x, float y, float width, float height, double angleDegrees)

Parameters

Name Type Description
x float

The X-coordinate of the rectangle location.

y float

The Y-coordinate of the rectangle location.

width float

The rectangle width.

height float

The rectangle height.

angleDegrees double

The rectangle rotation angle, in degrees.

OrientedRectangle(float x, float y, float width, float height) Constructor

Initializes a new oriented rectangle with the specified coordinates and size.

Declaration

public OrientedRectangle(float x, float y, float width, float height)

Parameters

Name Type Description
x float

The X-coordinate of the rectangle location.

y float

The Y-coordinate of the rectangle location.

width float

The rectangle width.

height float

The rectangle height.

OrientedRectangle(PointF location, float width, float height, double angleDegrees) Constructor

Initializes a new oriented rectangle with the specified location, size, and rotation angle.

Declaration

public OrientedRectangle(PointF location, float width, float height, double angleDegrees)

Parameters

Name Type Description
location com.devexpress.system.drawing.PointF

The rectangle location.

width float

The rectangle width.

height float

The rectangle height.

angleDegrees double

The rectangle rotation angle, in degrees.

OrientedRectangle(PointF location, float width, float height, PointF pivot, PointF linePivot, double angleDegrees, double skewX, double skewY) Constructor

Initializes a new oriented rectangle with the specified location, size, pivot point, line pivot point, rotation angle, horizontal skew angle, and vertical skew angle.

Declaration

public OrientedRectangle(PointF location, float width, float height, PointF pivot, PointF linePivot, double angleDegrees, double skewX, double skewY)

Parameters

Name Type Description
location com.devexpress.system.drawing.PointF

The rectangle location.

width float

The rectangle width.

height float

The rectangle height.

pivot com.devexpress.system.drawing.PointF

The rectangle pivot point.

linePivot com.devexpress.system.drawing.PointF

The line pivot point.

angleDegrees double

The rectangle rotation angle, in degrees.

skewX double

The horizontal skew angle, in degrees.

skewY double

The vertical skew angle, in degrees.

OrientedRectangle(PointF location, float width, float height, PointF pivot, PointF linePivot, double angleDegrees, double skewX) Constructor

Initializes a new oriented rectangle with the specified location, size, pivot point, line pivot point, rotation angle, and horizontal skew angle.

Declaration

public OrientedRectangle(PointF location, float width, float height, PointF pivot, PointF linePivot, double angleDegrees, double skewX)

Parameters

Name Type Description
location com.devexpress.system.drawing.PointF

The rectangle location.

width float

The rectangle width.

height float

The rectangle height.

pivot com.devexpress.system.drawing.PointF

The rectangle pivot point.

linePivot com.devexpress.system.drawing.PointF

The line pivot point.

angleDegrees double

The rectangle rotation angle, in degrees.

skewX double

The horizontal skew angle, in degrees.

OrientedRectangle(PointF location, float width, float height, PointF pivot, PointF linePivot, double angleDegrees) Constructor

Initializes a new oriented rectangle with the specified location, size, pivot point, line pivot point, and rotation angle.

Declaration

public OrientedRectangle(PointF location, float width, float height, PointF pivot, PointF linePivot, double angleDegrees)

Parameters

Name Type Description
location com.devexpress.system.drawing.PointF

The rectangle location.

width float

The rectangle width.

height float

The rectangle height.

pivot com.devexpress.system.drawing.PointF

The rectangle pivot point.

linePivot com.devexpress.system.drawing.PointF

The line pivot point.

angleDegrees double

The rectangle rotation angle, in degrees.

OrientedRectangle(PointF location, float width, float height, PointF pivot, PointF linePivot) Constructor

Initializes a new oriented rectangle with the specified location, size, pivot point, and line pivot point.

Declaration

public OrientedRectangle(PointF location, float width, float height, PointF pivot, PointF linePivot)

Parameters

Name Type Description
location com.devexpress.system.drawing.PointF

The rectangle location.

width float

The rectangle width.

height float

The rectangle height.

pivot com.devexpress.system.drawing.PointF

The rectangle pivot point.

linePivot com.devexpress.system.drawing.PointF

The line pivot point.

OrientedRectangle(PointF location, float width, float height) Constructor

Initializes a new oriented rectangle with the specified location and size.

Declaration

public OrientedRectangle(PointF location, float width, float height)

Parameters

Name Type Description
location com.devexpress.system.drawing.PointF

The rectangle location.

width float

The rectangle width.

height float

The rectangle height.

OrientedRectangle(RectangleF rect, double angleDegrees) Constructor

Initializes a new oriented rectangle with the specified rectangle bounds and rotation angle.

Declaration

public OrientedRectangle(RectangleF rect, double angleDegrees)

Parameters

Name Type Description
rect RectangleF

The rectangle bounds.

angleDegrees double

The rectangle rotation angle, in degrees.

OrientedRectangle(RectangleF rect) Constructor

Initializes a new oriented rectangle with the specified rectangle bounds.

Declaration

public OrientedRectangle(RectangleF rect)

Parameters

Name Type Description
rect RectangleF

The rectangle bounds.

Methods

equals(Object obj) Method

Returns whether the specified object equals this oriented rectangle.

Declaration

public boolean equals(Object obj)

Parameters

Name Type Description
obj Object

The object to compare with this oriented rectangle.

Returns

Type Description
boolean

true if the specified object equals this oriented rectangle; otherwise, false.

getAngle() Method

Returns the rectangle rotation angle.

Declaration

public double getAngle()

Returns

Type Description
double

The rectangle rotation angle, in degrees.

getBottom() Method

Returns the bottom coordinate of the rectangle bounds.

Declaration

public float getBottom()

Returns

Type Description
float

The bottom coordinate of the rectangle bounds.

getBottomLeft() Method

Returns the bottom-left vertex of the rectangle.

Declaration

public PointF getBottomLeft()

Returns

Type Description
com.devexpress.system.drawing.PointF

The bottom-left vertex of the rectangle.

getBottomRight() Method

Returns the bottom-right vertex of the rectangle.

Declaration

public PointF getBottomRight()

Returns

Type Description
com.devexpress.system.drawing.PointF

The bottom-right vertex of the rectangle.

getBoundingBox() Method

Returns the rectangle bounding box.

Declaration

public RectangleF getBoundingBox()

Returns

Type Description
RectangleF

The rectangle bounding box.

getHeight() Method

Returns the rectangle height.

Declaration

public float getHeight()

Returns

Type Description
float

The rectangle height.

getLeft() Method

Returns the left coordinate of the rectangle bounds.

Declaration

public float getLeft()

Returns

Type Description
float

The left coordinate of the rectangle bounds.

getLocation() Method

Returns the rectangle location.

Declaration

public PointF getLocation()

Returns

Type Description
com.devexpress.system.drawing.PointF

The rectangle location.

getPivot() Method

Returns the rectangle pivot point.

Declaration

public PointF getPivot()

Returns

Type Description
com.devexpress.system.drawing.PointF

The rectangle pivot point.

getRight() Method

Returns the right coordinate of the rectangle bounds.

Declaration

public float getRight()

Returns

Type Description
float

The right coordinate of the rectangle bounds.

getSkewX() Method

Returns the horizontal skew angle.

Declaration

public double getSkewX()

Returns

Type Description
double

The horizontal skew angle, in degrees.

getSkewY() Method

Returns the vertical skew angle.

Declaration

public double getSkewY()

Returns

Type Description
double

The vertical skew angle, in degrees.

getTop() Method

Returns the top coordinate of the rectangle bounds.

Declaration

public float getTop()

Returns

Type Description
float

The top coordinate of the rectangle bounds.

getTopLeft() Method

Returns the top-left vertex of the rectangle.

Declaration

public PointF getTopLeft()

Returns

Type Description
com.devexpress.system.drawing.PointF

The top-left vertex of the rectangle.

getTopRight() Method

Returns the top-right vertex of the rectangle.

Declaration

public PointF getTopRight()

Returns

Type Description
com.devexpress.system.drawing.PointF

The top-right vertex of the rectangle.

getVertices() Method

Returns the rectangle vertices.

Declaration

public PointF[] getVertices()

Returns

Type Description
com.devexpress.system.drawing.PointF[]

The rectangle vertices.

getWidth() Method

Returns the rectangle width.

Declaration

public float getWidth()

Returns

Type Description
float

The rectangle width.

hashCode() Method

Returns the hash code for the oriented rectangle.

Declaration

public int hashCode()

Returns

Type Description
int

The hash code for the oriented rectangle.