I

IPortDefaults

Interface used by IGraph to declare and obtain the defaults for ports at nodes and edges.
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 ports
// Ports on nodes and edges have different IPortDefault instances.
// These can be retrieved from their owner type's defaults

// 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

// the defaults for edge ports can be set on the IPortDefaults instance
// found at the Ports property of the edge defaults
graph.edgeDefaults.ports.autoCleanUp = false
graph.edgeDefaults.ports.locationParameter =
  BendAnchoredPortLocationModel.FIRST_BEND

See Also

Developer's Guide

API

IPort, ports, ports, nodeDefaults, edgeDefaults

Members

No filters for this type

Properties

Gets or sets whether unused ports should automatically be removed from their owners as soon as no further edge is connected to them.
abstract

Examples

AutoCleanUp: removing ports when an edge is removed
const node1 = graph.createNode()
const node2 = graph.createNode()
const port1_1 = graph.addPort(node1)
const port1_2 = graph.addPort(node1)
const port2 = graph.addPort(node2)
const edge1 = graph.createEdge(port1_1, port2)
const edge2 = graph.createEdge(port1_2, port2)

// enable auto cleanup
graph.nodeDefaults.ports.autoCleanUp = true
graph.remove(edge1)
// port1_1 is removed with the edge
console.log(graph.contains(port1_1)) // false
// port2 is not removed since edge2 still is linked to it
console.log(graph.contains(port2))
// disable auto cleanup
graph.nodeDefaults.ports.autoCleanUp = false
graph.remove(edge2)
// no port is removed with the edge now
console.log(graph.contains(port1_2)) // true
console.log(graph.contains(port2)) // true

See Also

Developer's Guide
API
remove
Gets or sets the defaults for labels at ports.
abstract

Property Value

The label defaults.

Examples

graph.nodeDefaults.ports.labels.layoutParameter =
  FreePortLabelModel.CENTER

See Also

Developer's Guide

Implemented in

PortDefaults.labels
Gets or sets the location model parameter to use for ports.
Depending on the setting of shareLocationParameterInstance, the getLocationParameterInstance method should return a clone of this instance or the very same instance.
abstract

Property Value

The parameter to use as a template.

Examples

graph.nodeDefaults.ports.style = new ShapePortStyle({
  shape: ShapeNodeShape.ELLIPSE,
})
graph.nodeDefaults.ports.locationParameter =
  FreeNodePortLocationModel.CENTER

See Also

Developer's Guide
API
shareLocationParameterInstance, getLocationParameterInstance
Gets or sets a value indicating whether the locationParameter instance should be shared referentially or cloned upon a call to getLocationParameterInstance.
abstract

Property Value

true if the reference should be shared; false otherwise.

See Also

API
getLocationParameterInstance, locationParameter
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 n1 = graph.createNodeAt(new Point(0, 0))
const n2 = graph.createNodeAt(new Point(0, 50))
const n3 = graph.createNodeAt(new Point(0, 100))
const n4 = graph.createNodeAt(new Point(0, 150))

const defaultStyle = new ShapePortStyle({
  renderSize: new Size(5, 5),
})
graph.nodeDefaults.ports.style = defaultStyle

// share style instances
graph.nodeDefaults.ports.shareStyleInstance = true
const p1 = graph.addPort(n1)
const p2 = graph.addPort(n2)
// p1.style === defaultStyle; p2.style === defaultStyle; p1.style === p2.style;
defaultStyle.renderSize = new Size(10, 10) // p1 and p2 both get larger

// clone style instances
graph.nodeDefaults.ports.shareStyleInstance = false
const p3 = graph.addPort(n3)
const p4 = graph.addPort(n4)
// p3.style !== defaultStyle; p4.style !== defaultStyle; p3.style !== p4.style;
defaultStyle.renderSize = new Size(20, 20) // p3 and p4 don't change their size

See Also

API
getStyleInstance, style
Gets or sets the style to use for ports.
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

graph.nodeDefaults.ports.style = new ShapePortStyle({
  shape: ShapeNodeShape.ELLIPSE,
})
graph.nodeDefaults.ports.locationParameter =
  FreeNodePortLocationModel.CENTER

See Also

API
shareStyleInstance

Implemented in

PortDefaults.style

Methods

Factory method that returns a location model parameter instance for use with newly created ports.
Most implementations will yield either a clone or the locationParameter property if shareLocationParameterInstance is enabled, but they might use more complicated logic, too.
abstract

Parameters

owner: IPortOwner
The owner of the port that will be created.

Return Value

IPortLocationModelParameter
The parameter to use, which for most implementations is either a clone or the locationParameter property if shareLocationParameterInstance is enabled.
Factory method that returns a style instance for use with newly created ports.
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

Parameters

owner: IPortOwner
The owner of the port that will be created.

Return Value

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