Class PACurveMakerIO

java.lang.Object
net.paulhertz.pixelaudio.io.PACurveMakerIO

public final class PACurveMakerIO extends Object
JSON read/write support for PACurveMaker.
Filename convention suggestion: gesture_001_gesture.json Used in the example sketch Bagatelle.
  • Field Details

  • Constructor Details

    • PACurveMakerIO

      private PACurveMakerIO()
  • Method Details

    • toJson

      public static processing.data.JSONObject toJson(PACurveMaker curve, PACurveMakerIO.Meta meta)
      Serializes a PACurveMaker to a JSON object.
      Parameters:
      curve - curve to serialize
      meta - 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 file
      curve - curve to serialize
      meta - optional metadata
      Throws:
      IOException - if the file cannot be written
    • read

      public static PACurveMakerIO.Result read(File file) throws IOException
      Reads a curve JSON file.
      Parameters:
      file - source file
      Returns:
      parsed gesture result
      Throws:
      IOException - if the file cannot be read
    • fromJson

      public static PACurveMakerIO.Result fromJson(processing.data.JSONObject root)
      Reconstructs a curve from a parsed JSON root object.
      Parameters:
      root - parsed JSON root
      Returns:
      parsed gesture result
    • pointsToJson

      private static processing.data.JSONArray pointsToJson(List<processing.core.PVector> points)
    • jsonToPoints

      private static ArrayList<processing.core.PVector> jsonToPoints(processing.data.JSONArray arr)
    • intsToJson

      private static processing.data.JSONArray intsToJson(int[] values)
    • jsonToIntsList

      private static ArrayList<Integer> jsonToIntsList(processing.data.JSONArray arr)
    • requireHeader

      private static void requireHeader(processing.data.JSONObject header, String expectedFormat, int expectedVersion)
    • putIfPresent

      private static void putIfPresent(processing.data.JSONObject obj, String key, String value)
    • nonNull

      private static String nonNull(String value, String fallback)