Package net.paulhertz.pixelaudio.io
Class PACurveMakerIO
java.lang.Object
net.paulhertz.pixelaudio.io.PACurveMakerIO
JSON read/write support for PACurveMaker.
Filename convention suggestion: gesture_001_gesture.json Used in the example sketch
Filename convention suggestion: gesture_001_gesture.json Used in the example sketch
Bagatelle.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classOptional metadata written with a gesture JSON file.static final classResult of reading a gesture JSON file. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PACurveMakerIO.ResultfromJson(processing.data.JSONObject root) Reconstructs a curve from a parsed JSON root object.private static processing.data.JSONArrayintsToJson(int[] values) jsonToIntsList(processing.data.JSONArray arr) private static ArrayList<processing.core.PVector>jsonToPoints(processing.data.JSONArray arr) private static Stringprivate static processing.data.JSONArraypointsToJson(List<processing.core.PVector> points) private static voidputIfPresent(processing.data.JSONObject obj, String key, String value) static PACurveMakerIO.ResultReads a curve JSON file.private static voidrequireHeader(processing.data.JSONObject header, String expectedFormat, int expectedVersion) static processing.data.JSONObjecttoJson(PACurveMaker curve, PACurveMakerIO.Meta meta) Serializes aPACurveMakerto a JSON object.static voidwrite(File file, PACurveMaker curve, PACurveMakerIO.Meta meta) Writes a curve JSON file.
-
Field Details
-
FORMAT
Format identifier written to gesture JSON headers.- See Also:
-
VERSION
public static final int VERSIONGesture JSON format version.- See Also:
-
-
Constructor Details
-
PACurveMakerIO
private PACurveMakerIO()
-
-
Method Details
-
toJson
Serializes aPACurveMakerto a JSON object.- Parameters:
curve- curve to serializemeta- optional metadata- Returns:
- JSON root object
-
write
public static void write(File file, PACurveMaker curve, PACurveMakerIO.Meta meta) throws IOException Writes a curve JSON file.- Parameters:
file- destination filecurve- curve to serializemeta- optional metadata- Throws:
IOException- if the file cannot be written
-
read
Reads a curve JSON file.- Parameters:
file- source file- Returns:
- parsed gesture result
- Throws:
IOException- if the file cannot be read
-
fromJson
Reconstructs a curve from a parsed JSON root object.- Parameters:
root- parsed JSON root- Returns:
- parsed gesture result
-
pointsToJson
-
jsonToPoints
-
intsToJson
private static processing.data.JSONArray intsToJson(int[] values) -
jsonToIntsList
-
requireHeader
private static void requireHeader(processing.data.JSONObject header, String expectedFormat, int expectedVersion) -
putIfPresent
-
nonNull
-