AbsoluteSymbolPosition (int offset) { if (offset < 0 || offset > myDocument.getTextLength()) { throw new IllegalArgumentException("offset=" + offset + " document.length=" + myDocument.getTextLength()); } for (int i = pagesInDocument.size() - 1; i >= 0; i--) { int symbolOffsetToStartOfPage = getSymbolOffsetToStartOfPage(i); if (offset >= symbolOffsetToStartOfPage) { return new AbsoluteSymbolPosition(pagesInDocument.get(i).getPageNumber(), offset - symbolOffsetToStartOfPage); } } // unreachable code LOG.warn(new UnsupportedOperationException("offset=" + offset + " document.length=" + myDocument.getTextLength() + " pagesInDocument.size=" + pagesInDocument.size())); return new AbsoluteSymbolPosition(0, 0); }