IGraph’s creation methods for elements allow creation of elements without explicitly
specifying initial properties like a style or an initial geometry. If an initial value is not explicitly specified,
a default value which is defined on IGraph’s nodeDefaults
or edgeDefaults properties is used.
Note that the defaults for labels and ports are not defined in a property of IGraph
but in properties of the INodeDefaults and IEdgeDefaults, respectively.
This allows different default configurations for node and edge labels and ports. Similarly,
the defaults for port labels are defined in the IPortDefaults which themselves are defined
in the defaults of the port’s owner.
If no style is provided upon creation the IGraph implementations delegate to the
getStyleInstance method to get the style instance to use for the newly created item.
Depending on the value of shareStyleInstance this method either returns the
style instance provided by style or a clone thereof.
If set to true the same style instance is used as style for each newly created element. Otherwise, a clone
of the default style is used. Default is true.
Queried to return a default style instance for a newly created graph item. Depending on the value of
shareStyleInstance this is either the instance provided by
style or a clone of it.
Note that although shown for INodeDefaults the above methods are defined
on IEdgeDefaults, ILabelDefaults, and IPortDefaults, too.
It is possible to set a new INodeDefaults instance here, as well. That way, it is possible to
share the same defaults for group nodes and normal nodes:
or to share only the label defaults:
or to keep pre-configured defaults:
The IPortDefaults.autoCleanUp property plays a
special role in that it controls a behavior, rather than providing a default value:
If set to true a port is automatically removed when the last edge connected to it is removed.
That means that ports can implicitly get removed. Default is true.