public void updateViewportFromMouse(int mousex, int mousey,
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
{
- int x = mousex;
- int y = mousey;
+ int xAsRes = getLeftXFromCentreX(mousex, hiddenCols);
+ int yAsSeq = getTopYFromCentreY(mousey, hiddenSeqs);
resetAlignmentDims();
- if (x < 0)
+ if (xAsRes < 0)
{
- x = 0;
+ xAsRes = 0;
}
- if (y < 0)
+ if (yAsSeq < 0)
{
- y = 0;
+ yAsSeq = 0;
}
//
// correction
// convert x to residues - this is an absolute position
- int xAsRes = Math.round((float) x * alwidth / width);
+ // int xAsRes = Math.round((float) x * alwidth / width);
// get viewport width in residues
int vpwidth = ranges.getViewportWidth();
//
// convert y to residues
- int yAsSeq = Math.round((float) y * alheight / sequencesHeight);
+ // int yAsSeq = Math.round((float) y * alheight / sequencesHeight);
// get viewport height in sequences
int vpheight = ranges.getViewportHeight();
alwidth = ranges.getAbsoluteAlignmentWidth();
alheight = ranges.getAbsoluteAlignmentHeight();
}
+
+ @Override
+ protected int getLeftXFromCentreX(int mousex, HiddenColumns hidden)
+ {
+ int vpx = Math.round((float) mousex * alwidth / width);
+ return hidden.findColumnPosition(hidden.subtractVisibleColumns(
+ ranges.getViewportWidth() / 2, vpx));
+ }
+
+ @Override
+ protected int getTopYFromCentreY(int mousey, HiddenSequences hidden)
+ {
+ int vpy = Math.round((float) mousey * alheight / sequencesHeight);
+ return hidden.findIndexWithoutHiddenSeqs(hidden.subtractVisibleRows(
+ ranges.getViewportHeight() / 2, vpy));
+ }
}