Package net.paulhertz.pixelaudio.curves

# Class PABoundsPolicy

java.lang.Object
net.paulhertz.pixelaudio.curves.PABoundsPolicy

public final class PABoundsPolicy extends Object
Boundary policy for mapping gesture points into a rectangular domain. Intended use: geometric data in PACurveMaker and GestureSchedule may legitimately extend outside mapper/display bounds. This class applies an interpretation policy before point->index conversion. Spatial remap modes: CLIP clamp to rectangle WRAP wrap modulo width/height REFLECT reflect repeatedly across edges Omission/time modes: SKIP_TIME drop out-of-bounds points and compress time across removed spans KEEP_TIME drop out-of-bounds points and preserve surviving timestamps

See Also:
  - `code: Bagatelle, TutorialOne_03_Drawing, TutorialOne_04_Network, TutorialOne_06_WindowBuffer`

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `PABoundsPolicy.PABoundaryMode`
  Provides descriptors for PABoundsPolicy: CLIP, WRAP, REFLECT, SKIP_TIME, KEEP_TIME.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `private final float`
  `height`
  `private final float`
  `maxX`
  `private final float`
  `maxY`
  `private final float`
  `minX`
  `private final float`
  `minY`
  `private final PABoundsPolicy.PABoundaryMode`
  `mode`
  `private final float`
  `width`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PABoundsPolicy(float minX, float minY, float maxX, float maxY, PABoundsPolicy.PABoundaryMode mode)`
  Rectangle is inclusive on both ends: [minX..maxX], [minY..maxY].

- ## Method Summary

  Modifier and Type
  Method
  Description
  `processing.core.PVector`
  `apply(processing.core.PVector p)`
  Applies the policy to a single point.
  `private GestureSchedule`
  `applyKeepTimeSchedule(GestureSchedule sched)`
  Drop out-of-bounds points, preserve original timestamps of survivors.
  `private GestureSchedule`
  `applyMappedSchedule(GestureSchedule sched)`
  `ArrayList<processing.core.PVector>`
  `applyPoints(List<processing.core.PVector> points)`
  Applies the policy pointwise to a list.
  `GestureSchedule`
  `applySchedule(GestureSchedule sched)`
  Applies the policy to a GestureSchedule.
  `private GestureSchedule`
  `applySkipTimeSchedule(GestureSchedule sched)`
  Drop out-of-bounds points, compress time across removed spans.
  `private static float`
  `clamp(float v, float lo, float hi)`
  `boolean`
  `contains(float x, float y)`
  `boolean`
  `contains(processing.core.PVector p)`
  `static PABoundsPolicy`
  `fromWidthHeight(int width, int height, PABoundsPolicy.PABoundaryMode mode)`
  `float`
  `height()`
  `float`
  `maxX()`
  `float`
  `maxY()`
  `float`
  `minX()`
  `float`
  `minY()`
  `PABoundsPolicy.PABoundaryMode`
  `mode()`
  `private static float`
  `reflect(float v, float lo, float hi)`
  Reflect v repeatedly into [lo, hi].
  `private static float[]`
  `toFloatArray(List<Float> vals)`
  `String`
  `toString()`
  `float`
  `width()`
  `private static float`
  `wrap(float v, float origin, float size)`
  Wrap v into [origin, origin + size).

  ### Methods inherited from class java.lang.Object

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

- ## Field Details

  - ### minX

    private final float minX

  - ### minY

    private final float minY

  - ### maxX

    private final float maxX

  - ### maxY

    private final float maxY

  - ### width

    private final float width

  - ### height

    private final float height

  - ### mode

    private final PABoundsPolicy.PABoundaryMode mode

- ## Constructor Details

  - ### PABoundsPolicy

    public PABoundsPolicy(float minX, float minY, float maxX, float maxY, PABoundsPolicy.PABoundaryMode mode)
    Rectangle is inclusive on both ends: [minX..maxX], [minY..maxY].

- ## Method Details

  - ### fromWidthHeight

    public static PABoundsPolicy fromWidthHeight(int width, int height, PABoundsPolicy.PABoundaryMode mode)

  - ### minX

    public float minX()

  - ### minY

    public float minY()

  - ### maxX

    public float maxX()

  - ### maxY

    public float maxY()

  - ### width

    public float width()

  - ### height

    public float height()

  - ### mode

    public PABoundsPolicy.PABoundaryMode mode()

  - ### contains

    public boolean contains(float x, float y)

  - ### contains

    public boolean contains(processing.core.PVector p)

  - ### apply

    public processing.core.PVector apply(processing.core.PVector p)
    Applies the policy to a single point. For CLIP / WRAP / REFLECT: returns a mapped point. For SKIP_TIME / KEEP_TIME: returns the original point if in bounds, otherwise null.

  - ### applyPoints

    public ArrayList<processing.core.PVector> applyPoints(List<processing.core.PVector> points)
    Applies the policy pointwise to a list. CLIP / WRAP / REFLECT keep cardinality. SKIP_TIME / KEEP_TIME omit out-of-bounds points.

  - ### applySchedule

    public GestureSchedule applySchedule(GestureSchedule sched)
    Applies the policy to a GestureSchedule. CLIP / WRAP / REFLECT: preserve point count and times. KEEP_TIME: omit out-of-bounds points and keep surviving timestamps unchanged. SKIP_TIME: omit out-of-bounds points and compress time across removed spans. Returns null if the input is null.

  - ### applyMappedSchedule

    private GestureSchedule applyMappedSchedule(GestureSchedule sched)

  - ### applyKeepTimeSchedule

    private GestureSchedule applyKeepTimeSchedule(GestureSchedule sched)
    Drop out-of-bounds points, preserve original timestamps of survivors.

  - ### applySkipTimeSchedule

    private GestureSchedule applySkipTimeSchedule(GestureSchedule sched)
    Drop out-of-bounds points, compress time across removed spans. Example: original times [0, 100, 200, 300, 600] if points at 200,300 are dropped: result times [0, 100, 400] More precisely: each surviving point keeps its local in-bounds time, but accumulated durations spent entirely in skipped regions are removed.

  - ### clamp

    private static float clamp(float v, float lo, float hi)

  - ### wrap

    private static float wrap(float v, float origin, float size)
    Wrap v into [origin, origin + size). Since our public bounds are inclusive, callers should pass size=max-min+1.

  - ### reflect

    private static float reflect(float v, float lo, float hi)
    Reflect v repeatedly into [lo, hi]. Works for arbitrarily large excursions.

  - ### toFloatArray

    private static float[] toFloatArray(List<Float> vals)

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`