private void createOrUpdateImageBuffer(final JComponent component, final Graphics2D graphics, final Dimension size) {
    if (ApplicationManager.getApplication().isUnitTestMode()) {
      if (myImage == null || !isLargeEnough(myImage, size)) {
        int width = (int) Math.ceil(PaintUtil.alignToInt(size.width, graphics, PaintUtil.RoundingMode.CEIL));
        int height = (int) Math.ceil(PaintUtil.alignToInt(size.height, graphics, PaintUtil.RoundingMode.CEIL));
        myImage = ImageUtil.createImage(width, height, BufferedImage.TYPE_INT_RGB);
      }
    }
    else {
      if (myImage == null) {
        myImage = component.createVolatileImage(size.width, size.height);
      }
      else if (!isLargeEnough(myImage, size) || !isImageValid((VolatileImage)myImage, component)) {
        myImage.flush();
        myImage = component.createVolatileImage(size.width, size.height);
      }
    }
  }
private void createOrUpdateImageBuffer(final JComponent component, final Graphics2D graphics, final Dimension size)