Used by the GraphClipboard to assign IDs for elements in the clipboard.
Inheritance Hierarchy
IClipboardIdProvider
Remarks
IDs are created when items are copied (or cut) into the clipboard and queried when the items are pasted from the clipboard.
Providing a custom ID provider allows for identifying conceptually identical items across different graph instances.
The default implementation uses the IModelItem object reference as the ID.
Type Details
- yFiles module
- view
Methods
Gets the ID for the given originalItem
.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- context - IGraphClipboardContext
- The clipboard context
- originalItem - IModelItem
- The original item which is copied. The item is part of the original graph from which the item is copied.
Returns
- ↪any
- An ID for the given item. The object should be suitable for use in a HashMap<TKey,TValue>.
Gets the item which is represented by the given id
.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- context - IGraphClipboardContext
- The clipboard context.
- id - any
- The ID to get the item for.
Returns
- ↪IModelItem?
- The item which is represented by the given ID or
null
if the item cannot be located or is invalid. The item needs to be part of the target graph for paste operations.
Examples
/**
* @param _context - The information which items to copy.
* @param sourceLabel - The label to be duplicated from the source graph or copied from the ClipboardGraph.
*/
getTarget(
_context: ClipboardOperationContext,
sourceLabel: ILabel,
): ILabelOwner | null {
// sourceLabel lives in the clipboard graph
// get the original label, i.e. the label which has been copied from the original graph
const originalLabel = this.idProvider.getItem(
this.clipboardContext!,
this.getId(sourceLabel),
) as ILabel
// return the original label's owner as the pasted label's owner
return originalLabel.owner
}
Static Methods
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- getId - function(IGraphClipboardContext, IModelItem):any
Gets the ID for the given
originalItem
.This property holds the implementation for getId.
- getItem - function(IGraphClipboardContext, any):IModelItem
Gets the item which is represented by the given
id
.This property holds the implementation for getItem.