gvsig-geoprocess / org.gvsig.geoprocess / trunk / org.gvsig.geoprocess / org.gvsig.geoprocess.app / org.gvsig.geoprocess.app.mainplugin / src / main / java / org / gvsig / geoprocess / extension / GeoprocessPointSelectionListener.java @ 230
History | View | Annotate | Download (1.7 KB)
1 |
package org.gvsig.geoprocess.extension; |
---|---|
2 |
|
3 |
import java.awt.geom.Point2D; |
4 |
|
5 |
import javax.swing.JOptionPane; |
6 |
|
7 |
import es.unex.sextante.gui.core.NamedPoint; |
8 |
import es.unex.sextante.gui.core.SextanteGUI; |
9 |
|
10 |
import org.gvsig.fmap.mapcontrol.MapControl; |
11 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
12 |
import org.gvsig.fmap.mapcontrol.tools.PointSelectionListener; |
13 |
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent; |
14 |
import org.gvsig.i18n.Messages; |
15 |
|
16 |
/**
|
17 |
* Tool to collect points over the gvSIG view document window, to be used
|
18 |
* in the geoprocess parameters extension definition.
|
19 |
*
|
20 |
* @author gvSIG Team
|
21 |
* @version $Id$
|
22 |
*/
|
23 |
public class GeoprocessPointSelectionListener extends PointSelectionListener { |
24 |
|
25 |
/**
|
26 |
* Listener constructor with a given {@link MapControl}.
|
27 |
*
|
28 |
* @param mapControl
|
29 |
* to use to get the points from
|
30 |
*/
|
31 |
public GeoprocessPointSelectionListener(MapControl mapControl) {
|
32 |
super(mapControl);
|
33 |
} |
34 |
|
35 |
public void point(final PointEvent event) throws BehaviorException { |
36 |
Point2D point = event.getPoint();
|
37 |
Point2D mapPoint = mapCtrl.getViewPort().toMapPoint(point);
|
38 |
|
39 |
String pointName =
|
40 |
JOptionPane.showInputDialog(
|
41 |
null,
|
42 |
"X: " + Double.toString(mapPoint.getX()) + "\n" + "Y: " |
43 |
+ Double.toString(mapPoint.getY()) + "\n" |
44 |
+ Messages.getText("Point_name") + ":", |
45 |
Messages.getText("New_point"));
|
46 |
|
47 |
if (pointName != null) { |
48 |
NamedPoint namedPoint = new NamedPoint(pointName, mapPoint);
|
49 |
SextanteGUI.getGUIFactory().getCoordinatesList().add(namedPoint); |
50 |
} |
51 |
} |
52 |
} |