code: private void paintDirectly(Graphics2D g, JComponent c, int w, int h, Object[] extendedCacheKeys) {
          g = (Graphics2D) g.create();
          configureGraphics(g);
          doPaint(g, c, w, h, extendedCacheKeys);
          g.dispose();
      }
docs: Convenience method which creates a temporary graphics object by creating
  a clone of the passed in one, configuring it, drawing with it, disposing
  it. These steps have to be taken to ensure that any hints set on the
  graphics are removed subsequent to painting.
  
  @param g                 the Graphics2D context to paint with.
  @param c                 the component to paint.
  @param w                 the component width.
  @param h                 the component height.
  @param extendedCacheKeys extended cache keys.