* list of hidden column [start, end] ranges; the list is maintained in
* ascending start column order
*/
- private List<int[]> hiddenColumns;
+ private List<int[]> hiddenColumns = new ArrayList<>();
/**
* Constructor
LOCK.writeLock().lock();
if (copy != null)
{
- hiddenColumns = new ArrayList<>();
numColumns = 0;
Iterator<int[]> it = copy.getBoundedIterator(start, end);
while (it.hasNext())
int previndex = 0;
int prevHiddenCount = 0;
int regionindex = 0;
- if (hiddenColumns == null)
- {
- hiddenColumns = new ArrayList<>();
- }
- else
+ if (!hiddenColumns.isEmpty())
{
// set up cursor reset values
HiddenCursorPosition cursorPos = cursor.findRegionForColumn(start);
try
{
LOCK.writeLock().lock();
- if (hiddenColumns != null)
+
+ Iterator<int[]> it = hiddenColumns.iterator();
+ while (it.hasNext())
{
- Iterator<int[]> it = hiddenColumns.iterator();
- while (it.hasNext())
+ int[] region = it.next();
+ for (int j = region[0]; j < region[1] + 1; j++)
{
- int[] region = it.next();
- for (int j = region[0]; j < region[1] + 1; j++)
- {
- sel.addElement(j);
- }
+ sel.addElement(j);
}
- hiddenColumns = null;
- cursor.resetCursor(hiddenColumns);
- numColumns = 0;
}
+ hiddenColumns.clear();
+ cursor.resetCursor(hiddenColumns);
+ numColumns = 0;
+
} finally
{
LOCK.writeLock().unlock();
{
LOCK.writeLock().lock();
- if (hiddenColumns != null)
+ if (!hiddenColumns.isEmpty())
{
int regionIndex = cursor.findRegionForColumn(start)
.getRegionIndex();
if (hiddenColumns.isEmpty())
{
- hiddenColumns = null;
+ hiddenColumns.clear();
numColumns = 0;
}
else
BitSet hidden = new BitSet();
markHiddenRegions(hidden);
hidden.andNot(gaps);
- hiddenColumns = null;
+ hiddenColumns.clear();
this.hideColumns(hidden);
// for each sequence in the alignment, except the profile sequence,
{
LOCK.readLock().lock();
StringBuilder regionBuilder = new StringBuilder();
- if (hiddenColumns != null)
+
+ Iterator<int[]> it = hiddenColumns.iterator();
+ while (it.hasNext())
{
- Iterator<int[]> it = hiddenColumns.iterator();
- while (it.hasNext())
+ int[] range = it.next();
+ regionBuilder.append(delimiter).append(range[0]).append(between)
+ .append(range[1]);
+ if (!it.hasNext())
{
- int[] range = it.next();
- regionBuilder.append(delimiter).append(range[0]).append(between)
- .append(range[1]);
- if (!it.hasNext())
- {
- regionBuilder.deleteCharAt(0);
- }
+ regionBuilder.deleteCharAt(0);
}
}
+
return regionBuilder.toString();
} finally
{
{
LOCK.readLock().lock();
- if (numColumns == 0 && hiddenColumns != null)
+ if (numColumns == 0)
{
// numColumns is out of date, so recalculate
int size = 0;
/*
* check hidden columns are either both null, or match
*/
- if (this.hiddenColumns == null)
- {
- return (that.hiddenColumns == null);
- }
- if (that.hiddenColumns == null
- || that.hiddenColumns.size() != this.hiddenColumns.size())
+
+ if (that.hiddenColumns.size() != this.hiddenColumns.size())
{
return false;
}
LOCK.readLock().lock();
int result = column;
- if (hiddenColumns != null)
+ if (!hiddenColumns.isEmpty())
{
result += cursor.findRegionForVisColumn(column).getHiddenSoFar();
}
LOCK.readLock().lock();
int result = hiddenColumn;
- if (hiddenColumns != null)
+ if (!hiddenColumns.isEmpty())
{
HiddenCursorPosition cursorPos = cursor
.findRegionForColumn(hiddenColumn);
try
{
LOCK.readLock().lock();
- if (hiddenColumns != null)
+ if (!hiddenColumns.isEmpty())
{
int index = cursor.findRegionForColumn(alPos).getRegionIndex();
if (index < hiddenColumns.size())
{
LOCK.readLock().lock();
- if (hiddenColumns != null)
+ if (!hiddenColumns.isEmpty())
{
int index = cursor.findRegionForColumn(alPos).getRegionIndex();
LOCK.readLock().lock();
int iSize = seqs.length;
String[] selections = new String[iSize];
- if (hiddenColumns != null && hiddenColumns.size() > 0)
+ if (!hiddenColumns.isEmpty())
{
for (int i = 0; i < iSize; i++)
{
LOCK.readLock().lock();
int start = 0;
- if (hiddenColumns == null || hiddenColumns.size() == 0)
+ if (hiddenColumns.isEmpty())
{
return seq.findIndex(seq.getStart()) - 1;
}
if (alignmentAnnotation != null
&& alignmentAnnotation.annotations != null)
{
- if (hiddenColumns != null && hiddenColumns.size() > 0)
+ if (!hiddenColumns.isEmpty())
{
removeHiddenAnnotation(startFrom, endAt, alignmentAnnotation);
}
// we don't use getSize()>0 here because it has to iterate over
// the full hiddenColumns collection and so will be much slower
- return hiddenColumns != null && hiddenColumns.size() > 0;
+ return (!hiddenColumns.isEmpty());
} finally
{
LOCK.readLock().unlock();
try
{
LOCK.readLock().lock();
- return hiddenColumns != null && hiddenColumns.size() > 1;
+ return !hiddenColumns.isEmpty() && hiddenColumns.size() > 1;
} finally
{
LOCK.readLock().unlock();
try
{
LOCK.readLock().lock();
- if (hiddenColumns == null)
- {
- return;
- }
+
Iterator<int[]> it = hiddenColumns.iterator();
while (it.hasNext())
{
int[] lowestRange = new int[] { -1, -1 };
int[] higestRange = new int[] { -1, -1 };
- if (hiddenColumns == null)
+ if (hiddenColumns.isEmpty())
{
return new int[] { startPos, endPos };
}
int[] reveal = null;
- if (hiddenColumns != null)
+ if (!hiddenColumns.isEmpty())
{
// look for a region ending just before adjres
int regionindex = cursor.findRegionForColumn(adjres - 1)
*/
package jalview.datamodel;
+import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
// absolute position of first hidden column
private int firstColumn;
- private List<int[]> hiddenColumns;
+ private List<int[]> hiddenColumns = new ArrayList<>();
// AtomicReference to hold the current region index and hidden column count
// Could be done with synchronisation but benchmarking shows this way is 2x
int hiddencount)
{
hiddenColumns = hiddenCols;
- if ((hiddenCols != null) && (!hiddenCols.isEmpty()))
+ if (!hiddenCols.isEmpty())
{
firstColumn = hiddenColumns.get(0)[0];
HiddenCursorPosition oldpos = cursorPos.get();
protected void updateForDeletedRegion(List<int[]> hiddenCols)
{
- if ((hiddenCols != null) && (!hiddenCols.isEmpty()))
+ if (!hiddenCols.isEmpty())
{
// if there is a region to the right of the current region,
// nothing changes; otherwise
*/
protected HiddenCursorPosition findRegionForColumn(int column)
{
- if (hiddenColumns == null)
+ if (hiddenColumns.isEmpty())
{
return null;
}
*/
protected HiddenCursorPosition findRegionForVisColumn(int column)
{
- if (hiddenColumns == null)
+ if (hiddenColumns.isEmpty())
{
return null;
}