* alignment. To iterate over the collection, or over visible columns/regions,
* use an iterator obtained from one of:
*
- * - getBoundedIterator: iterate over the hidden regions, within some bounds
+ * - getBoundedIterator: iterates over the hidden regions, within some bounds,
+ * returning absolute positions
*
- * - getBoundedStartIterator: iterate over the start positions of hidden
- * regions, within some bounds
+ * - getBoundedStartIterator: iterates over the start positions of hidden
+ * regions, within some bounds, returning visible positions
*
- * - getVisContigsIterator: iterate over visible regions in a range, returning
+ * - getVisContigsIterator: iterates over visible regions in a range, returning
* absolute positions
*
- * - getVisibleBlocksIterator
- *
- * - getVisibleColsIterator: iterate over the visible *columns*
+ * - getVisibleColsIterator: iterates over the visible *columns*
*
* For performance reasons, provide bounds where possible.
*
* Methods which change the hiddenColumns collection. These methods should
* use a writeLock to prevent other threads accessing the hiddenColumns
* collection while changes are being made. They should also reset the hidden
- * columns cursor, and either update the hidden columns count, or set it to 0.
+ * columns cursor, and either update the hidden columns count, or set it to 0
+ * (so that it will later be updated when needed).
*/
/**
{
// numColumns is out of date, so recalculate
int size = 0;
- if (hiddenColumns != null)
+
+ Iterator<int[]> it = hiddenColumns.iterator();
+ while (it.hasNext())
{
- Iterator<int[]> it = hiddenColumns.iterator();
- while (it.hasNext())
- {
- int[] range = it.next();
- size += range[1] - range[0] + 1;
- }
+ int[] range = it.next();
+ size += range[1] - range[0] + 1;
}
+
numColumns = size;
}
*/
public void makeVisibleAnnotation(AlignmentAnnotation alignmentAnnotation)
{
- makeVisibleAnnotation(0, alignmentAnnotation.annotations.length,
+ if (alignmentAnnotation != null
+ && alignmentAnnotation.annotations != null)
+ {
+ makeVisibleAnnotation(0, alignmentAnnotation.annotations.length,
alignmentAnnotation);
+ }
}
/**
int startFrom = start;
int endAt = end;
- if (alignmentAnnotation.annotations != null)
+ if (alignmentAnnotation != null
+ && alignmentAnnotation.annotations != null)
{
if (hiddenColumns != null && hiddenColumns.size() > 0)
{
higestRange = (range[1] >= endPos) ? range : higestRange;
}
- if (lowestRange[0] == -1 && lowestRange[1] == -1)
+ if (lowestRange[0] == -1) // includes (lowestRange[1] == -1)
{
startPos = alignmentStartEnd[0];
}
startPos = lowestRange[1] + 1;
}
- if (higestRange[0] == -1 && higestRange[1] == -1)
+ if (higestRange[0] == -1) // includes (higestRange[1] == -1)
{
endPos = alignmentStartEnd[1];
}
{
reveal = hiddenColumns.get(regionindex);
}
- // or try the next region
- else
- {
- regionindex++;
- if (regionindex < hiddenColumns.size()
- && hiddenColumns.get(regionindex)[0] == adjres + 1)
- {
- reveal = hiddenColumns.get(regionindex);
- }
- }
}
return reveal;