import jalview.util.ShiftList;
import java.util.ArrayList;
+import java.util.BitSet;
import java.util.Collections;
import java.util.List;
import java.util.Vector;
*
* @return empty list or List of hidden column intervals
*/
- public List<int[]> getListOfCols()
+ public List<int[]> getHiddenRegions()
{
return hiddenColumns == null ? Collections.<int[]> emptyList()
: hiddenColumns;
}
+ /**
+ * Find the number of hidden columns
+ *
+ * @return number of hidden columns
+ */
+ public int getSize()
+ {
+ int size = 0;
+ if (hasHidden())
+ {
+ for (int[] range : hiddenColumns)
+ {
+ size += range[1] - range[0] + 1;
+ }
+ }
+ return size;
+ }
+
+ /**
+ * Answers if there are any hidden columns
+ *
+ * @return true if there are hidden columns
+ */
public boolean hasHidden()
{
return (hiddenColumns != null) && (!hiddenColumns.isEmpty());
if (hiddenColumns != null && hiddenColumns.size() > 0)
{
List<int[]> visiblecontigs = new ArrayList<int[]>();
- List<int[]> regions = getListOfCols();
+ List<int[]> regions = getHiddenRegions();
int vstart = start;
int[] region;
for (i = 0; i < iSize; i++)
{
StringBuffer visibleSeq = new StringBuffer();
- List<int[]> regions = getListOfCols();
+ List<int[]> regions = getHiddenRegions();
int blockStart = start, blockEnd = end;
int[] region;
// Simply walk along the sequence whilst watching for hidden column
// boundaries
- List<int[]> regions = getListOfCols();
+ List<int[]> regions = getHiddenRegions();
int spos = fpos, lastvispos = -1, rcount = 0, hideStart = seq
.getLength(), hideEnd = -1;
int visPrev = 0, visNext = 0, firstP = -1, lastP = -1;
// then mangle the alignmentAnnotation annotation array
Vector<Annotation[]> annels = new Vector<Annotation[]>();
Annotation[] els = null;
- List<int[]> regions = getListOfCols();
+ List<int[]> regions = getHiddenRegions();
int blockStart = start, blockEnd = end;
int[] region;
int hideStart, hideEnd, w = 0;
/**
* Returns a hashCode built from hidden column ranges
*/
- public int hashCode(int hc)
+ @Override
+ public int hashCode()
{
- int hashCode = hc;
+ int hashCode = 1;
if (hiddenColumns != null)
{
for (int[] hidden : hiddenColumns)
return hashCode;
}
+ /**
+ * Hide columns corresponding to the marked bits
+ *
+ * @param inserts
+ * - columns map to bits starting from zero
+ */
+ public void hideMarkedBits(BitSet inserts)
+ {
+ for (int firstSet = inserts.nextSetBit(0), lastSet = 0; firstSet >= 0; firstSet = inserts
+ .nextSetBit(lastSet))
+ {
+ lastSet = inserts.nextClearBit(firstSet);
+ hideColumns(firstSet, lastSet - 1);
+ }
+ }
+
+ /**
+ *
+ * @param inserts
+ * BitSet where hidden columns will be marked
+ */
+ public void markHiddenRegions(BitSet inserts)
+ {
+ if (hiddenColumns == null)
+ {
+ return;
+ }
+ for (int[] range : hiddenColumns)
+ {
+ inserts.set(range[0], range[1] + 1);
+ }
+ }
+
}