# BoxAccumulator

Artifact: [androidx.ink:ink-geometry](https://developer.android.com/jetpack/androidx/releases/ink) [View Source](https://cs.android.com/search?q=file:androidx/ink/geometry/BoxAccumulator.kt+class:androidx.ink.geometry.BoxAccumulator) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

*** ** * ** ***

<br />

```
public final class BoxAccumulator
```

<br />

*** ** * ** ***

A helper class for accumulating the minimum bounding boxes of zero or more geometry objects. In colloquial terms, this can be used to find the smallest Box that contains a set of objects.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#BoxAccumulator()()` |
| `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#BoxAccumulator(androidx.ink.geometry.Box)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Box box)` Constructs a `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator`, populating the to accumulated bounding box from `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#(androidx.ink.geometry.Box)`. |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Box)(https://developer.android.com/reference/androidx/ink/geometry/Box box)` Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Box)`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.PartitionedMesh)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/PartitionedMesh mesh)` Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.PartitionedMesh)`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.BoxAccumulator)(https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator other)` Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.BoxAccumulator)`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Parallelogram)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Parallelogram parallelogram)` Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Parallelogram)`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Vec)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec point)` Expands the accumulated bounding box (if necessary) such that it also contains `Point`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Segment)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Segment segment)` Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Segment)`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Triangle)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Triangle triangle)` Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Triangle)`. |
| `boolean` | `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final https://developer.android.com/reference/androidx/ink/geometry/Box` | `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#getBox()()` The currently accumulated bounding box, or null if empty. |
| `int` | `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#hashCode()()` |
| `final boolean` | `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#isAlmostEqual(androidx.ink.geometry.BoxAccumulator,kotlin.Float)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator other, @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float tolerance )` Compares this `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` with `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#isAlmostEqual(androidx.ink.geometry.BoxAccumulator,kotlin.Float)`, and returns true if either: Both this and `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#isAlmostEqual(androidx.ink.geometry.BoxAccumulator,kotlin.Float)` are empty, or neither this and `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#isAlmostEqual(androidx.ink.geometry.BoxAccumulator,kotlin.Float)` are empty and their `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#box()`es are almost equal per `https://developer.android.com/reference/androidx/ink/geometry/Box#isAlmostEqual(androidx.ink.geometry.Box,kotlin.Float)` |
| `final boolean` | `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#isEmpty()()` Returns true if this `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` is not empty; this is equivalent to checking if the `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#box()` property is null. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#populateFrom(androidx.ink.geometry.Box)(https://developer.android.com/reference/androidx/ink/geometry/Box input)` Resets the `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` instance to contain just `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#populateFrom(androidx.ink.geometry.Box)`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#reset()()` Reset this object to have no bounds. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#toString()()` |

| ### Extension functions |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/androidx/ink/geometry/AndroidGraphicsConverter.https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#(androidx.ink.geometry.BoxAccumulator).add(android.graphics.RectF)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/RectF.html rect )` Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/androidx/ink/geometry/package-summary#(androidx.ink.geometry.BoxAccumulator).add(android.graphics.RectF)`. |
| `final boolean` | `https://developer.android.com/reference/androidx/ink/geometry/AndroidGraphicsConverter.https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#(androidx.ink.geometry.BoxAccumulator).getBounds(android.graphics.RectF)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/RectF.html outRect )` Fill the given `https://developer.android.com/reference/android/graphics/RectF.html` with the bounds of this `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator`, returning whether or not the object was actually overwritten. |

## Public constructors

### BoxAccumulator

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public BoxAccumulator()
```

### BoxAccumulator

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public BoxAccumulator(@NonNull Box box)
```

Constructs a `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator`, populating the to accumulated bounding box from `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#(androidx.ink.geometry.Box)`.

## Public methods

### add

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull BoxAccumulator add(Box box)
```

Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Box)`. If `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Box)` is null, this is a no-op.

Returns the modified instance to allow chaining function calls.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` | `this` |

### add

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull BoxAccumulator add(@NonNull PartitionedMesh mesh)
```

Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.PartitionedMesh)`. If `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.PartitionedMesh)` is empty, this is a no-op.

Returns the modified instance to allow chaining function calls.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` | `this` |

### add

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull BoxAccumulator add(BoxAccumulator other)
```

Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.BoxAccumulator)`. If `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.BoxAccumulator)` is null, this is a no-op.

Returns the modified instance to allow chaining function calls.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` | `this` |

### add

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull BoxAccumulator add(@NonNull Parallelogram parallelogram)
```

Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Parallelogram)`.

Returns the modified instance to allow chaining function calls.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` | `this` |

### add

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull BoxAccumulator add(@NonNull Vec point)
```

Expands the accumulated bounding box (if necessary) such that it also contains `Point`.

Returns the modified instance to allow chaining function calls.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` | `this` |

### add

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull BoxAccumulator add(@NonNull Segment segment)
```

Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Segment)`.

Returns the modified instance to allow chaining function calls.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` | `this` |

### add

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull BoxAccumulator add(@NonNull Triangle triangle)
```

Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Triangle)`.

Returns the modified instance to allow chaining function calls.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` | `this` |

### equals

```
public boolean equals(Object other)
```

### getBox

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final Box getBox()
```

The currently accumulated bounding box, or null if empty.

### hashCode

```
public int hashCode()
```

### isAlmostEqual

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final boolean isAlmostEqual(
    @NonNull BoxAccumulator other,
    @FloatRange(from = 0.0) float tolerance
)
```

Compares this `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` with `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#isAlmostEqual(androidx.ink.geometry.BoxAccumulator,kotlin.Float)`, and returns true if either: Both this and `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#isAlmostEqual(androidx.ink.geometry.BoxAccumulator,kotlin.Float)` are empty, or neither this and `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#isAlmostEqual(androidx.ink.geometry.BoxAccumulator,kotlin.Float)` are empty and their `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#box()`es are almost equal per `https://developer.android.com/reference/androidx/ink/geometry/Box#isAlmostEqual(androidx.ink.geometry.Box,kotlin.Float)`

### isEmpty

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final boolean isEmpty()
```

Returns true if this `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` is not empty; this is equivalent to checking if the `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#box()` property is null.

Note that a zero-area `https://developer.android.com/reference/androidx/ink/geometry/Box` is not considered empty, as a `https://developer.android.com/reference/androidx/ink/geometry/Box` contains its boundary; so `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#isEmpty()` will return false even if you have added only a single point to the `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator`.

### populateFrom

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull BoxAccumulator populateFrom(Box input)
```

Resets the `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` instance to contain just `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#populateFrom(androidx.ink.geometry.Box)`. If `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator#populateFrom(androidx.ink.geometry.Box)` is null, the instance will be reset to empty.

Returns the modified instance to allow chaining function calls.

A `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` can be efficiently set to the same values as another `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` with `populateFrom(other.box)`.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` | `this` |

### reset

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull BoxAccumulator reset()
```

Reset this object to have no bounds.

Returns the modified instance to allow chaining function calls.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` | `this` |

### toString

```
public @NonNull String toString()
```

## Extension functions

### AndroidGraphicsConverter.add

Artifact: [androidx.ink:ink-geometry](https://developer.android.com/jetpack/androidx/releases/ink) [View Source](https://cs.android.com/search?q=file:androidx/ink/geometry/AndroidGraphicsConversionExtensions.android.kt+function:add)

```
public final @NonNull BoxAccumulator AndroidGraphicsConverter.add(
    @NonNull BoxAccumulator receiver,
    @NonNull RectF rect
)
```

Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/androidx/ink/geometry/package-summary#(androidx.ink.geometry.BoxAccumulator).add(android.graphics.RectF)`. If `https://developer.android.com/reference/androidx/ink/geometry/package-summary#(androidx.ink.geometry.BoxAccumulator).add(android.graphics.RectF)` is null, this is a no-op.

This is functionally equivalent to, but more efficient than: `add(ImmutableBox.from(rect))`

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator` | `this` |

### AndroidGraphicsConverter.getBounds

Artifact: [androidx.ink:ink-geometry](https://developer.android.com/jetpack/androidx/releases/ink) [View Source](https://cs.android.com/search?q=file:androidx/ink/geometry/AndroidGraphicsConversionExtensions.android.kt+function:getBounds)

```
public final boolean AndroidGraphicsConverter.getBounds(
    @NonNull BoxAccumulator receiver,
    @NonNull RectF outRect
)
```

Fill the given `https://developer.android.com/reference/android/graphics/RectF.html` with the bounds of this `https://developer.android.com/reference/androidx/ink/geometry/BoxAccumulator`, returning whether or not the object was actually overwritten.