// define our cursor image
BufferedImage cursorImage = null;
- int yoffset = 0;
- int xoffset = 0;
- int startx = startRes;
- int endx = endRes;
- if (av.getWrapAlignment())
+ // don't do work unless we have to
+ if (av.cursorMode && cursorY >= startSeq && cursorY <= endSeq)
{
- // work out the correct offsets for the cursor
- int charHeight = av.getCharHeight();
- int charWidth = av.getCharWidth();
- int canvasWidth = getWidth();
- int canvasHeight = getHeight();
-
- // height gap above each panel
- int hgap = charHeight;
- if (av.getScaleAboveWrapped())
+ int yoffset = 0;
+ int xoffset = 0;
+ int startx = startRes;
+ int endx = endRes;
+ if (av.getWrapAlignment())
{
- hgap += charHeight;
- }
-
- int cWidth = (canvasWidth - labelWidthEast - labelWidthWest)
- / charWidth;
- int cHeight = av.getAlignment().getHeight() * charHeight;
-
- endx = startx + cWidth - 1;
- int ypos = hgap; // vertical offset
+ // work out the correct offsets for the cursor
+ int charHeight = av.getCharHeight();
+ int charWidth = av.getCharWidth();
+ int canvasWidth = getWidth();
+ int canvasHeight = getHeight();
+
+ // height gap above each panel
+ int hgap = charHeight;
+ if (av.getScaleAboveWrapped())
+ {
+ hgap += charHeight;
+ }
- // iterate down the wrapped panels
- while ((ypos <= canvasHeight) && (endx < cursorX))
- {
- // update vertical offset
- ypos += cHeight + getAnnotationHeight() + hgap;
+ int cWidth = (canvasWidth - labelWidthEast - labelWidthWest)
+ / charWidth;
+ int cHeight = av.getAlignment().getHeight() * charHeight;
- // update horizontal offset
- startx += cWidth;
endx = startx + cWidth - 1;
- }
- yoffset = ypos;
- xoffset = labelWidthWest;
- }
+ int ypos = hgap; // vertical offset
- if (av.cursorMode && cursorY >= startSeq && cursorY <= endSeq
- && cursorX >= startx && cursorX <= endx)
- {
- // get a new image of the correct size
- cursorImage = setupImage();
- Graphics2D g = (Graphics2D) cursorImage.getGraphics();
+ // iterate down the wrapped panels
+ while ((ypos <= canvasHeight) && (endx < cursorX))
+ {
+ // update vertical offset
+ ypos += cHeight + getAnnotationHeight() + hgap;
- // get the character the cursor is drawn at
- SequenceI seq = av.getAlignment().getSequenceAt(cursorY);
- char s = seq.getCharAt(cursorX);
+ // update horizontal offset
+ startx += cWidth;
+ endx = startx + cWidth - 1;
+ }
+ yoffset = ypos;
+ xoffset = labelWidthWest;
+ }
- seqRdr.drawCursor(g, s,
- xoffset + (cursorX - startx) * av.getCharWidth(),
- yoffset + (cursorY - startSeq) * av.getCharHeight());
- g.dispose();
+ // now check if cursor is within range for x values
+ if (cursorX >= startx && cursorX <= endx)
+ {
+ // 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);
+
+ seqRdr.drawCursor(g, s,
+ xoffset + (cursorX - startx) * av.getCharWidth(),
+ yoffset + (cursorY - startSeq) * av.getCharHeight());
+ g.dispose();
+ }
}
return cursorImage;