package jp.ac.kyutech.mns.ist;

import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;

import javax.swing.JFrame;

import edu.umd.cs.piccolo.event.PBasicInputEventHandler;
import edu.umd.cs.piccolo.event.PInputEvent;

public class Event_onFS extends PBasicInputEventHandler {
	FocusSrc fsrc;

	PInputEvent pressEv = null;
	Point2D pressP = null;
	int dragCount = 0;

	public Event_onFS(FocusSrc _src) {
		fsrc = _src;
	}

	public void mousePressed(final PInputEvent aEvent) {
		pressEv = aEvent;
		dragCount = 0;
		aEvent.setHandled(true);
	}
	public void mouseDragged(final PInputEvent aEvent) {
		dragCount++;
		aEvent.setHandled(true);
	}
	public void mouseReleased(final PInputEvent aEvent) {

		if (dragCount < 3){
			if (pressEv.getButton()==MouseEvent.BUTTON3){
				//ポップアップメニュー
				new PopupMenu_forFS(fsrc, pressEv, fsrc.fframe.satncanvas);
			} else if (pressEv.getButton()==MouseEvent.BUTTON1){
				if (SimpleATN.theapp.zrh.selection == null){
					if (fsrc.fframe.isVisible()){
						if (fsrc.fframe.getState()==JFrame.ICONIFIED){
							fsrc.fframe.setState(JFrame.NORMAL);
							fsrc.fframe.toFront();
						} else {
							fsrc.fr.focus();
							fsrc.fframe.toFront();
						}
					} else {
						fsrc.fframe.setVisible(true);
						fsrc.fframe.toFront();
					}
				}
			}
		}	
		aEvent.setHandled(true);
	}
	public void mouseEntered(PInputEvent e){
		fsrc.isHover(true);
	}
	public void mouseExited(PInputEvent e){
		fsrc.isHover(false);
	}
}