protected int alheight;
+ protected float widthRatio;
+
+ protected float heightRatio;
+
/**
* Create an OverviewDimensions object
*
// calculate translation in pixel terms:
// get mouse location in viewport coords, add translation in viewport
// coords, and update viewport as usual
- int vpx = Math.round((float) mousex * alwidth / width);
- int vpy = Math.round((float) mousey * alheight / sequencesHeight);
+ int vpx = Math.round(mousex * widthRatio);
+ int vpy = Math.round(mousey * heightRatio);
updateViewportFromTopLeft(vpx + xdiff, vpy + ydiff, hiddenSeqs,
hiddenCols);
{
alwidth = ranges.getVisibleAlignmentWidth();
alheight = ranges.getVisibleAlignmentHeight();
+
+ widthRatio = (float) alwidth / width;
+ heightRatio = (float) alheight / sequencesHeight;
}
@Override
protected int getLeftXFromCentreX(int mousex, HiddenColumns hidden)
{
- int vpx = Math.round((float) mousex * alwidth / width);
+ int vpx = Math.round(mousex * widthRatio);
return vpx - ranges.getViewportWidth() / 2;
}
@Override
protected int getTopYFromCentreY(int mousey, HiddenSequences hidden)
{
- int vpy = Math.round((float) mousey * alheight / sequencesHeight);
+ int vpy = Math.round(mousey * heightRatio);
return vpy - ranges.getViewportHeight() / 2;
}
{
// get alignment position of x and box (can get directly from vpranges) and
// calculate difference between the positions
- int vpx = Math.round((float) x * alwidth / width);
- int vpy = Math.round((float) y * alheight / sequencesHeight);
+ int vpx = Math.round(x * widthRatio);
+ int vpy = Math.round(y * heightRatio);
xdiff = ranges.getStartRes() - vpx;
ydiff = ranges.getStartSeq() - vpy;
// get mouse location in viewport coords, add translation in viewport
// coords,
// convert back to pixel coords
- int vpx = Math.round((float) mousex * alwidth / width);
+ int vpx = Math.round(mousex * widthRatio);
int visXAsRes = hiddenCols.findColumnPosition(vpx) + xdiff;
- int vpy = Math.round((float) mousey * alheight / sequencesHeight);
+ int vpy = Math.round(mousey * heightRatio);
int visYAsRes = hiddenSeqs.findIndexWithoutHiddenSeqs(vpy) + ydiff;
// update viewport accordingly
{
alwidth = ranges.getAbsoluteAlignmentWidth();
alheight = ranges.getAbsoluteAlignmentHeight();
+
+ widthRatio = (float) alwidth / width;
+ heightRatio = (float) alheight / sequencesHeight;
}
@Override
protected int getLeftXFromCentreX(int mousex, HiddenColumns hidden)
{
- int vpx = Math.round((float) mousex * alwidth / width);
+ int vpx = Math.round(mousex * widthRatio);
return hidden.subtractVisibleColumns(ranges.getViewportWidth() / 2,
vpx);
}
@Override
protected int getTopYFromCentreY(int mousey, HiddenSequences hidden)
{
- int vpy = Math.round((float) mousey * alheight / sequencesHeight);
+ int vpy = Math.round(mousey * heightRatio);
return hidden.subtractVisibleRows(ranges.getViewportHeight() / 2, vpy);
}
{
// get alignment position of x and box (can get directly from vpranges) and
// calculate difference between the positions
- int vpx = Math.round((float) x * alwidth / width);
- int vpy = Math.round((float) y * alheight / sequencesHeight);
+ int vpx = Math.round(x * widthRatio);
+ int vpy = Math.round(y * heightRatio);
xdiff = ranges.getStartRes() - hiddenCols.findColumnPosition(vpx);
ydiff = ranges.getStartSeq()