//StartStopClock.java

import java.awt.*;
import java.awt.event.*;
import java.lang.*;

public class StartStopClock extends Panel {   
	//private static final Color bgcolor = new Color(216,216,191);
	//private static final Color bgcolor = new Color(236,236,221);
        private static final Color bgcolor = new Color(180,180,180); // beige
	
	//public ImageButton button1, button2;
	public Button button1, button2;
        
        public ClockCanvas clockcanvas;
        public boolean IsStop;
	
	public StartStopClock(){
		super();
		setLayout(null);
                setBackground(bgcolor);
		IsStop = true;
		
                button1 = new Button("START");
                button2 = new Button("STOP");
                button1.setBounds(16,18,46,20);
		button2.setBounds(75,18,46,20);
		
                //button1.setBackground(Color.green.darker());
                //button2.setBackground(Color.red.darker());
                button1.setBackground(new Color(250,250,220));
                button2.setBackground(new Color(250,250,220));
                
                //button1.setForeground(Color.green.darker());
                button1.setForeground(new Color(0,100,0));
                
                button2.setForeground(Color.red.darker());
                //button1.setForeground(Color.black);
                //button2.setForeground(Color.black);
                
                button1.setFont(new Font("SanSerif",Font.BOLD,10)); 
                button2.setFont(new Font("SanSerif",Font.BOLD,10)); 
                
                button1.setEnabled(true);
                button2.setEnabled(false);
                
                clockcanvas = new ClockCanvas();
		clockcanvas.setBounds(138,4,50,50);
		add(button1);
		add(button2);
		add(clockcanvas);					
	}
	
	public void paint(Graphics g){
		//g.draw3DRect(0,0,size().width-1,size().height-1,false);
            g.setColor(Color.white);
            g.fillRect(0,0,getSize().width,getSize().height);
            g.setColor(Color.black);
            g.drawRect(0,0,getSize().width-1,getSize().height-1);

            // Start - Stop button backgrounds
            
            //-------------------------START BUTTON
            
            if(IsStop){
                g.setColor(Color.black);
                MaestroG.fillCircle(40,30,38,g);
                //g.setColor(Color.green);
                g.setColor(new Color(0,200,0));
                MaestroG.fillCircle(38,28,38,g);
                g.setColor(Color.green.darker());
                MaestroG.drawCircle(38,28,38,g);
                button1.setEnabled(true);
                button2.setEnabled(false);
                // rectangles behind actual buttons
                g.setColor(Color.green.darker());
                g.fillRect(15,17,48,22);
            
            }
            else{
                g.setColor(Color.gray);
                MaestroG.fillCircle(40,30,38,g);
                g.setColor(Color.lightGray);
                MaestroG.fillCircle(38,28,38,g);
                g.setColor(Color.gray);
                MaestroG.drawCircle(38,28,38,g);
                button1.setEnabled(false);
                button2.setEnabled(true);
                // rectangles behind actual buttons
                g.setColor(Color.black);
                g.fillRect(15,17,48,22);
            
            }
            
            //--------------------------STOP BUTTON
            
            if(!IsStop){
                g.setColor(Color.black);
                MaestroG.fillCircle(99,30,38,g);
                g.setColor(Color.red);
                MaestroG.fillCircle(97,28,38,g);
                g.setColor(Color.red.darker());
                MaestroG.drawCircle(97,28,38,g);
                // rectangles behind actual buttons
                g.setColor(Color.red.darker());
                g.fillRect(74,17,48,22);
            }
            else{
                g.setColor(Color.gray);
                MaestroG.fillCircle(99,30,38,g);
                g.setColor(Color.lightGray);
                MaestroG.fillCircle(97,28,38,g);
                g.setColor(Color.gray);
                MaestroG.drawCircle(97,28,38,g);
                // rectangles behind actual buttons
                g.setColor(Color.black);
                g.fillRect(74,17,48,22);
            }
	}
	
	public void pause(boolean arg){
		//clockcanvas.pause(arg);
	}
	
	public void start(){
		clockcanvas.start();
	}
	
	public void increment(){
		clockcanvas.increment();
	}
	
	public synchronized void setStatus(int CL_START, int CL_FINISH, int CL_DELTA){
		clockcanvas.setStatus(CL_START,CL_FINISH,CL_DELTA);
	}
	public synchronized void setSleepTime(int SleepTime){
		clockcanvas.setSleepTime(SleepTime);
	}
	public synchronized void reset(){
		clockcanvas.reset();
	}
	
}//End of StartStopClock.java
