+ /**
+ * Draw the cursor as a separate image and overlay
+ *
+ * @param startRes
+ * start residue of area to draw cursor in
+ * @param endRes
+ * end residue of area to draw cursor in
+ * @param startSeq
+ * start sequence of area to draw cursor in
+ * @param endSeq
+ * end sequence of are to draw cursor in
+ * @return a transparent image of the same size as the sequence canvas, with
+ * the cursor drawn on it, if any
+ */
+ private BufferedImage drawCursor(int startRes, int endRes, int startSeq,
+ int endSeq)
+ {
+ // define our cursor image
+ BufferedImage cursorImage = null;
+
+ if (av.cursorMode && cursorY >= startSeq && cursorY <= endSeq
+ && cursorX >= startRes && cursorX <= endRes)
+ {
+ // get a new image of the correct size
+ cursorImage = setupImage();
+ Graphics2D g = (Graphics2D) cursorImage.getGraphics();
+
+ // get the character the cursor is drawn at
+ SequenceI seq = av.getAlignment().getSequenceAt(cursorY);
+ char s = seq.getCharAt(cursorX);
+
+ int offset = 0;
+ if (av.getWrapAlignment())
+ {
+ // work out the correct offset for the cursor
+ offset = wrappedSpaceAboveAlignment;
+ int currentWidth = 0;
+ while ((currentWidth < wrappedVisibleWidths)
+ && (currentWidth < cursorX))
+ {
+ offset += wrappedRepeatHeightPx;
+ currentWidth++;
+ }
+ }
+
+ seqRdr.drawCursor(g, s,
+ (cursorX - startRes) * av.getCharWidth(),
+ offset + ((cursorY - startSeq) * av.getCharHeight()));
+ g.dispose();
+ }
+
+ return cursorImage;
+ }
+