ImmutableBox


public final class ImmutableBox extends Box


An immutable axis-aligned rectangle. See MutableBox for a mutable version.

Note that unlike android.graphics.RectF, this does not express an opinion about axis direction (e.g. the positive Y axis being "down"), because it is intended to be used with any coordinate system rather than just Android screen/View space.

Summary

Public methods

boolean
equals(Object other)
static final @NonNull ImmutableBox
fromCenterAndDimensions(
    @NonNull Vec center,
    @FloatRange(from = 0.0) float width,
    @FloatRange(from = 0.0) float height
)

Constructs an ImmutableBox with a given center, width, and height.

static final @NonNull ImmutableBox
fromTwoPoints(@NonNull Vec point1, @NonNull Vec point2)

Constructs the smallest ImmutableBox containing the two given points.

float

The upper bound in the X direction.

float

The lower bound in the X direction.

float

The upper bound in the Y direction.

float

The lower bound in the Y direction.

int
@NonNull String

Inherited methods

From androidx.ink.geometry.Box
final @NonNull MutableVec

Populates outVec with the center of the Box, and returns outVec.

final void
computeCorners(
    @NonNull MutableVec outVecXMinYMin,
    @NonNull MutableVec outVecXMaxYMin,
    @NonNull MutableVec outVecXMaxYMax,
    @NonNull MutableVec outVecXMinYMax
)

Populates the 4 output points with the corners of the Box.

final boolean
contains(@NonNull Box otherBox)

Returns whether the other Box is contained within this Box.

final boolean

Returns whether the given point is contained within the Box.

final @FloatRange(from = 0.0) float

The height of the rectangle.

final @FloatRange(from = 0.0) float

The width of the rectangle.

final boolean
isAlmostEqual(@NonNull Box other, @FloatRange(from = 0.0) float tolerance)

Compares this Box with other, and returns true if the difference between xMin and other.xMin is less than tolerance, and likewise for xMax, yMin, and yMax.

Public methods

equals

public boolean equals(Object other)

fromCenterAndDimensions

Added in 1.0.0-alpha01
public static final @NonNull ImmutableBox fromCenterAndDimensions(
    @NonNull Vec center,
    @FloatRange(from = 0.0) float width,
    @FloatRange(from = 0.0) float height
)

Constructs an ImmutableBox with a given center, width, and height.

fromTwoPoints

Added in 1.0.0-alpha01
public static final @NonNull ImmutableBox fromTwoPoints(@NonNull Vec point1, @NonNull Vec point2)

Constructs the smallest ImmutableBox containing the two given points.

getXMax

Added in 1.0.0-alpha01
public float getXMax()

The upper bound in the X direction.

getXMin

Added in 1.0.0-alpha01
public float getXMin()

The lower bound in the X direction.

getYMax

Added in 1.0.0-alpha01
public float getYMax()

The upper bound in the Y direction.

getYMin

Added in 1.0.0-alpha01
public float getYMin()

The lower bound in the Y direction.

hashCode

public int hashCode()

toString

public @NonNull String toString()