int (Rectangle visibleRect, int orientation, int direction) { if (orientation == SwingConstants.VERTICAL) { int lineHeight = myEditor.getLineHeight(); if (direction > 0) { int lineNumber = (visibleRect.y + visibleRect.height) / lineHeight; return lineHeight * lineNumber - visibleRect.y; } else { int lineNumber = (visibleRect.y - visibleRect.height) / lineHeight; return visibleRect.y - lineHeight * lineNumber; } } // if orientation == SwingConstants.HORIZONTAL return visibleRect.width; }