Packagecom.yworks.yfiles.util
Classpublic class GraphCopier
InheritanceGraphCopier Inheritance YObject Inheritance Object

A utility class that can be used to copy a graph's structure and possibly associated data to another instance. This class relies on implementations of com.yworks.yfiles.util.GraphCopier_CopyFactory that can either be any of the default implementations or any other implementation that can be associated with a com.yworks.yfiles.base.Graph 's copy factory property (com.yworks.yfiles.base.Graph.graphCopyFactory).

See also

com.yworks.yfiles.util.GraphCopier_CopyFactory
copy()
com.yworks.yfiles.base.Graph
copy factory property


Public Properties
 PropertyDefined By
  copyFactory : GraphCopier_CopyFactory
Returns the currently used copy factory.
GraphCopier
  dataProviderContentCopying : Boolean
Determines whether automatic copying of edge map contents should be performed.
GraphCopier
  edgeMapCopying : Boolean
Getter: Determines whether automatic copying of edge map contents is enabled.
GraphCopier
  nodeMapCopying : Boolean
Getter: Determines whether automatic copying of node map contents is enabled.
GraphCopier
Public Methods
 MethodDefined By
  
GraphCopier(init:Boolean = true)
Creates a new instance that uses a com.yworks.yfiles.base.GraphCopyFactory as the default factory.
GraphCopier
  
copy(sourceGraph:Graph):Graph
Copies the contents of the source graph to a newly created target graph and returns the new graph.
GraphCopier
  
copyFullSubgraph(sourceGraph:Graph, sourceNodes:NodeCursor):Graph
Copies the subgraph contained in graph induced by the source nodes to a newly created graph.
GraphCopier
  
copyFullSubgraphToGraph(sourceGraph:Graph, sourceNodes:NodeCursor, targetGraph:Graph):NodeList
Copies the subgraph contained in sourceGraph induced by the source nodes to the targetGraph.
GraphCopier
  
copySubgraphToGraph(sourceGraph:Graph, sourceNodes:NodeCursor, sourceEdges:EdgeCursor, targetGraph:Graph):NodeList
Copies the subgraph contained in sourceGraph induced by the source nodes and the provided source edges to the targetGraph.
GraphCopier
  
copyToGraph(sourceGraph:Graph, targetGraph:Graph):NodeList
Copies the contents of the source graph to the target graph and returns the newly created nodes in the target graph.
GraphCopier
 Inherited
equals(o:Object):Boolean
YObject
  
getClass():Class
[override]
GraphCopier
 Inherited
hashCode():int
YObject
  
[static] Creates a new instance that uses a com.yworks.yfiles.base.GraphCopyFactory as the default factory.
GraphCopier
  
[static] Creates a new instance that uses the specified factory to perform the actual copy operations.
GraphCopier
Protected Methods
 MethodDefined By
  
copyEdge(copyFactory:GraphCopier_CopyFactory, targetGraph:Graph, newSource:Node, newTarget:Node, edge:Edge):Edge
Callback that uses the given factory to perform the copy operation.
GraphCopier
  
copyNode(copyFactory:GraphCopier_CopyFactory, targetGraph:Graph, node:Node):Node
Callback that uses the given factory to perform the copy operation.
GraphCopier
  
Callback that creates the Map that will hold the mapping from the edges in the old source graph to the newly created edges in the target graph.
GraphCopier
  
Callback that uses the given factory to create a new graph.
GraphCopier
  
Callback that creates the Map that will hold the mapping from the nodes in the old source graph to the newly created nodes in the target graph.
GraphCopier
  
Determines the set of edge candidates from the source graph that should be copied.
GraphCopier
  
Determines the set of node candidates from the source graph that should be copied if no other nodes are specified by the user.
GraphCopier
  
Initializes this object.
GraphCopier
  
Initializes this object.
GraphCopier
  
postCopyGraphData(copyFactory:GraphCopier_CopyFactory, sourceGraph:Graph, targetGraph:Graph, nodeMap:Map, edgeMap:Map):void
Callback that uses the given factory to perform the copy operation.
GraphCopier
  
preCopyGraphData(copyFactory:GraphCopier_CopyFactory, sourceGraph:Graph, targetGraph:Graph):void
Callback that uses the given factory to perform the copy operation.
GraphCopier
Property Detail
copyFactoryproperty
copyFactory:GraphCopier_CopyFactory

Returns the currently used copy factory.


Implementation
    public function get copyFactory():GraphCopier_CopyFactory
    public function set copyFactory(value:GraphCopier_CopyFactory):void
dataProviderContentCopyingproperty 
dataProviderContentCopying:Boolean

Determines whether automatic copying of edge map contents should be performed. The default is false. Copying will be done by reference on Object basis. The backing store for the content will be HashMap based.


Implementation
    public function get dataProviderContentCopying():Boolean
    public function set dataProviderContentCopying(value:Boolean):void

See also

edgeMapCopyingproperty 
edgeMapCopying:Boolean

Getter: Determines whether automatic copying of edge map contents is enabled. The default is false.

Setter: Sets whether automatic copying of edge map contents should be performed. The default is false. Copying will be done by reference on Object basis. To store these objects, new com.yworks.yfiles.base.EdgeMap s are created for the target graph.

In order to access these EdgeMaps it is necessary to store the number of NodeMaps in the target graph before creating the EdgeMaps as they will be appended. After copying the graph a EdgeMap can be found using this number as offset and add the index of the map in the original graph.

Note: To be able to control and access EdgeMaps more easily, it is recommended to use com.yworks.yfiles.base.DataProvider s instead and have them copied.


Implementation
    public function get edgeMapCopying():Boolean
    public function set edgeMapCopying(value:Boolean):void

See also

nodeMapCopyingproperty 
nodeMapCopying:Boolean

Getter: Determines whether automatic copying of node map contents is enabled. The default is false.

Setter: Sets whether automatic copying of node map contents should be performed. The default is false. Copying will be done by reference on Object basis. To store these objects, new com.yworks.yfiles.base.NodeMap s are created for the target graph.

In order to access these NodeMaps it is necessary to store the number of NodeMaps in the target graph before creating the NodeMaps as they will be appended. After copying the graph a NodeMap can be found using this number as offset and add the index of the map in the original graph.

Note: To be able to control and access NodeMaps more easily, it is recommended to use com.yworks.yfiles.base.DataProvider s instead and have them copied.


Implementation
    public function get nodeMapCopying():Boolean
    public function set nodeMapCopying(value:Boolean):void

See also

Constructor Detail
GraphCopier()Constructor
public function GraphCopier(init:Boolean = true)

Creates a new instance that uses a com.yworks.yfiles.base.GraphCopyFactory as the default factory.

Parameters
init:Boolean (default = true) — An internally used switch to help handle proper instance initialization in inheritance chains where classes can have multiple constructor-like factory methods. This parameter can safely be ignored/omitted when calling the constructor.

See also

Method Detail
copy()method
public function copy(sourceGraph:Graph):Graph

Copies the contents of the source graph to a newly created target graph and returns the new graph.

Parameters

sourceGraph:Graph — the graph to copy the contents from

Returns
Graph — the newly created graph

See also

copyEdge()method 
protected function copyEdge(copyFactory:GraphCopier_CopyFactory, targetGraph:Graph, newSource:Node, newTarget:Node, edge:Edge):Edge

Callback that uses the given factory to perform the copy operation. This method simply delegates to com.yworks.yfiles.util.GraphCopier_CopyFactory.copyEdge() and can be overwritten to change the behavior.

Parameters

copyFactory:GraphCopier_CopyFactory — the factory delegate the operation to
 
targetGraph:Graph
 
newSource:Node
 
newTarget:Node
 
edge:Edge

Returns
Edge

See also

copyFullSubgraph()method 
public function copyFullSubgraph(sourceGraph:Graph, sourceNodes:NodeCursor):Graph

Copies the subgraph contained in graph induced by the source nodes to a newly created graph.

Parameters

sourceGraph:Graph — the graph to copy
 
sourceNodes:NodeCursor — the nodes in the sourceGraph to copy to the new graph

Returns
Graph — the newly created graph

See also

copyFullSubgraphToGraph()method 
public function copyFullSubgraphToGraph(sourceGraph:Graph, sourceNodes:NodeCursor, targetGraph:Graph):NodeList

Copies the subgraph contained in sourceGraph induced by the source nodes to the targetGraph. targetGraph is not cleared prior to the copy operation.

Parameters

sourceGraph:Graph — the graph to copy
 
sourceNodes:NodeCursor — the nodes in the sourceGraph to copy to the new graph
 
targetGraph:Graph — the graph to copy the sourceGraph's contents to

Returns
NodeList — the list of the new nodes in targetGraph
copyNode()method 
protected function copyNode(copyFactory:GraphCopier_CopyFactory, targetGraph:Graph, node:Node):Node

Callback that uses the given factory to perform the copy operation. This method simply delegates to com.yworks.yfiles.util.GraphCopier_CopyFactory.copyNode() and can be overwritten to change the behavior.

Parameters

copyFactory:GraphCopier_CopyFactory — the factory delegate the operation to
 
targetGraph:Graph
 
node:Node

Returns
Node

See also

copySubgraphToGraph()method 
public function copySubgraphToGraph(sourceGraph:Graph, sourceNodes:NodeCursor, sourceEdges:EdgeCursor, targetGraph:Graph):NodeList

Copies the subgraph contained in sourceGraph induced by the source nodes and the provided source edges to the targetGraph. targetGraph is not cleared prior to the copy operation.

Parameters

sourceGraph:Graph — the graph to copy
 
sourceNodes:NodeCursor — the nodes in the sourceGraph to copy to the new graph
 
sourceEdges:EdgeCursor — the edges in the sourceGraph to copy to the new graph
 
targetGraph:Graph — the graph to copy the sourceGraph's contents to

Returns
NodeList — the list of the new nodes in targetGraph
copyToGraph()method 
public function copyToGraph(sourceGraph:Graph, targetGraph:Graph):NodeList

Copies the contents of the source graph to the target graph and returns the newly created nodes in the target graph.

Parameters

sourceGraph:Graph — the graph to copy the contents from
 
targetGraph:Graph — the target graph to copy the contents to, it will not be cleared prior to the copying

Returns
NodeList — the list of Nodes that have been copied to the target graph.

See also

createEdgeMap()method 
protected function createEdgeMap():Map

Callback that creates the Map that will hold the mapping from the edges in the old source graph to the newly created edges in the target graph.

Returns
Map — A map that can be used to store the mapping.
createGraph()method 
protected function createGraph(factory:GraphCopier_CopyFactory, sourceGraph:Graph):Graph

Callback that uses the given factory to create a new graph. This method simply delegates to com.yworks.yfiles.util.GraphCopier_CopyFactory.createGraph() and can be overwritten to change the behavior.

Parameters

factory:GraphCopier_CopyFactory — the factory to use for the creation
 
sourceGraph:Graph — the graph that will be

Returns
Graph — the newly created graph

See also

createNodeMap()method 
protected function createNodeMap():Map

Callback that creates the Map that will hold the mapping from the nodes in the old source graph to the newly created nodes in the target graph.

Returns
Map — A map that can be used to store the mapping.
getClass()method 
override public function getClass():Class

Returns
Class
getSourceEdges()method 
protected function getSourceEdges(sourceGraph:Graph):EdgeCursor

Determines the set of edge candidates from the source graph that should be copied. Note that if any of the source or target node is not present in the target graph the edge will not be copied. This implementation simply returns com.yworks.yfiles.base.Graph.edges()

Parameters

sourceGraph:Graph — the graph to determine the edges to copy

Returns
EdgeCursor — the edges to copy

See also

getSourceNodes()method 
protected function getSourceNodes(sourceGraph:Graph):NodeCursor

Determines the set of node candidates from the source graph that should be copied if no other nodes are specified by the user. This implementation simply returns com.yworks.yfiles.base.Graph.nodes()

Parameters

sourceGraph:Graph — the graph to determine the nodes to copy

Returns
NodeCursor — the nodes to copy

See also

initGraphCopier1()method 
protected final function initGraphCopier1():void

Initializes this object. See the documentation of the corresponding factory method newGraphCopier1() for details.

See also

initGraphCopier2()method 
protected final function initGraphCopier2(copyFactory:GraphCopier_CopyFactory):void

Initializes this object. See the documentation of the corresponding factory method newGraphCopier2() for details.

Parameters

copyFactory:GraphCopier_CopyFactory

See also

newGraphCopier1()method 
public static function newGraphCopier1():GraphCopier

Creates a new instance that uses a com.yworks.yfiles.base.GraphCopyFactory as the default factory.

Returns
GraphCopier

See also

newGraphCopier2()method 
public static function newGraphCopier2(copyFactory:GraphCopier_CopyFactory):GraphCopier

Creates a new instance that uses the specified factory to perform the actual copy operations.

Parameters

copyFactory:GraphCopier_CopyFactory — the factory to use, must be non-null.

Returns
GraphCopier

Throws
ReferenceError — if copyFactory is null
postCopyGraphData()method 
protected function postCopyGraphData(copyFactory:GraphCopier_CopyFactory, sourceGraph:Graph, targetGraph:Graph, nodeMap:Map, edgeMap:Map):void

Callback that uses the given factory to perform the copy operation. This method simply delegates to com.yworks.yfiles.util.GraphCopier_CopyFactory.postCopyGraphData() and can be overwritten to change the behavior.

Parameters

copyFactory:GraphCopier_CopyFactory — the factory delegate the operation to
 
sourceGraph:Graph
 
targetGraph:Graph
 
nodeMap:Map
 
edgeMap:Map

See also

preCopyGraphData()method 
protected function preCopyGraphData(copyFactory:GraphCopier_CopyFactory, sourceGraph:Graph, targetGraph:Graph):void

Callback that uses the given factory to perform the copy operation. This method simply delegates to com.yworks.yfiles.util.GraphCopier_CopyFactory.preCopyGraphData() and can be overwritten to change the behavior.

Parameters

copyFactory:GraphCopier_CopyFactory — the factory delegate the operation to
 
sourceGraph:Graph
 
targetGraph:Graph

See also