base/common/src/main/com/thesett/common/swing/surface/Surface.java
public void paint(Graphics g)
    {
        // Get the size of the surface
        Dimension d = getSize();

        // Check if direct to screen rendering is to be used
        if (imageType == 1)
        {
            // Use no buffered image for direct rendering
            bimg = null;
        }

        // Check if no buffered image has been created yet or if the existing one has the wrong size
        else if ((bimg == null) || (biw != d.width) || (bih != d.height))
        {
            // Create a new bufferd image. Note that imageType has two subtracted for it as type 0 stands for auto
            // selection and type 1 for direct to screen. Subtracting two corresponds to the image types in the
            // BufferedImage class.
            bimg = createBufferedImage(d.width, d.height, imageType - 2);

            // Set clear once flag to clear the new image on the first pass
            clearOnce = true;
        }

        // Build a Graphics2D context for the image
        Graphics2D g2 = createGraphics2D(d.width, d.height, bimg, g);

        // Call the subclass to perform rendering
        render(d.width, d.height, g2);

        // Clear up the Graphics2D context
        g2.dispose();

        // Check if a buffered image was used (and not direct to screen rendering)
        if (bimg != null)
        {
            // Copy the buffered image onto the screen
            g.drawImage(bimg, 0, 0, null);

            // Ensure screen is up to date
            toolkit.sync();
        }
    }
public void paint(Graphics g)
    {
        // Get the size of the surface
        Dimension d = getSize();

        // Check if direct to screen rendering is to be used
        if (imageType == 1)
        {
            // Use no buffered image for direct rendering
            bimg = null;
        }

        // Check if no buffered image has been created yet or if the existing one has the wrong size
        else if ((bimg == null) || (biw != d.width) || (bih != d.height))
        {
            // Create a new bufferd image. Note that imageType has two subtracted for it as type 0 stands for auto
            // selection and type 1 for direct to screen. Subtracting two corresponds to the image types in the
            // BufferedImage class.
            bimg = createBufferedImage(d.width, d.height, imageType - 2);

            // Set clear once flag to clear the new image on the first pass
            clearOnce = true;
        }

        // Build a Graphics2D context for the image
        Graphics2D g2 = createGraphics2D(d.width, d.height, bimg, g);

        // Call the subclass to perform rendering
        render(d.width, d.height, g2);

        // Clear up the Graphics2D context
        g2.dispose();

        // Check if a buffered image was used (and not direct to screen rendering)
        if (bimg != null)
        {
            // Copy the buffered image onto the screen
            g.drawImage(bimg, 0, 0, null);

            // Ensure screen is up to date
            toolkit.sync();
        }
    }
public void paint ( Graphics g ) { // Get the size of the surface Dimension d = getSize ( ) ; // Check if direct to screen rendering is to be used if ( imageType == 1 ) { // Use no buffered image for direct rendering bimg = null ; } // Check if no buffered image has been created yet or if the existing one has the wrong size else if ( ( bimg == null ) || ( biw != d . width ) || ( bih != d . height ) ) { // Create a new bufferd image. Note that imageType has two subtracted for it as type 0 stands for auto // selection and type 1 for direct to screen. Subtracting two corresponds to the image types in the // BufferedImage class. bimg = createBufferedImage ( d . width , d . height , imageType - 2 ) ; // Set clear once flag to clear the new image on the first pass clearOnce = true ; } // Build a Graphics2D context for the image Graphics2D g2 = createGraphics2D ( d . width , d . height , bimg , g ) ; // Call the subclass to perform rendering render ( d . width , d . height , g2 ) ; // Clear up the Graphics2D context g2 . dispose ( ) ; // Check if a buffered image was used (and not direct to screen rendering) if ( bimg != null ) { // Copy the buffered image onto the screen g . drawImage ( bimg , 0 , 0 , null ) ; // Ensure screen is up to date toolkit . sync ( ) ; } }
Renders the surface. This method will create a buffered image to render in if one does not already exist. If
rendering is to be done directly to the screen no buffered image will be generated. If the size of the buffered
image does not match the Graphics context size then a new buffered image will be generated of the correct size
before rendering. The {@link #render} method will be called to do the actual drawing.

@param g The graphics context to paint.
Renders the surface . This method will create a buffered image to render in if one does not already exist . If rendering is to be done directly to the screen no buffered image will be generated . If the size of the buffered image does not match the Graphics context size then a new buffered image will be generated of the correct size before rendering . The { @link #render } method will be called to do the actual drawing .