int wrappedBlock = -1;
/**
- * Computes the column and sequence row (or possibly annotation row when in
+ * Computes the column and sequence row (and possibly annotation row when in
* wrapped mode) for the given mouse position
*
* @param evt
MousePos findMousePosition(MouseEvent evt)
{
int col = findColumn(evt);
- int seq = -1;
+ int seqIndex = -1;
int annIndex = -1;
int y = evt.getY();
final int alignmentHeightPixels = alignmentHeight * charHeight + hgap;
final int annotationHeight = seqCanvas.getAnnotationHeight();
- final int cHeight = alignmentHeightPixels + annotationHeight;
+ final int cHeight = alignmentHeightPixels + annotationHeight
+ + SeqCanvas.SEQS_ANNOTATION_GAP;
int yOffsetPx = y % cHeight; // yPos below repeating width(s)
- if (yOffsetPx > alignmentHeightPixels)
+ if (yOffsetPx >= alignmentHeightPixels
+ + SeqCanvas.SEQS_ANNOTATION_GAP)
{
/*
- * mouse is over annotations
+ * mouse is over annotations; find annotation index, also
+ * last sequence above (for backwards compatible behaviour)
*/
AlignmentAnnotation[] anns = av.getAlignment()
.getAlignmentAnnotation();
- int rowOffsetPx = yOffsetPx - alignmentHeightPixels;
+ int rowOffsetPx = yOffsetPx - alignmentHeightPixels
+ - SeqCanvas.SEQS_ANNOTATION_GAP;
annIndex = AnnotationPanel.getRowIndex(rowOffsetPx, anns);
- // also last sequence in alignment (for backwards compatible behaviour)
- seq = alignmentHeight - 1;
+ seqIndex = alignmentHeight - 1;
}
else
{
* mouse is over sequence (or the space above sequences)
*/
yOffsetPx -= hgap;
- if (yOffsetPx > 0)
+ if (yOffsetPx >= 0)
{
- seq = Math.min(yOffsetPx / charHeight, alignmentHeight - 1);
+ seqIndex = Math.min(yOffsetPx / charHeight, alignmentHeight - 1);
}
}
}
else
{
- seq = Math.min((y / charHeight) + av.getRanges().getStartSeq(),
+ seqIndex = Math.min((y / charHeight) + av.getRanges().getStartSeq(),
alignmentHeight - 1);
}
- int seqIndex = seq;
return new MousePos(col, seqIndex, annIndex);
}