void paint(Graphics2D g) {
    Rectangle clip = g.getClipBounds();

    if (myEditor.getContentComponent().isOpaque()) {
      g.setColor(myEditor.getBackgroundColor());
      g.fillRect(clip.x, clip.y, clip.width, clip.height);
    }

    if (paintPlaceholderText(g)) {
      paintCaret(g);
      return;
    }

    int startLine = myView.yToVisualLine(Math.max(clip.y, 0));
    int endLine = myView.yToVisualLine(Math.max(clip.y + clip.height, 0));
    int startOffset = myView.visualPositionToOffset(new VisualPosition(startLine, 0));
    int endOffset = myView.visualPositionToOffset(new VisualPosition(endLine + 1, 0, true));
    ClipDetector clipDetector = new ClipDetector(myEditor, clip);

    paintBackground(g, clip, startLine, endLine);
    paintRightMargin(g, clip);
    paintCustomRenderers(g, startOffset, endOffset);
    MarkupModelEx docMarkup =
        (MarkupModelEx) DocumentMarkupModel.forDocument(myDocument, myEditor.getProject(), true);
    paintLineMarkersSeparators(g, clip, docMarkup, startOffset, endOffset);
    paintLineMarkersSeparators(g, clip, myEditor.getMarkupModel(), startOffset, endOffset);
    paintTextWithEffects(g, clip, startLine, endLine);
    paintHighlightersAfterEndOfLine(g, docMarkup, startOffset, endOffset);
    paintHighlightersAfterEndOfLine(g, myEditor.getMarkupModel(), startOffset, endOffset);
    paintBorderEffect(g, clipDetector, myEditor.getHighlighter(), startOffset, endOffset);
    paintBorderEffect(g, clipDetector, docMarkup, startOffset, endOffset);
    paintBorderEffect(g, clipDetector, myEditor.getMarkupModel(), startOffset, endOffset);

    paintCaret(g);

    paintComposedTextDecoration(g);
  }
 private void paintCustomRenderers(
     final Graphics2D g, final int startOffset, final int endOffset) {
   myEditor
       .getMarkupModel()
       .processRangeHighlightersOverlappingWith(
           startOffset,
           endOffset,
           new Processor<RangeHighlighterEx>() {
             @Override
             public boolean process(RangeHighlighterEx highlighter) {
               if (highlighter.getEditorFilter().avaliableIn(myEditor)) {
                 CustomHighlighterRenderer customRenderer = highlighter.getCustomRenderer();
                 if (customRenderer != null
                     && startOffset < highlighter.getEndOffset()
                     && highlighter.getStartOffset() < endOffset) {
                   customRenderer.paint(myEditor, highlighter, g);
                 }
               }
               return true;
             }
           });
 }