I

INodeDefaults

Interface used by IGraph and the like to declare and obtain the defaults for nodes and their labels or ports.
Inheritance Hierarchy

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

Setting defaults for nodes
// 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

See Also

Developer's Guide

API

nodeDefaults, groupNodeDefaults

Members

No filters for this type

Properties

Gets or sets the defaults for labels at nodes.
abstract

Property Value

The label defaults.

Examples

Defaults for node labels have to be set on the Labels property of the NodeDefaults
// place node labels on the node center by default
graph.nodeDefaults.labels.layoutParameter = InteriorNodeLabelModel.CENTER

See Also

Developer's Guide

Implemented in

NodeDefaults.labels
Gets or sets the defaults for ports at nodes.
abstract

Property Value

The port defaults.

Examples

Defaults for node ports have to be set on the Ports property of the NodeDefaults
// don't remove node labels after their
// last adjacent edge has been removed
graph.nodeDefaults.ports.autoCleanUp = false

See Also

Developer's Guide

Implemented in

NodeDefaults.ports
Gets or sets a value indicating whether the style instance should be shared referentially or cloned upon a call to getStyleInstance.
abstract

Property Value

true if the reference should be shared; false otherwise.

Examples

Shared vs. cloned styles
const defaultStyle = new ShapeNodeStyle()
graph.nodeDefaults.style = defaultStyle

// share style instances
graph.nodeDefaults.shareStyleInstance = true
const n1 = graph.createNodeAt(new Point(0, 0))
const n2 = graph.createNodeAt(new Point(0, 50))
// n1.style === defaultStyle; n2.style == defaultStyle; n1.style === n2.style;
defaultStyle.fill = Color.RED // n1 and n2 both turn red, too

// clone style instances
graph.nodeDefaults.shareStyleInstance = false
const n3 = graph.createNodeAt(new Point(0, 100))
const n4 = graph.createNodeAt(new Point(0, 150))
// n3.style !== defaultStyle; n4.style !== defaultStyle; n3.style !== n4.style;
defaultStyle.fill = Color.YELLOW // n3 and n4 don't change their color

See Also

Developer's Guide
API
getStyleInstance, style
Gets or sets the default node size.
The values of this size will be used by createNodeAt.
abstractconversion

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,
})

Implemented in

NodeDefaults.size
Gets or sets the style to use for nodes.
Depending on the setting of shareStyleInstance, the getStyleInstance method should return a clone of this instance or the very same instance.
abstract

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

Developer's Guide
API
shareStyleInstance

Implemented in

NodeDefaults.style

Methods

Factory method that returns a style instance for use with newly created nodes.
Most implementations will yield either a clone of or the style property, if shareStyleInstance is enabled, but they might use more complicated logic, too.
abstract

Return Value

INodeStyle
The style to use, which for most implementations is either a clone of or the style property, if shareStyleInstance is enabled.

See Also

Developer's Guide