Interface used by IGraph and the like to declare and obtain the defaults for nodes and their labels or ports.
Inheritance Hierarchy
INodeDefaults
Remarks
Note that changing these defaults does not change properties of already created model items. Rather, only items created after the change are affected.
Examples
// the defaults for nodes can be set on the INodeDefaults instance
// which can be retrieved from the graph's node defaults property
graph.nodeDefaults.size = new Size(50, 30)
graph.nodeDefaults.style = new ShapeNodeStyle({
shape: ShapeNodeShape.ELLIPSE,
fill: Color.YELLOW,
})
// the defaults for node labels can be set on the ILabelDefaults instance
// found at the Labels property of the node defaults
graph.nodeDefaults.labels.layoutParameter = InteriorNodeLabelModel.CENTER
graph.nodeDefaults.labels.style = new LabelStyle()
// the defaults for node ports can be set on the IPortDefaults instance
// found at the Ports property of the node defaults
graph.nodeDefaults.ports.autoCleanUp = false
graph.nodeDefaults.ports.locationParameter =
FreeNodePortLocationModel.CENTER
Type Details
- yFiles module
- view
See Also
Properties
Gets or sets the defaults for labels at nodes.
Property Value
The label defaults.
Examples
// place node labels on the node center by default
graph.nodeDefaults.labels.layoutParameter = InteriorNodeLabelModel.CENTER
Gets or sets the defaults for ports at nodes.
Property Value
The port defaults.
Examples
// don't remove node labels after their
// last adjacent edge has been removed
graph.nodeDefaults.ports.autoCleanUp = false
Gets or sets the default node size.
Remarks
The values of this size will be used by createNodeAt.
Property Value
The default size of newly created nodes.
Throws
- Exception({ name: 'ArgumentError' })
value
contains one or more NaN values.
Examples
// set the size of newly created nodes to 50, 30
graph.nodeDefaults.size = new Size(50, 30)
// make them appear as yellow ellipse
graph.nodeDefaults.style = new ShapeNodeStyle({
shape: ShapeNodeShape.ELLIPSE,
fill: Color.YELLOW,
})
Gets or sets the style to use for nodes.
Remarks
Depending on the setting of shareStyleInstance, the getStyleInstance method should return a clone of this instance or the very same instance.
Property Value
The style to use as a template.
Examples
// set the size of newly created nodes to 50, 30
graph.nodeDefaults.size = new Size(50, 30)
// make them appear as yellow ellipse
graph.nodeDefaults.style = new ShapeNodeStyle({
shape: ShapeNodeShape.ELLIPSE,
fill: Color.YELLOW,
})
See Also
Methods
Factory method that returns a style instance for use with newly created nodes.
Remarks
Most implementations will yield either a clone of or the style property, if shareStyleInstance is enabled, but they might use more complicated logic, too.
Returns
- ↪INodeStyle
- The style to use, which for most implementations is either a clone of or the style property, if shareStyleInstance is enabled.