// Project 1 initial source code
// CMSC427 fall 2017

// Class Controller handles all GUI events
// 


import java.awt.event.MouseListener;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.KeyListener;
import java.awt.event.KeyEvent;


// An Adapter is a default implementation of a listener, so you don't have implement all 
// required methods
// An Interface Listener requires that you do
public class Controller extends MouseMotionAdapter implements KeyListener, MouseListener {
	
	Code myView;
	
	public Controller() {

	}
	
	// Need to add reference to ModelView object
	// So as to access redraw() and setAngle()
	public void addCode(Code c) {
		myView = c;
	}
	

	 public void mouseReleased(MouseEvent e) {
	    System.out.println("Mouse released; # of clicks: "
	                    + e.getClickCount());
	  }
	 
	 public void mousePressed(MouseEvent e) {
		
     }

	 public void mouseEntered(MouseEvent e) {
		      
	 }

	 public void mouseExited(MouseEvent e) {
		       
	 }

	 public void mouseClicked(MouseEvent e) {
		       
	 }
		
	 // Only function event at moment
	 public void mouseDragged(MouseEvent e) {
		  int mx = e.getX();
		  int my = e.getY();
		  System.out.println("event "+mx+" "+my);
		  myView.setAngles(mx,my);
		  myView.redraw();
		  }
		     
	 public void mouseMoved(MouseEvent e) {
		
	 }
	 
	 public void keyTyped(KeyEvent e) {
	    System.out.println("KEY TYPED: "+e.getKeyChar());
	 }

	 public void keyPressed(KeyEvent e) {
	    System.out.println("KEY PRESSED: ");
	 }

	    /** Handle the key-released event from the text field. */
	 public void keyReleased(KeyEvent e) {
	    System.out.println("KEY RELEASED: ");
	 }
}
