private void paintWithDoubleBuffering(final Graphics2D graphics, final Consumer<? super Graphics2D> painter) {
    final Rectangle bounds = graphics.getClipBounds();

    createOrUpdateImageBuffer(myEditor.getComponent(), graphics, bounds.getSize());

    useSafely(myImage.getGraphics(), imageGraphics -> {
      imageGraphics.translate(-bounds.x, -bounds.y);
      painter.consume(imageGraphics);
    });

    StartupUiUtil.drawImage(graphics, myImage, bounds.x, bounds.y, null);
  }
private void paintWithDoubleBuffering(final Graphics2D graphics, final Consumer<? super Graphics2D> painter)