- }
- return alPos;
- } finally
- {
- LOCK.readLock().unlock();
- }
- }
-
- /**
- * Adds the specified column range to the hidden columns collection
- *
- * @param start
- * start of range to add (absolute position in alignment)
- * @param end
- * end of range to add (absolute position in alignment)
- */
- public void hideColumns(int start, int end)
- {
- boolean wasAlreadyLocked = false;
- try
- {
- // check if the write lock was already locked by this thread,
- // as this method can be called internally in loops within HiddenColumns
- if (!LOCK.isWriteLockedByCurrentThread())
- {
- LOCK.writeLock().lock();
- }
- else
- {
- wasAlreadyLocked = true;
- }
-
- if (hiddenColumns == null)
- {
- hiddenColumns = new ArrayList<>();
- }
-
- /*
- * new range follows everything else; check first to avoid looping over whole hiddenColumns collection
- */
- if (hiddenColumns.isEmpty()
- || start > hiddenColumns.get(hiddenColumns.size() - 1)[1])
- {
- hiddenColumns.add(new int[] { start, end });
- }
- else
- {
- /*
- * traverse existing hidden ranges and insert / amend / append as
- * appropriate
- */
- boolean added = false;
- for (int i = 0; !added && i < hiddenColumns.size(); i++)
- {
- added = insertRangeAtRegion(i, start, end);
- } // for
- }
- if (!wasAlreadyLocked)
- {
- cursor.resetCursor(hiddenColumns);