base/common/src/main/com/thesett/common/swing/surface/Surface.java
protected Graphics2D createGraphics2D(int width, int height, BufferedImage bi, Graphics g)
    {
        Graphics2D g2 = null;

        // Check if the buffered image is null
        if (bi != null)
        {
            // Create Graphics2D context for the buffered image
            g2 = bi.createGraphics();
        }
        else
        {
            // The buffered image is null so create Graphics2D context for the Graphics context
            g2 = (Graphics2D) g;
        }

        // @todo what is this for?
        g2.setBackground(getBackground());

        // Set the rendering properties of the graphics context
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antiAlias);
        g2.setRenderingHint(RenderingHints.KEY_RENDERING, rendering);

        // Check the clear flags to see if the graphics context should be cleared
        if (clearSurface || clearOnce)
        {
            // Clear the image
            g2.clearRect(0, 0, width, height);

            // Reset the clear once flag to show that clearing has been done
            clearOnce = false;
        }

        // Check if a background fill texture is to be used
        if (texture != null)
        {
            // set composite to opaque for texture fills
            g2.setComposite(AlphaComposite.SrcOver);
            g2.setPaint(texture);
            g2.fillRect(0, 0, width, height);
        }

        // Check if alpha compositing is to be used
        if (composite != null)
        {
            // Set the alpha compositing algorithm
            g2.setComposite(composite);
        }

        return g2;
    }
protected Graphics2D createGraphics2D(int width, int height, BufferedImage bi, Graphics g)
    {
        Graphics2D g2 = null;

        // Check if the buffered image is null
        if (bi != null)
        {
            // Create Graphics2D context for the buffered image
            g2 = bi.createGraphics();
        }
        else
        {
            // The buffered image is null so create Graphics2D context for the Graphics context
            g2 = (Graphics2D) g;
        }

        // @todo what is this for?
        g2.setBackground(getBackground());

        // Set the rendering properties of the graphics context
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antiAlias);
        g2.setRenderingHint(RenderingHints.KEY_RENDERING, rendering);

        // Check the clear flags to see if the graphics context should be cleared
        if (clearSurface || clearOnce)
        {
            // Clear the image
            g2.clearRect(0, 0, width, height);

            // Reset the clear once flag to show that clearing has been done
            clearOnce = false;
        }

        // Check if a background fill texture is to be used
        if (texture != null)
        {
            // set composite to opaque for texture fills
            g2.setComposite(AlphaComposite.SrcOver);
            g2.setPaint(texture);
            g2.fillRect(0, 0, width, height);
        }

        // Check if alpha compositing is to be used
        if (composite != null)
        {
            // Set the alpha compositing algorithm
            g2.setComposite(composite);
        }

        return g2;
    }
protected Graphics2D createGraphics2D ( int width , int height , BufferedImage bi , Graphics g ) { Graphics2D g2 = null ; // Check if the buffered image is null if ( bi != null ) { // Create Graphics2D context for the buffered image g2 = bi . createGraphics ( ) ; } else { // The buffered image is null so create Graphics2D context for the Graphics context g2 = ( Graphics2D ) g ; } // @todo what is this for? g2 . setBackground ( getBackground ( ) ) ; // Set the rendering properties of the graphics context g2 . setRenderingHint ( RenderingHints . KEY_ANTIALIASING , antiAlias ) ; g2 . setRenderingHint ( RenderingHints . KEY_RENDERING , rendering ) ; // Check the clear flags to see if the graphics context should be cleared if ( clearSurface || clearOnce ) { // Clear the image g2 . clearRect ( 0 , 0 , width , height ) ; // Reset the clear once flag to show that clearing has been done clearOnce = false ; } // Check if a background fill texture is to be used if ( texture != null ) { // set composite to opaque for texture fills g2 . setComposite ( AlphaComposite . SrcOver ) ; g2 . setPaint ( texture ) ; g2 . fillRect ( 0 , 0 , width , height ) ; } // Check if alpha compositing is to be used if ( composite != null ) { // Set the alpha compositing algorithm g2 . setComposite ( composite ) ; } return g2 ; }
Creates a Graphics2D drawing context from a BufferedImage or Graphics context. The graphics context is built
using the properties defined for the surface. This method is used to generate the Graphics2D context that
subclasses will render in. IF the buffered image is null then the passed in Graphics context will be used to
generate the Graphics2D context. This is the case when no buffered image is used and the subclass renders
straight to the screen.

@param  width  The width of the buffered image.
@param  height The height of the buffered image.
@param  bi     The buffered image to generate a Graphics2D context for, or null if the next param is to be used.
@param  g      The Graphics context to generate a Graphics2D context for, only used if bi is null.

@return A Graphics2D drawing context of the specified size and type.
Creates a Graphics2D drawing context from a BufferedImage or Graphics context . The graphics context is built using the properties defined for the surface . This method is used to generate the Graphics2D context that subclasses will render in . IF the buffered image is null then the passed in Graphics context will be used to generate the Graphics2D context . This is the case when no buffered image is used and the subclass renders straight to the screen .