package jp.ac.kyutech.mns.ist;

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

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.KeyStroke;

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

public class PopupMenu_forSATN extends JPopupMenu {
	private static final long serialVersionUID = 7741402910818721975L;

	SimpleATN fframe;
	PInputEvent ie;
	PCanvas canvas;

	public PopupMenu_forSATN(SimpleATN aFR, PInputEvent _ie, PCanvas _canvas /*, JFrame _frame*/) {
		fframe = aFR;
		ie = _ie;
		canvas = _canvas;

		setLightWeightPopupEnabled(false);

		JMenuItem menuItem;

		menuItem = new JMenuItem("cancel");
		add(menuItem);
		menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));//メニュー表示時のショートカットキー

		addSeparator();

		//追加のメニューは，プラグインが直接オンデマンドで追加する
		fframe.addPluginMenuTo(this);
		
		showPopup();
	}

	public void showPopup() {
		Point2D cp = ie.getPositionRelativeTo(canvas.getCamera());

		show(canvas, (int)cp.getX(), (int)cp.getY());
	}
}
