From: jprocter Date: Tue, 17 Apr 2007 11:01:57 +0000 (+0000) Subject: proper copy constructor (not clone) X-Git-Tag: Release_2_3~242 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=d4b01f3adab0fab7774a0cb5e5226cfa44d303fe proper copy constructor (not clone) --- diff --git a/src/jalview/util/MapList.java b/src/jalview/util/MapList.java index 4a59f88..4922267 100644 --- a/src/jalview/util/MapList.java +++ b/src/jalview/util/MapList.java @@ -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}}