Copies parts of an IGraph to another instance.
Type Details
- yFiles module
- view
Constructors
Creates a new instance of an GraphCopier with the default settings.
Parameters
A map of options to pass to the method.
- cloneTypes - CloneTypes
- The types of items that should be cloned for the copy operation. This option sets the cloneTypes property on the created object.
- referentialIdentityTypes - CloneTypes
- The types of objects where the referential identity should be kept across clipboard operations. This option sets the referentialIdentityTypes property on the created object.
- copyGrouping - boolean
- A property that determines whether grouping information should be copied to target graphs. This option sets the copyGrouping property on the created object.
- copyFoldingStates - boolean
- A property that determines whether additional folding states should be copied to target graphs. This option sets the copyFoldingStates property on the created object.
Properties
Gets or sets the types of items that should be cloned for the copy operation.
Remarks
Property Value
Gets or sets a property that determines whether additional folding states should be copied to target graphs.
Remarks
true
.Gets or sets a property that determines whether grouping information should be copied to target graphs.
Remarks
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
.
Gets or sets the types of objects where the referential identity should be kept across clipboard operations.
Remarks
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.
Property Value
See Also
Methods
addBend
(sourceGraph: IGraph, targetGraph: IGraph, targetEdge: IEdge, sourceBend: IBend, offset: Point, index: number) : IBendAdds a bend to the targetEdge
in the targetGraph
as a copy of the sourceBend
.
Parameters
A map of options to pass to the method.
- sourceGraph - IGraph
- The source graph.
- targetGraph - IGraph
- The target graph.
- 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.
Returns
- ↪IBend?
- The newly created bend or
null
if none is created.
addLabel
(sourceGraph: IGraph, targetGraph: IGraph, targetOwner: ILabelOwner, sourceLabel: ILabel) : ILabelAdds a label to the targetOwner
in the targetGraph
as a copy of the sourceLabel
.
Remarks
Parameters
A map of options to pass to the method.
- sourceGraph - IGraph
- The source graph.
- targetGraph - IGraph
- The target graph.
- targetOwner - ILabelOwner
- The item owner in the target graph to add the label to.
- sourceLabel - ILabel
- The source label in the source graph.
Returns
- ↪ILabel?
- The newly created label or
null
if none is created.
addPort
(sourceGraph: IGraph, targetGraph: IGraph, targetOwner: IPortOwner, sourcePort: IPort) : IPortAdds a port to the targetOwner
in the targetGraph
as a copy of the sourcePort
.
Remarks
sourcePort
. This implementation uses copyPortLocationParameter, copyPortStyle, and copyPortTag as callbacks.Parameters
A map of options to pass to the method.
- sourceGraph - IGraph
- The source graph.
- targetGraph - IGraph
- The target graph.
- targetOwner - IPortOwner
- The port owner in the target graph to add the port to.
- sourcePort - IPort
- The source port in the source graph.
Returns
- ↪IPort?
- The newly created port or
null
if none is created.
This method places the given copy into an internal cache.
Remarks
Type Parameters
- T
- The type of the item to cache.
Parameters
A map of options to pass to the method.
- original - T
- The original item.
- copy - T
- The copy of the item.
See Also
Clears the cache for the cached copies of the instance copied using this class.
Remarks
copy
(sourceGraph: IGraph, targetGraph: IGraph, copyPredicate: function(IModelItem):boolean, targetRootNode?: INode, offset?: Point, itemCopiedCallback?: function(IModelItem, IModelItem):void)Copies a subgraph induced by an IEnumerable<IModelItem> from the sourceGraph
to the targetGraph
.
Remarks
For each item that has been copied, the itemCopiedCallback
will be invoked.
If sourceGraph
is a folding-enabled graph, only the currently visible view is copied.
Parameters
A map of options to pass to the method.
- sourceGraph - IGraph
- The graph to copy the items from.
- targetGraph - IGraph
- The graph to copy the items to.
- copyPredicate - function(IModelItem):boolean
- A predicate function which gets a model item and returns
true
if the given item should be copied.Signature Details
function(obj: IModelItem) : boolean
Represents the method that defines a set of criteria and determines whether the specified object meets those criteria.Parameters
- obj - IModelItem
- 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
.
- 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.
Signature Details
function(original: IModelItem, copy: IModelItem)
Callback delegate used by GraphCopier, ClipboardGraphCopier, and the like.Parameters
- original - IModelItem
- The element that has been copied.
- copy - IModelItem
- The copy of the original element.
Throws
- Exception({ name: 'ArgumentError' })
- if
targetRootNode
is not intargetGraph
sourceGraph
and targetGraph
must be a masterGraph. Furthermore, folding must be enabled on both graphs.copy
(sourceGraph: IGraph, targetGraph: IGraph, itemsToCopy?: IEnumerable<IModelItem>, targetRootNode?: INode, itemOffset?: Point, itemCopiedCallback?: function(IModelItem, IModelItem):void)Copies a subgraph induced by an IEnumerable<IModelItem> from the sourceGraph
to the targetGraph
.
Remarks
For each item that has been copied, the itemCopiedCallback
will be invoked.
If sourceGraph
is a folding-enabled graph, only the currently visible view is copied.
Parameters
A map of options to pass to the method.
- sourceGraph - IGraph
- The graph to copy the items from.
- targetGraph - IGraph
- The graph to copy the items to.
- itemsToCopy - IEnumerable<IModelItem>
- The items to copy. If
null
, the entiresourceGraph
is copied. - 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. - itemOffset - 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.
Signature Details
function(original: IModelItem, copy: IModelItem)
Callback delegate used by GraphCopier, ClipboardGraphCopier, and the like.Parameters
- original - IModelItem
- The element that has been copied.
- copy - IModelItem
- The copy of the original element.
Throws
- Exception({ name: 'ArgumentError' })
- if
targetRootNode
is not intargetGraph
itemsToCopy
contains an item instance multiple times, this method will create multiple copies of that item in targetGraph
.sourceGraph
and targetGraph
must be a masterGraph. Furthermore, folding must be enabled on both graphs.Copies an IEdgeStyle instance.
Remarks
Parameters
A map of options to pass to the method.
Returns
- ↪IEdgeStyle
- The style to apply for the copy.
Copies a ILabelModelParameter for a given label.
Remarks
Parameters
A map of options to pass to the method.
- graph - IGraph
- The graph that contains the label.
- label - ILabel
- The label to copy the label model parameter from.
Returns
- ↪ILabelModelParameter
- The copy of the parameter to apply for the copy.
Copies an ILabelStyle instance.
Remarks
Parameters
A map of options to pass to the method.
Returns
- ↪ILabelStyle
- The style to apply for the copy.
Copies an INodeStyle instance.
Remarks
Parameters
A map of options to pass to the method.
Returns
- ↪INodeStyle
- The style to apply for the copy.
Copies a IPortLocationModelParameter for a given port.
Remarks
Parameters
A map of options to pass to the method.
- graph - IGraph
- The graph that contains the port.
- port - IPort
- The port to copy the model parameter from.
Returns
- ↪IPortLocationModelParameter
- The copy of the parameter to apply for the copy.
Copies an IPortStyle instance.
Remarks
Parameters
A map of options to pass to the method.
Returns
- ↪IPortStyle
- The style to apply for the copy.
Callback that will copy a tag for the target graph.
Remarks
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.Parameters
A map of options to pass to the method.
- owner - IModelItem
- The old owner of the tag.
- tag - IModelItem['tag']
- The tag to copy.
Returns
- ↪any?
- A copy of the tag.
createEdge
(sourceGraph: IGraph, targetGraph: IGraph, sourceEdge: IEdge, targetSourcePort: IPort, targetTargetPort: IPort) : IEdgeAdds an edge to the targetGraph
as a copy of the sourceEdge
.
Remarks
sourceEdge
, nor should it copy IPorts or ILabels. This implementation uses copyEdgeStyle and copyEdgeTag as callbacks.Parameters
A map of options to pass to the method.
- sourceGraph - IGraph
- The source graph.
- targetGraph - IGraph
- The target graph.
- 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.
Returns
- ↪IEdge?
- The newly created edge or
null
if none is created.
createGroupNode
(sourceGraph: IGraph, targetGraph: IGraph, sourceGroupNode: INode, targetParent: INode, offset: Point) : INodeCreates a copy of the sourceGroupNode
in the targetGraph
.
Remarks
Parameters
A map of options to pass to the method.
- sourceGraph - IGraph
- The source graph.
- targetGraph - IGraph
- The target graph.
- 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.
Returns
- ↪INode?
- The newly created node or
null
if none is created.
Creates a copy of the sourceNode
in the targetGraph
.
Remarks
Parameters
A map of options to pass to the method.
- sourceGraph - IGraph
- The source graph.
- targetGraph - IGraph
- The target graph.
- sourceNode - INode
- The source node to create a copy of in the
targetGraph
. - offset - Point
- The offset to apply to the copied node.
Returns
- ↪INode?
- The newly created node or
null
if none is created.
false
. Otherwise, createNode and createGroupNode are called instead.createNode
(sourceGraph: IGraph, targetGraph: IGraph, sourceNode: INode, targetParent: INode, offset: Point) : INodeCreates a copy of the sourceNode
in the targetGraph
.
Remarks
Parameters
A map of options to pass to the method.
- sourceGraph - IGraph
- The source graph.
- targetGraph - IGraph
- The target graph.
- 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.
Returns
- ↪INode?
- The newly created node or
null
if none is created.
Tries to obtain a previously cached copy for the given original.
Remarks
null
is a valid return value that is the copied value of the original.Type Parameters
- T
- The type of the item to copy.
Parameters
A map of options to pass to the method.
- itemType - Constructor<T>
- The type of the item to copy.
- original - T
- The original item.
Returns
- ↪T?
- The copy of
original
or NO_COPY if no copy has been found.
See Also
Either yields a previously cached copy for the given original or uses the copyDelegate
to create the copy of the original.
Remarks
Type Parameters
- T
- The type of the item to copy.
Parameters
A map of options to pass to the method.
- 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.
Signature Details
function(arg: T) : T
Encapsulates a method that has one parameters and returns a value of the type specified by theTResult
parameter.Parameters
- arg - T
- The parameter of the method that this delegate encapsulates.
Returns
- T
- The return value of the method that this delegate encapsulates.
Returns
- ↪T?
- A copy of the original, either cached, or newly created and then cached.
Retrieves the FoldingManager from the given source graph.
Parameters
A map of options to pass to the method.
- sourceGraph - IGraph
- The source graph.
Returns
- ↪FoldingManager?
- The folding manager as obtained from the lookup of the graph.
Retrieves the FoldingManager from the given target graph.
Parameters
A map of options to pass to the method.
- targetGraph - IGraph
- The target graph.
Returns
- ↪FoldingManager?
- The folding manager as obtained from the lookup of the graph.
Called after a bend has been copied.
Remarks
Parameters
A map of options to pass to the method.
Called after an edge has been copied.
Remarks
Parameters
A map of options to pass to the method.
Called after the entire graph has been copied.
Remarks
Parameters
A map of options to pass to the method.
Called after a label has been copied.
Remarks
Parameters
A map of options to pass to the method.
Called after a node has been copied.
Remarks
Parameters
A map of options to pass to the method.
Triggers the object-copied event.
Parameters
A map of options to pass to the method.
- evt - ItemCopiedEventArgs<any>
- The event argument to use.
Called after a port has been copied.
Remarks
Parameters
A map of options to pass to the method.
Events
Occurs after a bend has been copied.
Remarks
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.
Occurs after an edge has been copied.
Remarks
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.
Occurs after the entire graph has been copied.
Remarks
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.
Occurs after a label has been copied.
Remarks
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.
Occurs after a node has been copied.
Remarks
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.
Occurs after a style or tag has been copied.
Remarks
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.
Occurs after a port has been copied.
Remarks
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.
Constants
The sentinel return value for use in getCopy.