Loading preferred layouts from .ivl files

The settings of the preferred layouts can be loaded from .ivl files using the method:
boolean loadPreferredLayoutsFromNamedProperties(IlvDefaultLayoutProvider 
provider, boolean withParameters, boolean traverse);   
The method takes the Layout Provider as an argument and several flags:
  • withParameters : if the flag is true , the parameters of the preferred layout instances are loaded. In this case it is not necessary to use the method loadParametersFromNamedProperties . Otherwise, after loading the .ivl file, the preferred layout will have, in this case, the default values for all its parameters.
  • traverse : if the flag is true , the method applies recursively to the subgraphs. Otherwise, the method loads only the preferred layout of the grapher adapter on which the method is called.
This method reads the named properties stored in the file and sets the preferred layout (if any has been stored) on the Layout Provider, using its method setPreferredLayout .
The following example shows how to load and recover the preferred layouts (with their parameters) when the preferred layout settings are stored in an .ivl file:
IlvGrapher grapher = new IlvGrapher();

// Create the grapher adapter for the topmost graph
IlvGrapherAdapter adapter = new IlvGrapherAdapter(grapher);

// Load the graphers from the .ivl file
grapher.read("abcd.ivl");

// Create the layout provider
IlvDefaultLayoutProvider provider = new IlvDefaultLayoutProvider();

// Load the preferred layouts into the provider
// (layout parameters are also read)
adapter.loadPreferredLayoutsFromNamedProperties(provider, true, true);

// Now the provider can be used to perform the recursive layout

adapter.performLayout(provider, true, true, true);

// Detach the layouts when the provider is no longer needed
provider.detachLayouts(adapter, true);
// Dispose the topmost adapter when no longer needed
adapter.dispose();