A
NodeView
displays an internal view model or data structure generated by the underlying NodeModel
. While the generated DataTables
and the user settings are stored automatically, the structure of the internal model is not predictable, thus, it has to be saved and loaded manually. Then the data for the view is available after re-opening an executed workflow.
The first parameter is the directory to store the files into, the second is an ExecutionMonitor
to report progress during these operations.
There are three possibilities to load and store the internal model:
- NodeSettings
- DataContainer
- own format
- user settings
- data provided at the outport (unless you need exactly this data for visualization purposes)
- data provided at the model outport (this is loaded and saved with the methods load/saveModelContent)
load-/saveInternals
and the reset
method. Everything which is necessary to restore the view and therefore has to be saved and loaded, has to be deleted in the reset
method, since the view displays the result of the execute
method and the reset
method should set the node to its initial state, i.e. as it was before execution.
NodeSettings:
TheNodeSettings
as already known from the NodeDialog
can also be used for the loading and saving of the internal view model. This is especially useful, if the internal view model is not very large or fits the structure of the NodeSettings
well. Saving using the NodeSettings
is done in the following way:
Example #1:
// create a settings object with a config name NodeSettings settings =new
NodeSettings(CFG_SETTINGSNAME); // store your values under a certain key settings.addInt(CFG_INT, yourInt); // create a file in the given directory File f =new
File(internDir, CFG_FILENAME); // and save it settings.saveToXML(new
FileOutputStream(f));
DataContainer:
If your internal model is stored in a DataTable (as for example in a scatter plot), then it is recommended to use the following approach, using the load and save mechanism of the DataContainer.Example #2:
// create the file
File f = new
File(internDir, CFG_FILENAME);
// store the table as a zipped archive
DataContainer.writeToZip(yourTable, f, exec);
Own Format:
Since only a directory is passed to the methods, theoretically any format is possible to store the internal model. However, the two above mentioned approaches are recommended. Defining you own format for the persistence of the internal model should only be done, if the internal model doesn't fit neither into theNodeSettings
nor into the DataTable
or if an own format increases the performance dramatically.