+ /*
+ * a class that holds computed mouse position
+ * - column of the alignment (0...)
+ * - sequence offset (0...)
+ * - annotation row offset (0...)
+ * where annotation offset is -1 unless the alignment is shown
+ * in wrapped mode, annotations are shown, and the mouse is
+ * over an annnotation row
+ */
+ static class MousePos
+ {
+ /*
+ * alignment column position of cursor (0...)
+ */
+ final int column;
+
+ /*
+ * index in alignment of sequence under cursor,
+ * or nearest above if cursor is not over a sequence
+ */
+ final int seqIndex;
+
+ /*
+ * index in annotations array of annotation under the cursor
+ * (only possible in wrapped mode with annotations shown),
+ * or -1 if cursor is not over an annotation row
+ */
+ final int annotationIndex;
+
+ MousePos(int col, int seq, int ann)
+ {
+ column = col;
+ seqIndex = seq;
+ annotationIndex = ann;
+ }
+
+ boolean isOverAnnotation()
+ {
+ return annotationIndex != -1;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == null || !(obj instanceof MousePos))
+ {
+ return false;
+ }
+ MousePos o = (MousePos) obj;
+ boolean b = (column == o.column && seqIndex == o.seqIndex
+ && annotationIndex == o.annotationIndex);
+ // System.out.println(obj + (b ? "= " : "!= ") + this);
+ return b;
+ }
+
+ /**
+ * A simple hashCode that ensures that instances that satisfy equals() have
+ * the same hashCode
+ */
+ @Override
+ public int hashCode()
+ {
+ return column + seqIndex + annotationIndex;
+ }
+
+ /**
+ * toString method for debug output purposes only
+ */
+ @Override
+ public String toString()
+ {
+ return String.format("c%d:s%d:a%d", column, seqIndex,
+ annotationIndex);
+ }
+ }
+
+ private static final int MAX_TOOLTIP_LENGTH = 300;
+