Package com.digitizer.io
Class JsonExporter
java.lang.Object
com.digitizer.io.JsonExporter
Handles JSON import and export of graph digitizer projects.
The JSON format contains project metadata (title and axis labels),
calibration settings (numeric ranges and log flags) and the complete list
of datasets and their points. The export path is compatible with the
ProjectJson model.
-
Method Summary
Modifier and TypeMethodDescriptionconvertJsonToDatasets(ProjectJson project, CalibrationState calibration) Converts imported JSON data back into application objects.static voidexportToJson(String filePath, String title, String xlabel, String ylabel, CalibrationState calibration, List<Dataset> datasets) Exports project data to a JSON file.static ProjectJsonimportFromJson(String filePath) Imports project data from a JSON file.
-
Method Details
-
exportToJson
public static void exportToJson(String filePath, String title, String xlabel, String ylabel, CalibrationState calibration, List<Dataset> datasets) throws IOException Exports project data to a JSON file.- Parameters:
filePath- the path where the JSON file will be writtentitle- the project titlexlabel- the x-axis labelylabel- the y-axis labelcalibration- the calibration state (may be null; defaults applied if null)datasets- the list of datasets to export- Throws:
IOException- if writing to the file fails
-
importFromJson
Imports project data from a JSON file.- Parameters:
filePath- the path to the JSON file to read- Returns:
- a ProjectJson object containing the imported data
- Throws:
IOException- if reading from the file failscom.google.gson.JsonSyntaxException- if the JSON is malformed
-
convertJsonToDatasets
public static List<Dataset> convertJsonToDatasets(ProjectJson project, CalibrationState calibration) Converts imported JSON data back into application objects.- Parameters:
project- the ProjectJson object imported from filecalibration- the CalibrationState to populate- Returns:
- a list of Dataset objects
-