org.eclipse.gef.graph

## Class GraphCopier

- java.lang.Object
- - org.eclipse.gef.graph.GraphCopier

    public class GraphCopier
    extends java.lang.Object

A copier for `Graph`s.

### Constructor Summary

Constructors
Constructor and Description
`GraphCopier(org.eclipse.gef.common.attributes.IAttributeCopier attributeCopier)` Creates a new `GraphCopier` instance with the given `IAttributeCopier`.

### Method Summary

All Methods Instance Methods Concrete Methods
`Graph` `copy(Graph graph)` Creates a copy of the given `Graph`.
`protected void` `copyAttributes(org.eclipse.gef.common.attributes.IAttributeStore inputStore, org.eclipse.gef.common.attributes.IAttributeStore outputStore)` Transfers attributes from the given input `Graph`, `Node`, or `Edge` to the given output `Graph`, `Node`, or `Edge`.
`protected Edge` `copyEdge(Edge edge)` Creates a copy of the given edge.
`protected Graph` `copyGraph(Graph graph)` Copies the given `Graph` using the current `IAttributeCopier`.
`protected Node` `copyNode(Node node)` Creates a copy of the given node.
`org.eclipse.gef.common.attributes.IAttributeCopier` `getAttributeCopier()` Returns the `IAttributeCopier` used by this `GraphCopier`.
`java.util.Map<Edge,Edge>` `getInputToOutputEdgeMap()` Returns an (unmodifiable) `Map` from input `Edge`s to output `Edge`s.
`java.util.Map<Node,Node>` `getInputToOutputNodeMap()` Returns an (unmodifiable) `Map` from input `Node`s to output `Node`s.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### GraphCopier

    public GraphCopier(org.eclipse.gef.common.attributes.IAttributeCopier attributeCopier)

Creates a new `GraphCopier` instance with the given `IAttributeCopier`.

Parameters:
  `attributeCopier` - The `IAttributeCopier` used to copy the attributes of `Graph`, `Node`s, and `Edge`s.

### Method Detail

#### copy

    public Graph copy(Graph graph)

Creates a copy of the given `Graph`.

Parameters:
  `graph` - The Graph to copy.
Returns:
  A new graph that is the result of the copy operation.

#### copyAttributes

    protected void copyAttributes(org.eclipse.gef.common.attributes.IAttributeStore inputStore,
                                  org.eclipse.gef.common.attributes.IAttributeStore outputStore)

Transfers attributes from the given input `Graph`, `Node`, or `Edge` to the given output `Graph`, `Node`, or `Edge`. The attributes may be copied or simply transferred. This lies within the responsibility of the `IAttributeCopier` that was passed in on construction of the `GraphCopier`.

Parameters:
  `inputStore` - The `Graph`, `Node`, or `Edge` from which to copy attributes.
  `outputStore` - The `Graph`, `Node`, or `Edge` to copy attributes to.

#### copyEdge

    protected Edge copyEdge(Edge edge)

Creates a copy of the given edge.

Parameters:
  `edge` - The Edge to copy.
Returns:
  A new `Edge` with transferred relations and (copied) attributes.

#### copyGraph

    protected Graph copyGraph(Graph graph)

Copies the given `Graph` using the current `IAttributeCopier`. Records the copied nodes in the `getInputToOutputNodeMap()` and the copied edges in the `getInputToOutputEdgeMap()`.

Parameters:
  `graph` - The input `Graph` to copy.
Returns:
  The copied result `Graph`.

#### copyNode

    protected Node copyNode(Node node)

Creates a copy of the given node.

Parameters:
  `node` - The `Node` to copy.
Returns:
  A new Node with transferred relations and (copied) attributes.

#### getAttributeCopier

    public org.eclipse.gef.common.attributes.IAttributeCopier getAttributeCopier()

Returns the `IAttributeCopier` used by this `GraphCopier`.

Returns:
  The `IAttributeCopier` used by this `GraphCopier`.

#### getInputToOutputEdgeMap

    public java.util.Map<Edge,Edge> getInputToOutputEdgeMap()

Returns an (unmodifiable) `Map` from input `Edge`s to output `Edge`s.

Returns:
  An (unmodifiable) `Map` from input `Edge`s to output `Edge`s.

#### getInputToOutputNodeMap

    public java.util.Map<Node,Node> getInputToOutputNodeMap()

Returns an (unmodifiable) `Map` from input `Node`s to output `Node`s.

Returns:
  An (unmodifiable) `Map` from input `Node`s to output `Node`s.