+ * Hide columns corresponding to the marked bits, within the range
+ * [start,end]. Entries in tohide which are outside [start,end] are ignored.
+ *
+ * @param tohide
+ * columns mapped to bits starting from zero
+ * @param start
+ * start of range to hide columns within
+ * @param end
+ * end of range to hide columns within
+ */
+ public void hideColumns(BitSet tohide, int start, int end)
+ {
+ clearHiddenColumnsInRange(start, end);
+
+ // make sure only bits between start and end are set
+ tohide.clear(0, start - 1);
+ tohide.clear(Math.min(end + 1, tohide.length() - 1),
+ tohide.length() - 1);
+
+ hideColumns(tohide);
+ }
+
+ /**
+ * Make all columns in the range [start,end] visible
+ *
+ * @param start
+ * start of range to show columns
+ * @param end
+ * end of range to show columns
+ */
+ private void clearHiddenColumnsInRange(int start, int end)
+ {
+ try
+ {
+ LOCK.writeLock().lock();
+
+ HiddenCursorPosition pos = cursor.findRegionForColumn(start);
+ int index = pos.getRegionIndex();
+ int startindex = index; // first index in hiddenColumns to remove
+
+ if (index != -1 && index != hiddenColumns.size())
+ {
+ // regionIndex is the region which either contains start
+ // or lies to the right of start
+ int[] region = hiddenColumns.get(index);
+ if (region[0] < start && region[1] >= start)
+ {
+ // region contains start, truncate so that it ends just before start
+ region[1] = start - 1;
+ startindex++;
+ }
+ }
+
+ pos = cursor.findRegionForColumn(end);
+ index = pos.getRegionIndex();
+ int endindex = index - 1; // last index in hiddenColumns to remove
+
+ if (index != -1 && index != hiddenColumns.size())
+ {
+ // regionIndex is the region which either contains end
+ // or lies to the right of end
+ int[] region = hiddenColumns.get(index);
+ if (region[0] <= end && region[1] > end)
+ {
+ // region contains end, truncate so that it starts just after end
+ region[0] = end + 1;
+ }
+ }
+
+ hiddenColumns.subList(startindex, endindex + 1).clear();
+ cursor.resetCursor(hiddenColumns);
+ numColumns = 0;
+ } finally
+ {
+ LOCK.writeLock().unlock();
+ }
+ }
+
+ /**