/**
* Copyright (c) 2009-2011, chunquedong(YangJiandong)
*
* This file is part of ChunMap project
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
*
* History:
* 2010-05-05 Jed Young Creation
*/
package chunmap.app.tools.create;
import java.awt.AWTEvent;
import java.awt.event.MouseEvent;
import chunmap.app.bench.AbstractTool;
import chunmap.app.bench.EventType;
import chunmap.model.geom.GeoPoint;
import chunmap.util.CMEventListenerList;
public class PointTool extends AbstractTool{
public CMEventListenerList onCreateFinish=new CMEventListenerList();
@Override
public boolean actionEvent(AWTEvent event, EventType type) {
if (event instanceof MouseEvent)
{
MouseEvent e = (MouseEvent)event;
if (type == EventType.MouseClik && !e.isMetaDown())
{
mouseClicked(e);
return false;
}
}
return true;
}
private void mouseClicked(MouseEvent e)
{
double x = e.getX();
double y = e.getY();
map.getGraphics().drawOval((int)x, (int)y, 5, 5);
GeoPoint p = new GeoPoint(map.getView().x2World(x),map.getView().y2World(y));
finish(p);
}
private void finish(GeoPoint p)
{
onCreateFinish.fire(p);
}
}