y = 0;
}
+ if (ranges.isWrappedMode())
+ {
+ y = 0; // sorry, no vertical scroll when wrapped
+ }
+
//
// Convert x value to residue position
//
int xAsRes = Math.round((float) x * alwidth / width);
// get viewport width in residues
- int vpwidth = ranges.getEndRes() - ranges.getStartRes() + 1;
+ int vpwidth = ranges.getViewportWidth();
// get where x should be when accounting for hidden cols
// if x is in a hidden col region, shift to left - but we still need
// 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) < visAlignWidth)
+ if (ranges.getEndRes() < visAlignWidth)
{
visXAsRes = hiddenCols.findColumnPosition(hiddenCols
.subtractVisibleColumns(vpwidth - 1, alwidth - 1));
}
else
{
- visXAsRes = scrollCol;
+ visXAsRes = ranges.getStartRes();
}
}
int yAsSeq = Math.round((float) y * alheight / sequencesHeight);
// 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();
// get where y should be when accounting for hidden rows
// if y is in a hidden row region, shift up - but we still need absolute
// so convert back after getting visible region position
yAsSeq = hiddenSeqs.adjustForHiddenSeqs(hiddenSeqs
.findIndexWithoutHiddenSeqs(yAsSeq));
+ yAsSeq = Math.max(yAsSeq, 0); // -1 if before first visible sequence
// check in case we went off the edge of the alignment
int visAlignHeight = hiddenSeqs.findIndexWithoutHiddenSeqs(alheight);
int visYAsSeq = hiddenSeqs.findIndexWithoutHiddenSeqs(yAsSeq);
+ visYAsSeq = Math.max(visYAsSeq, 0); // -1 if before first visible sequence
if (visYAsSeq + vpheight - 1 > visAlignHeight)
{
// went past the end of the alignment, adjust backwards
- if ((scrollRow + vpheight - 1) < visAlignHeight)
+ if (ranges.getEndSeq() < visAlignHeight)
{
visYAsSeq = hiddenSeqs.findIndexWithoutHiddenSeqs(hiddenSeqs
.subtractVisibleRows(vpheight - 1, alheight - 1));
}
else
{
- visYAsSeq = scrollRow;
+ visYAsSeq = ranges.getStartSeq();
}
}
- // update scroll values
- scrollCol = visXAsRes;
- scrollRow = visYAsSeq;
-
+ // update viewport
+ ranges.setStartRes(visXAsRes);
+ ranges.setStartSeq(visYAsSeq);
}
/**
HiddenColumns hiddenCols)
{
// work with absolute values of startRes and endRes
- int startRes = hiddenCols
- .adjustForHiddenColumns(ranges.getStartRes());
+ int startRes = hiddenCols.adjustForHiddenColumns(ranges.getStartRes());
int endRes = hiddenCols.adjustForHiddenColumns(ranges.getEndRes());
// work with absolute values of startSeq and endSeq
int startSeq = hiddenSeqs.adjustForHiddenSeqs(ranges.getStartSeq());
int endSeq = hiddenSeqs.adjustForHiddenSeqs(ranges.getEndSeq());
- setBoxPosition(startRes, endRes, startSeq, endSeq);
+ setBoxPosition(startRes, startSeq, endRes - startRes + 1, endSeq
+ - startSeq + 1);
}
@Override