package jp.ac.kyutech.mns.ist;

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

import edu.umd.cs.piccolo.PCamera;
import edu.umd.cs.piccolo.PNode;
import edu.umd.cs.piccolo.event.PBasicInputEventHandler;
import edu.umd.cs.piccolo.event.PInputEvent;
import edu.umd.cs.piccolo.nodes.PText;

public class Event_onSATN extends PBasicInputEventHandler {
	SimpleATN frame;

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

	public Event_onSATN(SimpleATN _ff) {
		frame = _ff;
	}

	public void mousePressed(final PInputEvent aEvent) {
		pressEv = aEvent;
		pressPN = aEvent.getPickedNode();
		dragCount = 0;
	}
	public void mouseDragged(final PInputEvent aEvent) {
		dragCount++;
	}
	public void mouseReleased(final PInputEvent aEvent) {
		if (pressEv == null) return;
		if (pressPN.getAttribute("nozoom") != null) return;//nozoomタグがついていたら，ズームインしない（色付けボタン:FRPaletteのPPathなので）
		if (dragCount < 3){
			if (pressEv.getButton()==MouseEvent.BUTTON3){
				//ポップアップメニュー
				if (pressPN instanceof PCamera || pressPN instanceof PText) //Sheetのときは表示しない．
				new PopupMenu_forSATN(frame, pressEv, frame.getCanvas());
			} else if (pressEv.getButton()==MouseEvent.BUTTON1){
//				if (SimpleATN.theapp.zrh.selection == null){
//					frame.focus();
//				}
			}
		}	
	}
}