proper copy constructor (not clone)
authorjprocter <Jim Procter>
Tue, 17 Apr 2007 11:01:57 +0000 (11:01 +0000)
committerjprocter <Jim Procter>
Tue, 17 Apr 2007 11:01:57 +0000 (11:01 +0000)
src/jalview/util/MapList.java

index 4a59f88..4922267 100644 (file)
@@ -31,13 +31,6 @@ import java.util.*;
 public class MapList
 {
   /* (non-Javadoc)
-   * @see java.lang.Object#clone()
-   */
-  protected Object clone() throws CloneNotSupportedException {
-    // TODO Auto-generated method stub
-    return super.clone();
-  }
-  /* (non-Javadoc)
    * @see java.lang.Object#equals(java.lang.Object)
    */
   public boolean equals(MapList obj) {
@@ -131,6 +124,37 @@ public class MapList
     this.fromRatio=fromRatio;
     this.toRatio=toRatio;
   }
+  public MapList(MapList map)
+  {
+    this.fromRange = new int[]
+    { map.fromRange[0], map.fromRange[1] };
+    this.toRange = new int[]
+    { map.toRange[0], map.toRange[1] };
+    this.fromRatio = map.fromRatio;
+    this.toRatio = map.toRatio;
+    if (map.fromShifts != null)
+    {
+      this.fromShifts = new Vector();
+      Enumeration e = map.fromShifts.elements();
+      while (e.hasMoreElements())
+      {
+        int[] el = (int[]) e.nextElement();
+        fromShifts.addElement(new int[]
+        { el[0], el[1] });
+      }
+    }
+    if (map.toShifts != null)
+    {
+      this.toShifts = new Vector();
+      Enumeration e = map.toShifts.elements();
+      while (e.hasMoreElements())
+      {
+        int[] el = (int[]) e.nextElement();
+        toShifts.addElement(new int[]
+        { el[0], el[1] });
+      }
+    }
+  }
   /**
    * get all mapped positions from 'from' to 'to'
    * @return int[][] { int[] { fromStart, fromFinish, toStart, toFinish }, int [fromFinish-fromStart+2] { toStart..toFinish mappings}}