public void drawCursor(Graphics2D g) {
if (needsRepaint()) {
final int y = (myCursorCoordinates.y - 1 - myClientScrollOrigin);
if (y >= 0 && y < myTermSize.height) {
TextStyle current = myStyleState.getCurrent();
boolean isCursorShown = calculateIsCursorShown(System.currentTimeMillis());
if (isCursorShown) {
g.setColor(current.getForeground());
}
else {
g.setColor(current.getBackground());
}
g.fillRect(myCursorCoordinates.x * myCharSize.width, y * myCharSize.height,
myCharSize.width, myCharSize.height);