X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FMapList.java;h=986b18cf270c855a00a7369d2c2aa060d4a6beab;hb=6398c0217546a4d6943f63f670c2684c7c7274be;hp=9f28ee19f5cdf8fb6c262e13087c9ef7af2741ee;hpb=10dd3a771da0085ead2318b7385211c7b675d7f4;p=jalview.git diff --git a/src/jalview/util/MapList.java b/src/jalview/util/MapList.java index 9f28ee1..986b18c 100644 --- a/src/jalview/util/MapList.java +++ b/src/jalview/util/MapList.java @@ -1044,70 +1044,15 @@ public class MapList for (int[] range : map.getFromRanges()) { - addRange(range, fromShifts); + MappingUtils.addRange(range, fromShifts); } for (int[] range : map.getToRanges()) { - addRange(range, toShifts); + MappingUtils.addRange(range, toShifts); } } /** - * Adds the given range to a list of ranges. If the new range just extends - * existing ranges, the current endpoint is updated instead. - * - * @param range - * @param addTo - */ - static void addRange(int[] range, List addTo) - { - /* - * list is empty - add to it! - */ - if (addTo.size() == 0) - { - addTo.add(range); - return; - } - - int[] last = addTo.get(addTo.size() - 1); - boolean lastForward = last[1] >= last[0]; - boolean newForward = range[1] >= range[0]; - - /* - * contiguous range in the same direction - just update endpoint - */ - if (lastForward == newForward && last[1] == range[0]) - { - last[1] = range[1]; - return; - } - - /* - * next range starts at +1 in forward sense - update endpoint - */ - if (lastForward && newForward && range[0] == last[1] + 1) - { - last[1] = range[1]; - return; - } - - /* - * next range starts at -1 in reverse sense - update endpoint - */ - if (!lastForward && !newForward && range[0] == last[1] - 1) - { - last[1] = range[1]; - return; - } - - /* - * just add the new range - */ - addTo.add(range); - } - - /** * Returns true if mapping is from forward strand, false if from reverse * strand. Result is just based on the first 'from' range that is not a single * position. Default is true unless proven to be false. Behaviour is not well @@ -1236,4 +1181,14 @@ public class MapList return new MapList(getFromRanges(), toRanges, outFromRatio, outToRatio); } + /** + * Answers true if the mapping is from one contiguous range to another, else + * false + * + * @return + */ + public boolean isContiguous() + { + return fromShifts.size() == 1 && toShifts.size() == 1; + } }