MutableStrokeInputBatch


class MutableStrokeInputBatch : StrokeInputBatch


A mutable implementation of StrokeInputBatch. For an immutable alternative, see ImmutableStrokeInputBatch.

Each appended StrokeInput value is validated compared to the existing batch contents. This means:

  1. All floating point values are required to be finite and the format of all inputs must be consistent. This means all inputs must have the same set of optional member variables that hold a value. For example, every input holds a pressure value if-and-only-if every other input holds a pressure value. This is also true for tiltRadians and orientationRadians.

  2. The sequence of StrokeInput values must not contain repeated x-y-t triplets, and the time values must be non-negative and non-decreasing.

  3. Values of strokeUnitLengthCm must be finite and positive, or be StrokeInput.NO_STROKE_UNIT_LENGTH.

  4. Values of StrokeInput.pressure must fall within the range of 0, 1 or be StrokeInput.NO_PRESSURE

  5. Values of StrokeInput.tiltRadians must fall within the range of 0, π/2 or be StrokeInput.NO_TILT.

  6. Values of StrokeInput.orientationRadians must fall within the range of [0, 2π) or be StrokeInput.NO_ORIENTATION.

  7. The toolType and strokeUnitLengthCm values must be the same across all inputs.

Summary

Public constructors

Public functions

MutableStrokeInputBatch

Validates and appends an inputBatch.

MutableStrokeInputBatch

Validates and appends an input.

MutableStrokeInputBatch

Validates and appends a collection of StrokeInput.

MutableStrokeInputBatch
addOrIgnore(
    type: InputToolType,
    x: Float,
    y: Float,
    elapsedTimeMillis: Long,
    strokeUnitLengthCm: Float,
    pressure: Float,
    tiltRadians: Float,
    orientationRadians: Float
)

Validates and appends an input.

MutableStrokeInputBatch

Validates and appends an inputBatch.

MutableStrokeInputBatch

Validates and appends an input.

MutableStrokeInputBatch

Validates and appends a collection of StrokeInput.

MutableStrokeInputBatch
addOrThrow(
    type: InputToolType,
    x: Float,
    y: Float,
    elapsedTimeMillis: Long,
    strokeUnitLengthCm: Float,
    pressure: Float,
    tiltRadians: Float,
    orientationRadians: Float
)

Validates and appends an input.

Unit
open String

Inherited functions

From androidx.ink.strokes.StrokeInputBatch
Unit
operator StrokeInput
get(index: Int)

Gets the value of the i-th input.

Long

The duration between the first and last input in milliseconds.

Float

The physical distance in centimeters that the pointer must travel in order to produce an input motion of one stroke unit.

InputToolType

How this input stream should be interpreted, as coming from a InputToolType.MOUSE, InputToolType.TOUCH, or InputToolType.STYLUS.

Boolean

Whether all of the individual inputs have a defined value for StrokeInput.orientationRadians.

Boolean

Whether all of the individual inputs have a defined value for StrokeInput.pressure.

Boolean

Whether strokeUnitLengthCm has a valid value, which is something other than StrokeInput.NO_STROKE_UNIT_LENGTH.

Boolean

Whether all of the individual inputs have a defined value for StrokeInput.tiltRadians.

Boolean

true if there are no StrokeInput objects in the batch, and false otherwise.

StrokeInput
populate(index: Int, outStrokeInput: StrokeInput)

Gets the value of the i-th input and overwrites outStrokeInput, which it then returns.

Inherited properties

From androidx.ink.strokes.StrokeInputBatch
Int

Number of StrokeInput objects in the batch.

Public constructors

MutableStrokeInputBatch

Added in 1.0.0-alpha01
MutableStrokeInputBatch()

Public functions

addOrIgnore

Added in 1.0.0-alpha01
fun addOrIgnore(inputBatch: StrokeInputBatch): MutableStrokeInputBatch

Validates and appends an inputBatch. Invalid inputBatch will result in no change. No exception will be thrown for invalid additions.

addOrIgnore

Added in 1.0.0-alpha01
fun addOrIgnore(input: StrokeInput): MutableStrokeInputBatch

Validates and appends an input. Invalid input will result in no change. No exception will be thrown for invalid additions.

addOrIgnore

Added in 1.0.0-alpha01
fun addOrIgnore(inputs: Collection<StrokeInput>): MutableStrokeInputBatch

Validates and appends a collection of StrokeInput. Invalid inputs will result in no change. No exception will be thrown for invalid additions.

addOrIgnore

Added in 1.0.0-alpha01
fun addOrIgnore(
    type: InputToolType,
    x: Float,
    y: Float,
    elapsedTimeMillis: Long,
    strokeUnitLengthCm: Float = StrokeInput.NO_STROKE_UNIT_LENGTH,
    pressure: Float = StrokeInput.NO_PRESSURE,
    tiltRadians: Float = StrokeInput.NO_TILT,
    orientationRadians: Float = StrokeInput.NO_ORIENTATION
): MutableStrokeInputBatch

Validates and appends an input. Invalid input will result in no change. No exception will be thrown for invalid additions.

addOrThrow

Added in 1.0.0-alpha01
fun addOrThrow(inputBatch: StrokeInputBatch): MutableStrokeInputBatch

Validates and appends an inputBatch. Invalid inputBatch will result in no change. An exception will be thrown for invalid additions.

addOrThrow

Added in 1.0.0-alpha01
fun addOrThrow(input: StrokeInput): MutableStrokeInputBatch

Validates and appends an input. Invalid input will result in no change. An exception will be thrown for invalid additions.

addOrThrow

Added in 1.0.0-alpha01
fun addOrThrow(inputs: Collection<StrokeInput>): MutableStrokeInputBatch

Validates and appends a collection of StrokeInput. Invalid inputs will result in no change. An exception will be thrown for invalid additions.

addOrThrow

Added in 1.0.0-alpha01
fun addOrThrow(
    type: InputToolType,
    x: Float,
    y: Float,
    elapsedTimeMillis: Long,
    strokeUnitLengthCm: Float = StrokeInput.NO_STROKE_UNIT_LENGTH,
    pressure: Float = StrokeInput.NO_PRESSURE,
    tiltRadians: Float = StrokeInput.NO_TILT,
    orientationRadians: Float = StrokeInput.NO_ORIENTATION
): MutableStrokeInputBatch

Validates and appends an input. Invalid input will result in no change. An exception will be thrown for invalid additions.

clear

Added in 1.0.0-alpha01
fun clear(): Unit

toString

open fun toString(): String