+ }
+ else
+ {
+ this.sequenceMapping = null;
+ }
+ }
+ // TODO: check if we need to do this: JAL-952
+ // if (this.isrna=annotation.isrna)
+ {
+ // _rnasecstr=new SequenceFeature[annotation._rnasecstr];
+ }
+ 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)
+ {
+ Map<Integer, Annotation> newmapping = new HashMap<Integer, Annotation>();
+ Iterator<Integer> e = sequenceMapping.keySet().iterator();
+ while (e.hasNext())
+ {
+ Integer pos = e.next();
+ 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;
+
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ @Override
+ public String toString()
+ {
+ if (annotations == null)
+ {
+ return "";
+ }
+ StringBuilder buffer = new StringBuilder(256);