jpl.mipl.jade
Interface BackgroundPainter

All Known Implementing Classes:
JadeDisplay

public interface BackgroundPainter

An interface that allows backgrounds to be painted on a JadeDisplay component before the actual image is drawn. This allows customization of the component's appearance while waiting for tiles to be painted. For example, a Photoshop-style checkerboard could be drawn instead of simply erasing to black.

See JadeDisplay.backgroundPainter() for an example implementation.

Author:
Bob Deen, JPL

Method Summary
 void paintBackground(Graphics g, int x, int y, int width, int height, boolean isNoErase, boolean isInsideImage, boolean isDeferredTile)
          This function is called to paint the background for the area specified.
 

Method Detail

paintBackground

void paintBackground(Graphics g,
                     int x,
                     int y,
                     int width,
                     int height,
                     boolean isNoErase,
                     boolean isInsideImage,
                     boolean isDeferredTile)
This function is called to paint the background for the area specified. It is called by the JadeDisplay component.

This routine should be fast. The idea is to not slow down the actual image display, but simply put something up indicating the image is not yet displayed.

The first parameters provide the Graphics object on which to draw, and the x/y/width/height of the area to draw. These parameters are measured in image coordinates and may be passed in exactly as-is to Graphics.fillRect(x,y,w,h) - the supplied Graphics object is properly translated, and is clipped to the passed-in bounds. Thus, you can paint outside the bounds if necessary; the excess will be clipped off.

Several flags are passed in which help to determine why the area is being erased. These should have an impact on what you draw:

A note regarding the passed-in Graphics object. This object is used only for background painting. Thus, you can set any parameters in the Graphics object that you want, and do not necessarily have to re-set them when done. However, while the same object may be re-used in subsequent calls to the background painter, there is no guarantee of this. So while you don't have to reset to initial state at the end, you do have to set all state parameters you want before starting the paint.

Parameters:
g - The Graphics into which to paint. This is most likely a Graphics2D instance, but that is not guaranteed by JadeDisplay. It is usually whatever was passed in to paint(g), translated and clipped appropriately.
x - The X coordinate of the rectangle to be painted
y - The Y coordinate of the rectangle to be painted
width - The width of the rectangle to be painted
height - The height of the rectangle to be painted
isNoErase - True if called from paintNoErase()
isInsideImage - True if rectangle is inside the image bounds
isDeferredTile - True if tile is deferred (this is the second call)
See Also:
JadeDisplay, JadeDisplay.setBackgroundPainter(jpl.mipl.jade.BackgroundPainter), Graphics.fillRect(int,int,int,int)