Search this API

y.view
Class Graph2DCopyFactory.RecursiveGraph2DCopyFactory

java.lang.Object
  extended by y.view.Graph2DCopyFactory.RecursiveGraph2DCopyFactory
All Implemented Interfaces:
GraphCopier.CopyFactory
Enclosing class:
Graph2DCopyFactory

public static class Graph2DCopyFactory.RecursiveGraph2DCopyFactory
extends java.lang.Object
implements GraphCopier.CopyFactory

A decorator for the a GraphCopier.CopyFactory that recursively copies the contents of folder nodes and correctly adjusts the inter-edge state. This factory can be used as follows:

 GraphCopier.CopyFactory factory = graph.getGraphCopyFactory();
 
 Graph2DCopyFactory.RecursiveGraph2DCopyFactory recursiveFactory =
   new Graph2DCopyFactory.RecursiveGraph2DCopyFactory(factory);

 GraphCopier copier = new GraphCopier(recursiveFactory);
 recursiveFactory.setFolderGraphCopier(copier);

 copier.copy(sourceGraph, sourceNodes, targetGraph);
 

See Also:
copyRecursively(Graph2D, Graph2D)
 

Constructor Summary
Graph2DCopyFactory.RecursiveGraph2DCopyFactory(GraphCopier.CopyFactory delegateFactory)
          Creates a new instance that delegates the actual creation to a Graph2DCopyFactory.
 
Method Summary
protected  void convertToInterEdge(Edge srcEdge, HierarchyManager dstHierarchyManager, Edge dstEdge, Node newRealSource, Node newRealTarget)
          Callback method that is used after the contents have been copied recursively Converts the edge to an interEdge using the HierarchyManager.convertToInterEdge(y.base.Edge, y.base.Node, y.base.Node) method.
 Edge copyEdge(Graph targetGraph, Node newSource, Node newTarget, Edge originalEdge)
          Delegates to the wrapped factory.
protected  void copyFolderNodeContents(Node src, HierarchyManager srcHierarchyManager, Node dst, HierarchyManager dstHierarchyManager)
          Callback method that actually copies the contents of a folder node
 Node copyNode(Graph targetGraph, Node originalNode)
          Delegates to the wrapped factory.
 void copyRecursively(Graph2D sourceGraph, Graph2D targetGraph)
          Convenience method that creates a new GraphCopier, sets the copier as this getFolderGraphCopier() and then calls GraphCopier.copy(y.base.Graph, y.base.Graph) on it.
 Graph createGraph()
          Delegates to the wrapped factory.
protected  GraphCopier getFoldedGraphCopier(Node src, HierarchyManager srcHierarchyManager, Node dst, HierarchyManager dstHierarchyManager)
          Obtains the copier to use for copying the folder node contents.
 GraphCopier getFolderGraphCopier()
          Gets the copier to use for recursively copying the contents of the folder nodes.
 void postCopyGraphData(Graph src, Graph newGraph, java.util.Map nodeMap, java.util.Map edgeMap)
          Delegates to the wrapped factory and then recursively copies folder nodes contents
 void preCopyGraphData(Graph sourceGraph, Graph targetGraph)
          Delegates to the wrapped factory and performs initialization steps
 void setFolderGraphCopier(GraphCopier folderGraphCopier)
          Sets the copier to use for recursively copying the contents of the folder nodes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Graph2DCopyFactory.RecursiveGraph2DCopyFactory

public Graph2DCopyFactory.RecursiveGraph2DCopyFactory(GraphCopier.CopyFactory delegateFactory)
Creates a new instance that delegates the actual creation to a Graph2DCopyFactory.

Method Detail

copyEdge

public Edge copyEdge(Graph targetGraph,
                     Node newSource,
                     Node newTarget,
                     Edge originalEdge)
Delegates to the wrapped factory.

Specified by:
copyEdge in interface GraphCopier.CopyFactory
Parameters:
targetGraph - the graph to create the new node in
newSource - the source node in the target graph to use for the newly created edge
newTarget - the target node in the target graph to use for the newly created edge
originalEdge - the original edge from the source graph
Returns:
the newly created edge

copyNode

public Node copyNode(Graph targetGraph,
                     Node originalNode)
Delegates to the wrapped factory.

Specified by:
copyNode in interface GraphCopier.CopyFactory
Parameters:
targetGraph - the graph to create the new node in
originalNode - the original node from the source graph
Returns:
the newly created node

copyRecursively

public void copyRecursively(Graph2D sourceGraph,
                            Graph2D targetGraph)
Convenience method that creates a new GraphCopier, sets the copier as this getFolderGraphCopier() and then calls GraphCopier.copy(y.base.Graph, y.base.Graph) on it.

Parameters:
sourceGraph - The graph to copy
targetGraph - The graph to copy into.

createGraph

public Graph createGraph()
Delegates to the wrapped factory.

Specified by:
createGraph in interface GraphCopier.CopyFactory
Returns:
the graph to use as the target graph

getFolderGraphCopier

public GraphCopier getFolderGraphCopier()
Gets the copier to use for recursively copying the contents of the folder nodes. If null the folder contents will not be copied.

Returns:
The copier to use for copying the folder node contents.
See Also:
setFolderGraphCopier(y.util.GraphCopier)

setFolderGraphCopier

public void setFolderGraphCopier(GraphCopier folderGraphCopier)
Sets the copier to use for recursively copying the contents of the folder nodes. If null the folder contents will not be copied.

Parameters:
folderGraphCopier - The copier to use for copying the folder node contents.
See Also:
getFolderGraphCopier()

postCopyGraphData

public void postCopyGraphData(Graph src,
                              Graph newGraph,
                              java.util.Map nodeMap,
                              java.util.Map edgeMap)
Delegates to the wrapped factory and then recursively copies folder nodes contents

Specified by:
postCopyGraphData in interface GraphCopier.CopyFactory
Parameters:
src - the graph that was used to copy the entities from.
newGraph - the graph that was used to copy the entities to.
nodeMap - a map that contains a mapping between the nodes in the source graph to their corresponding nodes in the new graph.
edgeMap - a map that contains a mapping between the edges in the source graph to their corresponding edges in the new graph.

preCopyGraphData

public void preCopyGraphData(Graph sourceGraph,
                             Graph targetGraph)
Delegates to the wrapped factory and performs initialization steps

Specified by:
preCopyGraphData in interface GraphCopier.CopyFactory
Parameters:
sourceGraph - the graph that will be used to copy the entities from.
targetGraph - the graph that will be used to copy the entities to.

convertToInterEdge

protected void convertToInterEdge(Edge srcEdge,
                                  HierarchyManager dstHierarchyManager,
                                  Edge dstEdge,
                                  Node newRealSource,
                                  Node newRealTarget)
Callback method that is used after the contents have been copied recursively Converts the edge to an interEdge using the HierarchyManager.convertToInterEdge(y.base.Edge, y.base.Node, y.base.Node) method.

Parameters:
srcEdge - The edge in the source Graph.
dstHierarchyManager - The hierarchy manager in the target graph.
dstEdge - The edge to convert
newRealSource - The new real source.
newRealTarget - The new real target.

copyFolderNodeContents

protected void copyFolderNodeContents(Node src,
                                      HierarchyManager srcHierarchyManager,
                                      Node dst,
                                      HierarchyManager dstHierarchyManager)
Callback method that actually copies the contents of a folder node

Parameters:
src - The original folder node in the source graph.
srcHierarchyManager - The hierarchy manager in the source graph.
dst - the target node to convert to a folder.
dstHierarchyManager - The hierarchy manager in the target graph.

getFoldedGraphCopier

protected GraphCopier getFoldedGraphCopier(Node src,
                                           HierarchyManager srcHierarchyManager,
                                           Node dst,
                                           HierarchyManager dstHierarchyManager)
Obtains the copier to use for copying the folder node contents. This method delegates to getFolderGraphCopier()

Parameters:
src - The source folder node
srcHierarchyManager - The hierarchy manager of the source graph.
dst - The target folder node
dstHierarchyManager - The hierarchy manager of the target graph.
Returns:
The copier instance to use for copying the contents.

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.