loadInternals

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:

  1. NodeSettings
  2. DataContainer
  3. own format

Important: with the above mentioned methods only the data used by the view should be loaded and saved. These methods are not intended to load and save:

  • 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)

Note: there is a strong connection between the 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:

The NodeSettings 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. Loading using the NodeSettings is done in the following way:

Example #1:

	// create the file 
File f = new File(internDir, CFG_FILENAME);
// load the settings from the file 
NodeSettingsRO settings = NodeSettings.loadFromXML(
	new FileInputStream(f));
// retrieve the stored values
int yourInt = settings.getInt(CFG_INT);

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);
// load the table 
yourTable = DataContainer.readFromZip(f);

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 the NodeSettings nor into the DataTable or if an own format increases the performance dramatically.