Class GestureSchedule

java.lang.Object
net.paulhertz.pixelaudio.schedule.GestureSchedule
All Implemented Interfaces:
PAGesture

public final class GestureSchedule extends Object implements PAGesture
Data container for a PAGesture with immutable points and times and an optional start time (in milliseconds).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final List<processing.core.PVector>
    Gesture positions.
    long
    Optional absolute start time in milliseconds.
    final float[]
    Gesture time offsets in milliseconds, same length as points.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GestureSchedule(List<processing.core.PVector> points, float[] timesMs)
    Creates a gesture schedule from point and time arrays.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    Returns the schedule duration.
    static void
    Mutates a time array so values never decrease.
    List<processing.core.PVector>
    Dense gesture points.
    long
    Absolute start time (e.g.
    float[]
    Time offsets in ms, same length as getAllPoints(), first element typically 0.
    boolean
    Reports whether the gesture contains no points.
    static float[]
    normalizeTimesToStartAtZero(float[] timesMs)
    Returns a copy of the time array shifted so the first value is zero.
    void
    setStartTimeMs(long startTimeMs)
    Sets the absolute schedule start time.
    int
    Returns the number of gesture points.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.paulhertz.pixelaudio.curves.PAGesture

    getAllPointsSchedule
  • Field Details

    • points

      public final List<processing.core.PVector> points
      Gesture positions.
    • timesMs

      public final float[] timesMs
      Gesture time offsets in milliseconds, same length as points.
    • startTimeMs

      public long startTimeMs
      Optional absolute start time in milliseconds.
  • Constructor Details

    • GestureSchedule

      public GestureSchedule(List<processing.core.PVector> points, float[] timesMs)
      Creates a gesture schedule from point and time arrays.
      Parameters:
      points - gesture positions
      timesMs - time offsets in milliseconds, one per point
  • Method Details

    • getAllPoints

      public List<processing.core.PVector> getAllPoints()
      Description copied from interface: PAGesture
      Dense gesture points.
      Specified by:
      getAllPoints in interface PAGesture
      Returns:
      gesture points
    • getTimeOffsetsMs

      public float[] getTimeOffsetsMs()
      Description copied from interface: PAGesture
      Time offsets in ms, same length as getAllPoints(), first element typically 0.
      Specified by:
      getTimeOffsetsMs in interface PAGesture
      Returns:
      gesture time offsets in milliseconds
    • getStartTimeMs

      public long getStartTimeMs()
      Description copied from interface: PAGesture
      Absolute start time (e.g. millis() when gesture began).
      Specified by:
      getStartTimeMs in interface PAGesture
      Returns:
      absolute gesture start time in milliseconds
    • setStartTimeMs

      public void setStartTimeMs(long startTimeMs)
      Sets the absolute schedule start time.
      Parameters:
      startTimeMs - start time in milliseconds
    • size

      public int size()
      Description copied from interface: PAGesture
      Returns the number of gesture points.
      Specified by:
      size in interface PAGesture
      Returns:
      gesture point count
    • durationMs

      public float durationMs()
      Returns the schedule duration.
      Returns:
      elapsed milliseconds between first and last time offset
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: PAGesture
      Reports whether the gesture contains no points.
      Specified by:
      isEmpty in interface PAGesture
      Returns:
      true when the gesture has no points
    • normalizeTimesToStartAtZero

      public static float[] normalizeTimesToStartAtZero(float[] timesMs)
      Returns a copy of the time array shifted so the first value is zero.
      Parameters:
      timesMs - source time offsets
      Returns:
      normalized time offsets
    • enforceNonDecreasing

      public static void enforceNonDecreasing(float[] t)
      Mutates a time array so values never decrease.
      Parameters:
      t - time offsets to adjust in place