Package net.paulhertz.pixelaudio.curves
Class PABoundsPolicy
java.lang.Object
net.paulhertz.pixelaudio.curves.PABoundsPolicy
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumProvides descriptors for PABoundsPolicy: CLIP, WRAP, REFLECT, SKIP_TIME, KEEP_TIME. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPABoundsPolicy(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 TypeMethodDescriptionprocessing.core.PVectorapply(processing.core.PVector p) Applies the policy to a single point.private GestureScheduleDrop out-of-bounds points, preserve original timestamps of survivors.private GestureScheduleArrayList<processing.core.PVector>applyPoints(List<processing.core.PVector> points) Applies the policy pointwise to a list.applySchedule(GestureSchedule sched) Applies the policy to a GestureSchedule.private GestureScheduleDrop out-of-bounds points, compress time across removed spans.private static floatclamp(float v, float lo, float hi) booleancontains(float x, float y) booleancontains(processing.core.PVector p) static PABoundsPolicyfromWidthHeight(int width, int height, PABoundsPolicy.PABoundaryMode mode) floatheight()floatmaxX()floatmaxY()floatminX()floatminY()mode()private static floatreflect(float v, float lo, float hi) Reflect v repeatedly into [lo, hi].private static float[]toFloatArray(List<Float> vals) toString()floatwidth()private static floatwrap(float v, float origin, float size) Wrap v into [origin, origin + size).
-
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
-
-
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
-
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
Applies the policy pointwise to a list. CLIP / WRAP / REFLECT keep cardinality. SKIP_TIME / KEEP_TIME omit out-of-bounds points. -
applySchedule
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
-
applyKeepTimeSchedule
Drop out-of-bounds points, preserve original timestamps of survivors. -
applySkipTimeSchedule
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
-
toString
-