//package maestro.lib.graphics;
import java.awt.*;
import java.lang.*;

public class SimpleMessageCanvas extends Canvas{
    //private static final Color bgcolor = new Color(216,216,191);
    private static final Color bgcolor = new Color(236,236,236);
    private String myString;
    private Font myFont;
    public SimpleMessageCanvas(){
	super();
	myString = "Unknown message";
	myFont = new Font("SanSerif",Font.PLAIN,11);
    }
    
    public SimpleMessageCanvas(String myString){
	super();
	this.myString = myString;
	myFont = new Font("SanSerif",Font.PLAIN,11);
    }
    
    public void paint(Graphics g){
	Graphics2D g2d = (Graphics2D)g;
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
        g.setColor(bgcolor);	
	g.fillRect(0,0,getSize().width-1,getSize().height-1);
	g.setColor(Color.black);
        g.drawLine(0,getSize().height-1,getSize().width-1,getSize().height-1);
        g.drawLine(getSize().width-1,0,getSize().width-1,getSize().height-1);
        g.setColor(Color.white);
        g.drawLine(0,0,getSize().width-1,0);
        g.drawLine(0,0,0,getSize().height-1);

	g.setColor(Color.black);
	g.setFont(myFont);
	FontMetrics fmetrics=g.getFontMetrics();
	g.drawString(myString,(getSize().width-fmetrics.stringWidth(myString))/2,fmetrics.getHeight()+5);   
    }
    
    public void update(Graphics g){
	paint(g);
    }
    
    public synchronized void setMessage(String myString){
	this.myString = myString;
	repaint();
    }
    
    public void setFont(Font myFont){
	this.myFont = myFont;
	repaint();
    }
}