+ * clip the annotation to the columns given by startRes and endRes (inclusive)
+ * and prune any existing sequenceMapping to just those columns.
+ *
+ * @param startRes
+ * @param endRes
+ */
+ public void restrict(int startRes, int endRes)
+ {
+ if (annotations == null)
+ {
+ // non-positional
+ return;
+ }
+ if (startRes < 0)
+ startRes = 0;
+ if (startRes >= annotations.length)
+ startRes = annotations.length - 1;
+ if (endRes >= annotations.length)
+ endRes = annotations.length - 1;
+ if (annotations == null)
+ return;
+ Annotation[] temp = new Annotation[endRes - startRes + 1];
+ if (startRes < annotations.length)
+ {
+ System.arraycopy(annotations, startRes, temp, 0, endRes - startRes
+ + 1);
+ }
+ if (sequenceRef != null)
+ {
+ // Clip the mapping, if it exists.
+ int spos = sequenceRef.findPosition(startRes);
+ int epos = sequenceRef.findPosition(endRes);
+ if (sequenceMapping != null)
+ {
+ Hashtable newmapping = new Hashtable();
+ Enumeration e = sequenceMapping.keys();
+ while (e.hasMoreElements())
+ {
+ Integer pos = (Integer) e.nextElement();
+ if (pos.intValue() >= spos && pos.intValue() <= epos)
+ {
+ newmapping.put(pos, sequenceMapping.get(pos));
+ }
+ }
+ sequenceMapping.clear();
+ sequenceMapping = newmapping;
+ }
+ }
+ annotations = temp;
+ }
+
+ /**
+ * set the annotation row to be at least length Annotations
+ *
+ * @param length
+ * minimum number of columns required in the annotation row
+ * @return false if the annotation row is greater than length
+ */
+ public boolean padAnnotation(int length)
+ {
+ if (annotations == null)
+ {
+ return true; // annotation row is correct - null == not visible and
+ // undefined length
+ }
+ if (annotations.length < length)
+ {
+ Annotation[] na = new Annotation[length];
+ System.arraycopy(annotations, 0, na, 0, annotations.length);
+ annotations = na;
+ return true;
+ }
+ return annotations.length > length;
+
+ }
+
+ /**