Search this API

y.view
Class Graph2DCopyFactory

java.lang.Object
  extended by y.view.Graph2DCopyFactory
All Implemented Interfaces:
GraphFactory, GraphCopier.CopyFactory

public class Graph2DCopyFactory
extends java.lang.Object
implements GraphCopier.CopyFactory, GraphFactory

A graph factory that creates elements of a Graph2D as copies of other elements. Also this instance implements the GraphCopier.CopyFactory to conveniently copy elements into a Graph2D from any Graph implementation.

 
Your browser does not support SVG content.

Nested Class Summary
static class Graph2DCopyFactory.HierarchicGraph2DCopyFactory
          A copy factory implementation that copies hierarchy information to a newly created Graph2D.
static class Graph2DCopyFactory.RecursiveGraph2DCopyFactory
          A decorator for the a GraphCopier.CopyFactory that recursively copies the contents of folder nodes and correctly adjusts the inter-edge state.
 
Constructor Summary
Graph2DCopyFactory()
           
 
Method Summary
 Edge copyEdge(Graph targetGraph, Node newSource, Node newTarget, Edge originalEdge)
          Copies the originalEdge from the source graph to the new targetGraph using the specified new source and target node in the target graph.
 Node copyNode(Graph targetGraph, Node originalNode)
          Copies the originalNode from the source graph to the new targetGraph
protected  EdgeRealizer copyRealizer(EdgeRealizer realizer)
          Callback to actually copy the EdgeRealizer.
protected  NodeRealizer copyRealizer(NodeRealizer realizer)
          Callback to actually copy the NodeRealizer.
 Edge createEdge(Graph graph, Node source, Node target, java.lang.Object hint)
          Creates an edge in the given graph.
 Graph createGraph()
          Creates a new Graph2D.
 Graph createGraph(java.lang.Object hint)
          Creates a new instance of Graph2D.
 Node createNode(Graph graph, java.lang.Object hint)
          Creates a node in the given graph.
 void postCopyGraphData(Graph originalGraph, Graph newGraph, java.util.Map nodeMap, java.util.Map edgeMap)
          Callback that will be called after the copy operation has completed.
 void preCopyGraphData(Graph originalGraph, Graph newGraph)
          Callback that will be called before the copy operation takes place.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Graph2DCopyFactory

public Graph2DCopyFactory()
Method Detail

createGraph

public Graph createGraph(java.lang.Object hint)
Creates a new instance of Graph2D. If the hint is an instance of Graph2D then the returned graph will be a copy of the hint.

Specified by:
createGraph in interface GraphFactory
Parameters:
hint - Context-specific hint information.
Returns:
The newly created Graph object.

createNode

public Node createNode(Graph graph,
                       java.lang.Object hint)
Creates a node in the given graph. If the hint object is an instance of class Node, then the newly created node will be assigned an exact copy of the node realizer bound to this original node.

Specified by:
createNode in interface GraphFactory
Parameters:
graph - The graph that should contain the newly created node.
hint - Context-specific hint information.
Returns:
The newly created Node object.

createEdge

public Edge createEdge(Graph graph,
                       Node source,
                       Node target,
                       java.lang.Object hint)
Creates an edge in the given graph. If the hint object is an instance of class Edge, then the newly created edge will be assigned an exact copy of the edge realizer bound to this original edge.

Specified by:
createEdge in interface GraphFactory
Parameters:
graph - The graph that should contain the newly created edge.
source - The source node of the newly created edge.
target - The target node of the newly created edge.
hint - Context-specific hint information.
Returns:
The newly created Edge object.

copyRealizer

protected EdgeRealizer copyRealizer(EdgeRealizer realizer)
Callback to actually copy the EdgeRealizer.


copyNode

public Node copyNode(Graph targetGraph,
                     Node originalNode)
Description copied from interface: GraphCopier.CopyFactory
Copies the originalNode from the source graph to the new targetGraph

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

copyRealizer

protected NodeRealizer copyRealizer(NodeRealizer realizer)
Callback to actually copy the NodeRealizer.


copyEdge

public Edge copyEdge(Graph targetGraph,
                     Node newSource,
                     Node newTarget,
                     Edge originalEdge)
Description copied from interface: GraphCopier.CopyFactory
Copies the originalEdge from the source graph to the new targetGraph using the specified new source and target node in the target graph.

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

createGraph

public Graph createGraph()
Creates a new Graph2D.

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

preCopyGraphData

public void preCopyGraphData(Graph originalGraph,
                             Graph newGraph)
Description copied from interface: GraphCopier.CopyFactory
Callback that will be called before the copy operation takes place. At that point in time no entities have been copied to the new graph.

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

postCopyGraphData

public void postCopyGraphData(Graph originalGraph,
                              Graph newGraph,
                              java.util.Map nodeMap,
                              java.util.Map edgeMap)
Description copied from interface: GraphCopier.CopyFactory
Callback that will be called after the copy operation has completed. At that point in time all entities have been copied to the new graph.

Specified by:
postCopyGraphData in interface GraphCopier.CopyFactory
Parameters:
originalGraph - 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.

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