Revision 39192
tags/v2_0_0_Build_2057/extensions/org.gvsig.selectiontools.app/README.txt | ||
---|---|---|
1 |
The first time you checkout the current project to a new workspace, |
|
2 |
you have to prepare it to be able to work easily with maven from |
|
3 |
eclipse itself. |
|
4 |
|
|
5 |
Perform the following steps: |
|
6 |
|
|
7 |
1.- Launch the *prepare-workspace.xml* ant build file. |
|
8 |
You can do it by loading the file into the ant view, |
|
9 |
and running the default task, or right-clicking the |
|
10 |
file from the package explorer or the navigator and |
|
11 |
select the option: *Run as > Ant build*. |
|
12 |
|
|
13 |
2.- Restart eclipse. |
|
14 |
|
|
15 |
3.- Import the subprojects of the project you have just checked out. |
|
16 |
|
|
17 |
Those steps are only needed once per workspace. |
|
18 |
|
|
0 | 19 |
tags/v2_0_0_Build_2057/extensions/org.gvsig.selectiontools.app/distribution/distribution.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
</assembly> |
|
0 | 3 |
tags/v2_0_0_Build_2057/extensions/org.gvsig.selectiontools.app/buildNumber.properties | ||
---|---|---|
1 |
#maven.buildNumber.plugin properties file |
|
2 |
#Mon Nov 05 17:12:03 CET 2012 |
|
3 |
buildNumber=2076 |
tags/v2_0_0_Build_2057/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/distribution/distribution.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>distribution</id> |
|
3 |
<formats> |
|
4 |
<format>dir</format> |
|
5 |
</formats> |
|
6 |
<fileSets> |
|
7 |
<!-- Estructure for the extension --> |
|
8 |
<fileSet> |
|
9 |
<directory>src/main/resources</directory> |
|
10 |
<outputDirectory>${extension.install.dir.name} |
|
11 |
</outputDirectory> |
|
12 |
</fileSet> |
|
13 |
</fileSets> |
|
14 |
<files> |
|
15 |
<file> |
|
16 |
<source>package.info</source> |
|
17 |
<outputDirectory>${extension.install.dir.name} |
|
18 |
</outputDirectory> |
|
19 |
</file> |
|
20 |
</files> |
|
21 |
<dependencySets> |
|
22 |
<dependencySet> |
|
23 |
<outputDirectory>${extension.install.dir.name}/${library-dir} |
|
24 |
</outputDirectory> |
|
25 |
<includes> |
|
26 |
<include>org.gvsig:org.gvsig.selectiontools.app.extension</include> |
|
27 |
</includes> |
|
28 |
</dependencySet> |
|
29 |
</dependencySets> |
|
30 |
</assembly> |
|
0 | 31 |
tags/v2_0_0_Build_2057/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/buildNumber.properties | ||
---|---|---|
1 |
#maven.buildNumber.plugin properties file |
|
2 |
#Mon Nov 05 17:12:03 CET 2012 |
|
3 |
buildNumber=2068 |
tags/v2_0_0_Build_2057/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/test/resources/README.txt | ||
---|---|---|
1 |
Put into this folder the resources needed by your test classes. |
|
2 |
|
|
3 |
This folder is added to the Tests classpath, so you can load any resources |
|
4 |
through the ClassLoader. |
|
5 |
|
|
6 |
By default, in this folder you can find an example of log4j configuration, |
|
7 |
prepared to log messages through the console, so logging works when you |
|
8 |
run your tests classes. |
|
0 | 9 |
tags/v2_0_0_Build_2057/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/test/resources/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1" ?> |
|
2 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
3 |
|
|
4 |
<!-- |
|
5 |
Log4J configuration file for unit tests execution. |
|
6 |
--> |
|
7 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
8 |
|
|
9 |
<!-- Appender configuration to show logging messages through the console --> |
|
10 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
11 |
<layout class="org.apache.log4j.PatternLayout"> |
|
12 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
13 |
</layout> |
|
14 |
</appender> |
|
15 |
|
|
16 |
<!-- |
|
17 |
Activate logging messages of DEBUG level of higher only for the |
|
18 |
org.gvsig.tools packages. |
|
19 |
You can put full classes names or packages instead, to configure |
|
20 |
logging for all the classes and subpackages of the package. |
|
21 |
--> |
|
22 |
<category name="org.gvsig.tools"> |
|
23 |
<priority value="DEBUG" /> |
|
24 |
</category> |
|
25 |
<category name="org.gvsig.selectiontools"> |
|
26 |
<priority value="DEBUG" /> |
|
27 |
</category> |
|
28 |
|
|
29 |
<!-- |
|
30 |
By default, show only logging messages of INFO level or higher, |
|
31 |
through the previously configured CONSOLE appender. |
|
32 |
--> |
|
33 |
<root> |
|
34 |
<priority value="INFO" /> |
|
35 |
<appender-ref ref="CONSOLE" /> |
|
36 |
</root> |
|
37 |
</log4j:configuration> |
|
0 | 38 |
tags/v2_0_0_Build_2057/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/resources/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<plugin-config> |
|
3 |
<depends plugin-name="org.gvsig.app" /> |
|
4 |
<resourceBundle name="text"/> |
|
5 |
<libraries library-dir="lib"/> |
|
6 |
<extensions> |
|
7 |
|
|
8 |
<!-- <extension class-name="org.gvsig.selectiontools.app.extension.AboutSelectionToolsExtension" --> |
|
9 |
<!-- description="Extension Selection Tools of the Consejer?a de Medio Ambiente of the Junta de Castilla y Le?n Project." --> |
|
10 |
<!-- active="true" --> |
|
11 |
<!-- priority="1"> --> |
|
12 |
<!-- </extension> --> |
|
13 |
|
|
14 |
<extension class-name="org.gvsig.selectiontools.app.extension.SelectAllExtension" |
|
15 |
description="Extension that allows select all geometries of the selected vectorial layers." |
|
16 |
active="true" |
|
17 |
priority="30"> |
|
18 |
<menu text="Selection/SelectAll" |
|
19 |
action-command="SELALL" |
|
20 |
tooltip="SelectAll" |
|
21 |
icon="selection-select-all" |
|
22 |
position="300400000"/> |
|
23 |
<tool-bar name="Tools_Select" position="6"> |
|
24 |
<selectable-tool icon="selection-select-all" action-command="SELALL" tooltip="SelectAll" position="7"/> |
|
25 |
</tool-bar> |
|
26 |
</extension> |
|
27 |
<extension class-name="org.gvsig.selectiontools.app.extension.SelectByCircleExtension" |
|
28 |
description="Extension that allows select all geometries of the selected vectorial layers that are contained or intersect with a circle defined by the user." |
|
29 |
active="true" |
|
30 |
priority="30"> |
|
31 |
<menu text="Selection/Select_by_circle" |
|
32 |
action-command="SELCIRCLE" |
|
33 |
tooltip="Select_by_circle" |
|
34 |
icon="selection-select-by-circle" |
|
35 |
position="301000000"/> |
|
36 |
<tool-bar name="Tools_Select" position="6"> |
|
37 |
<selectable-tool icon="selection-select-by-circle" action-command="SELCIRCLE" tooltip="Select_by_circle" position="6"/> |
|
38 |
</tool-bar> |
|
39 |
</extension> |
|
40 |
<extension class-name="org.gvsig.selectiontools.app.extension.SelectByPolylineExtension" |
|
41 |
description="Extension that allows select all geometries of the selected vectorial layers that intersect with a polyline defined by the user." |
|
42 |
active="false" |
|
43 |
priority="30"> |
|
44 |
<menu text="Selection/Select_by_polyline" |
|
45 |
action-command="SELPOLYLINE" |
|
46 |
tooltip="Select_by_polyline" |
|
47 |
icon="selection-select-by-polyline" |
|
48 |
position="301300000"/> |
|
49 |
<tool-bar name="Tools_Select" position="6"> |
|
50 |
<selectable-tool icon="selection-select-by-polyline" action-command="SELPOLYLINE" tooltip="Select_by_polyline" position="5"/> |
|
51 |
</tool-bar> |
|
52 |
</extension> |
|
53 |
|
|
54 |
<extension class-name="org.gvsig.selectiontools.app.extension.SelectByBufferExtension" |
|
55 |
description="Extension that allows select all geometries of the selected vectorial layers that intersect with a buffer around their previously selected geometries." |
|
56 |
active="true" |
|
57 |
priority="30"> |
|
58 |
<menu text="Selection/Select_by_buffer" |
|
59 |
action-command="SELBUFFER" |
|
60 |
tooltip="Select_by_buffer" |
|
61 |
icon="selection-select-by-buffer" |
|
62 |
position="300900000"/> |
|
63 |
<tool-bar name="Tools_Select" position="6"> |
|
64 |
<action-tool icon="selection-select-by-buffer" action-command="SELBUFFER" tooltip="Select_by_buffer" position="7"/> |
|
65 |
</tool-bar> |
|
66 |
</extension> |
|
67 |
|
|
68 |
</extensions> |
|
69 |
</plugin-config> |
|
0 | 70 |
tags/v2_0_0_Build_2057/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/SelectByBufferExtension.java | ||
---|---|---|
1 |
package org.gvsig.selectiontools.app.extension; |
|
2 |
|
|
3 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
4 |
* |
|
5 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
6 |
* of the Valencian Government (CIT) |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
* MA 02110-1301, USA. |
|
22 |
* |
|
23 |
*/ |
|
24 |
|
|
25 |
import java.util.ArrayList; |
|
26 |
|
|
27 |
import javax.swing.JOptionPane; |
|
28 |
|
|
29 |
import org.gvsig.andami.IconThemeHelper; |
|
30 |
import org.gvsig.andami.PluginServices; |
|
31 |
import org.gvsig.andami.plugins.Extension; |
|
32 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
33 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
34 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
35 |
import org.gvsig.fmap.dal.exception.DataException; |
|
36 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
37 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
38 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
39 |
import org.gvsig.selectiontools.app.extension.tools.buffer.gui.BufferConfigurationPanel; |
|
40 |
|
|
41 |
/** |
|
42 |
* <p> |
|
43 |
* Extension to add support for selecting the geometries of the active vector |
|
44 |
* layers that intersect with a buffer around their previously selected |
|
45 |
* geometries. |
|
46 |
* </p> |
|
47 |
* |
|
48 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
49 |
*/ |
|
50 |
public class SelectByBufferExtension extends Extension { |
|
51 |
|
|
52 |
public static final String BUFFER_SELECTION_TOOL_NAME = "bufferSelection"; |
|
53 |
|
|
54 |
/* |
|
55 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
56 |
*/ |
|
57 |
public void initialize() { |
|
58 |
IconThemeHelper.registerIcon("action", "selection-select-by-buffer", this); |
|
59 |
IconThemeHelper.registerIcon("cursor", "cursor-select-by-buffer", this); |
|
60 |
} |
|
61 |
|
|
62 |
/* |
|
63 |
* (non-Javadoc) |
|
64 |
* |
|
65 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String) |
|
66 |
*/ |
|
67 |
public void execute(String actionCommand) { |
|
68 |
if (actionCommand.equals("SELBUFFER")) { |
|
69 |
IWindow win = PluginServices.getMDIManager().getActiveWindow(); |
|
70 |
|
|
71 |
if (win instanceof IView) { |
|
72 |
IView view = (IView) win; |
|
73 |
ViewDocument model = view.getViewDocument(); |
|
74 |
|
|
75 |
/* |
|
76 |
* Unavaliable tool with views in geographic projections |
|
77 |
*/ |
|
78 |
if (!view.getMapControl().getProjection().isProjected()) { |
|
79 |
JOptionPane.showMessageDialog(null, |
|
80 |
PluginServices.getText(null, |
|
81 |
"Tool_unavaliable_with_view_in_geographic_projection"), |
|
82 |
PluginServices.getText(this, "Warning"), |
|
83 |
JOptionPane.ERROR_MESSAGE); |
|
84 |
return; |
|
85 |
} |
|
86 |
|
|
87 |
MapContext mapContext = model.getMapContext(); |
|
88 |
|
|
89 |
// If there is at least one active vector layer that has |
|
90 |
// geometries selected -> can use this tool, otherwise notifies |
|
91 |
// the |
|
92 |
// limitation in a JOptionPane |
|
93 |
FLayer layers[] = mapContext.getLayers().getActives(); |
|
94 |
FLayer layer; |
|
95 |
ArrayList<FLyrVect> usefulLayers = new ArrayList<FLyrVect>(); |
|
96 |
int emptySelectionLayers = 0; |
|
97 |
|
|
98 |
for (int i = 0; i < layers.length; i++) { |
|
99 |
layer = layers[i]; |
|
100 |
|
|
101 |
if ((layer instanceof FLyrVect) && (layer.isAvailable()) |
|
102 |
&& (layer.isActive())) { |
|
103 |
usefulLayers.add((FLyrVect) layer); |
|
104 |
try { |
|
105 |
if (((FLyrVect) layer).getFeatureStore() |
|
106 |
.getFeatureSelection() |
|
107 |
.isEmpty()) { |
|
108 |
emptySelectionLayers++; |
|
109 |
} |
|
110 |
} catch (DataException e) { |
|
111 |
JOptionPane.showMessageDialog(null, |
|
112 |
PluginServices.getText(null, |
|
113 |
"Failed_selecting_layer") |
|
114 |
+ ": " |
|
115 |
+ layer.getName(), |
|
116 |
PluginServices.getText(null, "Warning"), |
|
117 |
JOptionPane.WARNING_MESSAGE); |
|
118 |
} |
|
119 |
} |
|
120 |
} |
|
121 |
|
|
122 |
if (usefulLayers.size() == 0 |
|
123 |
|| emptySelectionLayers == usefulLayers.size()) { |
|
124 |
JOptionPane.showMessageDialog(null, |
|
125 |
PluginServices.getText(null, |
|
126 |
"There_are_no_geometries_selected"), |
|
127 |
PluginServices.getText(null, "Warning"), |
|
128 |
JOptionPane.WARNING_MESSAGE); |
|
129 |
|
|
130 |
return; |
|
131 |
} |
|
132 |
|
|
133 |
// Creates and displays the configuration panel |
|
134 |
PluginServices.getMDIManager() |
|
135 |
.addWindow(new BufferConfigurationPanel((FLyrVect[]) usefulLayers.toArray(new FLyrVect[0]), |
|
136 |
view)); |
|
137 |
} |
|
138 |
} |
|
139 |
} |
|
140 |
|
|
141 |
/* |
|
142 |
* @see com.iver.andami.plugins.IExtension#isVisible() |
|
143 |
*/ |
|
144 |
public boolean isVisible() { |
|
145 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
146 |
|
|
147 |
if (f == null) { |
|
148 |
return false; |
|
149 |
} |
|
150 |
|
|
151 |
if (f instanceof IView) { |
|
152 |
IView vista = (IView) f; |
|
153 |
ViewDocument model = vista.getViewDocument(); |
|
154 |
MapContext mapa = model.getMapContext(); |
|
155 |
|
|
156 |
return mapa.getLayers().getLayersCount() > 0; |
|
157 |
} |
|
158 |
|
|
159 |
return false; |
|
160 |
} |
|
161 |
|
|
162 |
/* |
|
163 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
164 |
*/ |
|
165 |
public boolean isEnabled() { |
|
166 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
167 |
|
|
168 |
if (f == null) { |
|
169 |
return false; |
|
170 |
} |
|
171 |
|
|
172 |
if (f instanceof IView) { |
|
173 |
IView vista = (IView) f; |
|
174 |
ViewDocument model = vista.getViewDocument(); |
|
175 |
|
|
176 |
/* |
|
177 |
* Unavaliable tool with views in geographic projections |
|
178 |
*/ |
|
179 |
if (!(vista.getMapControl().getProjection().isProjected())) { |
|
180 |
return false; |
|
181 |
} |
|
182 |
|
|
183 |
MapContext mapa = model.getMapContext(); |
|
184 |
|
|
185 |
FLayer layers[] = mapa.getLayers().getActives(); |
|
186 |
FLayer layer; |
|
187 |
|
|
188 |
for (int i = 0; i < layers.length; i++) { |
|
189 |
layer = layers[i]; |
|
190 |
|
|
191 |
if ((layer instanceof FLyrVect) && (layer.isAvailable()) |
|
192 |
&& (layer.isActive())) |
|
193 |
return true; |
|
194 |
} |
|
195 |
} |
|
196 |
|
|
197 |
return false; |
|
198 |
} |
|
199 |
} |
|
0 | 200 |
tags/v2_0_0_Build_2057/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/SelectByPolylineExtension.java | ||
---|---|---|
1 |
package org.gvsig.selectiontools.app.extension; |
|
2 |
|
|
3 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
4 |
* |
|
5 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
6 |
* of the Valencian Government (CIT) |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
* MA 02110-1301, USA. |
|
22 |
* |
|
23 |
*/ |
|
24 |
|
|
25 |
import org.gvsig.andami.IconThemeHelper; |
|
26 |
import org.gvsig.andami.PluginServices; |
|
27 |
import org.gvsig.andami.plugins.Extension; |
|
28 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
29 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
30 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
31 |
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener; |
|
32 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
33 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
34 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
35 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
36 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
|
37 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseMovementBehavior; |
|
38 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.PolylineBehavior; |
|
39 |
import org.gvsig.selectiontools.app.extension.tools.PolyLineSelectListener; |
|
40 |
|
|
41 |
/** |
|
42 |
* <p> |
|
43 |
* Extension to add support for selecting the geometries of the active vector |
|
44 |
* layers that intersect with a polyline defined by the user. |
|
45 |
* </p> |
|
46 |
* |
|
47 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
48 |
*/ |
|
49 |
public class SelectByPolylineExtension extends Extension { |
|
50 |
|
|
51 |
public static final String POLYLINE_SELECTION_TOOL_NAME = |
|
52 |
"polylineSelection"; |
|
53 |
|
|
54 |
/* |
|
55 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
56 |
*/ |
|
57 |
public void initialize() { |
|
58 |
IconThemeHelper.registerIcon("action", "selection-select-by-polyline", this); |
|
59 |
IconThemeHelper.registerIcon("cursor", "cursor-select-by-polyline", this); |
|
60 |
} |
|
61 |
|
|
62 |
/* |
|
63 |
* (non-Javadoc) |
|
64 |
* |
|
65 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String) |
|
66 |
*/ |
|
67 |
public void execute(String actionCommand) { |
|
68 |
if (actionCommand.equals("SELPOLYLINE")) { |
|
69 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
70 |
if (window instanceof IView) { |
|
71 |
IView view = (IView) window; |
|
72 |
// Selection by polyline |
|
73 |
MapControl mc = view.getMapControl(); |
|
74 |
|
|
75 |
// If current's view MapControl doesn't have the |
|
76 |
// "CircleSelection" tool, adds it |
|
77 |
if (!mc.getNamesMapTools() |
|
78 |
.containsKey(POLYLINE_SELECTION_TOOL_NAME)) { |
|
79 |
PolyLineSelectListener polylineSelListener = |
|
80 |
new PolyLineSelectListener(mc); |
|
81 |
mc.addBehavior(POLYLINE_SELECTION_TOOL_NAME, |
|
82 |
new Behavior[] { |
|
83 |
new PolylineBehavior(polylineSelListener), |
|
84 |
new MouseMovementBehavior(new StatusBarListener(mc)) }); |
|
85 |
} |
|
86 |
|
|
87 |
mc.setTool(POLYLINE_SELECTION_TOOL_NAME); |
|
88 |
} |
|
89 |
} |
|
90 |
} |
|
91 |
|
|
92 |
/* |
|
93 |
* @see com.iver.andami.plugins.IExtension#isVisible() |
|
94 |
*/ |
|
95 |
public boolean isVisible() { |
|
96 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
97 |
|
|
98 |
if (f == null) { |
|
99 |
return false; |
|
100 |
} |
|
101 |
|
|
102 |
if (f instanceof IView) { |
|
103 |
IView vista = (IView) f; |
|
104 |
ViewDocument model = vista.getViewDocument(); |
|
105 |
MapContext mapa = model.getMapContext(); |
|
106 |
|
|
107 |
return mapa.getLayers().getLayersCount() > 0; |
|
108 |
} |
|
109 |
|
|
110 |
return false; |
|
111 |
} |
|
112 |
|
|
113 |
/* |
|
114 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
115 |
*/ |
|
116 |
public boolean isEnabled() { |
|
117 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
118 |
|
|
119 |
if (f == null) { |
|
120 |
return false; |
|
121 |
} |
|
122 |
|
|
123 |
if (f instanceof IView) { |
|
124 |
IView vista = (IView) f; |
|
125 |
ViewDocument model = vista.getViewDocument(); |
|
126 |
MapContext mapa = model.getMapContext(); |
|
127 |
|
|
128 |
FLayer layers[] = mapa.getLayers().getActives(); |
|
129 |
FLayer layer; |
|
130 |
|
|
131 |
for (int i = 0; i < layers.length; i++) { |
|
132 |
layer = layers[i]; |
|
133 |
|
|
134 |
if ((layer instanceof FLyrVect) && (layer.isAvailable()) |
|
135 |
&& (layer.isActive())) |
|
136 |
return true; |
|
137 |
} |
|
138 |
} |
|
139 |
|
|
140 |
return false; |
|
141 |
} |
|
142 |
} |
|
0 | 143 |
tags/v2_0_0_Build_2057/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/SelectAllExtension.java | ||
---|---|---|
1 |
package org.gvsig.selectiontools.app.extension; |
|
2 |
|
|
3 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
4 |
* |
|
5 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
6 |
* of the Valencian Government (CIT) |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
* MA 02110-1301, USA. |
|
22 |
* |
|
23 |
*/ |
|
24 |
|
|
25 |
import org.gvsig.andami.IconThemeHelper; |
|
26 |
import org.gvsig.andami.PluginServices; |
|
27 |
import org.gvsig.andami.messages.NotificationManager; |
|
28 |
import org.gvsig.andami.plugins.Extension; |
|
29 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
30 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
31 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
32 |
import org.gvsig.fmap.dal.exception.DataException; |
|
33 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
34 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
35 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
36 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
37 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
38 |
|
|
39 |
/** |
|
40 |
* <p> |
|
41 |
* Extension to add support for selecting all the features of a vector layer. |
|
42 |
* </p> |
|
43 |
* |
|
44 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
45 |
*/ |
|
46 |
public class SelectAllExtension extends Extension { |
|
47 |
|
|
48 |
/* |
|
49 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
50 |
*/ |
|
51 |
public void initialize() { |
|
52 |
IconThemeHelper.registerIcon("action", "selection-select-all", this); |
|
53 |
} |
|
54 |
|
|
55 |
/* |
|
56 |
* (non-Javadoc) |
|
57 |
* |
|
58 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String) |
|
59 |
*/ |
|
60 |
public void execute(String actionCommand) { |
|
61 |
if (actionCommand.equals("SELALL")) { |
|
62 |
IWindow view = PluginServices.getMDIManager().getActiveWindow(); |
|
63 |
if (view instanceof IView) { |
|
64 |
MapControl mc = ((IView) view).getMapControl(); |
|
65 |
FLayer[] activeLayers = |
|
66 |
mc.getMapContext().getLayers().getActives(); |
|
67 |
|
|
68 |
FLayer layer; |
|
69 |
|
|
70 |
for (int i = 0; i < activeLayers.length; i++) { |
|
71 |
layer = activeLayers[i]; |
|
72 |
|
|
73 |
if ((layer.isAvailable()) && (layer instanceof FLyrVect)) { |
|
74 |
FLyrVect lyrVect = (FLyrVect) layer; |
|
75 |
|
|
76 |
try { |
|
77 |
FeatureStore fs = lyrVect.getFeatureStore(); |
|
78 |
fs.getFeatureSelection().selectAll(); |
|
79 |
} catch (DataException e) { |
|
80 |
NotificationManager.showMessageError("Data exception", |
|
81 |
e); |
|
82 |
} |
|
83 |
} |
|
84 |
} |
|
85 |
} |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
89 |
/* |
|
90 |
* @see com.iver.andami.plugins.IExtension#isVisible() |
|
91 |
*/ |
|
92 |
public boolean isVisible() { |
|
93 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
94 |
|
|
95 |
if (f == null) { |
|
96 |
return false; |
|
97 |
} |
|
98 |
|
|
99 |
if (f instanceof IView) { |
|
100 |
IView vista = (IView) f; |
|
101 |
ViewDocument viewDocument = vista.getViewDocument(); // .getModel(); |
|
102 |
MapContext mapa = viewDocument.getMapContext(); |
|
103 |
|
|
104 |
return mapa.getLayers().getLayersCount() > 0; |
|
105 |
} |
|
106 |
|
|
107 |
return false; |
|
108 |
} |
|
109 |
|
|
110 |
/* |
|
111 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
112 |
*/ |
|
113 |
public boolean isEnabled() { |
|
114 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
115 |
|
|
116 |
if (f == null) { |
|
117 |
return false; |
|
118 |
} |
|
119 |
|
|
120 |
if (f instanceof IView) { |
|
121 |
IView vista = (IView) f; |
|
122 |
ViewDocument viewDocument = vista.getViewDocument(); |
|
123 |
MapContext mapa = viewDocument.getMapContext(); |
|
124 |
|
|
125 |
FLayer layers[] = mapa.getLayers().getActives(); |
|
126 |
FLayer layer; |
|
127 |
|
|
128 |
for (int i = 0; i < layers.length; i++) { |
|
129 |
layer = layers[i]; |
|
130 |
|
|
131 |
if ((layer instanceof FLyrVect) && (layer.isAvailable()) |
|
132 |
&& (layer.isActive())) |
|
133 |
return true; |
|
134 |
} |
|
135 |
} |
|
136 |
|
|
137 |
return false; |
|
138 |
} |
|
139 |
} |
|
0 | 140 |
tags/v2_0_0_Build_2057/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/SelectByCircleExtension.java | ||
---|---|---|
1 |
package org.gvsig.selectiontools.app.extension; |
|
2 |
|
|
3 |
import org.gvsig.andami.IconThemeHelper; |
|
4 |
import org.gvsig.andami.PluginServices; |
|
5 |
import org.gvsig.andami.plugins.Extension; |
|
6 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
7 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
8 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
9 |
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener; |
|
10 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
11 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
12 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
13 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
14 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
|
15 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseMovementBehavior; |
|
16 |
import org.gvsig.selectiontools.app.extension.tools.CircleSelectListener; |
|
17 |
import org.gvsig.selectiontools.app.extension.tools.behavior.CircleSelectionBehavior; |
|
18 |
|
|
19 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
20 |
* |
|
21 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
22 |
* of the Valencian Government (CIT) |
|
23 |
* |
|
24 |
* This program is free software; you can redistribute it and/or |
|
25 |
* modify it under the terms of the GNU General Public License |
|
26 |
* as published by the Free Software Foundation; either version 2 |
|
27 |
* of the License, or (at your option) any later version. |
|
28 |
* |
|
29 |
* This program is distributed in the hope that it will be useful, |
|
30 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
31 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
32 |
* GNU General Public License for more details. |
|
33 |
* |
|
34 |
* You should have received a copy of the GNU General Public License |
|
35 |
* along with this program; if not, write to the Free Software |
|
36 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
37 |
* MA 02110-1301, USA. |
|
38 |
* |
|
39 |
*/ |
|
40 |
|
|
41 |
/** |
|
42 |
* <p> |
|
43 |
* Extension to add support for selecting the geometries of the active vector |
|
44 |
* layers that intersect with a circle defined by the user. |
|
45 |
* </p> |
|
46 |
* |
|
47 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
48 |
*/ |
|
49 |
public class SelectByCircleExtension extends Extension { |
|
50 |
|
|
51 |
public static final String CIRCLE_SELECTION_TOOL_NAME = "circleSelection"; |
|
52 |
|
|
53 |
/* |
|
54 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
55 |
*/ |
|
56 |
public void initialize() { |
|
57 |
IconThemeHelper.registerIcon("action", "selection-select-by-circle", this); |
|
58 |
IconThemeHelper.registerIcon("cursor", "cursor-select-by-circle", this); |
|
59 |
} |
|
60 |
|
|
61 |
/* |
|
62 |
* (non-Javadoc) |
|
63 |
* |
|
64 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String) |
|
65 |
*/ |
|
66 |
public void execute(String actionCommand) { |
|
67 |
if (actionCommand.equals("SELCIRCLE")) { |
|
68 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
69 |
if (window instanceof IView) { |
|
70 |
IView view = (IView) window; |
|
71 |
// Selection by circle |
|
72 |
MapControl mc = view.getMapControl(); |
|
73 |
|
|
74 |
// If current's view MapControl doesn't have the |
|
75 |
// "CircleSelection" tool, adds it |
|
76 |
if (!mc.getNamesMapTools() |
|
77 |
.containsKey(CIRCLE_SELECTION_TOOL_NAME)) { |
|
78 |
CircleSelectListener circleSelListener = |
|
79 |
new CircleSelectListener(mc); |
|
80 |
mc.addBehavior(CIRCLE_SELECTION_TOOL_NAME, new Behavior[] { |
|
81 |
new CircleSelectionBehavior(circleSelListener), |
|
82 |
new MouseMovementBehavior(new StatusBarListener(mc)) }); |
|
83 |
} |
|
84 |
|
|
85 |
mc.setTool(CIRCLE_SELECTION_TOOL_NAME); |
|
86 |
} |
|
87 |
} |
|
88 |
} |
|
89 |
|
|
90 |
/* |
|
91 |
* @see com.iver.andami.plugins.IExtension#isVisible() |
|
92 |
*/ |
|
93 |
public boolean isVisible() { |
|
94 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
95 |
|
|
96 |
if (f == null) { |
|
97 |
return false; |
|
98 |
} |
|
99 |
|
|
100 |
if (f instanceof IView) { |
|
101 |
IView vista = (IView) f; |
|
102 |
ViewDocument model = vista.getViewDocument(); |
|
103 |
MapContext mapa = model.getMapContext(); |
|
104 |
|
|
105 |
return mapa.getLayers().getLayersCount() > 0; |
|
106 |
} |
|
107 |
|
|
108 |
return false; |
|
109 |
} |
|
110 |
|
|
111 |
/* |
|
112 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
113 |
*/ |
|
114 |
public boolean isEnabled() { |
|
115 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
116 |
|
|
117 |
if (f == null) { |
|
118 |
return false; |
|
119 |
} |
|
120 |
|
|
121 |
if (f instanceof IView) { |
|
122 |
IView vista = (IView) f; |
|
123 |
ViewDocument model = vista.getViewDocument(); |
|
124 |
MapContext mapa = model.getMapContext(); |
|
125 |
|
|
126 |
FLayer layers[] = mapa.getLayers().getActives(); |
|
127 |
FLayer layer; |
|
128 |
|
|
129 |
for (int i = 0; i < layers.length; i++) { |
|
130 |
layer = layers[i]; |
|
131 |
|
|
132 |
if ((layer instanceof FLyrVect) && (layer.isAvailable()) |
|
133 |
&& (layer.isActive())) |
|
134 |
return true; |
|
135 |
} |
|
136 |
} |
|
137 |
|
|
138 |
return false; |
|
139 |
} |
|
140 |
} |
|
0 | 141 |
tags/v2_0_0_Build_2057/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/tools/behavior/CircleSelectionBehavior.java | ||
---|---|---|
1 |
package org.gvsig.selectiontools.app.extension.tools.behavior; |
|
2 |
|
|
3 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
4 |
* |
|
5 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
6 |
* of the Valencian Government (CIT) |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
* MA 02110-1301, USA. |
|
22 |
* |
|
23 |
*/ |
|
24 |
|
|
25 |
import java.awt.Color; |
|
26 |
import java.awt.Graphics; |
|
27 |
import java.awt.Graphics2D; |
|
28 |
import java.awt.Point; |
|
29 |
import java.awt.Rectangle; |
|
30 |
import java.awt.event.MouseEvent; |
|
31 |
import java.awt.geom.Arc2D; |
|
32 |
import java.awt.geom.Point2D; |
|
33 |
import java.awt.geom.Rectangle2D; |
|
34 |
import java.awt.image.BufferedImage; |
|
35 |
|
|
36 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
37 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
38 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.CircleBehavior; |
|
39 |
import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent; |
|
40 |
import org.gvsig.fmap.mapcontrol.tools.Listeners.CircleListener; |
|
41 |
|
|
42 |
/** |
|
43 |
* |
|
44 |
* |
|
45 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
46 |
*/ |
|
47 |
public class CircleSelectionBehavior extends CircleBehavior { |
|
48 |
|
|
49 |
/** |
|
50 |
* |
|
51 |
*/ |
|
52 |
private CircleListener listener; |
|
53 |
|
|
54 |
/** |
|
55 |
* Auxiliary point that represents a corner selected in image coordinates. |
|
56 |
*/ |
|
57 |
private Point2D m_PointAnt; |
|
58 |
|
|
59 |
public CircleSelectionBehavior(CircleListener zili) { |
|
60 |
super(zili); |
|
61 |
|
|
62 |
listener = zili; |
|
63 |
} |
|
64 |
|
|
65 |
/* |
|
66 |
* (non-Javadoc) |
|
67 |
* |
|
68 |
* @see |
|
69 |
* com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#paintComponent(java.awt |
|
70 |
* .Graphics) |
|
71 |
*/ |
|
72 |
public void paintComponent(Graphics g) { |
|
73 |
double radio; |
|
74 |
BufferedImage img = getMapControl().getImage(); |
|
75 |
g.drawImage(img, 0, 0, null); |
|
76 |
g.setColor(Color.black); |
|
77 |
g.setXORMode(Color.white); |
|
78 |
if ((m_FirstPoint != null) && (m_LastPoint != null)) { |
|
79 |
radio = m_LastPoint.distance(m_FirstPoint); |
|
80 |
Arc2D.Double arc = |
|
81 |
new Arc2D.Double(m_FirstPoint.getX() - radio, |
|
82 |
m_FirstPoint.getY() - radio, |
|
83 |
2 * radio, |
|
84 |
2 * radio, |
|
85 |
0, |
|
86 |
360, |
|
87 |
Arc2D.OPEN); |
|
88 |
|
|
89 |
((Graphics2D) g).draw(arc); |
|
90 |
} |
|
91 |
} |
|
92 |
|
|
93 |
/* |
|
94 |
* (non-Javadoc) |
|
95 |
* |
|
96 |
* @see |
|
97 |
* com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mousePressed(java.awt |
|
98 |
* .event.MouseEvent) |
|
99 |
*/ |
|
100 |
public void mousePressed(MouseEvent e) { |
|
101 |
|
|
102 |
Point pScreen = e.getPoint(); |
|
103 |
m_PointAnt = pScreen; |
|
104 |
|
|
105 |
if ((!isClicked) && (e.getButton() == MouseEvent.BUTTON1)) { |
|
106 |
m_PointAnt = pScreen; |
|
107 |
m_FirstPoint = m_PointAnt; |
|
108 |
isClicked = true; |
|
109 |
} |
|
110 |
|
|
111 |
if (listener.cancelDrawing()) { |
|
112 |
getMapControl().cancelDrawing(); |
|
113 |
isClicked = false; |
|
114 |
} |
|
115 |
getMapControl().repaint(); |
|
116 |
} |
|
117 |
|
|
118 |
/* |
|
119 |
* (non-Javadoc) |
|
120 |
* |
|
121 |
* @see |
|
122 |
* com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseReleased(java.awt |
|
123 |
* .event.MouseEvent) |
|
124 |
*/ |
|
125 |
public void mouseReleased(MouseEvent e) throws BehaviorException { |
|
126 |
if ((m_FirstPoint == null) || (m_LastPoint == null)) |
|
127 |
return; |
|
128 |
|
|
129 |
Point2D p1; |
|
130 |
Point2D p2; |
|
131 |
Point pScreen = e.getPoint(); |
|
132 |
|
|
133 |
ViewPort vp = getMapControl().getMapContext().getViewPort(); |
|
134 |
|
|
135 |
p1 = vp.toMapPoint(m_FirstPoint); |
|
136 |
p2 = vp.toMapPoint(pScreen); |
|
137 |
|
|
138 |
// Fijamos el nuevo extent |
|
139 |
Rectangle2D.Double r = new Rectangle2D.Double(); |
|
140 |
r.setFrameFromDiagonal(p1, p2); |
|
141 |
|
|
142 |
Rectangle2D rectPixel = new Rectangle(); |
|
143 |
rectPixel.setFrameFromDiagonal(m_FirstPoint, pScreen); |
|
144 |
|
|
145 |
Double[] x = new Double[2]; |
|
146 |
Double[] y = new Double[2]; |
|
147 |
x[0] = new Double(p1.getX()); |
|
148 |
x[1] = new Double(p2.getX()); |
|
149 |
y[0] = new Double(p1.getY()); |
|
150 |
y[1] = new Double(p2.getY()); |
|
151 |
MeasureEvent event = new MeasureEvent(x, y, e); |
|
152 |
listener.circle(event); |
|
153 |
getMapControl().repaint(); |
|
154 |
|
|
155 |
m_FirstPoint = null; |
|
156 |
m_LastPoint = null; |
|
157 |
isClicked = false; |
|
158 |
} |
|
159 |
|
|
160 |
/* |
|
161 |
* (non-Javadoc) |
|
162 |
* |
|
163 |
* @see |
|
164 |
* com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseDragged(java.awt |
|
165 |
* .event.MouseEvent) |
|
166 |
*/ |
|
167 |
public void mouseDragged(MouseEvent e) throws BehaviorException { |
|
168 |
mouseMoved(e); |
|
169 |
} |
|
170 |
|
|
171 |
/* |
|
172 |
* (non-Javadoc) |
|
173 |
* |
|
174 |
* @see |
|
175 |
* com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseMoved(java.awt.event |
|
176 |
* .MouseEvent) |
|
177 |
*/ |
|
178 |
public void mouseMoved(MouseEvent e) throws BehaviorException { |
|
179 |
if (!isClicked) |
|
180 |
return; |
|
181 |
|
|
182 |
m_LastPoint = e.getPoint(); |
|
183 |
|
|
184 |
if (m_FirstPoint == null) |
|
185 |
return; |
|
186 |
Point2D p1; |
|
187 |
Point2D p2; |
|
188 |
Point pScreen = e.getPoint(); |
|
189 |
|
|
190 |
ViewPort vp = getMapControl().getMapContext().getViewPort(); |
|
191 |
|
|
192 |
p1 = vp.toMapPoint(m_FirstPoint); |
|
193 |
p2 = vp.toMapPoint(pScreen); |
|
194 |
|
|
195 |
// Fijamos el nuevo extent |
|
196 |
Rectangle2D.Double r = new Rectangle2D.Double(); |
|
197 |
r.setFrameFromDiagonal(p1, p2); |
|
198 |
|
|
199 |
Rectangle2D rectPixel = new Rectangle(); |
|
200 |
rectPixel.setFrameFromDiagonal(m_FirstPoint, pScreen); |
|
201 |
|
|
202 |
Double[] x = new Double[2]; |
|
203 |
Double[] y = new Double[2]; |
|
204 |
x[0] = new Double(p1.getX()); |
|
205 |
x[1] = new Double(p2.getX()); |
|
206 |
y[0] = new Double(p1.getY()); |
|
207 |
y[1] = new Double(p2.getY()); |
|
208 |
MeasureEvent event = new MeasureEvent(x, y, e); |
|
209 |
listener.circle(event); |
|
210 |
getMapControl().repaint(); |
|
211 |
} |
|
212 |
} |
|
0 | 213 |
tags/v2_0_0_Build_2057/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/tools/PolyLineSelectListener.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 |
*/ |
|
22 |
|
|
23 |
package org.gvsig.selectiontools.app.extension.tools; |
|
24 |
|
|
25 |
import org.gvsig.andami.PluginServices; |
|
26 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
27 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
28 |
import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent; |
|
29 |
|
|
30 |
/** |
|
31 |
* |
|
32 |
* @version 06/04/2009 |
|
33 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
34 |
*/ |
|
35 |
public class PolyLineSelectListener extends PolyLineSelectionListener { |
|
36 |
|
|
37 |
public PolyLineSelectListener(MapControl mc) { |
|
38 |
super(mc); |
|
39 |
} |
|
40 |
|
|
41 |
public void polylineFinished(MeasureEvent event) throws BehaviorException { |
|
42 |
super.polylineFinished(event); |
|
43 |
PluginServices.getMainFrame().enableControls(); |
|
44 |
} |
|
45 |
} |
|
0 | 46 |
tags/v2_0_0_Build_2057/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/tools/CircleSelectListener.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 |
*/ |
|
22 |
|
|
23 |
package org.gvsig.selectiontools.app.extension.tools; |
|
24 |
|
|
25 |
import org.gvsig.andami.PluginServices; |
|
26 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
27 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
28 |
import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent; |
|
29 |
|
|
30 |
/** |
|
31 |
* |
|
32 |
* @version 06/04/2009 |
|
33 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
34 |
*/ |
|
35 |
public class CircleSelectListener extends CircleSelectionListener { |
|
36 |
|
|
37 |
public CircleSelectListener(MapControl mc) { |
|
38 |
super(mc); |
|
39 |
} |
|
40 |
|
|
41 |
public void circle(MeasureEvent event) throws BehaviorException { |
|
42 |
super.circle(event); |
|
43 |
PluginServices.getMainFrame().enableControls(); |
|
44 |
} |
|
45 |
} |
|
0 | 46 |
tags/v2_0_0_Build_2057/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/tools/PolyLineSelectionListener.java | ||
---|---|---|
1 |
package org.gvsig.selectiontools.app.extension.tools; |
|
2 |
|
|
3 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
4 |
* |
|
5 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
6 |
* of the Valencian Government (CIT) |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
* MA 02110-1301, USA. |
|
22 |
* |
|
23 |
*/ |
|
24 |
|
|
25 |
import java.awt.Cursor; |
|
26 |
import java.awt.Image; |
|
27 |
import java.awt.Point; |
|
28 |
import java.awt.Toolkit; |
|
29 |
|
|
30 |
import javax.swing.ImageIcon; |
|
31 |
|
|
32 |
import org.gvsig.andami.IconThemeHelper; |
|
33 |
import org.gvsig.andami.PluginServices; |
|
34 |
import org.gvsig.andami.messages.NotificationManager; |
|
35 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
36 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
37 |
import org.gvsig.fmap.geom.Geometry; |
|
38 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
39 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
40 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
41 |
import org.gvsig.fmap.geom.GeometryManager; |
|
42 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
43 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
44 |
import org.gvsig.fmap.geom.primitive.Surface; |
|
45 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
46 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
47 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
48 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
49 |
import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent; |
|
50 |
import org.gvsig.fmap.mapcontrol.tools.Listeners.PolylineListener; |
|
51 |
|
|
52 |
/** |
|
53 |
* <p> |
|
54 |
* Listener that selects all features of the active and vector layers which |
|
55 |
* intersect with the defined polyline in the associated {@link MapControl |
|
56 |
* MapControl} object. |
|
57 |
* </p> |
|
58 |
* |
|
59 |
* <p> |
|
60 |
* The selection will be produced after user finishes the creation of the |
|
61 |
* polyline. |
|
62 |
* </p> |
|
63 |
* |
|
64 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
65 |
*/ |
|
66 |
public class PolyLineSelectionListener implements PolylineListener { |
|
67 |
|
|
68 |
/** |
|
69 |
* The image to display when the cursor is active. |
|
70 |
*/ |
|
71 |
// private final Image img = PluginServices.getIconTheme().get("cursor-select-by-polygon").getImage(); |
|
72 |
|
|
73 |
/** |
|
74 |
* The cursor used to work with this tool listener. |
|
75 |
* |
|
76 |
* @see #getCursor() |
|
77 |
*/ |
|
78 |
private Cursor cur = null; |
|
79 |
|
|
80 |
/** |
|
81 |
* Reference to the <code>MapControl</code> object that uses. |
|
82 |
*/ |
|
83 |
private MapControl mapCtrl; |
|
84 |
|
|
85 |
/** |
|
86 |
* <p> |
|
87 |
* Creates a new <code>PolygonSelectionListener</code> object. |
|
88 |
* </p> |
|
89 |
* |
|
90 |
* @param mc |
|
91 |
* the <code>MapControl</code> where is drawn the polyline |
|
92 |
*/ |
|
93 |
public PolyLineSelectionListener(MapControl mc) { |
|
94 |
this.mapCtrl = mc; |
|
95 |
} |
|
96 |
|
|
97 |
/* |
|
98 |
* (non-Javadoc) |
|
99 |
* |
|
100 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor() |
|
101 |
*/ |
|
102 |
public Cursor getCursor() { |
|
103 |
if( cur == null ) { |
|
104 |
cur = Toolkit.getDefaultToolkit().createCustomCursor(this.getImageCursor(), |
|
105 |
new Point(16, 16), |
|
106 |
""); |
|
107 |
} |
|
108 |
return cur; |
|
109 |
} |
|
110 |
|
|
111 |
/* |
|
112 |
* (non-Javadoc) |
|
113 |
* |
|
114 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing() |
|
115 |
*/ |
|
116 |
public boolean cancelDrawing() { |
|
117 |
return false; |
|
118 |
} |
|
119 |
|
|
120 |
/* |
|
121 |
* (non-Javadoc) |
|
122 |
* |
|
123 |
* @see |
|
124 |
* com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#points(com.iver |
|
125 |
* .cit.gvsig.fmap.tools.Events.MeasureEvent) |
|
126 |
*/ |
|
127 |
public void points(MeasureEvent event) throws BehaviorException { |
|
128 |
} |
|
129 |
|
|
130 |
/* |
|
131 |
* (non-Javadoc) |
|
132 |
* |
|
133 |
* @see |
|
134 |
* com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#pointFixed(com |
|
135 |
* .iver.cit.gvsig.fmap.tools.Events.MeasureEvent) |
|
136 |
*/ |
|
137 |
public void pointFixed(MeasureEvent event) throws BehaviorException { |
|
138 |
} |
|
139 |
|
|
140 |
/* |
|
141 |
* (non-Javadoc) |
|
142 |
* |
|
143 |
* @see |
|
144 |
* com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#polylineFinished |
|
145 |
* (com.iver.cit.gvsig.fmap.tools.Events.MeasureEvent) |
|
146 |
*/ |
|
147 |
public void polylineFinished(MeasureEvent event) throws BehaviorException { |
|
148 |
try { |
|
149 |
GeneralPathX gp = event.getGP(); |
|
150 |
GeometryManager manager = GeometryLocator.getGeometryManager(); |
|
151 |
Geometry geom = null; |
|
152 |
Surface surface = null; |
|
153 |
try { |
|
154 |
surface = |
|
155 |
(Surface) manager.create(TYPES.SURFACE, SUBTYPES.GEOM2D); |
|
156 |
surface.setGeneralPath(gp); |
|
157 |
geom = surface; |
|
158 |
} catch (CreateGeometryException e1) { |
|
159 |
NotificationManager.showMessageError(PluginServices.getText(null, |
|
160 |
"Failed_creating_geometry"), |
|
161 |
e1); |
|
162 |
} |
|
163 |
if (geom == null) |
|
164 |
return; |
|
165 |
|
|
166 |
FLayer[] actives = mapCtrl.getMapContext().getLayers().getActives(); |
|
167 |
|
|
168 |
for (int i = 0; i < actives.length; i++) { |
|
169 |
if (actives[i] instanceof FLyrVect) { |
|
170 |
FLyrVect lyrVect = (FLyrVect) actives[i]; |
|
171 |
FeatureSet newSelection = null; |
|
172 |
|
|
173 |
newSelection = |
|
174 |
lyrVect.queryByGeometry(geom, lyrVect.getFeatureStore() |
|
175 |
.getDefaultFeatureType()); |
|
176 |
|
|
177 |
if (event.getEvent().isControlDown()) { |
|
178 |
((FeatureSelection) lyrVect.getDataStore() |
Also available in: Unified diff