+ this.sequenceMapping = null;
+ }
+ }
+ }
+ validateRangeAndDisplay(); // construct hashcodes, etc.
+ }
+
+ /**
+ * 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)