Class GraphCopier


  • public class GraphCopier
    extends java.lang.Object
    A copier for graphs. After a graph was copied, the copier can be queried for the mappings of input nodes to output nodes and input edges to output edges. A copier is a stateful utility.
    • Constructor Summary

      Constructors 
      Constructor Description
      GraphCopier​(org.eclipse.gef.common.attributes.IAttributeCopier attributeCopier)
      Creates a new GraphCopier instance with the given IAttributeCopier.
    • 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, Nodes, and Edges.
    • Method Detail

      • clearInputToOutputMaps

        protected void clearInputToOutputMaps()
        Discard any data that was tracked in previous copy operations.
        Since:
        5.1
      • 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.
      • copyEdges

        protected void copyEdges​(Graph graph,
                                 Graph outputGraph)
        Copies all the edges of the given graph into the output graph.
        Parameters:
        graph - The input Graph to copy.
        outputGraph - The output Graph.
        Since:
        5.1
      • 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.
      • copyNodes

        protected void copyNodes​(Graph graph,
                                 Graph outputGraph)
        Copies all the nodes of the given graph into the output graph.
        Parameters:
        graph - The input Graph to copy.
        outputGraph - The output Graph.
        Since:
        5.1
      • 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 Edges to output Edges.
        Returns:
        An (unmodifiable) Map from input Edges to output Edges.
      • getInputToOutputNodeMap

        public java.util.Map<Node,​Node> getInputToOutputNodeMap()
        Returns an (unmodifiable) Map from input Nodes to output Nodes.
        Returns:
        An (unmodifiable) Map from input Nodes to output Nodes.
      • trackCopiedEdge

        protected void trackCopiedEdge​(Edge inputEdge,
                                       Edge outputEdge)
        Maintains a mapping from the input edge to the output edge.
        Parameters:
        inputEdge - the input edge.
        outputEdge - the output edge.
        Since:
        5.1
      • trackCopiedNode

        protected void trackCopiedNode​(Node inputNode,
                                       Node outputNode)
        Maintains a mapping from the input node to the output node.
        Parameters:
        inputNode - the input node.
        outputNode - the output node.
        Since:
        5.1