StrokeInputBatch


public abstract class StrokeInputBatch

Known direct subclasses
ImmutableStrokeInputBatch

An immutable implementation of StrokeInputBatch.

MutableStrokeInputBatch

A mutable implementation of StrokeInputBatch.


A read-only view of an object that stores multiple StrokeInput values together in a more memory-efficient manner than just List<StrokeInput>. The input points in this batch are guaranteed to be consistent with one another – for example, they all have the same toolType and the same set of optional fields like pressure/tilt/orientation, and their timestamps are all monotonically non-decreasing. This can be an ImmutableStrokeInputBatch for data that cannot change, and a MutableStrokeInputBatch for data that is meant to be modified or incrementally built.

Summary

Public methods

final @NonNull StrokeInput
get(int index)

Gets the value of the i-th input.

final long

The duration between the first and last input in milliseconds.

final int

Number of StrokeInput objects in the batch.

final float

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

final @NonNull InputToolType

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

final boolean

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

final boolean

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

final boolean

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

final boolean

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

final boolean

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

final @NonNull StrokeInput
populate(int index, @NonNull StrokeInput outStrokeInput)

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

Protected methods

final void

Public methods

get

Added in 1.0.0-alpha02
public final @NonNull StrokeInput get(int index)

Gets the value of the i-th input. Requires that index is positive and less than size.

In performance-sensitive code, prefer to use populate to pass in a pre-allocated instance and reuse that instance across multiple calls to this function.

getDurationMillis

Added in 1.0.0-alpha02
public final long getDurationMillis()

The duration between the first and last input in milliseconds.

getSize

Added in 1.0.0-alpha02
public final int getSize()

Number of StrokeInput objects in the batch.

getStrokeUnitLengthCm

Added in 1.0.0-alpha02
public final float getStrokeUnitLengthCm()

The physical distance in centimeters that the pointer must travel in order to produce an input motion of one stroke unit. For stylus/touch, this is the real-world distance that the stylus/fingertip must move in physical space; for mouse, this is the visual distance that the mouse pointer must travel along the surface of the display.

A value of StrokeInput.NO_STROKE_UNIT_LENGTH indicates that the relationship between stroke space and physical space is unknown or ill-defined.

getToolType

Added in 1.0.0-alpha02
public final @NonNull InputToolType getToolType()

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

hasOrientation

Added in 1.0.0-alpha02
public final boolean hasOrientation()

Whether all of the individual inputs have a defined value for StrokeInput.orientationRadians. If not, then no input items have an orientation value.

hasPressure

Added in 1.0.0-alpha02
public final boolean hasPressure()

Whether all of the individual inputs have a defined value for StrokeInput.pressure. If not, then no input items have a pressure value.

hasStrokeUnitLength

Added in 1.0.0-alpha02
public final boolean hasStrokeUnitLength()

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

hasTilt

Added in 1.0.0-alpha02
public final boolean hasTilt()

Whether all of the individual inputs have a defined value for StrokeInput.tiltRadians. If not, then no input items have a tilt value.

isEmpty

Added in 1.0.0-alpha02
public final boolean isEmpty()

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

populate

Added in 1.0.0-alpha02
public final @NonNull StrokeInput populate(int index, @NonNull StrokeInput outStrokeInput)

Gets the value of the i-th input and overwrites outStrokeInput, which it then returns. Requires that index is positive and less than size.

Protected methods

finalize

Added in 1.0.0-alpha02
protected final void finalize()