}
/**
- * Returns the flattened 'from' ranges as [start1, end1, start2, end2, ...]
+ * Returns the 'from' ranges as {[start1, end1], [start2, end2], ...}
*
* @return
*/
- public int[] getFromRanges()
+ public List<int[]> getFromRanges()
{
- return getRanges(fromShifts);
+ return fromShifts;
}
/**
- * Returns the flattened 'to' ranges as [start1, end1, start2, end2, ...]
+ * Returns the 'to' ranges as {[start1, end1], [start2, end2], ...}
*
* @return
*/
- public int[] getToRanges()
+ public List<int[]> getToRanges()
{
- return getRanges(toShifts);
+ return toShifts;
}
/**
*/
public MapList(int from[], int to[], int fromRatio, int toRatio)
{
+ this.fromRatio = fromRatio;
+ this.toRatio = toRatio;
fromLowest = from[0];
fromHighest = from[1];
for (int i = 0; i < from.length; i += 2)
toShifts.add(new int[]
{ to[i], to[i + 1] });
}
- this.fromRatio = fromRatio;
- this.toRatio = toRatio;
}
/**
}
/**
+ * Constructor given ranges as lists of [start, end] positions
+ *
+ * @param fromRange
+ * @param toRange
+ * @param fromRatio
+ * @param toRatio
+ */
+ public MapList(List<int[]> fromRange, List<int[]> toRange,
+ int fromRatio, int toRatio)
+ {
+ this.fromShifts = fromRange;
+ this.toShifts = toRange;
+ this.fromRatio = fromRatio;
+ this.toRatio = toRatio;
+
+ fromLowest = Integer.MAX_VALUE;
+ fromHighest = 0;
+ for (int[] range : fromRange) {
+ fromLowest = Math.min(fromLowest, range[0]);
+ fromHighest = Math.max(fromHighest, range[1]);
+ }
+
+ toLowest = Integer.MAX_VALUE;
+ toHighest = 0;
+ for (int[] range : toRange)
+ {
+ toLowest = Math.min(toLowest, range[0]);
+ toHighest = Math.max(toHighest, range[1]);
+ }
+ }
+
+ /**
* get all mapped positions from 'from' to 'to'
*
* @return int[][] { int[] { fromStart, fromFinish, toStart, toFinish }, int