try
{
LOCK.readLock().lock();
- int[] alignmentStartEnd = new int[] { 0, width - 1 };
- int startPos = alignmentStartEnd[0];
- int endPos = alignmentStartEnd[1];
- int[] lowestRange = new int[] { -1, -1 };
- int[] higestRange = new int[] { -1, -1 };
+ int firstVisible = 0;
+ int lastVisible = width - 1;
- if (hiddenColumns.isEmpty())
- {
- return new int[] { startPos, endPos };
- }
-
- for (int[] range : hiddenColumns)
+ if (!hiddenColumns.isEmpty())
{
- lowestRange = (range[0] <= startPos) ? range : lowestRange;
- higestRange = (range[1] >= endPos) ? range : higestRange;
- }
+ // first visible col with index 0, convert to absolute index
+ firstVisible = visibleToAbsoluteColumn(0);
- if (lowestRange[0] == -1) // includes (lowestRange[1] == -1)
- {
- startPos = alignmentStartEnd[0];
- }
- else
- {
- startPos = lowestRange[1] + 1;
+ // last visible column is either immediately to left of
+ // last hidden region, or is just the last column in the alignment
+ int[] lastregion = hiddenColumns.get(hiddenColumns.size() - 1);
+ if (lastregion[1] == width - 1)
+ {
+ // last region is at very end of alignment
+ // last visible column immediately precedes it
+ lastVisible = lastregion[0] - 1;
+ }
}
+ return new int[] { firstVisible, lastVisible };
- if (higestRange[0] == -1) // includes (higestRange[1] == -1)
- {
- endPos = alignmentStartEnd[1];
- }
- else
- {
- endPos = higestRange[0] - 1;
- }
- return new int[] { startPos, endPos };
} finally
{
LOCK.readLock().unlock();
}
@Test(groups = { "Functional" })
- public void testHideBitset()
+ public void testHideColumns_BitSet()
{
HiddenColumns cs;
}
@Test(groups = "Functional")
- public void testSubtractVisibleColumns()
+ public void testOffsetByVisibleColumns()
{
HiddenColumns h = new HiddenColumns();
int result = h.offsetByVisibleColumns(-1, 10);