|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.util.GraphCopier
public class GraphCopier
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 GraphCopier.CopyFactory
that can either be any of the default
implementations or any other implementation that can be associated with a Graph
's
copy factory property
.
GraphCopier.CopyFactory
,
copy(y.base.Graph)
Nested Class Summary | |
---|---|
static interface |
GraphCopier.CopyFactory
The copy factory interface used by GraphCopier to delegate the actual work to. |
static class |
GraphCopier.DataProviderCopyFactory
Abstract helper class that provides helper methods to copy DataProvider contents. |
static class |
GraphCopier.EdgeDataProviderCopyFactory
Helper class implementation of GraphCopier.CopyFactory that
can be used to copy the contents of a DataProvider registered with
the source graph onto the target graph storing the values in newly a
created edge map . |
static class |
GraphCopier.EdgeMapCopyFactory
A helper wrapping implementation of the GraphCopier.CopyFactory interface that copies the contents
of the edge maps from the source to the target graph. |
static class |
GraphCopier.GraphDataCopyFactory
An abstract base implementation of a delegating GraphCopier.GraphDataCopyFactory that
copies data for items being copied. |
static class |
GraphCopier.ItemDataProviderCopyFactory
Helper class implementation of GraphCopier.CopyFactory that
can be used to copy the contents of a DataProvider registered with
the source graph onto the target graph storing the values in newly created
HashMap based DataMap s. |
static class |
GraphCopier.NodeDataProviderCopyFactory
Helper class implementation of GraphCopier.CopyFactory that
can be used to copy the contents of a DataProvider registered with
the source graph onto the target graph storing the values in newly created
node map . |
static class |
GraphCopier.NodeMapCopyFactory
A helper wrapping implementation of the GraphCopier.CopyFactory interface that copies the contents
of the node maps from the source to the target graph. |
Constructor Summary | |
---|---|
GraphCopier()
Creates a new instance that uses a GraphCopyFactory as the default factory. |
|
GraphCopier(GraphCopier.CopyFactory copyFactory)
Creates a new instance that uses the specified factory to perform the actual copy operations. |
Method Summary | |
---|---|
Graph |
copy(Graph sourceGraph)
Copies the contents of the source graph to a newly created target graph and returns the new graph. |
NodeList |
copy(Graph sourceGraph,
Graph targetGraph)
Copies the contents of the source graph to the target graph and returns the newly created nodes in the target graph. |
Graph |
copy(Graph sourceGraph,
NodeCursor sourceNodes)
Copies the subgraph contained in graph induced by the source nodes to a newly created graph. |
NodeList |
copy(Graph sourceGraph,
NodeCursor sourceNodes,
EdgeCursor sourceEdges,
Graph targetGraph)
Copies the subgraph contained in sourceGraph induced by the source nodes and the provided source edges to the targetGraph. |
NodeList |
copy(Graph sourceGraph,
NodeCursor sourceNodes,
Graph targetGraph)
Copies the subgraph contained in sourceGraph induced by the source nodes to the targetGraph. targetGraph is not cleared prior to the copy operation. |
protected Edge |
copyEdge(GraphCopier.CopyFactory copyFactory,
Graph targetGraph,
Node newSource,
Node newTarget,
Edge edge)
Callback that uses the given factory to perform the copy operation. |
protected Node |
copyNode(GraphCopier.CopyFactory copyFactory,
Graph targetGraph,
Node node)
Callback that uses the given factory to perform the copy operation. |
protected java.util.Map |
createEdgeMap()
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. |
protected Graph |
createGraph(GraphCopier.CopyFactory factory,
Graph sourceGraph)
Callback that uses the given factory to create a new graph. |
protected java.util.Map |
createNodeMap()
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.CopyFactory |
getCopyFactory()
Returns the factory that is used for copy operations. |
protected EdgeCursor |
getSourceEdges(Graph sourceGraph)
Determines the set of edge candidates from the source graph that should be copied. |
protected NodeCursor |
getSourceNodes(Graph sourceGraph)
Determines the set of node candidates from the source graph that should be copied if no other nodes are specified by the user. |
boolean |
isDataProviderContentCopying()
Determines if the contents of data providers are copied automatically. |
boolean |
isEdgeMapCopying()
Determines if the contents of edge maps are copied automatically. |
boolean |
isNodeMapCopying()
Determines if the contents of node maps are copied automatically. |
protected void |
postCopyGraphData(GraphCopier.CopyFactory copyFactory,
Graph sourceGraph,
Graph targetGraph,
java.util.Map nodeMap,
java.util.Map edgeMap)
Callback that uses the given factory to perform the copy operation. |
protected void |
preCopyGraphData(GraphCopier.CopyFactory copyFactory,
Graph sourceGraph,
Graph targetGraph)
Callback that uses the given factory to perform the copy operation. |
void |
setCopyFactory(GraphCopier.CopyFactory copyFactory)
Sets the factory that is used for copy operations. |
void |
setDataProviderContentCopying(boolean dataProviderContentCopying)
Specifies if the contents of data providers are copied automatically. |
void |
setEdgeMapCopying(boolean edgeMapCopying)
Specifies if the contents of edge maps are copied automatically. |
void |
setNodeMapCopying(boolean nodeMapCopying)
Specifies if the contents of node maps are copied automatically. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GraphCopier()
GraphCopyFactory
as the default factory.
public GraphCopier(GraphCopier.CopyFactory copyFactory)
copyFactory
- the factory to use, must be non-null
.
java.lang.NullPointerException
- if copyFactory
is null
Method Detail |
---|
public boolean isNodeMapCopying()
The default is false
.
setNodeMapCopying(boolean)
public void setNodeMapCopying(boolean nodeMapCopying)
The default is false
.
Copying will be done by reference on Object
basis. To store these objects, new
NodeMap
s are created for the target graph.
In order to access these NodeMap
s it is necessary to store the number of NodeMap
s in
the target graph before creating the NodeMap
s 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 NodeMap
s more easily, it is recommended to use
DataProvider
s instead and have them copied.
nodeMapCopying
- whether to copy node maps and their contents.isNodeMapCopying()
,
GraphCopier.NodeMapCopyFactory
,
Graph.getRegisteredNodeMaps()
,
setDataProviderContentCopying(boolean)
public boolean isEdgeMapCopying()
The default is false
.
setEdgeMapCopying(boolean)
public void setEdgeMapCopying(boolean edgeMapCopying)
The default is false
.
Copying will be done by reference on Object
basis. To store these objects, new
EdgeMap
s are created for the target graph.
In order to access these EdgeMap
s it is necessary to store the number of EdgeMap
s in
the target graph before creating the EdgeMap
s as they will be appended. After copying the graph an
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 EdgeMap
s more easily, it is recommended to use
DataProvider
s instead and have them copied.
edgeMapCopying
- whether to copy edge maps and their contents.isEdgeMapCopying()
,
GraphCopier.EdgeMapCopyFactory
,
Graph.getRegisteredEdgeMaps()
,
setDataProviderContentCopying(boolean)
public boolean isDataProviderContentCopying()
The default is false
.
setDataProviderContentCopying(boolean)
public void setDataProviderContentCopying(boolean dataProviderContentCopying)
The default is false
.
Copying will be done by reference on Object
basis.
The backing store for the content will be HashMap
based.
GraphCopier.ItemDataProviderCopyFactory
,
isDataProviderContentCopying()
public NodeList copy(Graph sourceGraph, Graph targetGraph)
sourceGraph
- the graph to copy the contents fromtargetGraph
- the target graph to copy the contents to, it will not be cleared prior to the copying
copy(y.base.Graph,y.base.NodeCursor,y.base.Graph)
public Graph copy(Graph sourceGraph)
sourceGraph
- the graph to copy the contents from
GraphCopier.CopyFactory.createGraph()
public Graph copy(Graph sourceGraph, NodeCursor sourceNodes)
sourceGraph
- the graph to copysourceNodes
- the nodes in the sourceGraph to copy to the new graph
GraphCopier.CopyFactory.createGraph()
public GraphCopier.CopyFactory getCopyFactory()
setCopyFactory(CopyFactory)
public void setCopyFactory(GraphCopier.CopyFactory copyFactory)
copyFactory
- the factory to use, must be non-null
.
java.lang.NullPointerException
- if copyFactory
is null
getCopyFactory()
,
GraphCopier(CopyFactory)
protected Graph createGraph(GraphCopier.CopyFactory factory, Graph sourceGraph)
GraphCopier.CopyFactory.createGraph()
and can be overwritten to change the behavior.
factory
- the factory to use for the creationsourceGraph
- the graph that will be
public NodeList copy(Graph sourceGraph, NodeCursor sourceNodes, Graph targetGraph)
sourceGraph
- the graph to copysourceNodes
- the nodes in the sourceGraph to copy to the new graphtargetGraph
- the graph to copy the sourceGraph's contents to
public NodeList copy(Graph sourceGraph, NodeCursor sourceNodes, EdgeCursor sourceEdges, Graph targetGraph)
sourceGraph
- the graph to copysourceNodes
- the nodes in the sourceGraph to copy to the new graphtargetGraph
- the graph to copy the sourceGraph's contents tosourceEdges
- the edges in the sourceGraph to copy to the new graph
protected void preCopyGraphData(GraphCopier.CopyFactory copyFactory, Graph sourceGraph, Graph targetGraph)
GraphCopier.CopyFactory.preCopyGraphData(y.base.Graph,y.base.Graph)
and can be overwritten to change
the behavior.
copyFactory
- the factory delegate the operation toprotected void postCopyGraphData(GraphCopier.CopyFactory copyFactory, Graph sourceGraph, Graph targetGraph, java.util.Map nodeMap, java.util.Map edgeMap)
GraphCopier.CopyFactory.postCopyGraphData(y.base.Graph,y.base.Graph,java.util.Map,java.util.Map)
and can
be overwritten to change the behavior.
copyFactory
- the factory delegate the operation toprotected java.util.Map createEdgeMap()
protected Edge copyEdge(GraphCopier.CopyFactory copyFactory, Graph targetGraph, Node newSource, Node newTarget, Edge edge)
GraphCopier.CopyFactory.copyEdge(y.base.Graph,y.base.Node,y.base.Node,y.base.Edge)
and can be
overwritten to change the behavior.
copyFactory
- the factory delegate the operation toprotected EdgeCursor getSourceEdges(Graph sourceGraph)
Graph.edges()
sourceGraph
- the graph to determine the edges to copy
protected Node copyNode(GraphCopier.CopyFactory copyFactory, Graph targetGraph, Node node)
GraphCopier.CopyFactory.copyNode(y.base.Graph, y.base.Node)
and can be overwritten to change the behavior.
copyFactory
- the factory delegate the operation toprotected java.util.Map createNodeMap()
protected NodeCursor getSourceNodes(Graph sourceGraph)
Graph.nodes()
sourceGraph
- the graph to determine the nodes to copy
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |