public void updateViewportFromMouse(int mousex, int mousey,
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
{
public void updateViewportFromMouse(int mousex, int mousey,
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
{
// convert mousex and mousey to alignment units as well as
// translating to top left corner of viewport - this is an absolute position
int xAsRes = getLeftXFromCentreX(mousex, hiddenCols);
int yAsSeq = getTopYFromCentreY(mousey, hiddenSeqs);
// convert to visible positions
// convert mousex and mousey to alignment units as well as
// translating to top left corner of viewport - this is an absolute position
int xAsRes = getLeftXFromCentreX(mousex, hiddenCols);
int yAsSeq = getTopYFromCentreY(mousey, hiddenSeqs);
// convert to visible positions
// update viewport accordingly
updateViewportFromTopLeft(visXAsRes, visYAsSeq, hiddenSeqs, hiddenCols);
// update viewport accordingly
updateViewportFromTopLeft(visXAsRes, visYAsSeq, hiddenSeqs, hiddenCols);
public void adjustViewportFromMouse(int mousex, int mousey,
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
{
public void adjustViewportFromMouse(int mousex, int mousey,
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
{
// calculate translation in pixel terms:
// get mouse location in viewport coords, add translation in viewport
// coords,
// convert back to pixel coords
int vpx = Math.round((float) mousex * alwidth / width);
// calculate translation in pixel terms:
// get mouse location in viewport coords, add translation in viewport
// coords,
// convert back to pixel coords
int vpx = Math.round((float) mousex * alwidth / width);
- updateViewportFromTopLeft(visXAsRes, visYAsRes,
- hiddenSeqs,
- hiddenCols);
+ updateViewportFromTopLeft(visXAsRes, visYAsRes, hiddenSeqs, hiddenCols);
@Override
protected void updateViewportFromTopLeft(int leftx, int topy,
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
{
int visXAsRes = leftx;
int visYAsSeq = topy;
@Override
protected void updateViewportFromTopLeft(int leftx, int topy,
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
{
int visXAsRes = leftx;
int visYAsSeq = topy;
// Determine where scrollCol should be, given visXAsRes
// get viewport width in residues
int vpwidth = ranges.getViewportWidth();
// check in case we went off the edge of the alignment
// Determine where scrollCol should be, given visXAsRes
// get viewport width in residues
int vpwidth = ranges.getViewportWidth();
// check in case we went off the edge of the alignment
if (visXAsRes + vpwidth - 1 > visAlignWidth)
{
// went past the end of the alignment, adjust backwards
if (visXAsRes + vpwidth - 1 > visAlignWidth)
{
// went past the end of the alignment, adjust backwards
// if last position was before the end of the alignment, need to update
if (ranges.getEndRes() < visAlignWidth)
{
// if last position was before the end of the alignment, need to update
if (ranges.getEndRes() < visAlignWidth)
{
- visXAsRes = hiddenCols.findColumnPosition(hiddenCols
- .subtractVisibleColumns(vpwidth - 1, alwidth - 1));
+ visXAsRes = hiddenCols.absoluteToVisibleColumn(hiddenCols
+ .offsetByVisibleColumns(-(vpwidth - 1), alwidth - 1));
// went past the end of the alignment, adjust backwards
if (ranges.getEndSeq() < visAlignHeight)
{
// went past the end of the alignment, adjust backwards
if (ranges.getEndSeq() < visAlignHeight)
{
- visYAsSeq = hiddenSeqs.findIndexWithoutHiddenSeqs(hiddenSeqs
- .subtractVisibleRows(vpheight - 1, alheight - 1));
+ visYAsSeq = hiddenSeqs.findIndexWithoutHiddenSeqs(
+ hiddenSeqs.subtractVisibleRows(vpheight - 1, alheight - 1));
- int startRes = hiddenCols.adjustForHiddenColumns(ranges.getStartRes());
- int endRes = hiddenCols.adjustForHiddenColumns(ranges.getEndRes());
+ int startRes = hiddenCols.visibleToAbsoluteColumn(ranges.getStartRes());
+ int endRes = hiddenCols.visibleToAbsoluteColumn(ranges.getEndRes());
// work with absolute values of startSeq and endSeq
int startSeq = hiddenSeqs.adjustForHiddenSeqs(ranges.getStartSeq());
int endSeq = hiddenSeqs.adjustForHiddenSeqs(ranges.getEndSeq());
// work with absolute values of startSeq and endSeq
int startSeq = hiddenSeqs.adjustForHiddenSeqs(ranges.getStartSeq());
int endSeq = hiddenSeqs.adjustForHiddenSeqs(ranges.getEndSeq());
- setBoxPosition(startRes, startSeq, endRes - startRes + 1, endSeq
- - startSeq + 1);
+ setBoxPosition(startRes, startSeq, endRes - startRes + 1,
+ endSeq - startSeq + 1);
- return new AllColsCollection(0,
- ranges.getAbsoluteAlignmentWidth() - 1, al);
+ return new AllColsCollection(0, ranges.getAbsoluteAlignmentWidth() - 1,
+ al);
- return new AllRowsCollection(0,
- ranges.getAbsoluteAlignmentHeight() - 1,
+ return new AllRowsCollection(0, ranges.getAbsoluteAlignmentHeight() - 1,
@Override
protected int getLeftXFromCentreX(int mousex, HiddenColumns hidden)
{
int vpx = Math.round((float) mousex * alwidth / width);
@Override
protected int getLeftXFromCentreX(int mousex, HiddenColumns hidden)
{
int vpx = Math.round((float) mousex * alwidth / width);
public void setDragPoint(int x, int y, HiddenSequences hiddenSeqs,
HiddenColumns hiddenCols)
{
public void setDragPoint(int x, int y, HiddenSequences hiddenSeqs,
HiddenColumns hiddenCols)
{
// get alignment position of x and box (can get directly from vpranges) and
// calculate difference between the positions
// get alignment position of x and box (can get directly from vpranges) and
// calculate difference between the positions