package jp.ac.kyutech.mns.ist;

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

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

public class Event_onSSGroup extends PBasicInputEventHandler {
	SSGroup ssgroup;
	
	PInputEvent pressEv = null;
	Point2D pressP = null;
	int dragCount = 0;
	
	public Event_onSSGroup(SSGroup _ssg) {
		ssgroup = _ssg;
	}

	public void mousePressed(final PInputEvent aEvent) {
		pressEv = aEvent;
		dragCount = 0;
	}
	public void mouseDragged(final PInputEvent aEvent) {
		dragCount++;
	}
	public void mouseReleased(final PInputEvent aEvent) {
		
		if (dragCount < 3){
			if (pressEv.getButton()==MouseEvent.BUTTON1){
				Rectangle2D globalb;
				int zL = SimpleATN.theapp.getZoomLevel();
				System.out.println("zoomlevel "+zL);
				if (zL < 1){
//					globalb = ssgroup.getParent().getGlobalBounds(); 
					globalb = ssgroup.sheet.getGlobalBounds(); //上と同じだけど．．．一応
				} else {
					globalb = ssgroup.getGlobalBounds();
				}
				
				SimpleATN.theapp.zoomToBounds(globalb, 1000, "Event_onSSGroup", aEvent);
				
			} else if (pressEv.getButton()==MouseEvent.BUTTON3){
				new PopupMenu_forSSGroup(ssgroup, pressEv, SimpleATN.theapp.getCanvas());
			}
		}
	}

}
