int xAsRes = Math.round((float) x * alwidth / width);
// get viewport width in residues
- int vpwidth = ranges.getEndRes() - ranges.getStartRes() + 1;
+ int vpwidth = ranges.getViewportWidth();
if (xAsRes + vpwidth > alwidth)
{
// went past the end of the alignment, adjust backwards
// if last position was before the end of the alignment, need to update
- if ((scrollCol + vpwidth - 1) < alwidth)
+ if ((ranges.getEndRes() + vpwidth - 1) < alwidth)
{
xAsRes = alwidth - vpwidth;
}
else
{
- xAsRes = scrollCol;
+ xAsRes = ranges.getEndRes();
}
}
// get viewport height in sequences
// add 1 because height includes both endSeq and startSeq
- int vpheight = ranges.getEndSeq() - ranges.getStartSeq() + 1;
+ int vpheight = ranges.getViewportHeight();
if (yAsSeq + vpheight > alheight)
{
// went past the end of the alignment, adjust backwards
- if ((scrollRow + vpheight - 1) < alheight)
+ if ((ranges.getEndSeq() + vpheight - 1) < alheight)
{
yAsSeq = alheight - vpheight;
}
else
{
- yAsSeq = scrollRow;
+ yAsSeq = ranges.getEndSeq();
}
}
- // update scroll values
- scrollCol = xAsRes;
- scrollRow = yAsSeq;
+ // update viewport
+ ranges.setStartRes(xAsRes);
+ ranges.setStartSeq(yAsSeq);
}