C

ClipboardGraphCopier

Used by GraphClipboard to copy IModelItems to and from the clipboardGraph.
Inheritance Hierarchy

Remarks

This copier is optimized to work with the GraphClipboard. To copy parts of an IGraph please use GraphCopier.

See Also

Developer's Guide

Members

Show:

Constructors

Properties

Gets or sets the types of items that should be cloned for the copy operation.
By default, everything but tags are cloned.
Only items which implement ICloneable can be cloned.
conversionfinal

Property Value

A bitwise combination of the types to clone.
Gets or sets a property that determines whether additional folding states should be copied to target graphs.
If the source and target graphs have an instance of FoldingManager in their lookup, the additional folding state of the nodes and edges will be copied. The default is true.
If items from a folding-enabled graph should be copied, both source graph and target graph must be a masterGraph. Furthermore, folding must be enabled on both graphs.
final
Gets or sets a property that determines whether grouping information should be copied to target graphs.

With this property set to false the GraphCopier can be used to flatten a grouped graph, i.e. remove the grouping information.

The default is true.

final
Gets or sets the types of objects where the referential identity should be kept across clipboard operations.

For each of the types that are set via this property, this implementation will use a caching copy mechanism as follows: If there has already been an instance copied via this clipboard (getCopy), that instance will instead be returned, otherwise, this implementation will clone the original instance (depending on the setting of cloneTypes) and cache the copy until after the operation the cache is cleared. This feature is implemented directly by the various CopyXXX methods.

Let's say nodes n1 and n2 share the same style instance s1. Then its copies share the same style instance s2 which is, however, another reference than the original s1.

By default, this is enabled for all types.

Only types which implement ICloneable can be cloned.
conversionfinal

Property Value

The referential identity types.

See Also

API
getOrCreateCopy

Methods

Adds a bend to the targetEdge in the targetGraph as a copy of the sourceBend.
protected

Parameters

context: ClipboardOperationContext
The operation context to get, e.g., the targetGraph from.
targetEdge: IEdge
The target edge to add the bend to.
sourceBend: IBend
The source bend to copy the values from.
offset: Point
The offset to apply to the copied bend.
index: number
The index to add the bend at.

Return Value

IBend
The newly created bend or null if none is created.
Adds a label to the targetOwner in the targetGraph as a copy of the sourceLabel.
This implementation uses copyLabelLayoutParameter, copyLabelStyle, and copyLabelTag as callbacks.
protected

Parameters

context: ClipboardOperationContext
The operation context to get, e.g., the targetGraph from.
targetOwner: ILabelOwner
The item owner in the target graph to add the label to.
sourceLabel: ILabel
The source label in the source graph.

Return Value

ILabel
The newly created label or null if none is created.
Adds a port to the targetOwner in the targetGraph as a copy of the sourcePort.
This implementation does not need to copy the adjacent IEdges of the sourcePort. This implementation uses copyPortLocationParameter, copyPortStyle, and copyPortTag as callbacks.
protected

Parameters

context: ClipboardOperationContext
The operation context to get, e.g., the targetGraph from.
targetOwner: IPortOwner
The port owner in the target graph to add the port to.
sourcePort: IPort
The source port in the source graph.

Return Value

IPort
The newly created port or null if none is created.
This method places the given copy into an internal cache.
The cache can be queried using getCopy. The cache is held until clearCopyCache is called.
protected

Parameters

original: T
The original item.
copy: T
The copy of the item.

See Also

API
getOrCreateCopy
Clears the cache for the cached copies of the instance copied using this class.
This method is called before and after a copy operation.
protected
Copies a subgraph from the sourceGraph to the targetGraph as defined in the context.
For each item that has been copied, the itemCopiedCallback will be invoked.
If items from a folding-enabled graph should be copied both the source graph and target graph must be a masterGraph. Furthermore, folding must be enabled on both graphs.

Parameters

context: ClipboardOperationContext
The information which items to copy.
targetRootNode: INode
The group node that should act as the root node for the pasted items. May be null if there is no such node.
offset?: Point
The offset to apply to the copied items. Only nodes and bends will be offset explicitly, while other items will move implicitly.
itemCopiedCallback?: function(IModelItem, IModelItem): void
A delegate to invoke for each item being copied.

Throws

Exception ({ name: 'ArgumentError' })
if targetRootNode is not in targetGraph
Copies an IEdgeStyle instance.
This implementation uses the clone method to create a copy if cloneTypes is set to copy EDGE_STYLE.
protected

Parameters

graph: IGraph
The graph that contains the edge.
edge: IEdge
The edge to copy the style from.

Return Value

IEdgeStyle
The style to apply for the copy.

See Also

API
copy
Copies the tag of an IEdge.
This implementation simply delegates to copyTag.
protected

Parameters

edge: IEdge
The old edge.
tag: any
The tag to copy.

Return Value

any
The copy of the tag.
Copies a ILabelModelParameter for a given label.
This implementation just returns the original parameter as these parameters are typically immutable so cloning them would have no use.
protected

Parameters

graph: IGraph
The graph that contains the label.
label: ILabel
The label to copy the label model parameter from.

Return Value

ILabelModelParameter
The copy of the parameter to apply for the copy.

See Also

API
copy
Copies an ILabelStyle instance.
This implementation uses the clone method to create a copy if cloneTypes is set to copy LABEL_STYLE.
protected

Parameters

graph: IGraph
The graph that contains the label.
label: ILabel
The label to copy the style from.

Return Value

ILabelStyle
The style to apply for the copy.

See Also

API
copy
Copies the tag of an ILabel.
This implementation simply delegates to copyTag.
protected

Parameters

label: ILabel
The old label.
tag: any
The tag to copy.

Return Value

any
The copy of the tag.
Copies an INodeStyle instance.
This implementation uses the clone method to create a copy if cloneTypes is set to copy NODE_STYLE.
protected

Parameters

graph: IGraph
The graph that contains the node.
node: INode
The node to copy the style from.

Return Value

INodeStyle
The style to apply for the copy.

See Also

API
copy
Copies the tag of an INode.
This implementation simply delegates to copyTag
protected

Parameters

node: INode
The old node.
tag: any
The tag to copy.

Return Value

any
The copy of the tag.
Copies a IPortLocationModelParameter for a given port.
This implementation just returns the original parameter as these parameters are typically immutable so cloning them would have no use.
protected

Parameters

graph: IGraph
The graph that contains the port.
port: IPort
The port to copy the model parameter from.

Return Value

IPortLocationModelParameter
The copy of the parameter to apply for the copy.

See Also

API
copy
Copies an IPortStyle instance.
This implementation uses the clone method to create a copy if cloneTypes is set to copy PORT_STYLE.
protected

Parameters

graph: IGraph
The graph that contains the port.
port: IPort
The port to copy the style from.

Return Value

IPortStyle
The style to apply for the copy.

See Also

API
copy
Copies the tag of an IPort.
This implementation simply delegates to copyTag.
protected

Parameters

port: IPort
The old port.
tag: any
The tag to copy.

Return Value

any
The copy of the tag.
Callback that will copy a tag for the target graph.
This implementation will try to clone the tag if the cloneTypes property has the TAGS flag set. If this is not the case or the tag is not ICloneable, the instance will be returned.
protected

Parameters

owner: IModelItem
The old owner of the tag.
tag: any
The tag to copy.

Return Value

any
A copy of the tag.
Adds an edge to the targetGraph as a copy of the sourceEdge.
This implementation does not need to copy the IBends of the sourceEdge, nor should it copy IPorts or ILabels. This implementation uses copyEdgeStyle and copyEdgeTag as callbacks.
protected

Parameters

context: ClipboardOperationContext
The operation context to get, e.g., the targetGraph from.
sourceEdge: IEdge
The edge in the source graph.
targetSourcePort: IPort
The new source port in the target graph.
targetTargetPort: IPort
The new target port in the target graph.

Return Value

IEdge
The newly created edge or null if none is created.
Creates a copy of the sourceGroupNode in the targetGraph.
This implementation does not need to copy IPorts or ILabels. This implementation uses copyNodeStyle and copyNodeTag as callbacks.
This method is only called if copyGrouping is set to true. Otherwise, createNode is called instead.
protected

Parameters

context: ClipboardOperationContext
The operation context to get, e.g. the targetGraph from.
sourceGroupNode: INode
The source node to create a copy of in the targetGraph.
targetParent: INode
The parent of the group node in the target graph.
offset: Point
The offset to apply to the copied node.

Return Value

INode
The newly created node or null if none is created.
Creates a copy of the sourceNode in the targetGraph.
This implementation does not need to copy IPorts or ILabels. This implementation uses copyNodeStyle and copyNodeTag as callbacks.
This method is only called if copyGrouping is set to false. Otherwise, createNode and createGroupNode are called instead.
protected

Parameters

context: ClipboardOperationContext
The operation context to get, e.g., the targetGraph from.
sourceNode: INode
The source node to create a copy of in the targetGraph.
offset: Point
The offset to apply to the copied node.

Return Value

INode
The newly created node or null if none is created.
Creates a copy of the sourceNode in the targetGraph.
This implementation does not need to copy IPorts or ILabels. This implementation uses copyNodeStyle and copyNodeTag as callbacks.
This method is only called if copyGrouping is set to true. Otherwise, createNode is called instead.
protected

Parameters

context: ClipboardOperationContext
The operation context to get, e.g. the targetGraph from.
sourceNode: INode
The source node to create a copy of in the targetGraph.
targetParent: INode
The parent of the group node in the target graph.
offset: Point
The offset to apply to the copied node.

Return Value

INode
The newly created node or null if none is created.
Tries to obtain a previously cached copy for the given original.
Values will be stored in the cache until the next call to clearCopyCache.
protected

Parameters

itemType: Constructor<T>
The type of the item to copy.
original: T
The original item.

Return Value

T
The copy of original or NO_COPY if no copy has been found.

See Also

API
cacheCopy, getOrCreateCopy
Either yields a previously cached copy for the given original or uses the copyDelegate to create the copy of the original.
If there is a cache miss, the delegate will be used to create the copy and the copy will be placed into the cache.
final

Parameters

tType: Constructor<T>
The type of the item to copy.
original: T
The original item.
copyDelegate: function(T): T
The copy delegate to create the copy.

Return Value

T
A copy of the original, either cached, or newly created and then cached.
Retrieves the FoldingManager from the given source graph.
protected

Parameters

sourceGraph: IGraph
The source graph.

Return Value

FoldingManager
The folding manager as obtained from the lookup of the graph.
Retrieves the FoldingManager from the given target graph.
protected

Parameters

targetGraph: IGraph
The target graph.

Return Value

FoldingManager
The folding manager as obtained from the lookup of the graph.
Called after a bend has been copied.
Raises the bend-copied event.
protected

Parameters

original: IBend
The original of the copied bend.
copy: IBend
The copied bend.
Called after an edge has been copied.
Raises the edge-copied event.
protected

Parameters

original: IEdge
The original of the copied edge.
copy: IEdge
The copied edge.
Called after the entire graph has been copied.
Raises the graph-copied event.
protected

Parameters

sourceGraph: IGraph
The source graph from which the items have been copied.
targetGraph: IGraph
The graph to which the items have been copied.
Called after a label has been copied.
Raises the label-copied event.
protected

Parameters

original: ILabel
The original of the copied label.
copy: ILabel
The copied label.
Called after a node has been copied.
Raises the node-copied event.
protected

Parameters

original: INode
The original of the copied node.
copy: INode
The copied node.
Triggers the object-copied event.
protected

Parameters

evt: ItemCopiedEventArgs<any>
The event argument to use.
Called after a port has been copied.
Raises the port-copied event.
protected

Parameters

original: IPort
The original of the copied port.
copy: IPort
The copied port.

Events

Occurs after a bend has been copied.

This event is dispatched after the item copied callback has been executed.

If this GraphCopier instance is used as GraphClipboard's toClipboardCopier (Cut/Copy) and the source graph is a folding view graph the original item is a master item, i.e. it belongs to the masterGraph.

If this GraphCopier instance is used as GraphClipboard's fromClipboardCopier (Paste) and the target graph is a folding view graph the copied item is a master item, i.e. it belongs to the masterGraph.

For folding edge bends, their view state representation is passed. These items are neither part of the masterGraph nor the view graph.

Properties of

ItemCopiedEventArgs<IBend>
copy: T
Gets the copied item.
original: T
Gets the original of the copied item.

See Also

Developer's Guide
Occurs after an edge has been copied.

This event is dispatched after the item copied callback has been executed.

If this GraphCopier instance is used as GraphClipboard's toClipboardCopier (Cut/Copy) and the source graph is a folding view graph the original item is a master item, i.e. it belongs to the masterGraph.

If this GraphCopier instance is used as GraphClipboard's fromClipboardCopier (Paste) and the target graph is a folding view graph the copied item is a master item, i.e. it belongs to the masterGraph.

Properties of

ItemCopiedEventArgs<IEdge>
copy: T
Gets the copied item.
original: T
Gets the original of the copied item.

See Also

Developer's Guide
Occurs after the entire graph has been copied.

This event is dispatched at the end of the copy method.

If this GraphCopier instance is used as GraphClipboard's toClipboardCopier (Cut/Copy) and the source graph is a folding view graph the source graph item is the masterGraph of the folding view.

If this GraphCopier instance is used as GraphClipboard's fromClipboardCopier (Paste) and the target graph is a folding view graph the target graph is the masterGraph of the folding view.

copy: T
Gets the copied item.
original: T
Gets the original of the copied item.
Occurs after a label has been copied.

This event is dispatched after the item copied callback has been executed.

If this GraphCopier instance is used as GraphClipboard's toClipboardCopier (Cut/Copy) and the source graph is a folding view graph the original item is a master item, i.e. it belongs to the masterGraph.

If this GraphCopier instance is used as GraphClipboard's fromClipboardCopier (Paste) and the target graph is a folding view graph the copied item is a master item, i.e. it belongs to the masterGraph.

For folding edge or helper node labels, their view state representation is passed. These items are neither part of the masterGraph nor the view graph.

copy: T
Gets the copied item.
original: T
Gets the original of the copied item.

See Also

Developer's Guide
Occurs after a node has been copied.

This event is dispatched after the item copied callback has been executed.

If this GraphCopier instance is used as GraphClipboard's toClipboardCopier (Cut/Copy) and the source graph is a folding view graph the original item is a master item, i.e. it belongs to the masterGraph.

If this GraphCopier instance is used as GraphClipboard's fromClipboardCopier (Paste) and the target graph is a folding view graph the copied item is a master item, i.e. it belongs to the masterGraph.

Properties of

ItemCopiedEventArgs<INode>
copy: T
Gets the copied item.
original: T
Gets the original of the copied item.

See Also

Developer's Guide
Occurs after a style or tag has been copied.

This event is triggered for all minor objects the graph items are made up of, e.g. the styles and tags.

This event will not be triggered for the graph items themselves and will not be triggered if the object reference is reused, i.e. it will only be triggered if the old and new references actually differ.

Properties of

ItemCopiedEventArgs<any>
copy: T
Gets the copied item.
original: T
Gets the original of the copied item.

See Also

Developer's Guide
Occurs after a port has been copied.

This event is dispatched after the item copied callback has been executed.

If this GraphCopier instance is used as GraphClipboard's toClipboardCopier (Cut/Copy) and the source graph is a folding view graph the original item is a master item, i.e. it belongs to the masterGraph.

If this GraphCopier instance is used as GraphClipboard's fromClipboardCopier (Paste) and the target graph is a folding view graph the copied item is a master item, i.e. it belongs to the masterGraph.

Properties of

ItemCopiedEventArgs<IPort>
copy: T
Gets the copied item.
original: T
Gets the original of the copied item.

See Also

Developer's Guide

Constants

The sentinel return value for use in getCopy.