C

LayoutGraphContext

This class is used to provide additional data to the graph and its elements that can be utilized by layout algorithms during computation.
Inheritance Hierarchy

Remarks

Data is stored on the graph using unique lookup key instances, typically defined by layout algorithms. Client code or LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> can supply additional data associated with a particular key. Layout algorithms can then retrieve this data using the keys and utilize it for computation.

Data can be added to the entire graph or to its individual elements, such as LayoutNodes, LayoutEdges, LayoutNodeLabels, and LayoutEdgeLabels. Adding data per element is facilitated by using IMapper<K, V>, ItemMapping<TItem, TValue>, or data getter. An ItemCollection<TItem> enables the definition of collections of elements. Additionally, shared information can be stored as a constant value for all elements of a certain type.

Data associated with a specific key can also be temporarily hidden or replaced. Replacing data is achieved by pushing a new layer onto the context, registering the new data with the same key, and subsequently removing the layer once the data is no longer needed.

This class cannot be instantiated

See Also

Developer's Guide

Members

No filters for this type

Properties

Gets the copy information that offers mappings between items in this graph and an original graph for instances that were created as a copy of another graph by using createCopy.
Will be null for graphs that were not created via method createCopy.
final
Gets or sets the LayoutAbortController used during the layout.
An LayoutAbortController can be used to gracefully stop or cancel a running layout and offers options for automatically doing so after a predetermined time.
final

Methods

Registers a single value data for the graph with the specified ValueDataKey<TValue>.
If a value is already registered with the same dataKey, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.
final

Parameters

dataKey: ValueDataKey<TValue>
The ValueDataKey<TValue> the data should be registered for.
data: TValue
The data to register.
Registers a constant value for all nodes at the graph with the specified data key.
If an IMapper<K, V> is already registered with the same dataKey, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.
final

Parameters

dataKey: NodeDataKey<TValue>
The NodeDataKey<TValue> the data should be registered for.
constantValue: TValue
The value returned as data for all nodes.

Return Value

IMapper<LayoutNode, TValue>
The created IMapper<Node, TValue> for the given constant.
Registers a constant value for all edges at the graph with the specified data key.
If an IMapper<K, V> is already registered with the same dataKey, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.
final

Parameters

dataKey: EdgeDataKey<TValue>
The EdgeDataKey<TValue> the data should be registered for.
constantValue: TValue
The value returned as data for all edges.

Return Value

IMapper<LayoutEdge, TValue>
The created IMapper<Edge, TValue> for the given constant.
Registers data for individual nodes at the graph with the specified NodeDataKey<TValue>.
If an IMapper<K, V> is already registered with the same dataKey, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.
final

Parameters

dataKey: NodeDataKey<TValue>
The NodeDataKey<TValue> the data should be registered for.
mapper: IMapper<LayoutNode, TValue>
The IMapper<K, V> that stores the data for each node.
Registers data for individual edges at the graph with the specified EdgeDataKey<TValue>.
If an IMapper<K, V> is already registered with the same dataKey, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.
final

Parameters

dataKey: EdgeDataKey<TValue>
The EdgeDataKey<TValue> the data should be registered for.
mapper: IMapper<LayoutEdge, TValue>
The IMapper<K, V> that stores the data for each edge.
Registers data for individual node labels at the graph with the specified NodeLabelDataKey<TValue>.
If an IMapper<K, V> is already registered with the same dataKey, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.
final

Parameters

dataKey: NodeLabelDataKey<TValue>
The NodeLabelDataKey<TValue> the data should be registered for.
mapper: IMapper<LayoutNodeLabel, TValue>
The IMapper<K, V> that stores the data for each node label.
Registers data for individual edge labels at the graph with the specified EdgeLabelDataKey<TValue>.
If an IMapper<K, V> is already registered with the same dataKey, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.
final

Parameters

dataKey: EdgeLabelDataKey<TValue>
The EdgeLabelDataKey<TValue> the data should be registered for.
mapper: IMapper<LayoutEdgeLabel, TValue>
The IMapper<K, V> that stores the data for each edge label.
Registers data for individual nodes at the graph with the specified NodeDataKey<TValue>.

The IMapper<K, V> is created from the given getter and optional setter callbacks.

If an IMapper<K, V> is already registered with the same dataKey, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.

final

Parameters

dataKey: NodeDataKey<TValue>
The NodeDataKey<TValue> the data should be registered for.
getter: function(LayoutNode): TValue
A callback to get the data for a node in the created mapper.
setter?: function(LayoutNode, TValue): void
A callback to set the data for a node in the created mapper.

Return Value

IMapper<LayoutNode, TValue>
The created IMapper<K, V> using the given getter and setter callbacks.
Registers data for individual edges at the graph with the specified EdgeDataKey<TValue>.

The IMapper<K, V> is created from the given getter and optional setter callbacks.

If an IMapper<K, V> is already registered with the same dataKey, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.

final

Parameters

dataKey: EdgeDataKey<TValue>
The EdgeDataKey<TValue> the data should be registered for.
getter: function(LayoutEdge): TValue
A callback to get the data for an edge in the created mapper.
setter?: function(LayoutEdge, TValue): void
A callback to set the data for an edge in the created mapper.

Return Value

IMapper<LayoutEdge, TValue>
The created IMapper<K, V> using the given getter and setter callbacks.
Registers data for individual node labels at the graph with the specified NodeLabelDataKey<TValue>.

The IMapper<K, V> is created from the given getter and optional setter callbacks.

If an IMapper<K, V> is already registered with the same dataKey, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.

final

Parameters

dataKey: NodeLabelDataKey<TValue>
The NodeLabelDataKey<TValue> the data should be registered for.
getter: function(LayoutNodeLabel): TValue
A callback to get the data for a node label in the created mapper.
setter?: function(LayoutNodeLabel, TValue): void
A callback to set the data for a node label in the created mapper.

Return Value

IMapper<LayoutNodeLabel, TValue>
The created IMapper<K, V> using the given getter and setter callbacks.
Registers data for individual edge labels at the graph with the specified EdgeLabelDataKey<TValue>.

The IMapper<K, V> is created from the given getter and optional setter callbacks.

If an IMapper<K, V> is already registered with the same dataKey, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.

final

Parameters

dataKey: EdgeLabelDataKey<TValue>
The EdgeLabelDataKey<TValue> the data should be registered for.
getter: function(LayoutEdgeLabel): TValue
A callback to get the data for an edge label in the created mapper.
setter?: function(LayoutEdgeLabel, TValue): void
A callback to set the data for an edge label in the created mapper.

Return Value

IMapper<LayoutEdgeLabel, TValue>
The created IMapper<K, V> using the given getter and setter callbacks.
Gets the single value data registered for the graph with the specified ValueDataKey<TValue>.

If no data is registered under the given dataKey, this method recursively searches the underlying layers for data associated with the dataKey.

Use this method when the type TValue is a class or nullable value type (struct). If TValue is a struct, use getNullableData instead. Otherwise, this method throws an exception if no value is registered.

final

Parameters

dataKey: ValueDataKey<TValue>
The ValueDataKey<TValue> for retrieving the data.

Return Value

TValue
The single value data registered for the graph with the specified dataKey, or null if nothing is registered.

Throws

Exception ({ name: 'NullReferenceError' })
Thrown if the data type is a value type (struct) and no value is registered with the dataKey. In such cases, use getNullableData instead.
Gets data for individual nodes registered for the graph with the specified NodeDataKey<TValue>.
If no data is registered under the given dataKey, this method recursively searches the underlying layers for data associated with the dataKey.
final

Parameters

dataKey: NodeDataKey<TValue>
The NodeDataKey<TValue> for retrieving the IMapper<K, V>.

Return Value

IMapper<LayoutNode, TValue>
The IMapper<K, V> registered for the graph with the specified dataKey.
Gets data for individual edges registered for the graph with the specified EdgeDataKey<TValue>.
If no data is registered under the given dataKey, this method recursively searches the underlying layers for data associated with the dataKey.
final

Parameters

dataKey: EdgeDataKey<TValue>
The EdgeDataKey<TValue> for retrieving the IMapper<K, V>.

Return Value

IMapper<LayoutEdge, TValue>
The IMapper<K, V> registered for the graph with the specified dataKey.
Gets data for individual node labels registered for the graph with the specified NodeLabelDataKey<TValue>.
If no data is registered under the given dataKey, this method recursively searches the underlying layers for data associated with the dataKey.
final

Parameters

dataKey: NodeLabelDataKey<TValue>
The NodeLabelDataKey<TValue> for retrieving the IMapper<K, V>.

Return Value

IMapper<LayoutNodeLabel, TValue>
The IMapper<K, V> registered for the graph with the specified dataKey.
Gets data for individual edge labels registered for the graph with the specified EdgeLabelDataKey<TValue>.
If no data is registered under the given dataKey, this method recursively searches the underlying layers for data associated with the dataKey.
final

Parameters

dataKey: EdgeLabelDataKey<TValue>
The EdgeLabelDataKey<TValue> for retrieving the IMapper<K, V>.

Return Value

IMapper<LayoutEdgeLabel, TValue>
The IMapper<K, V> registered for the graph with the specified dataKey.
Gets the single value data registered for the graph with the specified ValueDataKey<TValue>, modifying the type to be nullable.

If no data is registered under the given dataKey, this method recursively searches the underlying layers for data associated with the dataKey.

Use this method when the type TValue is a value data type (struct). If nothing is registered, null will be returned. For other data types, use the getData method instead.

final

Parameters

dataKey: ValueDataKey<TValue>
The ValueDataKey<TValue> for retrieving the data.

Return Value

TValue
The single value data registered for the graph with the specified dataKey, or null if nothing is registered.
Hides the data registered for the graph with the specified ValueDataKey<TValue>.
final

Parameters

key: ValueDataKey<TValue>
The ValueDataKey<TValue> for the data to hide.

Return Value

RestoreToken
A RestoreToken object to restore the hidden data.

Throws

Exception ({ name: 'ArgumentError' })
Thrown if key is null.
Hides the item data registered for the graph with the specified NodeDataKey<TValue>.
final

Parameters

dataKey: NodeDataKey<TValue>
The NodeDataKey<TValue> for the item data to hide.

Return Value

RestoreToken
A RestoreToken object to restore the hidden item data.

Throws

Exception ({ name: 'ArgumentError' })
Thrown if dataKey is null.
Hides the item data registered for the graph with the specified EdgeDataKey<TValue>.
final

Parameters

dataKey: EdgeDataKey<TValue>
The EdgeDataKey<TValue> for the item data to hide.

Return Value

RestoreToken
A RestoreToken object to restore the hidden item data.

Throws

Exception ({ name: 'ArgumentError' })
Thrown if dataKey is null.
Hides the item data registered for the graph with the specified NodeLabelDataKey<TValue>.
final

Parameters

dataKey: NodeLabelDataKey<TValue>
The NodeLabelDataKey<TValue> for the item data to hide.

Return Value

RestoreToken
A RestoreToken object to restore the hidden item data.

Throws

Exception ({ name: 'ArgumentError' })
Thrown if dataKey is null.
Hides the item data registered for the graph with the specified EdgeLabelDataKey<TValue>.
final

Parameters

dataKey: EdgeLabelDataKey<TValue>
The EdgeLabelDataKey<TValue> for the item data to hide.

Return Value

RestoreToken
A RestoreToken object to restore the hidden item data.

Throws

Exception ({ name: 'ArgumentError' })
Thrown if dataKey is null.
Hides the nullable data registered for the graph with the specified ValueDataKey<TValue>.
final

Parameters

key: ValueDataKey<TValue>
The ValueDataKey<TValue> for the nullable data to hide.

Return Value

RestoreToken
A RestoreToken object to restore the hidden data.

Throws

Exception ({ name: 'ArgumentError' })
Thrown if key is null.
Pops the top layer from the context.

popLayer removes the top layer from the stack, undoing the changes applied by the most recent pushLayer call.

All data registered on the layer will be removed from the graph. This includes the data added with pushLayer using the LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>.

Note that you should only pop a layer if you have previously pushed one.

final

See Also

API
pushLayer
Pushes a new layer onto the context, optionally applying layout data.

Internally, LayoutGraphContext operates as a stack of layers. Each call to pushLayer adds a new layer to the top of this stack, allowing you to temporarily override the data in the context.

Use this method when you need to temporarily override the data associated with a specific key with custom data. If layoutData is provided, the data defined within the layoutData will be added to the graph.

final

Parameters

layoutData?: LayoutData<LayoutNode, LayoutEdge, LayoutNodeLabel, LayoutEdgeLabel>
An optional LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> to apply to the graph. The data defined within the layoutData will be added to the graph.

Return Value

RestoreToken
A RestoreToken that can be used to remove the layer.

See Also

API
popLayer
Removes the data registered for the graph with the specified DataKey<TValue>.
This method only removes the data registered on the top level context layer. If this context has more layers (added via pushLayer), then other layers can still have data registered with the given dataKey. If it is desired that data with the dataKey is not visible at all, then hiding should be used (see e.g. method hideData or hideItemData).
final

Parameters

dataKey: DataKey<TValue>
The DataKey<TValue> the data should be removed for.