RangeMarker (Graphics2D g2d, PageFormat pageFormat, RangeMarker range) { assert isValidRange(range); int startOffset = range.getStartOffset(); int endOffset = range.getEndOffset(); myOffset = startOffset; mySegmentEnd = endOffset; myLineNumber = myDocument.getLineNumber(myOffset) + 1; Rectangle2D.Double clip = new Rectangle2D.Double(pageFormat.getImageableX(), pageFormat.getImageableY(), pageFormat.getImageableWidth(), pageFormat.getImageableHeight()); updateHighlightingInfoIfNeeded(); draw(g2d, clip); return myOffset > startOffset && myOffset < endOffset ? myDocument.createRangeMarker(myOffset, endOffset) : null; }