package jp.ac.kyutech.mns.ist;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
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_forBase extends JPopupMenu {
	private static final long serialVersionUID = 7741402910818721975L;

	PInputEvent ie;
	PCanvas canvas;
	ZoomRegionHandler zrh;

	public PopupMenu_forBase(PInputEvent _ie, PCanvas _canvas, ZoomRegionHandler _zrh) {
		ie = _ie;
		canvas = _canvas;
		zrh = _zrh;
		
		System.out.println(zrh.pressN.getClass().getName());

		setLightWeightPopupEnabled(false);

		JMenuItem menuItem;

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

		addSeparator();

		menuItem = new JMenuItem("zoom to region");
		add(menuItem);
		menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, 0));//メニュー表示時のショートカットキー
		menuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});

		showPopup();
	}

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

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