MutableBox


public final class MutableBox extends Box


A mutable axis-aligned rectangle. See ImmutableBox for an immutable 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 constructors

Constructs a MutableBox without any initial data.

Public methods

boolean
equals(Object other)
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
final @NonNull MutableBox

Fills this MutableBox with the same values contained in input.

final @NonNull MutableBox
populateFromCenterAndDimensions(
    @NonNull Vec center,
    @FloatRange(from = 0.0) float width,
    @FloatRange(from = 0.0) float height
)

Constructs a MutableBox with a given center, width, and height.

final @NonNull MutableBox

Constructs the smallest MutableBox containing the two given points.

final @NonNull MutableBox
setXBounds(float x1, float x2)

Sets the lower and upper bounds in the X direction to new values.

final @NonNull MutableBox
setYBounds(float y1, float y2)

Sets the lower and upper bounds in the Y direction to new values.

@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 constructors

MutableBox

Added in 1.0.0-alpha01
public MutableBox()

Constructs a MutableBox without any initial data. Fill with the appropriate setters or factory functions.

Public methods

equals

public boolean equals(Object other)

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()

populateFrom

Added in 1.0.0-alpha01
public final @NonNull MutableBox populateFrom(@NonNull Box input)

Fills this MutableBox with the same values contained in input.

populateFromCenterAndDimensions

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

Constructs a MutableBox with a given center, width, and height. width and height must be non-negative numbers.

populateFromTwoPoints

Added in 1.0.0-alpha01
public final @NonNull MutableBox populateFromTwoPoints(@NonNull Vec point1, @NonNull Vec point2)

Constructs the smallest MutableBox containing the two given points.

setXBounds

Added in 1.0.0-alpha01
public final @NonNull MutableBox setXBounds(float x1, float x2)

Sets the lower and upper bounds in the X direction to new values. The minimum value becomes xMin, and the maximum value becomes xMax. Returns the same instance to chain function calls.

setYBounds

Added in 1.0.0-alpha01
public final @NonNull MutableBox setYBounds(float y1, float y2)

Sets the lower and upper bounds in the Y direction to new values. The minimum value becomes yMin, and the maximum value becomes yMax. Returns the same instance to chain function calls.

toString

public @NonNull String toString()