documentationfor yFiles for HTML 2.6

DpKeyItemCollection<T>

An item collection that allows to specify the data provider key the collection is registered with.

Inheritance Hierarchy
ItemCollection<T>
DpKeyItemCollection

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

Constructors

Properties

Static Methods