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 @ 245
History | View | Annotate | Download (2.71 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2012 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.geoprocess.extension; |
25 |
|
26 |
import java.awt.geom.Point2D; |
27 |
|
28 |
import javax.swing.JOptionPane; |
29 |
|
30 |
import es.unex.sextante.gui.core.NamedPoint; |
31 |
import es.unex.sextante.gui.core.SextanteGUI; |
32 |
|
33 |
import org.gvsig.fmap.mapcontrol.MapControl; |
34 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
35 |
import org.gvsig.fmap.mapcontrol.tools.PointSelectionListener; |
36 |
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent; |
37 |
import org.gvsig.i18n.Messages; |
38 |
|
39 |
/**
|
40 |
* Tool to collect points over the gvSIG view document window, to be used
|
41 |
* in the geoprocess parameters extension definition.
|
42 |
*
|
43 |
* @author gvSIG Team
|
44 |
* @version $Id$
|
45 |
*/
|
46 |
public class GeoprocessPointSelectionListener extends PointSelectionListener { |
47 |
|
48 |
/**
|
49 |
* Listener constructor with a given {@link MapControl}.
|
50 |
*
|
51 |
* @param mapControl
|
52 |
* to use to get the points from
|
53 |
*/
|
54 |
public GeoprocessPointSelectionListener(MapControl mapControl) {
|
55 |
super(mapControl);
|
56 |
} |
57 |
|
58 |
public void point(final PointEvent event) throws BehaviorException { |
59 |
Point2D point = event.getPoint();
|
60 |
Point2D mapPoint = mapCtrl.getViewPort().toMapPoint(point);
|
61 |
|
62 |
// TODO: create an andami dialog window.
|
63 |
String pointName =
|
64 |
JOptionPane.showInputDialog(
|
65 |
null,
|
66 |
"X: " + Double.toString(mapPoint.getX()) + "\n" + "Y: " |
67 |
+ Double.toString(mapPoint.getY()) + "\n" |
68 |
+ Messages.getText("Point_name") + ":", |
69 |
Messages.getText("New_point"));
|
70 |
|
71 |
if (pointName != null) { |
72 |
NamedPoint namedPoint = new NamedPoint(pointName, mapPoint);
|
73 |
SextanteGUI.getGUIFactory().getCoordinatesList().add(namedPoint); |
74 |
} |
75 |
} |
76 |
} |