+ public AnnotationRenderer()
+ {
+ this(false);
+ }
+
+ /**
+ * Create a new annotation Renderer
+ *
+ * @param debugRedraw
+ * flag indicating if timing and redraw parameter info should be
+ * output
+ */
+ public AnnotationRenderer(boolean debugRedraw)
+ {
+ this.debugRedraw = debugRedraw;
+ }
+
+ /**
+ * Remove any references and resources when this object is no longer required
+ */
+ public void dispose()
+ {
+ hconsensus = null;
+ complementConsensus = null;
+ hStrucConsensus = null;
+ fadedImage = null;
+ annotationPanel = null;
+ }
+
+ void drawStemAnnot(Graphics g, Annotation[] row_annotations, int lastSSX,
+ int x, int y, int iconOffset, int startRes, int column,
+ boolean validRes, boolean validEnd)
+ {
+ g.setColor(STEM_COLOUR);
+ int sCol = (lastSSX / charWidth) + startRes;
+ int x1 = lastSSX;
+ int x2 = (x * charWidth);
+
+ char dc = (column == 0 || row_annotations[column - 1] == null) ? ' '
+ : row_annotations[column - 1].secondaryStructure;
+
+ boolean diffupstream = sCol == 0 || row_annotations[sCol - 1] == null
+ || dc != row_annotations[sCol - 1].secondaryStructure;
+ boolean diffdownstream = !validRes || !validEnd
+ || row_annotations[column] == null
+ || dc != row_annotations[column].secondaryStructure;
+
+ if (column > 0 && Rna.isClosingParenthesis(dc))
+ {
+ if (diffupstream)
+ // if (validRes && column>1 && row_annotations[column-2]!=null &&
+ // dc.equals(row_annotations[column-2].displayCharacter))
+ {
+ /*
+ * if new annotation with a closing base pair half of the stem,
+ * display a backward arrow
+ */
+ g.fillPolygon(new int[] { lastSSX + 5, lastSSX + 5, lastSSX },
+ new int[] { y + iconOffset, y + 14 + iconOffset,
+ y + 8 + iconOffset }, 3);
+ x1 += 5;
+ }
+ if (diffdownstream)
+ {
+ x2 -= 1;
+ }
+ }
+ else
+ {
+ // display a forward arrow
+ if (diffdownstream)
+ {
+ /*
+ * if annotation ending with an opeing base pair half of the stem,
+ * display a forward arrow
+ */
+ g.fillPolygon(new int[] { x2 - 5, x2 - 5, x2 }, new int[] {
+ y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset }, 3);
+ x2 -= 5;
+ }
+ if (diffupstream)
+ {
+ x1 += 1;
+ }
+ }
+ // draw arrow body
+ g.fillRect(x1, y + 4 + iconOffset, x2 - x1, 7);
+ }
+
+ void drawNotCanonicalAnnot(Graphics g, Color nonCanColor,