An interface for typed dictionary-like implementations.
Remarks
IMapper<K,V>s are most prominently used when working with supplemental configuration for layout algorithms and custom data in GraphML. IGraph also provides the mapperRegistry to add additional information to a graph.
This is a convertible type that is automatically converted from native JavaScript Map
instances in parameter lists, parameter objects or setters.
Related Reading in the Developer's Guide
Related Programming Samples
- Drag and Drop
- Shows drag and drop of nodes, groups and labels.
Type Parameters
- K
- The type of element this interface accepts as keys for the mapping.
- V
- The type of element this interface accepts as values for the mapping.
Type Details
- yfiles module
- core
- yfiles-umd modules
- All modules
- Legacy UMD name
- yfiles.collections.IMapper
See Also
Methods
Gets the value for a given key in the mapping.
Remarks
Setting a value for an already existing key overwrites the previous value.
It depends on the specific implementation of the mapper whether a mapping can be removed. If an implementation provides a way to remove a mapping, that should be preferred over setting a null
value. For example, see the delete and delete methods of HashMap<K,V> and Mapper<K,V>, respectively.
Parameters
A map of options to pass to the method.
- key - K
- The key of the mapping.
Returns
- ↪V
- The value.
See Also
Sets the value for a given key in the mapping.
Remarks
Setting a value for an already existing key overwrites the previous value.
It depends on the specific implementation of the mapper whether a mapping can be removed. If an implementation provides a way to remove a mapping, that should be preferred over setting a null
value. For example, see the delete and delete methods of HashMap<K,V> and Mapper<K,V>, respectively.
Parameters
A map of options to pass to the method.
- key - K
- The key of the mapping.
- value - V
- The value.
See Also
Static Methods
Creates an IMapper<K,V> instance from the given mapper-like object by performing automatic type conversion.
Type Parameters
- K
- The type of element this interface accepts as keys for the mapping.
- V
- The type of element this interface accepts as values for the mapping.
Parameters
A map of options to pass to the method.
- mapperLike - IMapper<K,V>
- The object to convert to a IMapper<K,V>
Returns
- ↪IMapper<K,V>
- An IMapper<K,V> instance, initialized with the values found in
mapperLike
.
Creates a constant mapper that will always return the constant
.
Type Parameters
- K
- The type of the key to use.
- V
- The type of the value to use.
Parameters
A map of options to pass to the method.
- constant - V
- The constant to return in get
Returns
- ↪IMapper<K,V>
- A new instance that will always return the same constant.
See Also
Create an implementation of IMapper<K,V> that delegates get getter calls to the provided handler.
Remarks
Type Parameters
- K
- The type of the key to use.
- V
- The type of the value to use.
Parameters
A map of options to pass to the method.
- getter - function(K):V
- The delegate to delegate get getter calls to.
Signature Details
function(key: K) : V
A delegate that mimics the get access.Parameters
- key - K
- The key of the mapping.
Returns
- V
- The value or a suitable default that is associated with
key
.
Returns
- ↪IMapper<K,V>
- An implementation that delegates to
getter
.