int y = evt.getY();
y -= hgap;
- x -= seqCanvas.LABEL_WEST;
+ x = Math.max(0, x - seqCanvas.LABEL_WEST);
int cwidth = seqCanvas.getWrappedCanvasWidth(getSize().width);
if (cwidth < 1)
wrappedBlock = y / cHeight;
wrappedBlock += av.getRanges().getStartRes() / cwidth;
- res = wrappedBlock * cwidth + x / av.getCharWidth();
-
+ res = wrappedBlock * cwidth
+ + Math.min(cwidth - 1, x / av.getCharWidth());
}
else
{
int y = evt.getY();
y -= hgap;
- x -= seqCanvas.LABEL_WEST;
+ x = Math.max(0, x - seqCanvas.LABEL_WEST);
int cwidth = seqCanvas.getWrappedCanvasWidth(this.getWidth());
if (cwidth < 1)
wrappedBlock = y / cHeight;
wrappedBlock += av.getRanges().getStartRes() / cwidth;
- res = wrappedBlock * cwidth + x / av.getCharWidth();
-
+ res = wrappedBlock * cwidth
+ + Math.min(cwidth - 1, x / av.getCharWidth());
}
else
{