public class HiddenColumns
{
private static final ReentrantReadWriteLock LOCK = new ReentrantReadWriteLock();
-
+
/*
* list of hidden column [start, end] ranges; the list is maintained in
* ascending start column order
}
}
return size;
- }
- finally
+ } finally
{
LOCK.readLock().unlock();
}
{
LOCK.readLock().lock();
- int distance = visibleDistance;
+ int distance = visibleDistance;
- // in case startColumn is in a hidden region, move it to the left
- int start = adjustForHiddenColumns(findColumnPosition(startColumn));
+ // in case startColumn is in a hidden region, move it to the left
+ int start = adjustForHiddenColumns(findColumnPosition(startColumn));
- // get index of hidden region to left of start
- int index = getHiddenIndexLeft(start);
- if (index == -1)
- {
- // no hidden regions to left of startColumn
- return start - distance;
- }
+ // get index of hidden region to left of start
+ int index = getHiddenIndexLeft(start);
+ if (index == -1)
+ {
+ // no hidden regions to left of startColumn
+ return start - distance;
+ }
- // walk backwards through the alignment subtracting the counts of visible
- // columns from distance
- int[] region;
- int gap = 0;
- int nextstart = start;
+ // walk backwards through the alignment subtracting the counts of visible
+ // columns from distance
+ int[] region;
+ int gap = 0;
+ int nextstart = start;
- while ((index > -1) && (distance - gap > 0))
- {
- // subtract the gap to right of region from distance
- distance -= gap;
- start = nextstart;
+ while ((index > -1) && (distance - gap > 0))
+ {
+ // subtract the gap to right of region from distance
+ distance -= gap;
+ start = nextstart;
- // calculate the next gap
- region = hiddenColumns.get(index);
- gap = start - region[1];
+ // calculate the next gap
+ region = hiddenColumns.get(index);
+ gap = start - region[1];
- // set start to just to left of current region
- nextstart = region[0] - 1;
- index--;
- }
+ // set start to just to left of current region
+ nextstart = region[0] - 1;
+ index--;
+ }
- if (distance - gap > 0)
- {
- // fell out of loop because there are no more hidden regions
- distance -= gap;
- return nextstart - distance;
- }
- return start - distance;
+ if (distance - gap > 0)
+ {
+ // fell out of loop because there are no more hidden regions
+ distance -= gap;
+ return nextstart - distance;
+ }
+ return start - distance;
} finally
{
LOCK.readLock().unlock();
}
return positions;
- }
- finally
+ } finally
{
LOCK.readLock().unlock();
}
{
LOCK.readLock().lock();
- if (hiddenColumns != null)
- {
- int index = hiddenColumns.size() - 1;
- do
+ if (hiddenColumns != null)
{
- int[] region = hiddenColumns.get(index);
- if (alPos > region[1])
+ int index = hiddenColumns.size() - 1;
+ do
{
- return region[1];
- }
+ int[] region = hiddenColumns.get(index);
+ if (alPos > region[1])
+ {
+ return region[1];
+ }
- index--;
- } while (index > -1);
- }
+ index--;
+ } while (index > -1);
+ }
- return alPos;
+ return alPos;
} finally
{
LOCK.readLock().unlock();
{
LOCK.readLock().lock();
- if (hiddenColumns != null)
- {
- int index = hiddenColumns.size() - 1;
- do
+ if (hiddenColumns != null)
{
- int[] region = hiddenColumns.get(index);
- if (pos > region[1])
+ int index = hiddenColumns.size() - 1;
+ do
{
- return index;
- }
+ int[] region = hiddenColumns.get(index);
+ if (pos > region[1])
+ {
+ return index;
+ }
- index--;
- } while (index > -1);
- }
+ index--;
+ } while (index > -1);
+ }
- return -1;
+ return -1;
} finally
{
LOCK.readLock().unlock();
}
return;
}
- }
+ }
- /*
- * remaining case is that the new range follows everything else
- */
+ /*
+ * remaining case is that the new range follows everything else
+ */
hiddenColumns.add(new int[] { start, end });
} finally
{
{
LOCK.readLock().lock();
- if (hiddenColumns != null)
- {
- for (int[] region : hiddenColumns)
+ if (hiddenColumns != null)
{
- if (column >= region[0] && column <= region[1])
+ for (int[] region : hiddenColumns)
{
- return false;
+ if (column >= region[0] && column <= region[1])
+ {
+ return false;
+ }
}
}
- }
- return true;
+ return true;
} finally
{
LOCK.readLock().unlock();
return copy;
}
-
+
/**
* Returns a copy of the vector of hidden regions, as an ArrayList. Before
* using this method please consider if you really need access to the hidden
}
}
}
- }
- finally
+ } finally
{
LOCK.writeLock().unlock();
}
{
return new int[] { start, end - 1 };
}
- }
- finally
+ } finally
{
LOCK.readLock().unlock();
}
}
return selections;
- }
- finally
+ } finally
{
LOCK.readLock().unlock();
}
}
// otherwise, sequence was completely hidden
return new int[] { visPrev, visNext, 0, 0, firstP, lastP };
- }
- finally
+ } finally
{
LOCK.readLock().unlock();
}
{
alignmentAnnotation.restrict(start, end);
}
- }
- finally
+ } finally
{
LOCK.readLock().unlock();
}
}
hiddenColumns = null;
- }
- finally
+ } finally
{
LOCK.writeLock().unlock();
}
{
hiddenColumns = null;
}
- }
- finally
+ } finally
{
LOCK.writeLock().unlock();
}
hiddenColumns = null;
}
}
- }
- finally
+ } finally
{
LOCK.writeLock().unlock();
}
}
else
{
- al.getSequenceAt(s).setSequence(
- sq.substring(0, spos + offset) + sb.toString()
- + sq.substring(spos + offset));
+ al.getSequenceAt(s).setSequence(sq.substring(0, spos + offset)
+ + sb.toString() + sq.substring(spos + offset));
}
}
}
{
// pad the final region with gaps.
StringBuffer sb = new StringBuffer();
- for (int s = 0, ns = profileseq.getLength() - spos - offset; s < ns; s++)
+ for (int s = 0, ns = profileseq.getLength() - spos
+ - offset; s < ns; s++)
{
sb.append(gc);
}
}
}
return hashCode;
- }
- finally
+ } finally
{
LOCK.readLock().unlock();
}
{
inserts.set(range[0], range[1] + 1);
}
- }
- finally
+ } finally
{
LOCK.readLock().unlock();
}