+ annotationId = this.hashCode() + "";
+ }
+ /**
+ * flyweight access to positions in the alignment annotation row for RNA processing
+ * @author jimp
+ *
+ */
+ private class AnnotCharSequence implements CharSequence
+ {
+ int offset=0;
+ int max=0;
+
+ public AnnotCharSequence() {
+ this(0,annotations.length);
+ }
+ public AnnotCharSequence(int start, int end) {
+ offset=start;
+ max=end;
+ }
+ @Override
+ public CharSequence subSequence(int start, int end)
+ {
+ return new AnnotCharSequence(offset+start, offset+end);
+ }
+
+ @Override
+ public int length()
+ {
+ return max-offset;
+ }
+
+ @Override
+ public char charAt(int index)
+ {
+ String dc;
+ return ((index+offset<0) || (index+offset)>=max || annotations[index+offset]==null || (dc=annotations[index+offset].displayCharacter.trim()).length()<1)
+ ? '.' : dc.charAt(0);
+ }
+ public String toString()
+ {
+ char[] string=new char[max-offset];
+ int mx=annotations.length;
+
+ for (int i=offset;i<mx;i++)
+ {
+ String dc;
+ string[i]=(annotations[i]==null || (dc=annotations[i].displayCharacter.trim()).length()<1 )? '.' : dc.charAt(0);
+ }
+ return new String(string);
+ }
+ };
+
+ private long _lastrnaannot=-1;
+ public String getRNAStruc(){
+ if (isrna)
+ {
+ String rnastruc = new AnnotCharSequence().toString();
+ if (_lastrnaannot!=rnastruc.hashCode())
+ {
+ // ensure rna structure contacts are up to date
+ _lastrnaannot=rnastruc.hashCode();
+ _updateRnaSecStr(rnastruc);
+ }
+ return rnastruc;
+ }
+ return null;
+ }
+
+/**
+ * Creates a new AlignmentAnnotation object.
+ *
+ * @param label
+ * DOCUMENT ME!
+ * @param description
+ * DOCUMENT ME!
+ * @param annotations
+ * DOCUMENT ME!
+ * @param min
+ * DOCUMENT ME!
+ * @param max
+ * DOCUMENT ME!
+ * @param winLength
+ * DOCUMENT ME!
+ */
+ public AlignmentAnnotation(String label, String description,
+ Annotation[] annotations, float min, float max, int graphType)
+ {
+ // graphs are not editable
+ editable = graphType == 0;
+
+ this.label = label;
+ this.description = description;
+ this.annotations = annotations;
+ graph = graphType;
+ graphMin = min;
+ graphMax = max;
+ validateRangeAndDisplay();
+ }
+
+ /**
+ * checks graphMin and graphMax, secondary structure symbols, sets graphType
+ * appropriately, sets null labels to the empty string if appropriate.
+ */
+ public void validateRangeAndDisplay()
+ {
+
+ if (annotations == null)
+ {
+ visible = false; // try to prevent renderer from displaying.
+ return; // this is a non-annotation row annotation - ie a sequence score.
+ }
+
+ int graphType = graph;
+ float min = graphMin;
+ float max = graphMax;
+ boolean drawValues = true;
+
+ if (min == max)
+ {
+ min = 999999999;
+ for (int i = 0; i < annotations.length; i++)
+ {
+ if (annotations[i] == null)
+ {
+ continue;
+ }
+
+ if (drawValues && annotations[i].displayCharacter != null
+ && annotations[i].displayCharacter.length() > 1)
+ {
+ drawValues = false;
+ }
+
+ if (annotations[i].value > max)
+ {
+ max = annotations[i].value;
+ }
+
+ if (annotations[i].value < min)
+ {
+ min = annotations[i].value;
+ }
+ }
+ // ensure zero is origin for min/max ranges on only one side of zero
+ if (min > 0)
+ {
+ min = 0;
+ }
+ else
+ {
+ if (max < 0)