+
+ @Override
+ public String getSequenceStringFromIterator(Iterator<int[]> it)
+ {
+ StringBuilder newSequence = new StringBuilder();
+ while (it.hasNext())
+ {
+ int[] block = it.next();
+ if (it.hasNext())
+ {
+ newSequence.append(getSequence(block[0], block[1] + 1));
+ }
+ else
+ {
+ newSequence.append(getSequence(block[0], block[1]));
+ }
+ }
+
+ return newSequence.toString();
+ }
+
+ @Override
+ public int firstResidueOutsideIterator(Iterator<int[]> regions)
+ {
+ int start = 0;
+
+ if (!regions.hasNext())
+ {
+ return findIndex(getStart()) - 1;
+ }
+
+ // Simply walk along the sequence whilst watching for region
+ // boundaries
+ int hideStart = getLength();
+ int hideEnd = -1;
+ boolean foundStart = false;
+
+ // step through the non-gapped positions of the sequence
+ for (int i = getStart(); i <= getEnd() && (!foundStart); i++)
+ {
+ // get alignment position of this residue in the sequence
+ int p = findIndex(i) - 1;
+
+ // update region start/end
+ while (hideEnd < p && regions.hasNext())
+ {
+ int[] region = regions.next();
+ hideStart = region[0];
+ hideEnd = region[1];
+ }
+ if (hideEnd < p)
+ {
+ hideStart = getLength();
+ }
+ // update boundary for sequence
+ if (p < hideStart)
+ {
+ start = p;
+ foundStart = true;
+ }
+ }
+
+ if (foundStart)
+ {
+ return start;
+ }
+ // otherwise, sequence was completely hidden
+ return 0;
+ }
+
+ private int[] argb;
+
+ @Override
+ public int getColor(int i)
+ {
+ return argb == null ? 0 : argb[i];
+ }
+
+ @Override
+ public int setColor(int i, int rgb)
+ {
+ if (argb == null)
+ {
+ argb = new int[this.sequence.length];
+ }
+ return (argb[i] = rgb);
+ }
+
+ @Override
+ public void resetColors()
+ {
+ argb = null;
+ }
+
+ /**
+ * @author Bob Hanson 2019.07.30
+ *
+ * allows passing the result ArrayList as a parameter to avoid
+ * unnecessary construction
+ * @return result (JavaScript) or new ArrayList (Java -- see FeatureRender)
+ *
+ */
+ @Override
+ public List<SequenceFeature> findFeatures(int column, String type,
+ List<SequenceFeature> result)
+ {
+ return getFeatures().findFeatures(findPosition(column - 1), type,
+ result);
+ }
+
+ /**
+ * allows early intervention for renderer if this returns false
+ */
+ @Override
+ public boolean hasFeatures(String type)
+ {
+ return getFeatures().hasFeatures(type);
+ }
+