+ * Computes the column and sequence row (and possibly annotation row when in
+ * wrapped mode) for the given mouse position
+ * <p>
+ * Mouse position is not set if in wrapped mode with the cursor either between
+ * sequences, or over the left or right vertical scale.
+ *
+ * @param evt
+ * @return
+ */
+ MousePos findMousePosition(MouseEvent evt)
+ {
+ int col = findColumn(evt);
+ int seqIndex = -1;
+ int annIndex = -1;
+ int y = evt.getY();
+
+ int charHeight = av.getCharHeight();
+ int alignmentHeight = av.getAlignment().getHeight();
+ if (av.getWrapAlignment())
+ {
+ seqCanvas.calculateWrappedGeometry(seqCanvas.getWidth(),
+ seqCanvas.getHeight());
+
+ /*
+ * yPos modulo height of repeating width
+ */
+ int yOffsetPx = y % seqCanvas.wrappedRepeatHeightPx;
+
+ /*
+ * height of sequences plus space / scale above,
+ * plus gap between sequences and annotations
+ */
+ int alignmentHeightPixels = seqCanvas.wrappedSpaceAboveAlignment
+ + alignmentHeight * charHeight
+ + SeqCanvas.SEQS_ANNOTATION_GAP;
+ if (yOffsetPx >= alignmentHeightPixels)
+ {
+ /*
+ * mouse is over annotations; find annotation index, also set
+ * last sequence above (for backwards compatible behaviour)
+ */
+ AlignmentAnnotation[] anns = av.getAlignment()
+ .getAlignmentAnnotation();
+ int rowOffsetPx = yOffsetPx - alignmentHeightPixels;
+ annIndex = AnnotationPanel.getRowIndex(rowOffsetPx, anns);
+ seqIndex = alignmentHeight - 1;
+ }
+ else
+ {
+ /*
+ * mouse is over sequence (or the space above sequences)
+ */
+ yOffsetPx -= seqCanvas.wrappedSpaceAboveAlignment;
+ if (yOffsetPx >= 0)
+ {
+ seqIndex = Math.min(yOffsetPx / charHeight, alignmentHeight - 1);
+ }
+ }
+ }
+ else
+ {
+ ViewportRanges ranges = av.getRanges();
+ seqIndex = Math.min((y / charHeight) + ranges.getStartSeq(),
+ alignmentHeight - 1);
+ seqIndex = Math.min(seqIndex, ranges.getEndSeq());
+ }
+
+ return new MousePos(col, seqIndex, annIndex);
+ }
+ /**