Revision 43567
tags/org.gvsig.desktop-2.0.207/org.gvsig.desktop.plugin/org.gvsig.selectiontools.app/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
|
|
3 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<artifactId>org.gvsig.selectiontools.app</artifactId> |
|
6 |
<name>${project.artifactId}</name> |
|
7 |
<packaging>pom</packaging> |
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.desktop.plugin</artifactId> |
|
11 |
<version>2.0.207</version> |
|
12 |
</parent> |
|
13 |
|
|
14 |
<modules> |
|
15 |
<module>org.gvsig.selectiontools.app.mainplugin</module> |
|
16 |
</modules> |
|
17 |
|
|
18 |
</project> |
|
0 | 19 |
tags/org.gvsig.desktop-2.0.207/org.gvsig.desktop.plugin/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#Thu Oct 12 07:03:53 CEST 2017 |
|
2 |
buildNumber=2749 |
|
0 | 3 |
tags/org.gvsig.desktop-2.0.207/org.gvsig.desktop.plugin/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.mainplugin/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/org.gvsig.desktop-2.0.207/org.gvsig.desktop.plugin/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.mainplugin/src/test/resources/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1" ?> |
|
2 |
<!-- |
|
3 |
|
|
4 |
gvSIG. Desktop Geographic Information System. |
|
5 |
|
|
6 |
Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
For any additional information, do not hesitate to contact us |
|
24 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
|
|
26 |
--> |
|
27 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
28 |
|
|
29 |
<!-- |
|
30 |
Log4J configuration file for unit tests execution. |
|
31 |
--> |
|
32 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
33 |
|
|
34 |
<!-- Appender configuration to show logging messages through the console --> |
|
35 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
36 |
<layout class="org.apache.log4j.PatternLayout"> |
|
37 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
38 |
</layout> |
|
39 |
</appender> |
|
40 |
|
|
41 |
<!-- |
|
42 |
Activate logging messages of DEBUG level of higher only for the |
|
43 |
org.gvsig.tools packages. |
|
44 |
You can put full classes names or packages instead, to configure |
|
45 |
logging for all the classes and subpackages of the package. |
|
46 |
--> |
|
47 |
<category name="org.gvsig.tools"> |
|
48 |
<priority value="DEBUG" /> |
|
49 |
</category> |
|
50 |
<category name="org.gvsig.selectiontools"> |
|
51 |
<priority value="DEBUG" /> |
|
52 |
</category> |
|
53 |
|
|
54 |
<!-- |
|
55 |
By default, show only logging messages of INFO level or higher, |
|
56 |
through the previously configured CONSOLE appender. |
|
57 |
--> |
|
58 |
<root> |
|
59 |
<priority value="INFO" /> |
|
60 |
<appender-ref ref="CONSOLE" /> |
|
61 |
</root> |
|
62 |
</log4j:configuration> |
|
0 | 63 |
tags/org.gvsig.desktop-2.0.207/org.gvsig.desktop.plugin/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties | ||
---|---|---|
1 |
Both=Inside and outside |
|
2 |
bufferWidth_TOOLTIP_HTML_explanation=Selection buffer width |
|
3 |
distanceUnitsLabel_TOOLTIP_HTML_explanation=Width units of the selection buffer (km=kilometers, m=meters, cm=centimeters, mm=milimeters, mi=miles, Ya=yards, ft=feet, in=inches) |
|
4 |
Inside=Inside |
|
5 |
Invalid_width_value=Invalid width value |
|
6 |
lineSideLabel_TOOLTIP_HTML_explanation=Line type geometries (towards outside) |
|
7 |
MultiLayer_selection=Multi-layer selection |
|
8 |
multiLayerSelection_checkbox_TOOLTIP_HTML_explanation=Enables selection for multiple layers |
|
9 |
MultiPoint=Multi-point |
|
10 |
multiPointSideLabel_TOOLTIP_HTML_explanation=Multipoint type geometries (towards outside) |
|
11 |
Outside=Outside |
|
12 |
Options=Options |
|
13 |
pointSideLabel_TOOLTIP_HTML_explanation=Point type geometries (towards outside) |
|
14 |
polygonSideLabel_TOOLTIP_HTML_explanation=Polygon type geometries (towards inside or towards outside) |
|
15 |
Select_by_polyline=Select by polyline |
|
16 |
_Select_by_circle=Select by circle |
|
17 |
_Select_all=Select all |
|
18 |
Side=Side |
|
19 |
sideLabel_TOOLTIP_HTML_explanation=Selects the buffer's creation side depending on the selected geometry |
|
20 |
Units=Units |
tags/org.gvsig.desktop-2.0.207/org.gvsig.desktop.plugin/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.mainplugin/src/main/resources-plugin/i18n/text.properties | ||
---|---|---|
1 |
Both=Dentro y fuera |
|
2 |
bufferWidth_TOOLTIP_HTML_explanation=Anchura del buffer de selecci\u00f3n |
|
3 |
distanceUnitsLabel_TOOLTIP_HTML_explanation=Unidades de la anchura del buffer de selecci\u00f3n (km=kil\u00f3metros, m=metros, cm=cent\u00edmetros, mm=mil\u00edmetros, mi=millas, Ya=yardas, ft=pies, in=pulgadas) |
|
4 |
Inside=Dentro |
|
5 |
Invalid_width_value=Valor de anchura no v\u00e1lido |
|
6 |
lineSideLabel_TOOLTIP_HTML_explanation=Geometr\u00edas de tipo l\u00ednea (hacia fuera) |
|
7 |
MultiLayer_selection=Selecci\u00f3n multi-capa |
|
8 |
multiLayerSelection_checkbox_TOOLTIP_HTML_explanation=Activa la selecci\u00f3n para varias capas |
|
9 |
MultiPoint=Multipunto |
|
10 |
multiPointSideLabel_TOOLTIP_HTML_explanation=Geometr\u00edas de tipo multipunto (hacia fuera) |
|
11 |
Options=Opciones |
|
12 |
Outside=Fuera |
|
13 |
pointSideLabel_TOOLTIP_HTML_explanation=Geometr\u00edas de tipo punto (hacia fuera) |
|
14 |
polygonSideLabel_TOOLTIP_HTML_explanation=Geometr\u00edas de tipo pol\u00edgono (hacia dentro o hacia fuera) |
|
15 |
Select_by_polyline=Seleccionar por polil\u00ednea |
|
16 |
_Select_by_circle=Seleccionar por c\u00edrculo |
|
17 |
_Select_all=Seleccionar todo |
|
18 |
Side=Lado |
|
19 |
sideLabel_TOOLTIP_HTML_explanation=Selecciona el lado de creaci\u00f3n del buffer dependiendo de la geometr\u00eda seleccionada |
|
20 |
Units=Unidades |
tags/org.gvsig.desktop-2.0.207/org.gvsig.desktop.plugin/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.mainplugin/src/main/resources-plugin/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<!-- |
|
3 |
|
|
4 |
gvSIG. Desktop Geographic Information System. |
|
5 |
|
|
6 |
Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
For any additional information, do not hesitate to contact us |
|
24 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
|
|
26 |
--> |
|
27 |
<plugin-config> |
|
28 |
<depends plugin-name="org.gvsig.app.mainplugin" /> |
|
29 |
<resourceBundle name="text"/> |
|
30 |
<libraries library-dir="lib"/> |
|
31 |
<extensions> |
|
32 |
|
|
33 |
<!-- <extension class-name="org.gvsig.selectiontools.app.extension.AboutSelectionToolsExtension" --> |
|
34 |
<!-- description="Extension Selection Tools of the Consejer?a de Medio Ambiente of the Junta de Castilla y Le?n Project." --> |
|
35 |
<!-- active="true" --> |
|
36 |
<!-- priority="1"> --> |
|
37 |
<!-- </extension> --> |
|
38 |
|
|
39 |
<extension class-name="org.gvsig.selectiontools.app.extension.SelectAllExtension" |
|
40 |
description="Extension that allows select all geometries of the selected vectorial layers." |
|
41 |
active="true" |
|
42 |
priority="30"> |
|
43 |
<action |
|
44 |
name="selection-select-all" |
|
45 |
label="_Select_all" |
|
46 |
tooltip="_Select_all" |
|
47 |
action-command="SELALL" |
|
48 |
icon="selection-select-all" |
|
49 |
position="300090000" |
|
50 |
accelerator="" |
|
51 |
/> |
|
52 |
|
|
53 |
<menu |
|
54 |
name="selection-select-all" |
|
55 |
text="Selection/SelectAll" |
|
56 |
/> |
|
57 |
|
|
58 |
<tool-bar name="selection"> |
|
59 |
<action-tool name="selection-select-all"/> |
|
60 |
</tool-bar> |
|
61 |
</extension> |
|
62 |
<extension class-name="org.gvsig.selectiontools.app.extension.SelectByCircleExtension" |
|
63 |
description="Extension that allows select all geometries of the selected vectorial layers that are contained or intersect with a circle defined by the user." |
|
64 |
active="true" |
|
65 |
priority="30"> |
|
66 |
<action |
|
67 |
name="selection-select-by-circle" |
|
68 |
label="_Select_by_circle" |
|
69 |
tooltip="_Select_by_circle" |
|
70 |
action-command="SELCIRCLE" |
|
71 |
icon="selection-select-by-circle" |
|
72 |
position="300050000" |
|
73 |
accelerator="" |
|
74 |
/> |
|
75 |
|
|
76 |
<menu |
|
77 |
name="selection-select-by-circle" |
|
78 |
text="Selection/Select_by_circle" |
|
79 |
/> |
|
80 |
|
|
81 |
<tool-bar name="selection"> |
|
82 |
<selectable-tool name="selection-select-by-circle"/> |
|
83 |
</tool-bar> |
|
84 |
</extension> |
|
85 |
<extension class-name="org.gvsig.selectiontools.app.extension.SelectByPolylineExtension" |
|
86 |
description="Extension that allows select all geometries of the selected vectorial layers that intersect with a polyline defined by the user." |
|
87 |
active="true" |
|
88 |
priority="30"> |
|
89 |
<action |
|
90 |
name="selection-select-by-polyline" |
|
91 |
label="Select_by_polyline" |
|
92 |
tooltip="Select_by_polyline" |
|
93 |
action-command="SELPOLYLINE" |
|
94 |
icon="selection-select-by-polyline" |
|
95 |
position="300040000" |
|
96 |
accelerator="" |
|
97 |
/> |
|
98 |
<menu |
|
99 |
name="selection-select-by-polyline" |
|
100 |
text="Selection/Select_by_polyline" |
|
101 |
/> |
|
102 |
<tool-bar name="selection"> |
|
103 |
<selectable-tool name="selection-select-by-polyline" /> |
|
104 |
</tool-bar> |
|
105 |
</extension> |
|
106 |
|
|
107 |
<extension class-name="org.gvsig.selectiontools.app.extension.SelectByBufferExtension" |
|
108 |
description="Extension that allows select all geometries of the selected vectorial layers that intersect with a buffer around their previously selected geometries." |
|
109 |
active="true" |
|
110 |
priority="30"> |
|
111 |
<action |
|
112 |
name="selection-select-by-buffer" |
|
113 |
label="Select_by_buffer" |
|
114 |
tooltip="Select_by_buffer" |
|
115 |
action-command="SELBUFFER" |
|
116 |
icon="selection-select-by-buffer" |
|
117 |
position="300060000" |
|
118 |
accelerator="" |
|
119 |
/> |
|
120 |
<menu |
|
121 |
name="selection-select-by-buffer" |
|
122 |
text="Selection/Select_by_buffer" |
|
123 |
/> |
|
124 |
|
|
125 |
<tool-bar name="selection"> |
|
126 |
<action-tool name="selection-select-by-buffer" /> |
|
127 |
</tool-bar> |
|
128 |
</extension> |
|
129 |
|
|
130 |
</extensions> |
|
131 |
</plugin-config> |
|
0 | 132 |
tags/org.gvsig.desktop-2.0.207/org.gvsig.desktop.plugin/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<!-- |
|
2 |
|
|
3 |
gvSIG. Desktop Geographic Information System. |
|
4 |
|
|
5 |
Copyright (C) 2007-2013 gvSIG Association. |
|
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
|
8 |
modify it under the terms of the GNU General Public License |
|
9 |
as published by the Free Software Foundation; either version 3 |
|
10 |
of the License, or (at your option) any later version. |
|
11 |
|
|
12 |
This program is distributed in the hope that it will be useful, |
|
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
GNU General Public License for more details. |
|
16 |
|
|
17 |
You should have received a copy of the GNU General Public License |
|
18 |
along with this program; if not, write to the Free Software |
|
19 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
MA 02110-1301, USA. |
|
21 |
|
|
22 |
For any additional information, do not hesitate to contact us |
|
23 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
24 |
|
|
25 |
--> |
|
26 |
<assembly> |
|
27 |
<id>gvsig-plugin-package</id> |
|
28 |
<formats> |
|
29 |
<format>zip</format> |
|
30 |
</formats> |
|
31 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
32 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
33 |
<files> |
|
34 |
<file> |
|
35 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
36 |
<outputDirectory>lib</outputDirectory> |
|
37 |
</file> |
|
38 |
<file> |
|
39 |
<source>target/package.info</source> |
|
40 |
</file> |
|
41 |
</files> |
|
42 |
|
|
43 |
<fileSets> |
|
44 |
<fileSet> |
|
45 |
<directory>src/main/resources-plugin</directory> |
|
46 |
<outputDirectory>.</outputDirectory> |
|
47 |
</fileSet> |
|
48 |
</fileSets> |
|
49 |
|
|
50 |
<!-- |
|
51 |
<dependencySets> |
|
52 |
<dependencySet> |
|
53 |
<useProjectArtifact>false</useProjectArtifact> |
|
54 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
55 |
<outputDirectory>lib</outputDirectory> |
|
56 |
<includes> |
|
57 |
<include>groupId:artifactId</include> |
|
58 |
</includes> |
|
59 |
</dependencySet> |
|
60 |
</dependencySets> |
|
61 |
--> |
|
62 |
</assembly> |
|
63 |
|
|
0 | 64 |
tags/org.gvsig.desktop-2.0.207/org.gvsig.desktop.plugin/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.mainplugin/src/main/java/org/gvsig/selectiontools/app/extension/tools/CircleSelectListener.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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 3 |
|
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.selectiontools.app.extension.tools; |
|
25 |
|
|
26 |
import org.gvsig.andami.PluginServices; |
|
27 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
28 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
29 |
import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent; |
|
30 |
|
|
31 |
/** |
|
32 |
* |
|
33 |
* @version 06/04/2009 |
|
34 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
35 |
*/ |
|
36 |
public class CircleSelectListener extends CircleSelectionListener { |
|
37 |
|
|
38 |
public CircleSelectListener(MapControl mc) { |
|
39 |
super(mc); |
|
40 |
} |
|
41 |
|
|
42 |
public void circle(MeasureEvent event) throws BehaviorException { |
|
43 |
super.circle(event); |
|
44 |
PluginServices.getMainFrame().enableControls(); |
|
45 |
} |
|
46 |
} |
|
0 | 47 |
tags/org.gvsig.desktop-2.0.207/org.gvsig.desktop.plugin/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.mainplugin/src/main/java/org/gvsig/selectiontools/app/extension/tools/PolyLineSelectionListener.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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 3 |
|
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.selectiontools.app.extension.tools; |
|
25 |
|
|
26 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
27 |
* |
|
28 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
29 |
* of the Valencian Government (CIT) |
|
30 |
* |
|
31 |
* This program is free software; you can redistribute it and/or |
|
32 |
* modify it under the terms of the GNU General Public License |
|
33 |
* as published by the Free Software Foundation; either version 2 |
|
34 |
* of the License, or (at your option) any later version. |
|
35 |
* |
|
36 |
* This program is distributed in the hope that it will be useful, |
|
37 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
38 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
39 |
* GNU General Public License for more details. |
|
40 |
* |
|
41 |
* You should have received a copy of the GNU General Public License |
|
42 |
* along with this program; if not, write to the Free Software |
|
43 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
44 |
* MA 02110-1301, USA. |
|
45 |
* |
|
46 |
*/ |
|
47 |
|
|
48 |
import java.awt.Cursor; |
|
49 |
import java.awt.Image; |
|
50 |
import java.awt.Point; |
|
51 |
import java.awt.Toolkit; |
|
52 |
|
|
53 |
import javax.swing.ImageIcon; |
|
54 |
|
|
55 |
import org.gvsig.andami.IconThemeHelper; |
|
56 |
import org.gvsig.andami.PluginServices; |
|
57 |
import org.gvsig.andami.messages.NotificationManager; |
|
58 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
59 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
60 |
import org.gvsig.fmap.geom.Geometry; |
|
61 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
62 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
63 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
64 |
import org.gvsig.fmap.geom.GeometryManager; |
|
65 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
66 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
67 |
import org.gvsig.fmap.geom.primitive.Surface; |
|
68 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
69 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
70 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
71 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
72 |
import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent; |
|
73 |
import org.gvsig.fmap.mapcontrol.tools.Listeners.PolylineListener; |
|
74 |
|
|
75 |
/** |
|
76 |
* <p> |
|
77 |
* Listener that selects all features of the active and vector layers which |
|
78 |
* intersect with the defined polyline in the associated {@link MapControl |
|
79 |
* MapControl} object. |
|
80 |
* </p> |
|
81 |
* |
|
82 |
* <p> |
|
83 |
* The selection will be produced after user finishes the creation of the |
|
84 |
* polyline. |
|
85 |
* </p> |
|
86 |
* |
|
87 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
88 |
*/ |
|
89 |
public class PolyLineSelectionListener implements PolylineListener { |
|
90 |
|
|
91 |
/** |
|
92 |
* The image to display when the cursor is active. |
|
93 |
*/ |
|
94 |
// private final Image img = PluginServices.getIconTheme().get("cursor-select-by-polygon").getImage(); |
|
95 |
|
|
96 |
/** |
|
97 |
* The cursor used to work with this tool listener. |
|
98 |
* |
|
99 |
* @see #getCursor() |
|
100 |
*/ |
|
101 |
private Cursor cur = null; |
|
102 |
|
|
103 |
/** |
|
104 |
* Reference to the <code>MapControl</code> object that uses. |
|
105 |
*/ |
|
106 |
private MapControl mapCtrl; |
|
107 |
|
|
108 |
/** |
|
109 |
* <p> |
|
110 |
* Creates a new <code>PolygonSelectionListener</code> object. |
|
111 |
* </p> |
|
112 |
* |
|
113 |
* @param mc |
|
114 |
* the <code>MapControl</code> where is drawn the polyline |
|
115 |
*/ |
|
116 |
public PolyLineSelectionListener(MapControl mc) { |
|
117 |
this.mapCtrl = mc; |
|
118 |
} |
|
119 |
|
|
120 |
/* |
|
121 |
* (non-Javadoc) |
|
122 |
* |
|
123 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor() |
|
124 |
*/ |
|
125 |
public Cursor getCursor() { |
|
126 |
if( cur == null ) { |
|
127 |
cur = Toolkit.getDefaultToolkit().createCustomCursor(this.getImageCursor(), |
|
128 |
new Point(16, 16), |
|
129 |
""); |
|
130 |
} |
|
131 |
return cur; |
|
132 |
} |
|
133 |
|
|
134 |
/* |
|
135 |
* (non-Javadoc) |
|
136 |
* |
|
137 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing() |
|
138 |
*/ |
|
139 |
public boolean cancelDrawing() { |
|
140 |
return false; |
|
141 |
} |
|
142 |
|
|
143 |
/* |
|
144 |
* (non-Javadoc) |
|
145 |
* |
|
146 |
* @see |
|
147 |
* com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#points(com.iver |
|
148 |
* .cit.gvsig.fmap.tools.Events.MeasureEvent) |
|
149 |
*/ |
|
150 |
public void points(MeasureEvent event) throws BehaviorException { |
|
151 |
} |
|
152 |
|
|
153 |
/* |
|
154 |
* (non-Javadoc) |
|
155 |
* |
|
156 |
* @see |
|
157 |
* com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#pointFixed(com |
|
158 |
* .iver.cit.gvsig.fmap.tools.Events.MeasureEvent) |
|
159 |
*/ |
|
160 |
public void pointFixed(MeasureEvent event) throws BehaviorException { |
|
161 |
} |
|
162 |
|
|
163 |
/* |
|
164 |
* (non-Javadoc) |
|
165 |
* |
|
166 |
* @see |
|
167 |
* com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#polylineFinished |
|
168 |
* (com.iver.cit.gvsig.fmap.tools.Events.MeasureEvent) |
|
169 |
*/ |
|
170 |
public void polylineFinished(MeasureEvent event) throws BehaviorException { |
|
171 |
try { |
|
172 |
GeneralPathX gp = event.getGP(); |
|
173 |
GeometryManager manager = GeometryLocator.getGeometryManager(); |
|
174 |
Geometry geom = null; |
|
175 |
Surface surface = null; |
|
176 |
try { |
|
177 |
surface = |
|
178 |
(Surface) manager.create(TYPES.SURFACE, SUBTYPES.GEOM2D); |
|
179 |
surface.setGeneralPath(gp); |
|
180 |
geom = surface; |
|
181 |
} catch (CreateGeometryException e1) { |
|
182 |
NotificationManager.showMessageError(PluginServices.getText(null, |
|
183 |
"Failed_creating_geometry"), |
|
184 |
e1); |
|
185 |
} |
|
186 |
if (geom == null) |
|
187 |
return; |
|
188 |
|
|
189 |
FLayer[] actives = mapCtrl.getMapContext().getLayers().getActives(); |
|
190 |
|
|
191 |
for (int i = 0; i < actives.length; i++) { |
|
192 |
if (actives[i] instanceof FLyrVect) { |
|
193 |
FLyrVect lyrVect = (FLyrVect) actives[i]; |
|
194 |
FeatureSet newSelection = null; |
|
195 |
|
|
196 |
newSelection = |
|
197 |
lyrVect.queryByGeometry(geom, lyrVect.getFeatureStore() |
|
198 |
.getDefaultFeatureType()); |
|
199 |
|
|
200 |
if (event.getEvent().isControlDown()) { |
|
201 |
((FeatureSelection) lyrVect.getDataStore() |
|
202 |
.getSelection()).select(newSelection); |
|
203 |
} else { |
|
204 |
lyrVect.getFeatureStore().setSelection(newSelection); |
|
205 |
} |
|
206 |
} |
|
207 |
} |
|
208 |
} catch (com.vividsolutions.jts.geom.TopologyException topEx) { |
|
209 |
NotificationManager.showMessageError(PluginServices.getText(null, |
|
210 |
"Failed_selecting_geometries_by_polyline_topology_exception_explanation"), |
|
211 |
topEx); |
|
212 |
} catch (Exception ex) { |
|
213 |
NotificationManager.showMessageError(PluginServices.getText(null, |
|
214 |
"Failed_selecting_geometries"), ex); |
|
215 |
} |
|
216 |
} |
|
217 |
|
|
218 |
public Image getImageCursor() { |
|
219 |
return IconThemeHelper.getImage("cursor-select-by-polyline"); |
|
220 |
} |
|
221 |
} |
|
0 | 222 |
tags/org.gvsig.desktop-2.0.207/org.gvsig.desktop.plugin/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.mainplugin/src/main/java/org/gvsig/selectiontools/app/extension/tools/buffer/process/BufferSelectionProcess.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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 3 |
|
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.selectiontools.app.extension.tools.buffer.process; |
|
25 |
|
|
26 |
import java.awt.event.MouseAdapter; |
|
27 |
import java.awt.event.MouseEvent; |
|
28 |
import java.util.ArrayList; |
|
29 |
import java.util.Iterator; |
|
30 |
|
|
31 |
import javax.swing.JButton; |
|
32 |
|
|
33 |
import org.cresques.cts.ICoordTrans; |
|
34 |
import org.cresques.cts.IProjection; |
|
35 |
import org.gvsig.andami.PluginServices; |
|
36 |
import org.gvsig.andami.messages.NotificationManager; |
|
37 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
38 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
39 |
import org.gvsig.fmap.dal.feature.Feature; |
|
40 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
41 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
42 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
43 |
import org.gvsig.fmap.geom.Geometry; |
|
44 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
45 |
import org.gvsig.fmap.geom.GeometryManager; |
|
46 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
47 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
48 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
49 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
50 |
import org.gvsig.gui.beans.incrementabletask.IncrementableProcess; |
|
51 |
import org.gvsig.gui.beans.incrementabletask.IncrementableTask; |
|
52 |
import org.gvsig.selectiontools.app.extension.tools.buffer.gui.BufferConfigurationPanel; |
|
53 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
54 |
|
|
55 |
public class BufferSelectionProcess extends IncrementableProcess { |
|
56 |
|
|
57 |
// private boolean layerWasBeingEdited = false; |
|
58 |
|
|
59 |
private MapControl mapControl = null; |
|
60 |
private byte pol_side = -1; |
|
61 |
private byte line_side = -1; |
|
62 |
private byte point_side = -1; |
|
63 |
private byte multi_point_side = -1; |
|
64 |
private short selectedDistanceUnit = -1; |
|
65 |
private FLyrVect[] layers = null; |
|
66 |
private final double f_width; |
|
67 |
private boolean multiLayerSelection = false; |
|
68 |
|
|
69 |
/** |
|
70 |
* For polygonal buffers, only compute interior buffers |
|
71 |
*/ |
|
72 |
public static final byte BUFFER_INSIDE_POLY = 0; |
|
73 |
|
|
74 |
/** |
|
75 |
* For polygonal buffers, only compute exterior buffers (is the default |
|
76 |
* operation, it applies to any geometry type) |
|
77 |
*/ |
|
78 |
public static final byte BUFFER_OUTSIDE_POLY = 1; |
|
79 |
|
|
80 |
/** |
|
81 |
* For polygonal buffers, compute interior and exterior buffers |
|
82 |
*/ |
|
83 |
public static final byte BUFFER_INSIDE_OUTSIDE_POLY = 2; |
|
84 |
|
|
85 |
/** |
|
86 |
* Buffer with square cap |
|
87 |
*/ |
|
88 |
public static final byte CAP_SQUARE = 0; |
|
89 |
/** |
|
90 |
* Buffer with round cap |
|
91 |
*/ |
|
92 |
public static final byte CAP_ROUND = 1; |
|
93 |
|
|
94 |
/** |
|
95 |
* flag that represents buffer computing with one only buffer distance. |
|
96 |
*/ |
|
97 |
public static final byte CONSTANT_DISTANCE_STRATEGY = 0; |
|
98 |
|
|
99 |
/** |
|
100 |
* buffer computing with variable buffer distance in function of feature |
|
101 |
* attribute value |
|
102 |
*/ |
|
103 |
public static final byte ATTRIBUTE_DISTANCE_STRATEGY = 1; |
|
104 |
|
|
105 |
/** |
|
106 |
* Creates a new |
|
107 |
* <p> |
|
108 |
* BufferSelectionProcess |
|
109 |
* </p> |
|
110 |
* . |
|
111 |
* |
|
112 |
* @param title |
|
113 |
* of the progress dialog |
|
114 |
* @param label |
|
115 |
* the label that explains the process |
|
116 |
* @param mapControl |
|
117 |
* reference to the current active view's <code>MapControl</code> |
|
118 |
* . |
|
119 |
* @param pol_side |
|
120 |
* side of the buffer in a polyline layer: |
|
121 |
* {@link BufferConfigurationPanel#OUTSIDE |
|
122 |
* BufferConfigurationPanel#OUTSIDE}, |
|
123 |
* {@link BufferConfigurationPanel#INSIDE |
|
124 |
* BufferConfigurationPanel#INSIDE}, or |
|
125 |
* {@link BufferConfigurationPanel#OUTSIDE_AND_INSIDE |
|
126 |
* BufferConfigurationPanel#OUTSIDE_AND_INSIDE} |
|
127 |
* @param line_side |
|
128 |
* side of the buffer in a line layer: |
|
129 |
* {@link BufferConfigurationPanel#OUTSIDE_AND_INSIDE |
|
130 |
* BufferConfigurationPanel#OUTSIDE_AND_INSIDE} |
|
131 |
* @param point_side |
|
132 |
* side of the buffer in a point layer: |
|
133 |
* {@link BufferConfigurationPanel#OUTSIDE |
|
134 |
* BufferConfigurationPanel#OUTSIDE} |
|
135 |
* @param multi_point_side |
|
136 |
* side of the buffer in a multi point layer: |
|
137 |
* {@link BufferConfigurationPanel#OUTSIDE |
|
138 |
* BufferConfigurationPanel#OUTSIDE} |
|
139 |
* @param width |
|
140 |
* buffer's width |
|
141 |
* @param selectedDistanceUnit |
|
142 |
* distance unit selected |
|
143 |
* @param activeLayers |
|
144 |
* current active view's active layers |
|
145 |
* @param showBufferLayers |
|
146 |
* determines if will show the layers with the buffers as new |
|
147 |
* temporal layers |
|
148 |
* @param multiLayerSelection |
|
149 |
* determines if the selection in each active layer affects the |
|
150 |
* other |
|
151 |
*/ |
|
152 |
public BufferSelectionProcess(String title, |
|
153 |
String label, |
|
154 |
MapControl mapControl, |
|
155 |
byte pol_side, |
|
156 |
byte line_side, |
|
157 |
byte point_side, |
|
158 |
byte multi_point_side, |
|
159 |
double width, |
|
160 |
short selectedDistanceUnit, |
|
161 |
FLyrVect[] activeLayers, |
|
162 |
boolean multiLayerSelection) { |
|
163 |
super(title); |
|
164 |
|
|
165 |
this.label = label; |
|
166 |
this.mapControl = mapControl; |
|
167 |
this.pol_side = pol_side; |
|
168 |
this.line_side = line_side; |
|
169 |
this.point_side = point_side; |
|
170 |
this.multi_point_side = multi_point_side; |
|
171 |
this.f_width = width; |
|
172 |
this.selectedDistanceUnit = selectedDistanceUnit; |
|
173 |
this.layers = activeLayers; |
|
174 |
this.multiLayerSelection = multiLayerSelection; |
|
175 |
this.isPausable = true; |
|
176 |
} |
|
177 |
|
|
178 |
/** |
|
179 |
* Sets the object that will display the evolution of this loading process |
|
180 |
* as a progress dialog. |
|
181 |
* |
|
182 |
* @param iTask |
|
183 |
* the object that will display the evolution of this loading |
|
184 |
* process |
|
185 |
*/ |
|
186 |
public void setIncrementableTask(IncrementableTask iTask) { |
|
187 |
this.iTask = iTask; |
|
188 |
iTask.setAskCancel(true); |
|
189 |
iTask.getButtonsPanel().addAccept(); |
|
190 |
iTask.getButtonsPanel().setEnabled(ButtonsPanel.BUTTON_ACCEPT, false); |
|
191 |
|
|
192 |
JButton jButton = |
|
193 |
iTask.getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT); |
|
194 |
jButton.addMouseListener(new MouseAdapter() { |
|
195 |
|
|
196 |
/* |
|
197 |
* (non-Javadoc) |
|
198 |
* |
|
199 |
* @see |
|
200 |
* java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent |
|
201 |
* ) |
|
202 |
*/ |
|
203 |
public void mouseClicked(MouseEvent e) { |
|
204 |
processFinalize(); |
|
205 |
// Force repaint |
|
206 |
mapControl.getMapContext().invalidate(); |
|
207 |
} |
|
208 |
}); |
|
209 |
} |
|
210 |
|
|
211 |
/** |
|
212 |
* Importation process. |
|
213 |
* |
|
214 |
* @throws InterruptedException |
|
215 |
* if fails the process |
|
216 |
*/ |
|
217 |
public void process() throws InterruptedException { |
|
218 |
percentage = 5; |
|
219 |
double inc = 0; |
|
220 |
FeatureSelection selections[] = new FeatureSelection[layers.length]; |
|
221 |
ArrayList<Geometry> buffer[] = new ArrayList[layers.length]; |
|
222 |
try { |
|
223 |
|
|
224 |
/* 2- Gets the distance relation */ |
|
225 |
percentage = 6; |
|
226 |
|
|
227 |
/* 3- Stores the new selections */ |
|
228 |
FLyrVect layer = null; |
|
229 |
|
|
230 |
// int size; |
|
231 |
|
|
232 |
percentage = 9; |
|
233 |
|
|
234 |
/* 4- Gets the buffer and intersects to select new geometries */ |
|
235 |
double width = 1; // default value (not used) |
|
236 |
byte side; |
|
237 |
|
|
238 |
percentage = 11; |
|
239 |
|
|
240 |
boolean isProjected = false; |
|
241 |
|
|
242 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
243 |
if (f instanceof IView) { |
|
244 |
IView vista = (IView) f; |
|
245 |
|
|
246 |
// Sets projection |
|
247 |
IProjection proj = |
|
248 |
vista.getMapControl().getViewPort().getProjection(); |
|
249 |
|
|
250 |
// Sets distance units |
|
251 |
isProjected = proj.isProjected(); |
|
252 |
} |
|
253 |
// Sets map units |
|
254 |
int mapUnits = -1; |
|
255 |
if (isProjected) { |
|
256 |
mapUnits = |
|
257 |
((IView) PluginServices.getMDIManager().getActiveWindow()).getMapControl() |
|
258 |
.getViewPort() |
|
259 |
.getMapUnits(); |
|
260 |
} else { |
|
261 |
mapUnits = 1; |
|
262 |
} |
|
263 |
|
|
264 |
percentage = 14; |
|
265 |
|
|
266 |
FeatureStore store = null; |
|
267 |
inc = (100 - percentage) / layers.length; |
|
268 |
|
|
269 |
/* 4.1- For each vector layer with geometries selected */ |
|
270 |
for (int i = 0; i < layers.length; i++) { |
|
271 |
try { |
|
272 |
if (cancelProcess.isCanceled()) { |
|
273 |
throw new InterruptedException(); |
|
274 |
} |
|
275 |
|
|
276 |
layer = layers[i]; |
|
277 |
store = layer.getFeatureStore(); |
|
278 |
FeatureSelection selection = (FeatureSelection) store |
|
279 |
.getFeatureSelection() |
|
280 |
.clone(); |
|
281 |
selections[i] = selection; |
|
282 |
|
|
283 |
log.addLine(PluginServices.getText(null, |
|
284 |
"Starting_selection_of_layer") |
|
285 |
+ " \"" |
|
286 |
+ layer.getName() + "\""); |
|
287 |
|
|
288 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
289 |
if( geomManager.isSubtype(Geometry.TYPES.POINT, layer.getShapeType()) ) { |
|
290 |
side = point_side; |
|
291 |
|
|
292 |
} else if( geomManager.isSubtype(Geometry.TYPES.CURVE, layer.getShapeType()) ) { |
|
293 |
side = line_side; |
|
294 |
|
|
295 |
} else if( geomManager.isSubtype(Geometry.TYPES.SURFACE, layer.getShapeType()) ) { |
|
296 |
side = pol_side; |
|
297 |
|
|
298 |
} else if( geomManager.isSubtype(Geometry.TYPES.MULTIPOINT, layer.getShapeType()) ) { |
|
299 |
side = multi_point_side; |
|
300 |
|
|
301 |
} else if( geomManager.isSubtype(Geometry.TYPES.MULTICURVE, layer.getShapeType()) ) { |
|
302 |
side = line_side; |
|
303 |
|
|
304 |
} else if( geomManager.isSubtype(Geometry.TYPES.MULTISURFACE, layer.getShapeType()) ) { |
|
305 |
side = pol_side; |
|
306 |
} else { |
|
307 |
log.addLine(PluginServices.getText(null, |
|
308 |
"Layer_with_unsupported_geometries_type")); |
|
309 |
percentage += inc; |
|
310 |
continue; |
|
311 |
} |
|
312 |
|
|
313 |
/* 4.2- Calculates the width */ |
|
314 |
width = |
|
315 |
f_width |
|
316 |
* MapContext.getDistanceTrans2Meter()[selectedDistanceUnit] |
|
317 |
/ MapContext.getDistanceTrans2Meter()[mapUnits]; |
|
318 |
|
|
319 |
/* 4.4- Sets the buffer width */ |
|
320 |
/* |
|
321 |
log.addLine(PluginServices.getText(null, |
|
322 |
"Buffer_information") + ":"); |
|
323 |
*/ |
|
324 |
|
|
325 |
/* 4.5- Shows width information */ |
|
326 |
/* |
|
327 |
if (mapControl.getProjection().isProjected()) { |
|
328 |
log.addLine(" " |
|
329 |
+ PluginServices.getText(null, "Buffer_width") |
|
330 |
+ ": " + width + " m."); |
|
331 |
} else { |
|
332 |
log.addLine(" " |
|
333 |
+ PluginServices.getText(null, "Buffer_width") |
|
334 |
+ ": " + width + " m"); |
|
335 |
log.addLine(" " |
|
336 |
+ PluginServices.getText(null, "Buffer_width") |
|
337 |
+ ": " + width |
|
338 |
/ MapContext.getDistanceTrans2Meter()[8] + " ?"); |
|
339 |
} |
|
340 |
|
|
341 |
log.addLine(" " |
|
342 |
+ PluginServices.getText(null, "Buffer_cap") + ": " |
|
343 |
+ PluginServices.getText(null, "Round")); |
|
344 |
|
|
345 |
switch (side) { |
|
346 |
case BUFFER_OUTSIDE_POLY: |
|
347 |
log.addLine(" " |
|
348 |
+ PluginServices.getText(null, "Side") + ": " |
|
349 |
+ PluginServices.getText(null, "Outside")); |
|
350 |
break; |
|
351 |
case BUFFER_INSIDE_POLY: |
|
352 |
log.addLine(" " |
|
353 |
+ PluginServices.getText(null, "Side") + ": " |
|
354 |
+ PluginServices.getText(null, "Inside")); |
|
355 |
break; |
|
356 |
case BUFFER_INSIDE_OUTSIDE_POLY: |
|
357 |
log.addLine(" " |
|
358 |
+ PluginServices.getText(null, "Side") |
|
359 |
+ ": " |
|
360 |
+ PluginServices.getText(null, "Outside_and_inside")); |
|
361 |
break; |
|
362 |
} |
|
363 |
*/ |
|
364 |
|
|
365 |
/* |
|
366 |
* 4.3- Creates the influence area |
|
367 |
*/ |
|
368 |
// if (cancelProcess.isCanceled()) { |
|
369 |
// throw new InterruptedException(); |
|
370 |
// } |
|
371 |
|
|
372 |
DisposableIterator selIt = selection.fastIterator(); |
|
373 |
ArrayList<Geometry> bufferLayer = new ArrayList<Geometry>(); |
|
374 |
while (selIt.hasNext()) { |
|
375 |
Feature feat = (Feature) selIt.next(); |
|
376 |
Geometry geomBuffer = null; |
|
377 |
switch (side) { |
|
378 |
case BUFFER_OUTSIDE_POLY: |
|
379 |
geomBuffer = buffer( |
|
380 |
feat.getDefaultGeometry(), |
|
381 |
layer.getProjection(), |
|
382 |
layer.getCoordTrans(), |
|
383 |
width); |
|
384 |
// feat.getDefaultGeometry().buffer(width); |
|
385 |
break; |
|
386 |
case BUFFER_INSIDE_POLY: |
|
387 |
geomBuffer = buffer( |
|
388 |
feat.getDefaultGeometry(), |
|
389 |
layer.getProjection(), |
|
390 |
layer.getCoordTrans(), |
|
391 |
-width); |
|
392 |
// feat.getDefaultGeometry().buffer(-width); |
|
393 |
break; |
|
394 |
case BUFFER_INSIDE_OUTSIDE_POLY: |
|
395 |
// Aqu? no deber?a llegar nunca, por si acaso lo |
|
396 |
// dejamos igual que el BUFFER_OUTSIDE_POLY |
|
397 |
geomBuffer = buffer( |
|
398 |
feat.getDefaultGeometry(), |
|
399 |
layer.getProjection(), |
|
400 |
layer.getCoordTrans(), |
|
401 |
width); |
|
402 |
// feat.getDefaultGeometry().buffer(width); |
|
403 |
break; |
|
404 |
} |
|
405 |
bufferLayer.add(geomBuffer); |
|
406 |
} |
|
407 |
buffer[i] = bufferLayer; |
|
408 |
selIt.dispose(); |
|
409 |
|
|
410 |
} catch (Exception e3) { |
|
411 |
/* Notifies the exception in the log */ |
|
412 |
if (!cancelProcess.isCanceled()) { |
|
413 |
NotificationManager.showMessageError(PluginServices.getText(null, |
|
414 |
"Error_fallo_geoproceso"), |
|
415 |
e3); |
|
416 |
log.addLine(PluginServices.getText(null, |
|
417 |
"Error_fallo_geoproceso")); |
|
418 |
} |
|
419 |
|
|
420 |
throw new InterruptedException(); |
|
421 |
} |
|
422 |
} |
|
423 |
|
|
424 |
for (int i = 0; i < layers.length; i++) { |
|
425 |
layer = layers[i]; |
|
426 |
|
|
427 |
layer.getFeatureStore().disableNotifications(); |
|
428 |
|
|
429 |
FeatureSelection layerSelection = |
|
430 |
layer.getFeatureStore().getFeatureSelection(); |
|
431 |
|
|
432 |
Geometry aux_geometry; |
|
433 |
if (multiLayerSelection) { |
|
434 |
for (int j = 0; j < buffer.length; j++) { |
|
435 |
ArrayList<Geometry> bufferLayer = buffer[j]; |
|
436 |
if (bufferLayer != null) { |
|
437 |
Iterator<Geometry> geomIt = bufferLayer.iterator(); |
|
438 |
while (geomIt.hasNext()) { |
|
439 |
aux_geometry = geomIt.next(); |
|
440 |
FeatureSet aux_featSet = |
|
441 |
layer.queryByGeometry(aux_geometry, |
|
442 |
layer.getFeatureStore() |
|
443 |
.getDefaultFeatureType()); |
|
444 |
layerSelection.select(aux_featSet); |
|
445 |
} |
|
446 |
} |
|
447 |
} |
|
448 |
|
|
449 |
} else { |
|
450 |
ArrayList<Geometry> bufferLayer = buffer[i]; |
|
451 |
Iterator<Geometry> geomIt = bufferLayer.iterator(); |
|
452 |
while (geomIt.hasNext()) { |
|
453 |
aux_geometry = geomIt.next(); |
|
454 |
FeatureSet aux_featSet = |
|
455 |
layer.queryByGeometry(aux_geometry, |
|
456 |
layer.getFeatureStore().getDefaultFeatureType()); |
|
457 |
layerSelection.select(aux_featSet); |
|
458 |
} |
|
459 |
|
|
460 |
} |
|
461 |
|
|
462 |
layer.getFeatureStore().enableNotifications(); |
|
463 |
} |
|
464 |
|
|
465 |
/* |
|
466 |
log.addLine(PluginServices.getText(null, |
|
467 |
"Selection_process_finished_succesfully")); |
|
468 |
log.addLine(""); // Empty line |
|
469 |
*/ |
|
470 |
|
|
471 |
} catch (Exception de) { |
|
472 |
/* 5- Notifies the exception in the log */ |
|
473 |
if (!cancelProcess.isCanceled()) { |
|
474 |
log.addLine(PluginServices.getText(null, "Selection_restored")); |
|
475 |
|
|
476 |
throw new InterruptedException(); |
|
477 |
} |
|
478 |
|
|
479 |
percentage += inc; |
|
480 |
} |
|
481 |
|
|
482 |
percentage = 100; |
|
483 |
} |
|
484 |
|
|
485 |
/** |
|
486 |
|
|
487 |
* @param geom geom of store |
|
488 |
* @param storeProj |
|
489 |
* @param layerCT |
|
490 |
* @param dist in meters |
|
491 |
* @return buffered geom in CRS of view |
|
492 |
*/ |
|
493 |
private Geometry buffer( |
|
494 |
Geometry geom, |
|
495 |
IProjection storeProj, |
|
496 |
ICoordTrans layerCT, |
|
497 |
double dist) throws Exception { |
|
498 |
|
|
499 |
if (layerCT == null) { |
|
500 |
// Not reprojected on the fly |
|
501 |
if (storeProj.isProjected()) { |
|
502 |
return geom.buffer(dist); |
|
503 |
} else { |
|
504 |
dist = dist * 180.0 / (Math.PI * 6378137); |
|
505 |
return geom.buffer(dist); |
|
506 |
} |
|
507 |
|
|
508 |
} else { |
|
509 |
|
|
510 |
// Reprojected on the fly |
|
511 |
Geometry aux = geom.cloneGeometry(); |
|
512 |
aux.reProject(layerCT); |
|
513 |
return buffer(aux, layerCT.getPDest(), null, dist); |
|
514 |
} |
|
515 |
} |
|
516 |
|
|
517 |
} |
|
0 | 518 |
tags/org.gvsig.desktop-2.0.207/org.gvsig.desktop.plugin/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.mainplugin/src/main/java/org/gvsig/selectiontools/app/extension/tools/buffer/gui/BufferConfigurationPanel.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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 3 |
|
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.selectiontools.app.extension.tools.buffer.gui; |
|
25 |
|
|
26 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
27 |
* |
|
28 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
29 |
* of the Valencian Government (CIT) |
|
30 |
* |
|
31 |
* This program is free software; you can redistribute it and/or |
|
32 |
* modify it under the terms of the GNU General Public License |
|
33 |
* as published by the Free Software Foundation; either version 2 |
|
34 |
* of the License, or (at your option) any later version. |
|
35 |
* |
|
36 |
* This program is distributed in the hope that it will be useful, |
|
37 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
38 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
39 |
* GNU General Public License for more details. |
|
40 |
* |
|
41 |
* You should have received a copy of the GNU General Public License |
|
42 |
* along with this program; if not, write to the Free Software |
|
43 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
44 |
* MA 02110-1301, USA. |
|
45 |
* |
|
46 |
*/ |
|
47 |
|
|
48 |
import java.awt.*; |
|
49 |
import java.awt.event.ActionEvent; |
|
50 |
import java.awt.event.ActionListener; |
|
51 |
import java.awt.event.ComponentAdapter; |
|
52 |
import java.awt.event.ComponentEvent; |
|
53 |
import java.util.ArrayList; |
|
54 |
import java.util.Arrays; |
|
55 |
import java.util.Iterator; |
|
56 |
import java.util.List; |
|
57 |
|
|
58 |
import javax.swing.BorderFactory; |
|
59 |
import javax.swing.JCheckBox; |
|
60 |
import javax.swing.JLabel; |
|
61 |
import javax.swing.JOptionPane; |
|
62 |
import javax.swing.JPanel; |
|
63 |
import javax.swing.JTextField; |
|
64 |
import javax.swing.border.EmptyBorder; |
|
65 |
|
|
66 |
import org.gvsig.andami.PluginServices; |
|
67 |
import org.gvsig.andami.messages.NotificationManager; |
|
68 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
69 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
70 |
import org.gvsig.app.ApplicationLocator; |
|
71 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
72 |
import org.gvsig.fmap.dal.exception.DataException; |
|
73 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
74 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
75 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
|
76 |
import org.gvsig.gui.beans.incrementabletask.IncrementableTask; |
|
77 |
import org.gvsig.gui.beans.progresspanel.ProgressPanel; |
|
78 |
import org.gvsig.i18n.Messages; |
|
79 |
import org.gvsig.selectiontools.app.extension.tools.buffer.process.BufferSelectionProcess; |
|
80 |
import org.gvsig.utils.swing.JComboBox; |
|
81 |
|
|
82 |
/** |
|
83 |
* |
|
84 |
* |
|
85 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
86 |
*/ |
|
87 |
public class BufferConfigurationPanel extends JPanel implements IWindow { |
|
88 |
|
|
89 |
private WindowInfo viewInfo = null; |
|
90 |
private JTextField distanceText = null; |
|
91 |
private JComboBox distanceUnitsCombo = null; |
|
92 |
private JComboBox polygonSidesCombo = null; |
|
93 |
private JComboBox lineSidesCombo = null; |
|
94 |
private JComboBox pointSidesCombo = null; |
|
95 |
private JComboBox multiPointSidesCombo = null; |
|
96 |
private JLabel distanceUnitsLabel = null; |
|
97 |
private JLabel polygonSideLabel = null; |
|
98 |
private JLabel lineSideLabel = null; |
|
99 |
private JLabel pointSideLabel = null; |
|
100 |
private JLabel multiPointSideLabel = null; |
|
101 |
private JPanel polygonSidePanel = null; |
|
102 |
private JPanel lineSidePanel = null; |
|
103 |
private JPanel pointSidePanel = null; |
|
104 |
private JPanel multiPointSidePanel = null; |
|
105 |
private JLabel widthLabel = null; |
|
106 |
private JPanel widthPanel = null; |
|
107 |
private JPanel sidePanel = null; |
|
108 |
private JPanel optionsPanel = null; |
|
109 |
private AdaptedAcceptCancelPanel acceptCancelPanel = null; |
|
110 |
private List<FLyrVect> layers; |
|
111 |
private MapControl mapControl; |
|
112 |
private IView view; |
|
113 |
private JCheckBox multiLayerSelectionCBox; |
|
114 |
private SideInfo outside, inside, out_in_side; |
|
115 |
|
|
116 |
/** |
|
117 |
* Creates a new form where user can define the option of the buffer. |
|
118 |
*/ |
|
119 |
public BufferConfigurationPanel(List<FLyrVect> layers, IView view) { |
|
120 |
super(); |
|
121 |
|
|
122 |
this.layers = layers; |
|
123 |
this.view = view; |
|
124 |
this.mapControl = view.getMapControl(); |
|
125 |
|
|
126 |
initialize(); |
|
127 |
} |
|
128 |
|
|
129 |
public BufferConfigurationPanel(FLyrVect[] array, IView view) { |
|
130 |
this(Arrays.asList(array),view); |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* Initializes this component. |
|
135 |
*/ |
|
136 |
private void initialize() { |
|
137 |
outside = |
|
138 |
new SideInfo(BufferSelectionProcess.BUFFER_OUTSIDE_POLY, |
|
139 |
PluginServices.getText(null, "Outside")); |
|
140 |
inside = |
|
141 |
new SideInfo(BufferSelectionProcess.BUFFER_INSIDE_POLY, |
|
142 |
PluginServices.getText(null, "Inside")); |
|
143 |
out_in_side = |
|
144 |
new SideInfo(BufferSelectionProcess.BUFFER_INSIDE_OUTSIDE_POLY, |
|
145 |
PluginServices.getText(null, "Both")); |
|
146 |
|
|
147 |
setLayout(new BorderLayout()); |
|
148 |
this.setBorder(new EmptyBorder(5, 5, 5, 5)); |
|
149 |
this.setSize(300, 275); |
|
150 |
|
|
151 |
GridBagLayout gbl = new GridBagLayout(); |
|
152 |
JPanel centerPanel = new JPanel(gbl); |
|
153 |
GridBagConstraints c = new GridBagConstraints(); |
|
154 |
|
|
155 |
c.fill = GridBagConstraints.BOTH; |
|
156 |
c.weightx = 1; |
|
157 |
c.weighty = 1; |
|
158 |
|
|
159 |
c.gridx = 0; |
|
160 |
c.gridy = 0; |
|
161 |
centerPanel.add(getWidthPanel(),c); |
|
162 |
|
|
163 |
c.gridy = 1; |
|
164 |
centerPanel.add(getSidePanel(),c); |
|
165 |
|
|
166 |
c.gridy = 2; |
|
167 |
centerPanel.add(getOptionsPanel(),c); |
|
168 |
|
|
169 |
this.add(centerPanel, BorderLayout.CENTER); |
|
170 |
|
|
171 |
this.add(getAdaptedAcceptCancelPanel(), BorderLayout.SOUTH); |
|
172 |
} |
|
173 |
|
|
174 |
private JPanel getOptionsPanel() { |
|
175 |
if (optionsPanel == null) { |
|
176 |
optionsPanel = new JPanel(new GridBagLayout()); |
|
177 |
optionsPanel.setBorder(BorderFactory.createTitledBorder(PluginServices.getText(optionsPanel, |
|
178 |
"Options"))); |
|
179 |
GridBagConstraints cons = new GridBagConstraints(); |
|
180 |
|
|
181 |
cons.fill = GridBagConstraints.BOTH; |
|
182 |
cons.insets = new Insets(0, 5, 0, 5); |
|
183 |
|
|
184 |
cons.gridx = 0; |
|
185 |
cons.gridy = 0; |
|
186 |
cons.weightx = 1; |
|
187 |
optionsPanel.add(getMultiLayerSelectionCBox(),cons); |
|
188 |
} |
|
189 |
|
|
190 |
return optionsPanel; |
|
191 |
} |
|
192 |
|
|
193 |
private JCheckBox getMultiLayerSelectionCBox() { |
|
194 |
if (multiLayerSelectionCBox == null) { |
|
195 |
multiLayerSelectionCBox = new JCheckBox(); |
|
196 |
multiLayerSelectionCBox.setText(PluginServices.getText(multiLayerSelectionCBox, |
|
197 |
"MultiLayer_selection")); |
|
198 |
multiLayerSelectionCBox.setSelected(true); |
|
199 |
multiLayerSelectionCBox.setToolTipText(PluginServices.getText(null, |
|
200 |
"multiLayerSelection_checkbox_TOOLTIP_HTML_explanation")); |
|
201 |
} |
|
202 |
|
|
203 |
return multiLayerSelectionCBox; |
|
204 |
} |
|
205 |
|
Also available in: Unified diff