int (int logicalLine) { int startOffset = myDocument.getLineStartOffset(logicalLine); int endOffset = myDocument.getLineEndOffset(logicalLine); while (afterLineEndInlayIndex < afterLineEndInlays.size() && afterLineEndInlays.get(afterLineEndInlayIndex).getOffset() < startOffset) { afterLineEndInlayIndex++; } while (afterLineEndInlayIndex > 0 && afterLineEndInlays.get(afterLineEndInlayIndex - 1).getOffset() >= startOffset) { afterLineEndInlayIndex--; } int width = 0; while (afterLineEndInlayIndex < afterLineEndInlays.size()) { Inlay<?> inlay = afterLineEndInlays.get(afterLineEndInlayIndex); int offset = inlay.getOffset(); if (offset < startOffset || offset > endOffset) break; width += inlay.getWidthInPixels(); afterLineEndInlayIndex++; } return width; }