*/
package jalview.datamodel;
+import jalview.util.Comparison;
import jalview.util.ShiftList;
import jalview.viewmodel.annotationfilter.AnnotationFilterParameter;
import jalview.viewmodel.annotationfilter.AnnotationFilterParameter.SearchableAnnotationField;
}
IntList selected = new IntList();
+
/*
* list of hidden column [start, end] ranges; the list is maintained in
* ascending start column order
public void hideSelectedColumns()
{
- synchronized (selected) {
- for (int[] selregions:selected.getRanges())
+ synchronized (selected)
+ {
+ for (int[] selregions : selected.getRanges())
{
hideColumns(selregions[0], selregions[1]);
}
/*
* remaining case is that the new range follows everything else
*/
- hiddenColumns.addElement(new int[] { start, end });
+ hiddenColumns.addElement(new int[] { start, end });
}
/**
}
/**
+ * Locate the first and last position visible for this sequence. if seq isn't
+ * visible then return the position of the left and right of the hidden
+ * boundary region
+ *
+ * @param seq
+ * @return int[] { visible start, visible end, first seqpos, last seqpos }
+ */
+ public int[] locateVisibleBoundsOfSequence(SequenceI seq)
+ {
+ int fpos=seq.getStart(),lpos= seq.getEnd();
+ int start = 0;
+ int end = seq.getLength();
+
+ if (hiddenColumns == null || hiddenColumns.size() == 0)
+ {
+ return new int[] { seq.findIndex(fpos), seq.findIndex(lpos), fpos,
+ lpos };
+ }
+
+ // Simply walk along the sequence whilst watching for hidden column
+ // boundaries
+ List<int[]> regions = getHiddenColumns();
+ int spos = fpos, lastvispos = -1, rcount = 0, hideStart = seq
+ .getLength(), hideEnd = -1;
+ int visPrev = 0, visNext = 0, base = 0;
+ boolean foundStart = false;
+ for (int p = 0, pLen = seq.getLength(); spos <= seq.getEnd()
+ && p < pLen; p++)
+ {
+ if (!Comparison.isGap(seq.getCharAt(p)))
+ {
+ // update hidden region start/end
+ while (hideEnd < p && rcount < regions.size())
+ {
+ int[] region = regions.get(rcount++);
+ visNext += region[1] + 1 - region[0];
+ visPrev = visNext-1;
+ hideStart = region[0];
+ hideEnd = region[1];
+ }
+ if (hideEnd < p)
+ {
+ hideStart = seq.getLength();
+ }
+ // update visible boundary for sequence
+ if (p < hideStart)
+ {
+ if (!foundStart)
+ {
+ fpos = spos;
+ start = p;
+ foundStart = true;
+ }
+ lastvispos = p;
+ lpos = spos;
+ }
+ // look for next sequence position
+ spos++;
+ }
+ }
+ if (foundStart)
+ {
+ return new int[] { findColumnPosition(start),
+ findColumnPosition(lastvispos), fpos, lpos };
+ }
+ // otherwise, sequence was completely hidden
+ return new int[] { visPrev, visNext, 0, 0 };
+ }
+
+ /**
* delete any columns in alignmentAnnotation that are hidden (including
* sequence associated annotation).
*