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 / GeoprocessPointSelectionExtension.java @ 245
History | View | Annotate | Download (2.7 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 org.gvsig.andami.plugins.Extension; |
27 |
import org.gvsig.app.ApplicationLocator; |
28 |
import org.gvsig.app.ApplicationManager; |
29 |
import org.gvsig.app.project.documents.view.gui.IView; |
30 |
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener; |
31 |
import org.gvsig.fmap.mapcontrol.MapControl; |
32 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
33 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseMovementBehavior; |
34 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior; |
35 |
|
36 |
/**
|
37 |
* Collector of points over the gvSIG view document window, to be used
|
38 |
* in the geoprocess parameters extension definition.
|
39 |
*
|
40 |
* @author gvSIG Team
|
41 |
* @version $Id$
|
42 |
*/
|
43 |
public class GeoprocessPointSelectionExtension extends Extension { |
44 |
|
45 |
private final static String TOOL_NAME = "GeoprocessingPointSelector"; |
46 |
private ApplicationManager manager;
|
47 |
|
48 |
public void initialize() { |
49 |
manager = ApplicationLocator.getManager(); |
50 |
} |
51 |
|
52 |
public void execute(final String s) { |
53 |
MapControl mapControl = |
54 |
((IView) manager.getActiveWindow()).getMapControl(); |
55 |
GeoprocessPointSelectionListener pointSelectorListener = |
56 |
new GeoprocessPointSelectionListener(mapControl);
|
57 |
StatusBarListener listener = new StatusBarListener(mapControl);
|
58 |
mapControl.addBehavior(TOOL_NAME, new Behavior[] { |
59 |
new PointBehavior(pointSelectorListener),
|
60 |
new MouseMovementBehavior(listener) });
|
61 |
mapControl.setTool(TOOL_NAME); |
62 |
} |
63 |
|
64 |
public boolean isEnabled() { |
65 |
return manager.getActiveWindow() instanceof IView; |
66 |
} |
67 |
|
68 |
public boolean isVisible() { |
69 |
return manager.getActiveWindow() instanceof IView; |
70 |
} |
71 |
} |