Copies parts of an IGraph to another instance.
Remarks
Type Details
- yfiles module
- view-component
- yfiles-umd modules
- All view modules
- Legacy UMD name
- yfiles.graph.GraphCopier
See Also
Constructors
Creates a new instance of an GraphCopier with the default settings.
Parameters
A map of options to pass to the method.
- clone - CloneTypes
- 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. 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
See Also
Gets or sets a property that determines whether additional folding states.
Remarks
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
.
See Also
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
.
See Also
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 clone) 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.
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 source bend.
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.
addLabel
(sourceGraph: IGraph, targetGraph: IGraph, targetOwner: ILabelOwner, sourceLabel: ILabel) : ILabelAdds a label to the target item in the targetGraph as a copy of the source label.
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.
addPort
(sourceGraph: IGraph, targetGraph: IGraph, targetOwner: IPortOwner, sourcePort: IPort) : IPortAdds a port to the targetPortOwner in the targetGraph as a copy of the source port.
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.
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
Copies sourceGraph
to targetGraph
.
Remarks
targetGraph
.Parameters
A map of options to pass to the method.
See Also
sourceGraph
and targetGraph
must be a masterGraph. Furthermore, folding must be enabled on both graphs.copy
(sourceGraph: IGraph, filter: function(IModelItem):boolean, targetGraph: IGraph, offset?: Point, elementCopiedCallback?: function(IModelItem, IModelItem):void)Copies a subgraph described by a predicate from the sourceGraph
to the targetGraph
.
Remarks
elementCopiedCallback
will be invoked. This method actually delegates to copy and provides the root as the "targetGraph" parameter if there is a hierarchy associated with targetGraph
.Parameters
A map of options to pass to the method.
- sourceGraph - IGraph
- The graph to copy the elements from.
- filter - function(IModelItem):boolean
- The filter that decides which elements to copy.
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
.
- targetGraph - IGraph
- The graph to copy the elements to.
- offset - Point
- The offset to apply to the copied items. Only nodes and bends will be offset explicitly, while other items will move implicitly.
- elementCopiedCallback - function(IModelItem, IModelItem):void
- A delegate to invoke for each element being copied.
Signature Details
function(original: IModelItem, copy: IModelItem)
Callback delegate used by GraphCopier and the like.Parameters
- original - IModelItem
- The element that has been copied.
- copy - IModelItem
- The copy of the original element.
sourceGraph
and targetGraph
must be a masterGraph. Furthermore, folding must be enabled on both graphs.copy
(sourceGraph: IGraph, filter: function(IModelItem):boolean, targetGraph: IGraph, targetRootNode: INode, offset?: Point, elementCopiedCallback?: function(IModelItem, IModelItem):void)Copies a subgraph induced by a predicate from the sourceGraph
to the targetGraph
.
Remarks
elementCopiedCallback
will be invoked.Parameters
A map of options to pass to the method.
- sourceGraph - IGraph
- The graph to copy the elements from.
- filter - function(IModelItem):boolean
- The filter that decides which elements to copy.
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
.
- targetGraph - IGraph
- The graph to copy the elements to.
- targetRootNode - INode
- The group node that should act as the root node for the pasted elements. 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.
- elementCopiedCallback - function(IModelItem, IModelItem):void
- A delegate to invoke for each element being copied.
Signature Details
function(original: IModelItem, copy: IModelItem)
Callback delegate used by GraphCopier 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
See Also
sourceGraph
and targetGraph
must be a masterGraph. Furthermore, folding must be enabled on both graphs.copyChildNode
(sourceGraph: IGraph, targetGraph: IGraph, node: INode, targetParent: INode, offset: Point) : INodeCreates a copy of the node
in the targetGraph
.
Remarks
Parameters
A map of options to pass to the method.
- sourceGraph - IGraph
- The source graph.
- targetGraph - IGraph
- The target graph.
- node - 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.
copyEdge
(sourceGraph: IGraph, targetGraph: IGraph, sourceEdge: IEdge, targetSourcePort: IPort, targetTargetPort: IPort) : IEdgeAdds an edge to the targetGraph as a copy of the source edge.
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.
Copies an IEdgeStyle instance.
Remarks
Parameters
A map of options to pass to the method.
Returns
- ↪IEdgeStyle
- The style to apply for the copy.
See Also
copyGroupNode
(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.
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.
See Also
Copies an ILabelStyle instance.
Remarks
Parameters
A map of options to pass to the method.
Returns
- ↪ILabelStyle
- The style to apply for the copy.
See Also
Creates a copy of the node
in the targetGraph
.
Remarks
Parameters
A map of options to pass to the method.
- sourceGraph - IGraph
- The source graph.
- targetGraph - IGraph
- The target graph.
- node - 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.
false
. Otherwise, copyChildNode and copyGroupNode are called instead.Copies an INodeStyle instance.
Remarks
Parameters
A map of options to pass to the method.
Returns
- ↪INodeStyle
- The style to apply for the copy.
See Also
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.
See Also
Copies an IPortStyle instance.
Remarks
Parameters
A map of options to pass to the method.
Returns
- ↪IPortStyle
- The style to apply for the copy.
See Also
Callback that will copy a tag for the target graph.
Remarks
tag
if the clone 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 - Object
- The tag to copy.
Returns
- ↪any
- A copy of the tag.
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 - Class
- 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 - Class
- 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.
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.
Emits the ObjectCopied event.
Parameters
A map of options to pass to the method.
- evt - ItemCopiedEventArgs<Object>
- The 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 element 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 elements are neither part of the masterGraph nor the view graph.
See Also
Event Registration
addBendCopiedListener(function(this, ItemCopiedEventArgs<IBend>):void)
Event Deregistration
removeBendCopiedListener(function(this, ItemCopiedEventArgs<IBend>):void)
Signature Details
function(sender: this, evt: ItemCopiedEventArgs<IBend>)
Parameters
- sender - this
- The source of the event.
- evt - ItemCopiedEventArgs<IBend>
- An object that contains the event data.
Occurs after an edge has been copied.
Remarks
This event is dispatched after the element 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.
See Also
Event Registration
addEdgeCopiedListener(function(this, ItemCopiedEventArgs<IEdge>):void)
Event Deregistration
removeEdgeCopiedListener(function(this, ItemCopiedEventArgs<IEdge>):void)
Signature Details
function(sender: this, evt: ItemCopiedEventArgs<IEdge>)
Parameters
- sender - this
- The source of the event.
- evt - ItemCopiedEventArgs<IEdge>
- An object that contains the event data.
Occurs after the entire graph has been copied.
Remarks
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 master graph 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 master graph of the folding view.
Event Registration
addGraphCopiedListener(function(this, ItemCopiedEventArgs<IGraph>):void)
Event Deregistration
removeGraphCopiedListener(function(this, ItemCopiedEventArgs<IGraph>):void)
Signature Details
function(sender: this, evt: ItemCopiedEventArgs<IGraph>)
Parameters
- sender - this
- The source of the event.
- evt - ItemCopiedEventArgs<IGraph>
- An object that contains the event data.
Occurs after a label has been copied.
Remarks
This event is dispatched after the element 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 dummy node labels, their view state representation is passed. These elements are neither part of the masterGraph nor the view graph.
See Also
Event Registration
addLabelCopiedListener(function(this, ItemCopiedEventArgs<ILabel>):void)
Event Deregistration
removeLabelCopiedListener(function(this, ItemCopiedEventArgs<ILabel>):void)
Signature Details
function(sender: this, evt: ItemCopiedEventArgs<ILabel>)
Parameters
- sender - this
- The source of the event.
- evt - ItemCopiedEventArgs<ILabel>
- An object that contains the event data.
Occurs after a node has been copied.
Remarks
This event is dispatched after the element 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.
See Also
Event Registration
addNodeCopiedListener(function(this, ItemCopiedEventArgs<INode>):void)
Event Deregistration
removeNodeCopiedListener(function(this, ItemCopiedEventArgs<INode>):void)
Signature Details
function(sender: this, evt: ItemCopiedEventArgs<INode>)
Parameters
- sender - this
- The source of the event.
- evt - ItemCopiedEventArgs<INode>
- An object that contains the event data.
Occurs after a style has been copied.
Remarks
This event is triggered for all minor objects the graph items are made up of, e.g. the styles, tags, labels, and port parameters.
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.
See Also
Event Registration
addObjectCopiedListener(function(this, ItemCopiedEventArgs<Object>):void)
Event Deregistration
removeObjectCopiedListener(function(this, ItemCopiedEventArgs<Object>):void)
Signature Details
function(sender: this, evt: ItemCopiedEventArgs<Object>)
Parameters
- sender - this
- The source of the event.
- evt - ItemCopiedEventArgs<Object>
- An object that contains the event data.
Occurs after a port has been copied.
Remarks
This event is dispatched after the element 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.
See Also
Event Registration
addPortCopiedListener(function(this, ItemCopiedEventArgs<IPort>):void)
Event Deregistration
removePortCopiedListener(function(this, ItemCopiedEventArgs<IPort>):void)
Signature Details
function(sender: this, evt: ItemCopiedEventArgs<IPort>)
Parameters
- sender - this
- The source of the event.
- evt - ItemCopiedEventArgs<IPort>
- An object that contains the event data.
Constants
The sentinel return value for use in getCopy.