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.getStartRes() < alwidth)
{
xAsRes = alwidth - vpwidth;
}
else
{
- xAsRes = scrollCol;
+ xAsRes = ranges.getStartRes();
}
}
// 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() < alheight)
{
yAsSeq = alheight - vpheight;
}
else
{
- yAsSeq = scrollRow;
+ yAsSeq = ranges.getStartSeq();
}
}
- // update scroll values
- scrollCol = xAsRes;
- scrollRow = yAsSeq;
+ // update viewport
+ ranges.setStartRes(xAsRes);
+ ranges.setStartSeq(yAsSeq);
}
public void setBoxPosition(HiddenSequences hiddenSeqs,
HiddenColumns hiddenCols)
{
- // work with visible values of startRes and endRes
- int startRes = ranges.getStartRes();
- int endRes = ranges.getEndRes();
-
- // work with visible values of startSeq and endSeq
- int startSeq = ranges.getStartSeq();
- int endSeq = ranges.getEndSeq();
-
- setBoxPosition(startRes, endRes, startSeq, endSeq);
+ setBoxPosition(ranges.getStartRes(), ranges.getStartSeq(),
+ ranges.getViewportWidth(), ranges.getViewportHeight());
}
@Override