An item collection that allows to specify the data provider key the collection is registered with.
Remarks
This class supports LayoutData implementations and does not usually have to be used explicitly.
Functions, IMapper<K,V>s, lists and single items are automatically converted to DpKeyItemCollection<T>s. For example:
// Delegate
new StraightLineEdgeRouterData({ affectedEdges: (edge) => isAffected(edge) })
// Item
new StraightLineEdgeRouterData({ affectedEdges: edge1 })
// Items
new StraightLineEdgeRouterData({ affectedEdges: [edge1, edge2] })
// Mapper
new StraightLineEdgeRouterData({ affectedEdges: new Mapper() })
// or a JavaScript Map
new StraightLineEdgeRouterData({ affectedEdges: new Map() })
// Source
treeLayoutData.assistantNodes = graphComponent.selection.selectedNodes
Furthermore, the conversion supports a parameter object to initialize the properties. For example:
// This provides a convenient way of specifying the affectedNodes of StraightLineEdgeRouterData:
const routerData = new StraightLineEdgeRouterData({
// only consider elliptical nodes in the graph
affectedNodes: (node) =>
node.style instanceof ShapeNodeStyle &&
node.style.shape === ShapeNodeShape.ELLIPSE
})
// This provides a convenient way of specifying the excluded elements of the DpKeyItemCollection:
const routerDataWithExcludes = new StraightLineEdgeRouterData({
affectedNodes: {
// only consider elliptical nodes in the graph
includes: (node) =>
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 DpKeyItemCollection from a JavaScript Map and initialize its 'mapper' with the new Map.
// This also works for the other properties as well.
const collectionFromMapper = DpKeyItemCollection.from({
mapper: new Map()
})
// Or, instead of providing the specific property, the 'includes' key can be used
const collectionFromIncludes = DpKeyItemCollection.from({
includes: new Map()
})
// This provides a convenient way of specifying the affectedNodes of StraightLineEdgeRouterData:
const routerData = new StraightLineEdgeRouterData({
// only consider elliptical nodes in the graph
affectedNodes: (node) =>
node.style instanceof ShapeNodeStyle &&
node.style.shape === ShapeNodeShape.ELLIPSE
})
// This provides a convenient way of specifying the excluded elements of the DpKeyItemCollection:
const routerDataWithExcludes = new StraightLineEdgeRouterData({
affectedNodes: {
// 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 DpKeyItemCollection from a JavaScript Map and initialize its 'mapper' with the new Map.
// This also works for the other properties as well.
const collectionFromMapper = DpKeyItemCollection.from({
mapper: new Map()
})
// Or, instead of providing the specific property, the 'includes' key can be used
const collectionFromIncludes = DpKeyItemCollection.from({
includes: new Map()
})
Type Parameters
- T
- The type of the items in the collection.
Type Details
- yfiles module
- view-layout-bridge
- yfiles-umd modules
- view-layout-bridge
- Legacy UMD name
- yfiles.layout.DpKeyItemCollection
Properties
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: T) : boolean
Parameters
- obj - T
- 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
Defined in
Gets or sets the data provider key that is used for the item collection.
Remarks
Gets or sets the single item this item collection contains.
Remarks
This facilitates declaring collections which contain only one single item.
Setting this property will override any previously set properties.
Defined in
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
Defined in
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
Defined in
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.
See Also
Defined in
Static Methods
Creates a DpKeyItemCollection<T> instance from the given object by performing automatic type conversion.
Type Parameters
- T
- The type of the items in the collection.
Parameters
A map of options to pass to the method.
- itemCollectionLike - DpKeyItemCollection<T>
- The object to convert to a DpKeyItemCollection<T>.
Returns
- ↪DpKeyItemCollection<T>
- Either
itemCollectionLike
if it is already a DpKeyItemCollection<T> or a new instance, initialized to /// the values found initemCollectionLike
.