+ /**
+ * Find the visible row which is a given visible number of rows above another
+ * visible row. i.e. for a startRow x, the row which is distance 1 away will
+ * be row x-1.
+ *
+ * @param visibleDistance
+ * the number of visible rows to offset by
+ * @param startRow
+ * the row to start from
+ * @return the position of the row in the visible alignment
+ */
+ public int subtractVisibleRows(int visibleDistance, int startRow)
+ {
+ // walk upwards through the alignment
+ // count all the non-null sequences until we have visibleDistance counted
+ // then return the next visible sequence
+ if (hiddenSequences == null)
+ {
+ return startRow - visibleDistance;
+ }
+
+ int index = Math.min(startRow, hiddenSequences.length - 1);
+ int count = 0;
+ while ((index > -1) && (count < visibleDistance))
+ {
+ if (hiddenSequences[index] == null)
+ {
+ // count visible sequences
+ count++;
+ }
+ index--;
+ }
+ return index;
+ }
+
+ /**
+ * Convert alignment index from visible alignment to absolute alignment
+ *
+ * @param alignmentIndex
+ * @return
+ */