{
resetAlignmentDims();
- int x = mousex;
- int y = mousey;
+ int xAsRes = getLeftXFromCentreX(mousex, hiddenCols);
+ int yAsSeq = getTopYFromCentreY(mousey, hiddenSeqs);
- 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();
// 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() + vpwidth - 1) < alwidth)
+ if (ranges.getStartRes() < alwidth)
{
xAsRes = alwidth - vpwidth;
}
// Convert y value to sequence position
//
- // convert y to residues
- 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.getViewportHeight();
if (yAsSeq + vpheight > alheight)
{
// went past the end of the alignment, adjust backwards
- if ((ranges.getEndSeq() + vpheight - 1) < alheight)
+ if (ranges.getEndSeq() < alheight)
{
yAsSeq = alheight - vpheight;
}
alwidth = ranges.getVisibleAlignmentWidth();
alheight = ranges.getVisibleAlignmentHeight();
}
+
+ @Override
+ protected int getLeftXFromCentreX(int mousex, HiddenColumns hidden)
+ {
+ int vpx = Math.round((float) mousex * alwidth / width);
+ return vpx - ranges.getViewportWidth() / 2;
+ }
+
+ @Override
+ protected int getTopYFromCentreY(int mousey, HiddenSequences hidden)
+ {
+ int vpy = Math.round((float) mousey * alheight / sequencesHeight);
+ return vpy - ranges.getViewportHeight() / 2;
+ }
}