package rpn.graphics;

import java.awt.*;
import real.Formats;

public class DirectRealCanvas extends Canvas {
	int w, h;
	RealGraphics gfx;

	/** The variables w and h determine the canvas size in pixels. */

	public DirectRealCanvas(int w, int h) {
		this.w = w;
		this.h = h;
		resize(w, h);
	}
	
	public Rectangle getBounds() {
		return(bounds());
	}
	
	/** Reverses the normal ordering of paint() and 
		update() for flicker-free performance. */
	public void paint(Graphics g) {
		update(g);
	}

	/** Usually overridden. */
	public void update(Graphics g) {
		if (gfx == null) {
			Graphics G = getGraphics();
			gfx = new RealGraphics(G, w, h);
		}
		gfx.setColor(Color.black);
		gfx.clear();
		PlotPath p = new PlotPath(gfx);
		p.moveto(0, 0);
		p.lineto(100, 100);
		p.stroke(Color.black);
	}
}
