package gui.simulator;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import java.util.TimerTask;

import javax.swing.BorderFactory;
import javax.swing.JPanel;

import agenda.Agenda;

public class SimulatorPane extends JPanel{
	
	private Agenda agenda;
	private Terrain terrain;
	private Timer framestimer, updatetimer;
	
	//terrain type enums
	public enum Terrains{BEACH, GRASS, URBAN, UNDEFINED};
	//object type enums
	public enum Objects{STAGE, DRINK, SNACKBAR, RESTROOM, SUNGLAS, WAYPOINT, ENTRANCE, EXIT, BORDER};
	
	public SimulatorPane(Agenda agenda, int length, int width, Terrains terrains){
        super.setLayout(new BorderLayout());
		this.agenda = agenda;
        this.setOpaque(true);
        this.setBackground(Color.WHITE);
        this.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
        this.terrain = new Terrain(length, width, terrains, this.agenda);
        this.add(this.terrain, BorderLayout.CENTER);
       updatetimer =  new Timer(1000/30, new ActionListener() {
        	@Override
			public void actionPerformed(ActionEvent arg0) {
				terrain.repaint();	
			}
		});
        framestimer = new Timer(1000/100, new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				terrain.calculate();
			}
		});
        
        framestimer.start();
        updatetimer.start();
	}
}
