Revision 37669
tags/v_2_0_0_Build_2043/extensions/org.gvsig.selectiontools.app/prepare-workspace.xml | ||
---|---|---|
1 |
<project name="org.gvsig.initial.build" default="prepare-workspace"> |
|
2 |
|
|
3 |
<dirname property="org.gvsig.initial.build.basedir" file="${ant.file.org.gvsig.initial.build}" /> |
|
4 |
|
|
5 |
<property name="workspace.basedir" value="${org.gvsig.initial.build.basedir}/.." /> |
|
6 |
<property name="build.basedir" value="${workspace.basedir}/org.gvsig.maven.base.build" description="Eclipse workspace location" /> |
|
7 |
<property name="build.jar.version" value="1.0.8-SNAPSHOT" /> |
|
8 |
<property name="build.jar.file" value="org.gvsig.maven.base.build-${build.jar.version}.jar" /> |
|
9 |
|
|
10 |
<property name="ant.libs.dir" location="${build.basedir}" description="Additional ant tasks libs folder" /> |
|
11 |
|
|
12 |
<target name="check-maven-base-build-available"> |
|
13 |
<available file="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" property="maven-base-build-available" /> |
|
14 |
</target> |
|
15 |
|
|
16 |
<target name="get-maven-base-build-local" depends="check-maven-base-build-available" if="maven-base-build-available"> |
|
17 |
<!-- Unzip de build jar file from the maven repository into the workspace root folder --> |
|
18 |
<copy todir="${workspace.basedir}" preservelastmodified="false" filtering="false"> |
|
19 |
<zipfileset src="${user.home}/.m2/repository/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}"> |
|
20 |
<patternset> |
|
21 |
<exclude name="META-INF/**" /> |
|
22 |
</patternset> |
|
23 |
</zipfileset> |
|
24 |
</copy> |
|
25 |
</target> |
|
26 |
|
|
27 |
<target name="get-maven-base-build-remote" depends="check-maven-base-build-available" unless="maven-base-build-available"> |
|
28 |
<mkdir dir="target" /> |
|
29 |
|
|
30 |
<!-- Download the build jar file --> |
|
31 |
<get src="http://devel.gvsig.org/m2repo/j2se/org/gvsig/org.gvsig.maven.base.build/${build.jar.version}/${build.jar.file}" dest="target/${build.jar.file}" verbose="true" /> |
|
32 |
|
|
33 |
<!-- Unzip de build jar file into the workspace root folder --> |
|
34 |
<copy todir="${workspace.basedir}" preservelastmodified="false" filtering="false"> |
|
35 |
<zipfileset src="target/${build.jar.file}"> |
|
36 |
<patternset> |
|
37 |
<exclude name="META-INF/**" /> |
|
38 |
</patternset> |
|
39 |
</zipfileset> |
|
40 |
</copy> |
|
41 |
|
|
42 |
</target> |
|
43 |
|
|
44 |
<target name="find.depends.natives.file"> |
|
45 |
<condition property="depends.natives.file.exists"> |
|
46 |
<available file="${org.gvsig.initial.build.basedir}/DEPENDS_ON_NATIVE_LIBRARIES"/> |
|
47 |
</condition> |
|
48 |
</target> |
|
49 |
|
|
50 |
<target name="find.gvsig.platform.properties.file" |
|
51 |
depends="find.depends.natives.file" |
|
52 |
if="depends.natives.file.exists"> |
|
53 |
<condition property="gvsig.platform.exists"> |
|
54 |
<available file="${user.home}/.gvsig.platform.properties"/> |
|
55 |
</condition> |
|
56 |
</target> |
|
57 |
|
|
58 |
<target name="check.gvsig.platform.properties" |
|
59 |
depends="find.gvsig.platform.properties.file"> |
|
60 |
<fail if="depends.natives.file.exists" unless="gvsig.platform.exists"> |
|
61 |
ERROR!! |
|
62 |
|
|
63 |
You have to define your gvSIG platform properties, |
|
64 |
by creating the file: ${user.home}/.gvsig.platform.properties |
|
65 |
with the following content: |
|
66 |
|
|
67 |
native_platform=linux |
|
68 |
native_distribution=all |
|
69 |
native_compiler=gcc4 |
|
70 |
native_arch=i386 |
|
71 |
native_libraryType=dynamic |
|
72 |
export native_classifier=${native_platform}-${native_distribution}-${native_compiler}-${native_arch}-${native_libraryType} |
|
73 |
|
|
74 |
Replace the fifth initial variables values with the ones appropiate |
|
75 |
to your platform. |
|
76 |
|
|
77 |
If you use maven in the command line, you can use the previous file also |
|
78 |
to define the MAVEN_OPTS environment variable, by adding to your |
|
79 |
.bash_rc file something like this: |
|
80 |
|
|
81 |
if [ -f "${HOME}/.gvsig.platform.properties" ] |
|
82 |
then |
|
83 |
. ${HOME}/.gvsig.platform.properties |
|
84 |
export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m -Dnative-classifier=${native_classifier}" |
|
85 |
else |
|
86 |
export MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=64m" |
|
87 |
fi |
|
88 |
|
|
89 |
It will work if you use the bash shell. In any other case or platform, you'll |
|
90 |
have to define your MAVEN_OPTS environment variable and set the |
|
91 |
"native-classifier" parameter directly. |
|
92 |
</fail> |
|
93 |
|
|
94 |
</target> |
|
95 |
|
|
96 |
<target name="prepare-workspace" depends="get-maven-base-build-local,get-maven-base-build-remote,check.gvsig.platform.properties"> |
|
97 |
|
|
98 |
<mkdir dir="target" /> |
|
99 |
|
|
100 |
<chmod dir="${build.basedir}/maven/bin" perm="u+x" includes="m2,mvn,mvnDebug" /> |
|
101 |
|
|
102 |
<!-- Copy the maven launchers to the workspace metadata folder --> |
|
103 |
<copy todir="${workspace.basedir}/.metadata"> |
|
104 |
<fileset dir="${build.basedir}/eclipse-launchers"> |
|
105 |
<exclude name="**/org.eclipse.jdt.core.prefs" /> |
|
106 |
<exclude name="**/org.eclipse.core.variables.prefs" /> |
|
107 |
</fileset> |
|
108 |
</copy> |
|
109 |
|
|
110 |
<concat destfile="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs" append="true"> |
|
111 |
<filelist dir="${build.basedir}/eclipse-launchers/.plugins/org.eclipse.core.runtime/.settings" files="org.eclipse.jdt.core.prefs" /> |
|
112 |
</concat> |
|
113 |
<concat destfile="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.variables.prefs" append="true"> |
|
114 |
<filelist dir="${build.basedir}/eclipse-launchers/.plugins/org.eclipse.core.runtime/.settings" files="org.eclipse.core.variables.prefs" /> |
|
115 |
</concat> |
|
116 |
|
|
117 |
<!-- Configure the eclipse workspace --> |
|
118 |
<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-configure-eclipse-workspace" /> |
|
119 |
|
|
120 |
<!-- Configure the gvSIG profile --> |
|
121 |
<ant antfile="${build.basedir}/check-gvsig-profile.xml" /> |
|
122 |
|
|
123 |
<property name="user-settings-file-location" value="${user.home}/.m2/settings.xml" /> |
|
124 |
|
|
125 |
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"> |
|
126 |
<classpath> |
|
127 |
<pathelement location="${ant.libs.dir}/com.oopsconsultancy.xmltask-1.16.1.jar" /> |
|
128 |
</classpath> |
|
129 |
</taskdef> |
|
130 |
|
|
131 |
<xmltask source="${user-settings-file-location}" dest="${user-settings-file-location}"> |
|
132 |
<copy path="//:settings/:profiles/:profile[:id/text() = 'gvsig-install']/:properties/:gvsig.install.dir/text()" property="current-gvsig-location" /> |
|
133 |
</xmltask> |
|
134 |
|
|
135 |
<replace file="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs" token="@GVSIG_HOME@" value="${current-gvsig-location}" /> |
|
136 |
<replace file="${workspace.basedir}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.variables.prefs" token="@GVSIG_HOME@" value="${current-gvsig-location}" /> |
|
137 |
|
|
138 |
<!-- Compile, install and generate eclipse projects --> |
|
139 |
<ant antfile="${build.basedir}/maven-goals.xml" target="mvn-install-and-eclipse-eclipse" /> |
|
140 |
|
|
141 |
<echo>INFORMATION!!!</echo> |
|
142 |
<echo>Restart eclipse and then proceed to import the subprojects contained into the main project</echo> |
|
143 |
|
|
144 |
<!-- TODO: copiar al proyecto de configuraciĆ³n general --> |
|
145 |
</target> |
|
146 |
|
|
147 |
<target name="clean"> |
|
148 |
<delete dir="target" /> |
|
149 |
</target> |
|
150 |
|
|
151 |
</project> |
|
0 | 152 |
tags/v_2_0_0_Build_2043/extensions/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" |
|
4 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
5 |
<modelVersion>4.0.0</modelVersion> |
|
6 |
<artifactId>org.gvsig.selectiontools.app</artifactId> |
|
7 |
<packaging>pom</packaging> |
|
8 |
<version>1.0.0-SNAPSHOT</version> |
|
9 |
<name>org.gvsig.selectiontools.app</name> |
|
10 |
<description>Advanced selection tools: |
|
11 |
- select all |
|
12 |
- by buffer |
|
13 |
- by cicle |
|
14 |
- by polilyne |
|
15 |
</description> |
|
16 |
<parent> |
|
17 |
<groupId>org.gvsig</groupId> |
|
18 |
<artifactId>org.gvsig.maven.base.extension.pom</artifactId> |
|
19 |
<version>1.0.8-SNAPSHOT</version> |
|
20 |
</parent> |
|
21 |
<scm> |
|
22 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-desktop/branches/v2_0_0_prep/extensions/org.gvsig.selectiontools.app</connection> |
|
23 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-desktop/branches/v2_0_0_prep/extensions/org.gvsig.selectiontools.app</developerConnection> |
|
24 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-desktop/repository/show/branches/v2_0_0_prep/extensions/org.gvsig.selectiontools.app</url> |
|
25 |
</scm> |
|
26 |
<repositories> |
|
27 |
<repository> |
|
28 |
<id>gvsig-public-http-repository</id> |
|
29 |
<name>gvSIG maven public HTTP repository</name> |
|
30 |
<url>http://devel.gvsig.org/m2repo/j2se</url> |
|
31 |
<releases> |
|
32 |
<enabled>true</enabled> |
|
33 |
<updatePolicy>daily</updatePolicy> |
|
34 |
<checksumPolicy>warn</checksumPolicy> |
|
35 |
</releases> |
|
36 |
<snapshots> |
|
37 |
<enabled>true</enabled> |
|
38 |
<updatePolicy>daily</updatePolicy> |
|
39 |
<checksumPolicy>warn</checksumPolicy> |
|
40 |
</snapshots> |
|
41 |
</repository> |
|
42 |
</repositories> |
|
43 |
<dependencyManagement> |
|
44 |
<dependencies> |
|
45 |
<dependency> |
|
46 |
<groupId>org.gvsig</groupId> |
|
47 |
<artifactId>org.gvsig.core.maven.dependencies</artifactId> |
|
48 |
<version>2.0.1-SNAPSHOT</version> |
|
49 |
<type>pom</type> |
|
50 |
<scope>import</scope> |
|
51 |
</dependency> |
|
52 |
</dependencies> |
|
53 |
</dependencyManagement> |
|
54 |
<modules> |
|
55 |
<module>org.gvsig.selectiontools.app.extension</module> |
|
56 |
</modules> |
|
57 |
<properties> |
|
58 |
<package.info.state>alpha3</package.info.state> |
|
59 |
</properties> |
|
60 |
|
|
61 |
</project> |
|
0 | 62 |
tags/v_2_0_0_Build_2043/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/v_2_0_0_Build_2043/extensions/org.gvsig.selectiontools.app/distribution/distribution.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
</assembly> |
|
0 | 3 |
tags/v_2_0_0_Build_2043/extensions/org.gvsig.selectiontools.app/buildNumber.properties | ||
---|---|---|
1 |
#maven.buildNumber.plugin properties file |
|
2 |
#Thu Jan 12 18:43:37 CET 2012 |
|
3 |
buildNumber=2051 |
tags/v_2_0_0_Build_2043/extensions/org.gvsig.selectiontools.app/.project | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>org.gvsig.selectiontools.app</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
</buildSpec> |
|
9 |
<natures> |
|
10 |
</natures> |
|
11 |
</projectDescription> |
tags/v_2_0_0_Build_2043/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/buildNumber.properties | ||
---|---|---|
1 |
#maven.buildNumber.plugin properties file |
|
2 |
#Thu Jan 12 18:43:37 CET 2012 |
|
3 |
buildNumber=2043 |
tags/v_2_0_0_Build_2043/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.PluginServices; |
|
26 |
import org.gvsig.andami.messages.NotificationManager; |
|
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.fmap.dal.exception.DataException; |
|
32 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
33 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
34 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
35 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
36 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
37 |
|
|
38 |
/** |
|
39 |
* <p> |
|
40 |
* Extension to add support for selecting all the features of a vector layer. |
|
41 |
* </p> |
|
42 |
* |
|
43 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
44 |
*/ |
|
45 |
public class SelectAllExtension extends Extension { |
|
46 |
|
|
47 |
/* |
|
48 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
49 |
*/ |
|
50 |
public void initialize() { |
|
51 |
registerIcons(); |
|
52 |
} |
|
53 |
|
|
54 |
private void registerIcons() { |
|
55 |
PluginServices.getIconTheme().registerDefault("select-all-icon", |
|
56 |
this.getClass() |
|
57 |
.getClassLoader() |
|
58 |
.getResource("images/select-all-icon.png")); |
|
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("SELALL")) { |
|
68 |
IWindow view = PluginServices.getMDIManager().getActiveWindow(); |
|
69 |
if (view instanceof IView) { |
|
70 |
MapControl mc = ((IView) view).getMapControl(); |
|
71 |
FLayer[] activeLayers = |
|
72 |
mc.getMapContext().getLayers().getActives(); |
|
73 |
|
|
74 |
FLayer layer; |
|
75 |
|
|
76 |
for (int i = 0; i < activeLayers.length; i++) { |
|
77 |
layer = activeLayers[i]; |
|
78 |
|
|
79 |
if ((layer.isAvailable()) && (layer instanceof FLyrVect)) { |
|
80 |
FLyrVect lyrVect = (FLyrVect) layer; |
|
81 |
|
|
82 |
try { |
|
83 |
FeatureStore fs = lyrVect.getFeatureStore(); |
|
84 |
fs.getFeatureSelection().selectAll(); |
|
85 |
} catch (DataException e) { |
|
86 |
NotificationManager.showMessageError("Data exception", |
|
87 |
e); |
|
88 |
} |
|
89 |
} |
|
90 |
} |
|
91 |
} |
|
92 |
} |
|
93 |
} |
|
94 |
|
|
95 |
/* |
|
96 |
* @see com.iver.andami.plugins.IExtension#isVisible() |
|
97 |
*/ |
|
98 |
public boolean isVisible() { |
|
99 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
100 |
|
|
101 |
if (f == null) { |
|
102 |
return false; |
|
103 |
} |
|
104 |
|
|
105 |
if (f instanceof IView) { |
|
106 |
IView vista = (IView) f; |
|
107 |
ViewDocument viewDocument = vista.getViewDocument(); // .getModel(); |
|
108 |
MapContext mapa = viewDocument.getMapContext(); |
|
109 |
|
|
110 |
return mapa.getLayers().getLayersCount() > 0; |
|
111 |
} |
|
112 |
|
|
113 |
return false; |
|
114 |
} |
|
115 |
|
|
116 |
/* |
|
117 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
118 |
*/ |
|
119 |
public boolean isEnabled() { |
|
120 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
121 |
|
|
122 |
if (f == null) { |
|
123 |
return false; |
|
124 |
} |
|
125 |
|
|
126 |
if (f instanceof IView) { |
|
127 |
IView vista = (IView) f; |
|
128 |
ViewDocument viewDocument = vista.getViewDocument(); |
|
129 |
MapContext mapa = viewDocument.getMapContext(); |
|
130 |
|
|
131 |
FLayer layers[] = mapa.getLayers().getActives(); |
|
132 |
FLayer layer; |
|
133 |
|
|
134 |
for (int i = 0; i < layers.length; i++) { |
|
135 |
layer = layers[i]; |
|
136 |
|
|
137 |
if ((layer instanceof FLyrVect) && (layer.isAvailable()) |
|
138 |
&& (layer.isActive())) |
|
139 |
return true; |
|
140 |
} |
|
141 |
} |
|
142 |
|
|
143 |
return false; |
|
144 |
} |
|
145 |
} |
|
0 | 146 |
tags/v_2_0_0_Build_2043/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.PluginServices; |
|
4 |
import org.gvsig.andami.plugins.Extension; |
|
5 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
6 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
7 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
8 |
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener; |
|
9 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
10 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
11 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
12 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
13 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
|
14 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseMovementBehavior; |
|
15 |
import org.gvsig.selectiontools.app.extension.tools.CircleSelectListener; |
|
16 |
import org.gvsig.selectiontools.app.extension.tools.behavior.CircleSelectionBehavior; |
|
17 |
|
|
18 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
19 |
* |
|
20 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
21 |
* of the Valencian Government (CIT) |
|
22 |
* |
|
23 |
* This program is free software; you can redistribute it and/or |
|
24 |
* modify it under the terms of the GNU General Public License |
|
25 |
* as published by the Free Software Foundation; either version 2 |
|
26 |
* of the License, or (at your option) any later version. |
|
27 |
* |
|
28 |
* This program is distributed in the hope that it will be useful, |
|
29 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
30 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
31 |
* GNU General Public License for more details. |
|
32 |
* |
|
33 |
* You should have received a copy of the GNU General Public License |
|
34 |
* along with this program; if not, write to the Free Software |
|
35 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
36 |
* MA 02110-1301, USA. |
|
37 |
* |
|
38 |
*/ |
|
39 |
|
|
40 |
/** |
|
41 |
* <p> |
|
42 |
* Extension to add support for selecting the geometries of the active vector |
|
43 |
* layers that intersect with a circle defined by the user. |
|
44 |
* </p> |
|
45 |
* |
|
46 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
47 |
*/ |
|
48 |
public class SelectByCircleExtension extends Extension { |
|
49 |
|
|
50 |
public static final String CIRCLE_SELECTION_TOOL_NAME = "circleSelection"; |
|
51 |
|
|
52 |
/* |
|
53 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
54 |
*/ |
|
55 |
public void initialize() { |
|
56 |
registerIcons(); |
|
57 |
} |
|
58 |
|
|
59 |
private void registerIcons() { |
|
60 |
PluginServices.getIconTheme().registerDefault("circle-cursor-icon", |
|
61 |
this.getClass() |
|
62 |
.getClassLoader() |
|
63 |
.getResource("images/circle-cursor-icon.png")); |
|
64 |
|
|
65 |
PluginServices.getIconTheme().registerDefault("select-by-circle-icon", |
|
66 |
this.getClass() |
|
67 |
.getClassLoader() |
|
68 |
.getResource("images/select-by-circle-icon.png")); |
|
69 |
} |
|
70 |
|
|
71 |
/* |
|
72 |
* (non-Javadoc) |
|
73 |
* |
|
74 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String) |
|
75 |
*/ |
|
76 |
public void execute(String actionCommand) { |
|
77 |
if (actionCommand.equals("SELCIRCLE")) { |
|
78 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
79 |
if (window instanceof IView) { |
|
80 |
IView view = (IView) window; |
|
81 |
// Selection by circle |
|
82 |
MapControl mc = view.getMapControl(); |
|
83 |
|
|
84 |
// If current's view MapControl doesn't have the |
|
85 |
// "CircleSelection" tool, adds it |
|
86 |
if (!mc.getNamesMapTools() |
|
87 |
.containsKey(CIRCLE_SELECTION_TOOL_NAME)) { |
|
88 |
CircleSelectListener circleSelListener = |
|
89 |
new CircleSelectListener(mc); |
|
90 |
mc.addBehavior(CIRCLE_SELECTION_TOOL_NAME, new Behavior[] { |
|
91 |
new CircleSelectionBehavior(circleSelListener), |
|
92 |
new MouseMovementBehavior(new StatusBarListener(mc)) }); |
|
93 |
} |
|
94 |
|
|
95 |
mc.setTool(CIRCLE_SELECTION_TOOL_NAME); |
|
96 |
} |
|
97 |
} |
|
98 |
} |
|
99 |
|
|
100 |
/* |
|
101 |
* @see com.iver.andami.plugins.IExtension#isVisible() |
|
102 |
*/ |
|
103 |
public boolean isVisible() { |
|
104 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
105 |
|
|
106 |
if (f == null) { |
|
107 |
return false; |
|
108 |
} |
|
109 |
|
|
110 |
if (f instanceof IView) { |
|
111 |
IView vista = (IView) f; |
|
112 |
ViewDocument model = vista.getViewDocument(); |
|
113 |
MapContext mapa = model.getMapContext(); |
|
114 |
|
|
115 |
return mapa.getLayers().getLayersCount() > 0; |
|
116 |
} |
|
117 |
|
|
118 |
return false; |
|
119 |
} |
|
120 |
|
|
121 |
/* |
|
122 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
123 |
*/ |
|
124 |
public boolean isEnabled() { |
|
125 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
126 |
|
|
127 |
if (f == null) { |
|
128 |
return false; |
|
129 |
} |
|
130 |
|
|
131 |
if (f instanceof IView) { |
|
132 |
IView vista = (IView) f; |
|
133 |
ViewDocument model = vista.getViewDocument(); |
|
134 |
MapContext mapa = model.getMapContext(); |
|
135 |
|
|
136 |
FLayer layers[] = mapa.getLayers().getActives(); |
|
137 |
FLayer layer; |
|
138 |
|
|
139 |
for (int i = 0; i < layers.length; i++) { |
|
140 |
layer = layers[i]; |
|
141 |
|
|
142 |
if ((layer instanceof FLyrVect) && (layer.isAvailable()) |
|
143 |
&& (layer.isActive())) |
|
144 |
return true; |
|
145 |
} |
|
146 |
} |
|
147 |
|
|
148 |
return false; |
|
149 |
} |
|
150 |
} |
|
0 | 151 |
tags/v_2_0_0_Build_2043/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/AboutSelectionToolsExtension.java | ||
---|---|---|
1 |
package org.gvsig.selectiontools.app.extension; |
|
2 |
|
|
3 |
import org.gvsig.about.AboutManager; |
|
4 |
import org.gvsig.about.AboutParticipant; |
|
5 |
import org.gvsig.andami.plugins.Extension; |
|
6 |
import org.gvsig.app.ApplicationLocator; |
|
7 |
import org.gvsig.app.ApplicationManager; |
|
8 |
|
|
9 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
10 |
* |
|
11 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
12 |
* of the Valencian Government (CIT) |
|
13 |
* |
|
14 |
* This program is free software; you can redistribute it and/or |
|
15 |
* modify it under the terms of the GNU General Public License |
|
16 |
* as published by the Free Software Foundation; either version 2 |
|
17 |
* of the License, or (at your option) any later version. |
|
18 |
* |
|
19 |
* This program is distributed in the hope that it will be useful, |
|
20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
22 |
* GNU General Public License for more details. |
|
23 |
* |
|
24 |
* You should have received a copy of the GNU General Public License |
|
25 |
* along with this program; if not, write to the Free Software |
|
26 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
27 |
* MA 02110-1301, USA. |
|
28 |
* |
|
29 |
*/ |
|
30 |
|
|
31 |
/** |
|
32 |
* <p> |
|
33 |
* Some selection tools for gvSIG of the <i>Consejer?a de Medio Ambiente de la |
|
34 |
* Junta de Castilla y Le?n.</i> |
|
35 |
* </p> |
|
36 |
* project. |
|
37 |
* |
|
38 |
* @author Vicente Caballero Navarro (vicente.caballero@iver.es) |
|
39 |
* @author Jaume Dom?nguez Faus (jaume.dominguez@iver.es) |
|
40 |
* @author C?sar Mart?nez Izquierdo (cesar.martinez@iver.es) |
|
41 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
42 |
* @author Jos? Manuel Viv? Arnal (josemanuel.vivo@iver.es) |
|
43 |
*/ |
|
44 |
public class AboutSelectionToolsExtension extends Extension { |
|
45 |
|
|
46 |
/* |
|
47 |
* (non-Javadoc) |
|
48 |
* |
|
49 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
50 |
*/ |
|
51 |
public void initialize() { |
|
52 |
} |
|
53 |
|
|
54 |
public void postInitialize() { |
|
55 |
// Register the about panel |
|
56 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
57 |
|
|
58 |
AboutManager about = application.getAbout(); |
|
59 |
|
|
60 |
about.addDeveloper("IVER", this.getClass().getClassLoader() |
|
61 |
.getResource("iver.html"), 1); |
|
62 |
|
|
63 |
AboutParticipant participant = about.getDeveloper("IVER"); |
|
64 |
participant.addContribution("SelectionToolsExtension", |
|
65 |
"Selection tools", 2009, 1, 1, 2009, 12, 31); |
|
66 |
|
|
67 |
about.addSponsor("Junta de Castilla y Le?n", // Junta de Castilla y Le?n |
|
68 |
getClass().getClassLoader().getResource("jcyl.html"), 2); |
|
69 |
} |
|
70 |
|
|
71 |
/* |
|
72 |
* (non-Javadoc) |
|
73 |
* |
|
74 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String) |
|
75 |
*/ |
|
76 |
public void execute(String actionCommand) { |
|
77 |
} |
|
78 |
|
|
79 |
/* |
|
80 |
* (non-Javadoc) |
|
81 |
* |
|
82 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
83 |
*/ |
|
84 |
public boolean isEnabled() { |
|
85 |
return false; |
|
86 |
} |
|
87 |
|
|
88 |
/* |
|
89 |
* (non-Javadoc) |
|
90 |
* |
|
91 |
* @see com.iver.andami.plugins.IExtension#isVisible() |
|
92 |
*/ |
|
93 |
public boolean isVisible() { |
|
94 |
return false; |
|
95 |
} |
|
96 |
} |
|
0 | 97 |
tags/v_2_0_0_Build_2043/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/v_2_0_0_Build_2043/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/v_2_0_0_Build_2043/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/v_2_0_0_Build_2043/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.PluginServices; |
|
33 |
import org.gvsig.andami.messages.NotificationManager; |
|
34 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
35 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
36 |
import org.gvsig.fmap.geom.Geometry; |
|
37 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
38 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
39 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
40 |
import org.gvsig.fmap.geom.GeometryManager; |
|
41 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
42 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
43 |
import org.gvsig.fmap.geom.primitive.Surface; |
|
44 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
45 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
46 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
47 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
48 |
import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent; |
|
49 |
import org.gvsig.fmap.mapcontrol.tools.Listeners.PolylineListener; |
|
50 |
|
|
51 |
/** |
|
52 |
* <p> |
|
53 |
* Listener that selects all features of the active and vector layers which |
|
54 |
* intersect with the defined polyline in the associated {@link MapControl |
|
55 |
* MapControl} object. |
|
56 |
* </p> |
|
57 |
* |
|
58 |
* <p> |
|
59 |
* The selection will be produced after user finishes the creation of the |
|
60 |
* polyline. |
|
61 |
* </p> |
|
62 |
* |
|
63 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
64 |
*/ |
|
65 |
public class PolyLineSelectionListener implements PolylineListener { |
|
66 |
|
|
67 |
/** |
|
68 |
* The image to display when the cursor is active. |
|
69 |
*/ |
|
70 |
private final Image img = new ImageIcon(this.getClass() |
|
71 |
.getClassLoader() |
|
72 |
.getResource("images/polyline-cursor-icon.png")).getImage(); |
|
73 |
|
|
74 |
/** |
|
75 |
* The cursor used to work with this tool listener. |
|
76 |
* |
|
77 |
* @see #getCursor() |
|
78 |
*/ |
|
79 |
private Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(img, |
|
80 |
new Point(16, 16), |
|
81 |
""); |
|
82 |
|
|
83 |
/** |
|
84 |
* Reference to the <code>MapControl</code> object that uses. |
|
85 |
*/ |
|
86 |
private MapControl mapCtrl; |
|
87 |
|
|
88 |
/** |
|
89 |
* <p> |
|
90 |
* Creates a new <code>PolygonSelectionListener</code> object. |
|
91 |
* </p> |
|
92 |
* |
|
93 |
* @param mc |
|
94 |
* the <code>MapControl</code> where is drawn the polyline |
|
95 |
*/ |
|
96 |
public PolyLineSelectionListener(MapControl mc) { |
|
97 |
this.mapCtrl = mc; |
|
98 |
} |
|
99 |
|
|
100 |
/* |
|
101 |
* (non-Javadoc) |
|
102 |
* |
|
103 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor() |
|
104 |
*/ |
|
105 |
public Cursor getCursor() { |
|
106 |
return cur; |
|
107 |
} |
|
108 |
|
|
109 |
/* |
|
110 |
* (non-Javadoc) |
|
111 |
* |
|
112 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing() |
|
113 |
*/ |
|
114 |
public boolean cancelDrawing() { |
|
115 |
return false; |
|
116 |
} |
|
117 |
|
|
118 |
/* |
|
119 |
* (non-Javadoc) |
|
120 |
* |
|
121 |
* @see |
|
122 |
* com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#points(com.iver |
|
123 |
* .cit.gvsig.fmap.tools.Events.MeasureEvent) |
|
124 |
*/ |
|
125 |
public void points(MeasureEvent event) throws BehaviorException { |
|
126 |
} |
|
127 |
|
|
128 |
/* |
|
129 |
* (non-Javadoc) |
|
130 |
* |
|
131 |
* @see |
|
132 |
* com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#pointFixed(com |
|
133 |
* .iver.cit.gvsig.fmap.tools.Events.MeasureEvent) |
|
134 |
*/ |
|
135 |
public void pointFixed(MeasureEvent event) throws BehaviorException { |
|
136 |
} |
|
137 |
|
|
138 |
/* |
|
139 |
* (non-Javadoc) |
|
140 |
* |
|
141 |
* @see |
|
142 |
* com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#polylineFinished |
|
143 |
* (com.iver.cit.gvsig.fmap.tools.Events.MeasureEvent) |
|
144 |
*/ |
|
145 |
public void polylineFinished(MeasureEvent event) throws BehaviorException { |
|
146 |
try { |
|
147 |
GeneralPathX gp = event.getGP(); |
|
148 |
GeometryManager manager = GeometryLocator.getGeometryManager(); |
|
149 |
Geometry geom = null; |
|
150 |
Surface surface = null; |
|
151 |
try { |
|
152 |
surface = |
|
153 |
(Surface) manager.create(TYPES.SURFACE, SUBTYPES.GEOM2D); |
|
154 |
surface.setGeneralPath(gp); |
|
155 |
geom = surface; |
|
156 |
} catch (CreateGeometryException e1) { |
|
157 |
NotificationManager.showMessageError(PluginServices.getText(null, |
|
158 |
"Failed_creating_geometry"), |
|
159 |
e1); |
|
160 |
} |
|
161 |
if (geom == null) |
|
162 |
return; |
|
163 |
|
|
164 |
FLayer[] actives = mapCtrl.getMapContext().getLayers().getActives(); |
|
165 |
|
|
166 |
for (int i = 0; i < actives.length; i++) { |
|
167 |
if (actives[i] instanceof FLyrVect) { |
|
168 |
FLyrVect lyrVect = (FLyrVect) actives[i]; |
|
169 |
FeatureSet newSelection = null; |
|
170 |
|
|
171 |
newSelection = |
|
172 |
lyrVect.queryByGeometry(geom, lyrVect.getFeatureStore() |
|
173 |
.getDefaultFeatureType()); |
|
174 |
|
|
175 |
if (event.getEvent().isControlDown()) { |
|
176 |
((FeatureSelection) lyrVect.getDataStore() |
|
177 |
.getSelection()).select(newSelection); |
|
178 |
} else { |
|
179 |
lyrVect.getFeatureStore().setSelection(newSelection); |
|
180 |
} |
|
181 |
} |
|
182 |
} |
|
183 |
} catch (com.vividsolutions.jts.geom.TopologyException topEx) { |
|
184 |
NotificationManager.showMessageError(PluginServices.getText(null, |
|
185 |
"Failed_selecting_geometries_by_polyline_topology_exception_explanation"), |
|
186 |
topEx); |
|
187 |
} catch (Exception ex) { |
|
188 |
NotificationManager.showMessageError(PluginServices.getText(null, |
|
189 |
"Failed_selecting_geometries"), ex); |
|
190 |
} |
|
191 |
} |
|
192 |
|
|
193 |
public Image getImageCursor() { |
|
194 |
return img; |
|
195 |
} |
|
196 |
} |
|
0 | 197 |
tags/v_2_0_0_Build_2043/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/tools/buffer/process/BufferSelectionProcess.java | ||
---|---|---|
1 |
package org.gvsig.selectiontools.app.extension.tools.buffer.process; |
|
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.event.MouseAdapter; |
|
26 |
import java.awt.event.MouseEvent; |
|
27 |
import java.util.ArrayList; |
|
28 |
import java.util.Iterator; |
|
29 |
|
|
30 |
import javax.swing.JButton; |
|
31 |
|
|
32 |
import org.cresques.cts.IProjection; |
|
33 |
import org.gvsig.andami.PluginServices; |
|
34 |
import org.gvsig.andami.messages.NotificationManager; |
|
35 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
36 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
37 |
import org.gvsig.fmap.dal.feature.Feature; |
|
38 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
39 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
40 |
import org.gvsig.fmap.geom.Geometry; |
|
41 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
42 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
43 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
44 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
45 |
import org.gvsig.gui.beans.incrementabletask.IncrementableProcess; |
|
46 |
import org.gvsig.gui.beans.incrementabletask.IncrementableTask; |
|
47 |
import org.gvsig.selectiontools.app.extension.tools.buffer.gui.BufferConfigurationPanel; |
|
48 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
49 |
|
|
50 |
/** |
|
51 |
* |
|
52 |
* |
|
53 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
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 |
} |
|
206 |
}); |
|
207 |
} |
|
208 |
|
|
209 |
/** |
|
210 |
* Importation process. |
|
211 |
* |
|
212 |
* @throws InterruptedException |
|
213 |
* if fails the process |
|
214 |
*/ |
|
215 |
public void process() throws InterruptedException { |
|
216 |
percentage = 5; |
|
217 |
double inc = 0; |
|
218 |
FeatureSelection selections[] = new FeatureSelection[layers.length]; |
|
219 |
ArrayList<Geometry> buffer[] = new ArrayList[layers.length]; |
|
220 |
try { |
Also available in: Unified diff