/*
- * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
- * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9)
+ * Copyright (C) 2015 The Jalview Authors
*
* This file is part of Jalview.
*
fromLowest = Math.min(fromLowest, from[i]);
fromHighest = Math.max(fromHighest, from[i + 1]);
- fromShifts.add(new int[]
- { from[i], from[i + 1] });
+ fromShifts.add(new int[] { from[i], from[i + 1] });
}
toLowest = to[0];
{
toLowest = Math.min(toLowest, to[i]);
toHighest = Math.max(toHighest, to[i + 1]);
- toShifts.add(new int[]
- { to[i], to[i + 1] });
+ toShifts.add(new int[] { to[i], to[i + 1] });
}
}
{
for (int[] r : map.fromShifts)
{
- fromShifts.add(new int[]
- { r[0], r[1] });
+ fromShifts.add(new int[] { r[0], r[1] });
}
}
if (map.toShifts != null)
{
for (int[] r : map.toShifts)
{
- toShifts.add(new int[]
- { r[0], r[1] });
+ toShifts.add(new int[] { r[0], r[1] });
}
}
}
* @param fromRatio
* @param toRatio
*/
- public MapList(List<int[]> fromRange, List<int[]> toRange,
- int fromRatio, int toRatio)
+ public MapList(List<int[]> fromRange, List<int[]> toRange, int fromRatio,
+ int toRatio)
{
this.fromShifts = fromRange;
this.toShifts = toRange;
fromLowest = Integer.MAX_VALUE;
fromHighest = 0;
- for (int[] range : fromRange) {
+ for (int[] range : fromRange)
+ {
fromLowest = Math.min(fromLowest, range[0]);
fromHighest = Math.max(fromHighest, range[1]);
}
* returning mapped position
*/
private int[][] posMap(List<int[]> shiftTo, int ratio,
- List<int[]> shiftFrom,
- int toRatio)
+ List<int[]> shiftFrom, int toRatio)
{
// TODO not used - remove??
int iv = 0, ivSize = shiftTo.size();
}
mp[i] = m;
}
- int[][] map = new int[][]
- { new int[]
- { from, to, tF, tT }, new int[to - from + 2] };
+ int[][] map = new int[][] { new int[] { from, to, tF, tT },
+ new int[to - from + 2] };
map[0][2] = tF;
map[0][3] = tT;
return null; // throw new Error("Bad Mapping!");
}
// System.out.println(fromCount[0]+" "+fromCount[1]+" "+toCount);
- return new int[]
- { toPos[0], fromRemainder, toPos[1] };
+ return new int[] { toPos[0], fromRemainder, toPos[1] };
}
/**
{
if (pos >= intv[0] && pos <= intv[1])
{
- return new int[]
- { count + pos - intv[0] + 1, +1 };
+ return new int[] { count + pos - intv[0] + 1, +1 };
}
else
{
{
if (pos >= intv[1] && pos <= intv[0])
{
- return new int[]
- { count + intv[0] - pos + 1, -1 };
+ return new int[] { count + intv[0] - pos + 1, -1 };
}
else
{
protected static int[] countToPos(List<int[]> shiftFrom, int pos)
{
int count = 0, diff = 0, iv = 0, ivSize = shiftFrom.size();
- int[] intv =
- { 0, 0 };
+ int[] intv = { 0, 0 };
while (iv < ivSize)
{
intv = shiftFrom.get(iv++);
{
if (pos <= count + 1 + diff)
{
- return new int[]
- { pos - count - 1 + intv[0], +1 };
+ return new int[] { pos - count - 1 + intv[0], +1 };
}
else
{
{
if (pos <= count + 1 - diff)
{
- return new int[]
- { intv[0] - (pos - count - 1), -1 };
+ return new int[] { intv[0] - (pos - count - 1), -1 };
}
else
{
* region to final position of ending region inclusive
*/
protected static int[] getIntervals(List<int[]> shiftFrom,
- int[] fromStart,
- int[] fromEnd, int fromRatio2)
+ int[] fromStart, int[] fromEnd, int fromRatio2)
{
if (fromStart == null || fromEnd == null)
{
i = fs;
// truncate initial interval
iv = shiftFrom.get(intv++);
- iv = new int[]
- { iv[0], iv[1] };// clone
+ iv = new int[] { iv[0], iv[1] };// clone
if (i == fs)
{
iv[0] = startpos;
{
ranges.add(iv); // add initial range
iv = shiftFrom.get(intv++); // get next interval
- iv = new int[]
- { iv[0], iv[1] };// clone
+ iv = new int[] { iv[0], iv[1] };// clone
i++;
}
if (i == fe)
i--;
}
iv = shiftFrom.get(i);
- iv = new int[]
- { iv[1], iv[0] };// reverse and clone
+ iv = new int[] { iv[1], iv[0] };// reverse and clone
// truncate initial interval
if (i == fs)
{
{ // fix apparent logic bug when fe==-1
ranges.add(iv); // add (truncated) reversed interval
iv = shiftFrom.get(i);
- iv = new int[]
- { iv[1], iv[0] }; // reverse and clone
+ iv = new int[] { iv[1], iv[0] }; // reverse and clone
}
if (i == fe)
{
int[] mp = shiftTo(mpos);
if (mp != null)
{
- return new int[]
- { mp[0], mp[0] + mp[2] * (getFromRatio() - 1) };
+ return new int[] { mp[0], mp[0] + mp[2] * (getFromRatio() - 1) };
}
return null;
}
int[] mp = shiftFrom(pos);
if (mp != null)
{
- return new int[]
- { mp[0], mp[0] + mp[2] * (getToRatio() - 1) };
+ return new int[] { mp[0], mp[0] + mp[2] * (getToRatio() - 1) };
}
return null;
}
.getToHighest()));
}
}
+
+ /**
+ * String representation - for debugging, not guaranteed not to change
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder(64);
+ sb.append("From (").append(fromRatio).append(":").append(toRatio)
+ .append(") [");
+ for (int[] shift : fromShifts)
+ {
+ sb.append(" ").append(Arrays.toString(shift));
+ }
+ sb.append(" ] To [");
+ for (int[] shift : toShifts)
+ {
+ sb.append(" ").append(Arrays.toString(shift));
+ }
+ sb.append(" ]");
+ return sb.toString();
+ }
}