Interface parameters
Some layout classes allow an interface as input parameter. For
instance, the method
setNodeBoxInterface
sets an IlvNodeBoxInterface (see IlvLinkLayout, IlvShortLinkLayout, and so on). If an
application uses a node box class that implements the node box
interface, this can only be stored to an
.ivl
file if the node box class also implements the
IlvPersistentObject
interface. Otherwise, the node box class is not saved to the
.ivl
file.
Compatibility issues
An
.ivl
file that contains layout properties can be loaded only when the
package ilog.views.graphlayout and its subpackages
are available.
Defining your own type of layout
If you develop your own layout algorithms by subclassing
IlvGraphLayout
and want to save the layout parameters of your own layout
algorithm in
.ivl
files, you should subclass IlvGraphLayoutGrapherProperty, IlvGraphLayoutNodeProperty, and IlvGraphLayoutLinkProperty, see Defining your own type of layout. You can
find example code by referring to these classes in the Java™ API
Reference Manual. You should also override the following methods
of
IlvGraphLayout
to return your subclasses:
protected IlvGraphLayoutGrapherProperty createLayoutGrapherProperty( String name, boolean withDefaults) { return new MyOwnLayoutGrapherProperty(name, this, withDefaults); } protected IlvGraphLayoutNodeProperty createLayoutNodeProperty( String name, IlvGraphic node, boolean withDefaults) { return new MyOwnLayoutNodeProperty(name, this, node, withDefaults); } protected IlvGraphLayoutLinkProperty createLayoutLinkProperty( String name, IlvGraphic link, boolean withDefaults) { return new MyOwnLayoutLinkProperty(name, this, link, withDefaults); }
Further applications of layout properties
The layout properties can be serialized. If you prefer to use the
standard serialization mechanism of Java instead of
.ivl
files, it is recommended to use the layout properties as well
because it guarantees that only the parameters are serialized and
not any temporary data that may exist in the layout instance.
The following code shows an easy way to copy the parameter
setting from
layout1
to
layout2
:
IlvGrapherAdapter adapter1 = (IlvGrapherAdapter)layout1.getGraphModel(); IlvGrapherAdapter adapter2 = (IlvGrapherAdapter)layout2.getGraphModel(); adapter1.saveParametersToNamedProperties(layout1, true); adapter2.loadParametersFromNamedProperties(layout2);
The following code shows an easy way to
undo temporary changes of layout parameters:
IlvGrapherAdapter adapter = (IlvGrapherAdapter)layout.getGraphModel(); adapter.saveParametersToNamedProperties(layout, true); ... change layout parameters ... work with changed parameters // restore the layout parameters as they were before adapter.loadParametersFromNamedProperties(layout);