int line = yToLine(y); int start = getLineStartOffset(line); return start + xToOffset(line,x);
FontMetrics fm = painter.getFontMetrics(); int height = fm.getHeight(); int line = y / height + firstLine;  if(line >= getLineCount()) return getBufferLength(); else return getLineStartOffset(line) + xToOffset(line,x);
	public int xyToOffset(int x, int y)	{		int line = yToLine(y);		int start = getLineStartOffset(line);		return start + xToOffset(line,x);	}