## devisor2.grid.backend
Class GridCloner

    java.lang.Object
      devisor2.grid.backend.GridCloner

public class GridCloner
extends java.lang.Object

This class performs the actual cloning which is basically used for the copy&paste operation. Here is how it works to make sure that not only shallow copies are created, but that after cloning, the object references are correct.
A Vector of selected items is passed as input for this class. Firstly, the given nodes are cloned, which means all the nodes contained in the vector and the nodes implicitely contained (as part of Tri and Quad elements or as BoundaryNodes). The original ones and the cloned copies are both stored in an array at the same index so that later on, it is still possible to figure out what node is a clone of what node.
After that, the elements are cloned shallowly, and for every node contained in the original, its clone is assigned to the element clone.
After that, parent-child-relationships are updated in the cloned elements. Last but not least, the affine transform to the new position is applied, and everything is added to the Domain.
This class provides methods to perform that, but is not intelligent: The whole copy&paste operation is controlled by the GridListener and MainActionListener classes. See there for more details about how this class is to be used.

Field Summary
`protected ControlCenter` `cc`
`protected Boundary[]` `clonedBounds`
`protected Cell2D[]` `clonedCells`
`protected Edge[]` `clonedEdges`
`protected Node[]` `clonedNodes`
`protected Segment[]` `clonedSegments`
`protected Boundary[]` `origBounds`
`protected Cell2D[]` `origCells`
`protected Edge[]` `origEdges`
`protected java.util.Vector` `originals`
`protected Node[]` `origNodes`
`protected Segment[]` `origSegments`

Constructor Summary
`GridCloner(java.util.Vector itemsToBeCloned)` the constructor just sets the references correctly

Method Summary
`void` `createClone()` creates a deep clone of the given items and stores it in the corresponding inner variable
`Segment` `getClone(Segment s)` get cloned Segment of the given Segment
`Boundary[]` `getClonedBoundaries()`
`java.util.Vector` `getClones()` returns all cloned items in one vector
`Boundary[]` `getOrigBoundaries()`
`Segment` `getOrigSegment(int index, int bno)`
`void` `print(java.lang.Object[] array)` debug purposes: prints out the contents of the given array

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### cc

    protected ControlCenter cc

### originals

    protected java.util.Vector originals

### origNodes

    protected Node[] origNodes

### clonedNodes

    protected Node[] clonedNodes

### origEdges

    protected Edge[] origEdges

### clonedEdges

    protected Edge[] clonedEdges

### origCells

    protected Cell2D[] origCells

### clonedCells

    protected Cell2D[] clonedCells

### origSegments

    protected Segment[] origSegments

### clonedSegments

    protected Segment[] clonedSegments

### origBounds

    protected Boundary[] origBounds

### clonedBounds

    protected Boundary[] clonedBounds

Constructor Detail

### GridCloner

    public GridCloner(java.util.Vector itemsToBeCloned)

  the constructor just sets the references correctly

Method Detail

### getClones

    public java.util.Vector getClones()

  returns all cloned items in one vector

### getOrigBoundaries

    public Boundary[] getOrigBoundaries()

  Returns:
    the originals of the boundaries (same indexing)

### getClonedBoundaries

    public Boundary[] getClonedBoundaries()

  Returns:
    all clones of the boundaries (deep/full clones)

### getClone

    public Segment getClone(Segment s)

  get cloned Segment of the given Segment

### getOrigSegment

    public Segment getOrigSegment(int index,
                                  int bno)

  Returns:
    the original segment belonging to the given segment on the given boundary

### createClone

    public void createClone()

  creates a deep clone of the given items and stores it in the corresponding inner variable

### print

    public void print(java.lang.Object[] array)

  debug purposes: prints out the contents of the given array