Provides different ways to define the items in a collection for use with LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel>.
Remarks
Only one of the provided ways to define a collection can be used at the same time, therefore only one of the properties item, items, mapper, and predicate should be set on each instance.
Items in the excludes property are explicitly excluded from this collection, even if they are included in one of the item, items, mapper, or predicate properties.
This class supports LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> implementations and does not usually have to be used explicitly.
Functions, IMapper<K,V>s, lists and single items are automatically converted to ItemCollection<TItem>s. For example:
// Delegate
new TreeLayoutData({ assistantNodes: (node) => isAssistant(node) })
// Item
new TreeLayoutData({ assistantNodes: node1 })
// Items
new TreeLayoutData({ assistantNodes: [node1, node2] })
// Mapper
new TreeLayoutData({ assistantNodes: new Mapper() })
// or a JavaScript Map
new TreeLayoutData({ assistantNodes: new Map() })
// Source
new TreeLayoutData({ assistantNodes: graphComponent.selection.nodes })
Furthermore, the conversion supports a parameter object to initialize the properties. For example:
// This provides a convenient way of specifying the subgraph for the algorithm:
const shortestPath1 = new ShortestPath({
// single source - single sink
source: startNode,
sink: endNode,
// only consider elliptical nodes in the graph
subgraphNodes: (node) =>
node.style instanceof ShapeNodeStyle &&
node.style.shape === ShapeNodeShape.ELLIPSE,
})
// This provides a convenient way of specifying the excluded elements of the ItemCollection:
const shortestPath2 = new ShortestPath({
// single source - single sink
source: startNode,
sink: endNode,
subgraphNodes: {
// only consider elliptical nodes in the graph
includes: (node: INode) =>
node.style instanceof ShapeNodeStyle &&
node.style.shape === ShapeNodeShape.ELLIPSE,
// but ignore the first node, regardless of its shape
excludes: graph.nodes.first()!,
},
})
// Create a new ItemCollection from a JavaScript Map and initialize its 'mapper' with the new Map.
// This also works for the other properties as well.
new ShortestPath({
subgraphNodes: new Map(),
})
// Or, instead of providing the specific property, the 'includes' key can be used
new ShortestPath({
subgraphNodes: {
includes: new Map(),
},
})
This class cannot be instantiated
Type Parameters
- TItem
- The type of the items in the collection.
Type Details
- yFiles module
- algorithms
See Also
Properties
Gets or sets a collection of items.
Remarks
This property is initialized by default, and the returned collection can be used directly to add items.
Setting this property will override any previously set properties.
See Also
Gets or sets a mapping from the items to a boolean value.
Remarks
This property does not get initialized by default and needs to be set to a new instance by the user, if required.
The mapped boolean value specifies whether an item is contained in the collection.
Setting this property will override any previously set properties.
See Also
Gets or sets a delegate from the items to a boolean value.
Remarks
The returned boolean value describes whether an item is contained in the collection.
Setting this property will override any previously set properties.
Signature Details
function(obj: TItem) : boolean
Parameters
- obj - TItem
- The object to compare against the criteria defined within the method represented by this delegate.
Returns
- boolean
true
if obj meets the criteria defined within the method represented by this delegate; otherwise,false
.
See Also
Get or sets an enumerable of items.
Remarks
This collection contains exactly the items in the given enumerable.
Setting this property will override any previously set properties.