Class RefImage

  • All Implemented Interfaces:
    java.awt.image.RenderedImage, java.awt.image.WritableRenderedImage, java.awt.Transparency

    public class RefImage
    extends java.awt.image.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 Summary

      Fields 
      Modifier and Type Field Description
      private java.awt.Graphics2D g
      a strong reference to the graphics object
      • Fields inherited from class java.awt.image.BufferedImage

        TYPE_3BYTE_BGR, TYPE_4BYTE_ABGR, TYPE_4BYTE_ABGR_PRE, TYPE_BYTE_BINARY, TYPE_BYTE_GRAY, TYPE_BYTE_INDEXED, TYPE_CUSTOM, TYPE_INT_ARGB, TYPE_INT_ARGB_PRE, TYPE_INT_BGR, TYPE_INT_RGB, TYPE_USHORT_555_RGB, TYPE_USHORT_565_RGB, TYPE_USHORT_GRAY
      • Fields inherited from class java.awt.Image

        accelerationPriority, SCALE_AREA_AVERAGING, SCALE_DEFAULT, SCALE_FAST, SCALE_REPLICATE, SCALE_SMOOTH, UndefinedProperty
      • Fields inherited from interface java.awt.Transparency

        BITMASK, OPAQUE, TRANSLUCENT
    • Constructor Summary

      Constructors 
      Constructor Description
      RefImage​(int width, int height, int type)
      Creates a new instance of RefImage
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.awt.Graphics2D createGraphics()
      Create a graphics object only if it is currently null, otherwise return the existing graphics object.
      • Methods inherited from class java.awt.image.BufferedImage

        addTileObserver, coerceData, copyData, getAlphaRaster, getColorModel, getData, getData, getGraphics, getHeight, getHeight, getMinTileX, getMinTileY, getMinX, getMinY, getNumXTiles, getNumYTiles, getProperty, getProperty, getPropertyNames, getRaster, getRGB, getRGB, getSampleModel, getSource, getSources, getSubimage, getTile, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getTransparency, getType, getWidth, getWidth, getWritableTile, getWritableTileIndices, hasTileWriters, isAlphaPremultiplied, isTileWritable, releaseWritableTile, removeTileObserver, setData, setRGB, setRGB, toString
      • Methods inherited from class java.awt.Image

        flush, getAccelerationPriority, getCapabilities, getScaledInstance, setAccelerationPriority
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • g

        private java.awt.Graphics2D g
        a strong reference to the graphics object
    • Constructor Detail

      • RefImage

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

      • createGraphics

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