Class RefImage

All Implemented Interfaces:
RenderedImage, WritableRenderedImage, Transparency

public class RefImage extends BufferedImage
A BufferedImage subclass that holds a strong reference to its graphics object. This means that the graphics will never go away as long as someone holds a reference to this image, and createGraphics() and getGraphics() can be called multiple times safely, and will always return the same graphics object.
  • Field Details

    • g

      private Graphics2D g
      a strong reference to the graphics object
  • Constructor Details

    • RefImage

      public RefImage(int width, int height, int type)
      Creates a new instance of RefImage
  • Method Details

    • createGraphics

      public Graphics2D createGraphics()
      Create a graphics object only if it is currently null, otherwise return the existing graphics object.
      Overrides:
      createGraphics in class BufferedImage