/**
* Set the cursor to a position
*
- * @param first
- * absolute position of first hidden column
- * @param last
- * absolute position of last hidden column
- * @param index
- * index of last visited region
- * @param hiddenCount
- * number of hidden columns before last visited region
+ * @param hiddenCols
*/
protected void resetCursor(List<int[]> hiddenCols)
{
synchronized (this)
{
+ hiddenColumns = hiddenCols;
if ((hiddenCols != null) && (!hiddenCols.isEmpty()))
{
- hiddenColumns = hiddenCols;
firstColumn = hiddenColumns.get(0)[0];
regionIndex = 0;
hiddenSoFar = 0;
}
}
+ /**
+ * Delete the region the cursor is currently at. Avoids having to reset the
+ * cursor just because we deleted a region.
+ *
+ * @param hiddenCols
+ */
+ protected void updateForDeletedRegion(List<int[]> hiddenCols)
+ {
+
+ if ((hiddenCols != null) && (!hiddenCols.isEmpty()))
+ {
+ // if there is a region to the right of the current region,
+ // nothing changes; otherwise
+ // we deleted the last region (index=hiddenCols.size()-1)
+ // or the index was at the end of the alignment (index=hiddenCols.size())
+ if (regionIndex >= hiddenColumns.size() - 1)
+ {
+ // deleted last region, index is now end of alignment
+ regionIndex = hiddenCols.size();
+ }
+ }
+
+ hiddenColumns = hiddenCols;
+ }
+
protected void updateCursor(int index, int hiddenCount)
{
synchronized (this)