X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FMapList.java;h=826ead7326bbd9cad27d1310f49b3c422b5f9eab;hb=3a2924d94334b170106141ec4e4773034c5995ce;hp=4a59f88aa50066da55870f06ec3651a68fb968db;hpb=539bd323123b239afdac5ef7b7706d6ccfc6a41d;p=jalview.git diff --git a/src/jalview/util/MapList.java b/src/jalview/util/MapList.java index 4a59f88..826ead7 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}} @@ -393,7 +417,7 @@ public class MapList public int[] locateInFrom(int start, int end) { // inefficient implementation int fromStart[] = shiftTo(start); - int fromEnd[] = shiftTo(end); + int fromEnd[] = shiftTo(end); // needs to be inclusive of end of symbol position if (fromStart==null || fromEnd==null) return null; int iv[] = getIntervals(fromShifts, fromStart, fromEnd,fromRatio); @@ -426,9 +450,11 @@ public class MapList */ private int[] getIntervals(Vector fromShifts2, int[] fromStart, int[] fromEnd, int fromRatio2) { - // correct for word direction for start and end - int startpos = fromStart[0]+fromStart[2]*(fromRatio2-1); - int endpos = fromEnd[0]+fromEnd[2]*(fromRatio2-1); + // TODO: correct for word boundary w.r.t. fromStart->fromEnd direction for startpos and endpos. + // test is (1,8,12,17) to (1,5) and features on to : 2,2; 3,3; 4,3; 3,4; 4,4; 5,3; 3,5; 2,4; 4,2; + // correct for word direction for start and end : + int startpos = fromStart[0]+fromStart[2]*(fromRatio2-1); // Math.min(fromStart[0], .. ); + int endpos = fromEnd[0]+fromEnd[2]*(fromRatio2-1); // Math.max(fromEnd[0],); int intv=0,intvSize= fromShifts2.size(); int iv[],i=0,fs=-1,fe=-1; // containing intervals while (intv