//package MCMC;

/*
 * ClassCanvas.java
 *
 * Created in 2004
 */

/**
 *
 * @author Hans Braxmeier
 */

import java.awt.*;
import java.awt.image.*;

public class ClassCanvas extends Canvas {

	Graphics2D offscreen;
	BufferedImage buffImage;
	
	int width;
	int height;

	public ClassCanvas(int width, int height) {
		this.width = width;
		this.height = height;
		buffImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
		offscreen = buffImage.createGraphics();
		// Nicht width - 1, height - 1, 
		// da sonst ein schwarzen Balken uebrigbleibt!
		offscreen.fillRect(0, 0, width, height);
		// Default Zeichenfarbe
		offscreen.setColor(Color.black);
		// Default Skalierung
		offscreen.scale(1.0, 1.0);
       }
        
       	public void update(Graphics g) {
		g.drawImage(buffImage, 0, 0,  this);
	}

	public void paint (Graphics g) {
		update(g);
	}
	
	public void setColor(Color c) {
		offscreen.setColor(c);
	}
		
	public void setHSBColor(float h, float s, float b) {
		offscreen.setColor(new Color(java.awt.Color.HSBtoRGB(h, s, b)));
	}

	public Color getColor() {
		return offscreen.getColor();
	}

	public void drawPoint(int x, int y) {
		offscreen.drawLine(x, y, x, y);
	}

	public void drawLine(int x, int y, int w, int h) {
		offscreen.drawLine(x, y, w, h);
	}
	
	public void drawRect(int x, int y, int w, int h) {
		offscreen.drawRect(x, y, w, h);
	}

	public void drawRectFilled(int x, int y, int w, int h) {
		offscreen.fillRect(x, y, w, h);
	}
}
