import java.awt.*;

/* This example extends DrawImage,
 * to draw the face of an ImageButton,
 * <IMG SRC="/cgi-bin/counter">
 * @author Morris Hirsch IPD */

public class GaugeFace extends DrawImage {

/* Coordinate that changes for animation */

    private int xx = 0;

    public void draw (Graphics g, int xo, int yo, boolean enabled) {

/* Declare our colors and gray them if disabled */

	Color Cgreen = Color.green;
	Color Cyellow = Color.yellow;
	Color Cred = Color.red;
	Color Cwhite = Color.white;

        if (!enabled) {
	   Cgreen = BWFilter (Color.green);
	   Cyellow = BWFilter (Color.yellow);
	   Cred = BWFilter (Color.red);
	   Cwhite = BWFilter (Color.white);
	}

/* Draw the constant part */

	g.setColor (Cgreen);
	g.fillRect (xo+0, yo+0, 32, 11);
	g.setColor (Cyellow);
	g.fillRect (xo+0, yo+11, 32, 11);
	g.setColor (Cred);
	g.fillRect (xo+0, yo+22, 32, 11);

/* Draw the animated part -- a moving vertical bar */

	g.setColor (Color.black);
	g.fillRect (xo+xx, yo, 3, 32);
    }

    public int getHeight () { return 32; }

    public int getWidth () { return 32; }

/** Constructors */

    GaugeFace () { }

    GaugeFace (float fraction) { setValue (fraction); }

    public void setValue (float fraction) {
	xx = (int)(32 * fraction);
	repaint (100);
    }
}
/* <IMG SRC="/cgi-bin/counter">*/
