Saving layout parameters to .ivl files

The following example shows how to save the IlvGrapher including all layout parameter settings into an .ivl file. The example assumes that an IlvGrapher is attached to three instances layout1 , layout2 and layout3 .
IlvGrapherAdapter adapter1 = (IlvGrapherAdapter)layout1.getGraphModel();
IlvGrapherAdapter adapter2 = (IlvGrapherAdapter)layout2.getGraphModel();
IlvGrapherAdapter adapter3 = (IlvGrapherAdapter)layout3.getGraphModel();
// transfer the layout parameters to named properties
if (layout1.supportsSaveParametersToNamedProperties())
  adapter1.saveParametersToNamedProperties(layout1, false);
if (layout2.supportsSaveParametersToNamedProperties())
  adapter2.saveParametersToNamedProperties(layout2, false);
if (layout3.supportsSaveParametersToNamedProperties())
  adapter3.saveParametersToNamedProperties(layout3, false);
// assume that adapter1, adapter2 and adapter3 work on the same grapher
// save the grapher with all 3 sets of named layout properties to file
grapher.write("abcd.ivl");
// remove the named layout properties because they are no longer needed
adapter1.removeParametersFromNamedProperties();
adapter2.removeParametersFromNamedProperties();
adapter3.removeParametersFromNamedProperties();
In this example, different grapher adapters of the same IlvGrapher are supposed to be attached to layout1 , layout2 and layout3 . If, in fact, the same grapher adapter (more precisely, grapher adapters that all work on the same set of nodes and links) is attached to all three layout instances, one call of the removeParametersFromNamedProperties method at the end is sufficient.
Take a look at the mechanism in detail:
String saveParametersToNamedProperties(IlvGraphLayout layout, boolean 
withDefaults);   
This method creates named properties for the input layout and transfers the complete layout parameter settings to these properties. The property name is an automatically generated, unique string that is returned. If the flag withDefaults is false , the created layout properties are persistent only if they contain a setting that is not the default setting. This means that the default values are not stored in the .ivl file and the file has a smaller size. If the flag withDefaults is true , the created properties are always persistent, that is, the default values are stored in the .ivl file as well.
The named properties that are created require additional memory. Therefore, it is recommended to remove them as soon as they are no longer needed. To remove the named layout properties, you can use one of the following methods:
The named layout properties are subclasses of IlvGraphLayoutGrapherProperty, IlvGraphLayoutNodeProperty, and IlvGraphLayoutLinkProperty, see the Java™ API Reference Manual for details of these classes.