Revision 38759

View differences:

tags/v2_0_0_Build_2051/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>devel</package.info.state>
59
		<!-- alpha-devel -->
60
	</properties>
61

  
62
</project>
0 63

  
tags/v2_0_0_Build_2051/extensions/org.gvsig.selectiontools.app/README.txt
1
The first time you checkout the current project to a new workspace, 
2
you have to prepare it to be able to work easily with maven from
3
eclipse itself.
4

  
5
Perform the following steps:
6

  
7
1.- Launch the *prepare-workspace.xml* ant build file. 
8
    You can do it by loading the file into the ant view, 
9
    and running the default task, or right-clicking the 
10
    file from the package explorer or the navigator and
11
    select the option: *Run as > Ant build*. 
12
    
13
2.- Restart eclipse.
14

  
15
3.- Import the subprojects of the project you have just checked out.
16

  
17
Those steps are only needed once per workspace.     
18

  
0 19

  
tags/v2_0_0_Build_2051/extensions/org.gvsig.selectiontools.app/distribution/distribution.xml
1
<assembly>
2
</assembly>
0 3

  
tags/v2_0_0_Build_2051/extensions/org.gvsig.selectiontools.app/buildNumber.properties
1
#maven.buildNumber.plugin properties file
2
#Tue Aug 14 13:06:40 CEST 2012
3
buildNumber=2068
tags/v2_0_0_Build_2051/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/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/maven-v4_0_0.xsd">
5
	<modelVersion>4.0.0</modelVersion>
6
	<artifactId>org.gvsig.selectiontools.app.extension</artifactId>
7
	<packaging>jar</packaging>
8
	<name>Tools: Selection tools</name>
9
	<parent>
10
		<groupId>org.gvsig</groupId>
11
		<artifactId>org.gvsig.selectiontools.app</artifactId>
12
		<version>1.0.0-SNAPSHOT</version>
13
	</parent>
14

  
15
	<dependencies>
16
		<dependency>
17
			<groupId>org.gvsig</groupId>
18
			<artifactId>org.gvsig.andami</artifactId>
19
            <scope>compile</scope>
20
		</dependency>
21
		<dependency>
22
			<groupId>org.gvsig</groupId>
23
			<artifactId>org.gvsig.i18n</artifactId>
24
            <scope>compile</scope>
25
		</dependency>
26
		<dependency>
27
			<groupId>org.gvsig</groupId>
28
			<artifactId>org.gvsig.tools.lib</artifactId>
29
            <scope>compile</scope>
30
		</dependency>
31
		<dependency>
32
			<groupId>org.gvsig</groupId>
33
			<artifactId>org.gvsig.tools.swing.api</artifactId>
34
            <scope>compile</scope>
35
		</dependency>
36
        <dependency>
37
			<groupId>org.gvsig</groupId>
38
			<artifactId>org.gvsig.app</artifactId>
39
			<version>2.0-SNAPSHOT</version>
40
            <scope>compile</scope>
41
		</dependency>
42
        <dependency>
43
            <groupId>org.gvsig</groupId>
44
            <artifactId>org.gvsig.about.api</artifactId>
45
            <scope>compile</scope>
46
        </dependency>
47
        <dependency>
48
            <groupId>org.gvsig</groupId>
49
            <artifactId>org.gvsig.fmap.dal</artifactId>
50
            <scope>compile</scope>
51
        </dependency>
52
        <dependency>
53
            <groupId>org.gvsig</groupId>
54
            <artifactId>org.gvsig.fmap.geometry</artifactId>
55
            <scope>compile</scope>
56
        </dependency>
57
        <dependency>
58
            <groupId>org.gvsig</groupId>
59
            <artifactId>org.gvsig.ui</artifactId>
60
            <scope>compile</scope>
61
        </dependency>
62
        <dependency>
63
            <groupId>org.gvsig</groupId>
64
            <artifactId>org.gvsig.fmap.mapcontext</artifactId>
65
            <scope>compile</scope>
66
        </dependency>
67
        <dependency>
68
            <groupId>org.gvsig</groupId>
69
            <artifactId>org.gvsig.fmap.control</artifactId>
70
            <scope>compile</scope>
71
        </dependency>
72
        <dependency>
73
            <groupId>org.gvsig</groupId>
74
            <artifactId>org.gvsig.utils</artifactId>
75
            <scope>compile</scope>
76
        </dependency>
77
        <dependency>
78
            <groupId>org.gvsig</groupId>
79
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
80
            <scope>compile</scope>
81
        </dependency>
82
        <dependency>
83
            <groupId>org.gvsig</groupId>
84
            <artifactId>org.gvsig.projection</artifactId>
85
            <scope>compile</scope>
86
        </dependency>
87
        <dependency>
88
            <groupId>org.slf4j</groupId>
89
            <artifactId>slf4j-api</artifactId>
90
            <scope>compile</scope>
91
        </dependency>
92
        <dependency>
93
            <groupId>com.vividsolutions</groupId>
94
            <artifactId>jts</artifactId>
95
            <scope>compile</scope>
96
        </dependency>
97
	</dependencies>
98
	<description>Advanced selection tools: 
99
- select all 
100
- by buffer 
101
- by cicle 
102
- by polilyne
103
</description>
104
	<profiles>
105
		<profile>
106
			<id>gvsig-install</id>
107
			<activation>
108
				<activeByDefault>true</activeByDefault>
109
			</activation>
110
			<properties>
111
				<!--
112
					Default gvSIG installation folder relative to the current workspace
113
				-->
114
				<gvsig.install.dir>${basedir}/../../build/product</gvsig.install.dir>
115
			</properties>
116
		</profile>
117
	</profiles>
118
	<properties>
119
        <package.info.categories>View,Vector</package.info.categories>
120
	</properties>
121
</project>
0 122

  
tags/v2_0_0_Build_2051/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/distribution/distribution.xml
1
<assembly>
2
	<id>distribution</id>
3
	<formats>
4
		<format>dir</format>
5
	</formats>
6
	<fileSets>
7
		<!-- Estructure for the extension -->
8
		<fileSet>
9
			<directory>src/main/resources</directory>
10
			<outputDirectory>${extension.install.dir.name}
11
			</outputDirectory>
12
		</fileSet>
13
	</fileSets>
14
	<files>
15
        <file>
16
            <source>package.info</source>
17
            <outputDirectory>${extension.install.dir.name}
18
            </outputDirectory>
19
        </file>
20
    </files>
21
    <dependencySets>
22
		<dependencySet>
23
			<outputDirectory>${extension.install.dir.name}/${library-dir}
24
			</outputDirectory>
25
			<includes>
26
				<include>org.gvsig:org.gvsig.selectiontools.app.extension</include>
27
			</includes>
28
		</dependencySet>
29
	</dependencySets>
30
</assembly>
0 31

  
tags/v2_0_0_Build_2051/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/buildNumber.properties
1
#maven.buildNumber.plugin properties file
2
#Tue Aug 14 13:06:40 CEST 2012
3
buildNumber=2060
tags/v2_0_0_Build_2051/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/test/resources/README.txt
1
Put into this folder the resources needed by your test classes.
2

  
3
This folder is added to the Tests classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, in this folder you can find an example of log4j configuration,
7
prepared to log messages through the console, so logging works when you
8
run your tests classes.
0 9

  
tags/v2_0_0_Build_2051/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/test/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3

  
4
<!-- 
5
Log4J configuration file for unit tests execution.
6
 -->
7
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
8

  
9
	<!-- Appender configuration to show logging messages through the console -->
10
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
11
		<layout class="org.apache.log4j.PatternLayout">
12
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
13
		</layout>
14
	</appender>
15

  
16
	<!-- 
17
	Activate logging messages of DEBUG level of higher only for the
18
	org.gvsig.tools packages.
19
	You can put full classes names or packages instead, to configure
20
	logging for all the classes and subpackages of the package.
21
	-->
22
	<category name="org.gvsig.tools">
23
		<priority value="DEBUG" />
24
	</category>
25
	<category name="org.gvsig.selectiontools">
26
		<priority value="DEBUG" />
27
	</category>
28

  
29
	<!-- 
30
	By default, show only logging messages of INFO level or higher, 
31
	through the previously configured CONSOLE appender. 
32
	-->
33
	<root>
34
		<priority value="INFO" />
35
		<appender-ref ref="CONSOLE" />
36
	</root>
37
</log4j:configuration>
0 38

  
tags/v2_0_0_Build_2051/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/resources/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<plugin-config>
3
	<depends plugin-name="org.gvsig.app" />
4
	<resourceBundle name="text"/>
5
	<libraries library-dir="lib"/>
6
	<extensions>
7

  
8
<!--  		<extension class-name="org.gvsig.selectiontools.app.extension.AboutSelectionToolsExtension" -->
9
<!--             description="Extension Selection Tools of the Consejer?a de Medio Ambiente of the Junta de Castilla y Le?n Project." -->
10
<!-- 			active="true" -->
11
<!-- 			priority="1"> -->
12
<!-- 		</extension> -->
13
		
14
		<extension class-name="org.gvsig.selectiontools.app.extension.SelectAllExtension"
15
			description="Extension that allows select all geometries of the selected vectorial layers."
16
			active="true"
17
			priority="30">
18
			<menu text="Selection/SelectAll"
19
				action-command="SELALL"
20
				tooltip="select_all_info"
21
				icon="selection-select-all"
22
				position="300400000"/>
23
			<tool-bar name="Tools_Select" position="6">
24
				<selectable-tool icon="selection-all" action-command="SELALL" tooltip="select_all_info" position="7"/>
25
			</tool-bar>
26
		</extension>		
27
		 <extension class-name="org.gvsig.selectiontools.app.extension.SelectByCircleExtension"
28
			description="Extension that allows select all geometries of the selected vectorial layers that are contained or intersect with a circle defined by the user."
29
			active="true"
30
			priority="30">
31
			<menu text="Selection/Select_by_circle"
32
				action-command="SELCIRCLE"
33
				tooltip="select_by_circle_info"
34
				icon="selection-select-by-circle"
35
				position="301000000"/>
36
			<tool-bar name="Tools_Select" position="6">
37
				<selectable-tool icon="selection-select-by-circle" action-command="SELCIRCLE" tooltip="select_by_circle" position="6"/>
38
			</tool-bar>
39
		</extension>		
40
		<extension class-name="org.gvsig.selectiontools.app.extension.SelectByPolylineExtension"
41
			description="Extension that allows select all geometries of the selected vectorial layers that intersect with a polyline defined by the user."
42
			active="false"
43
			priority="30">
44
			<menu text="Selection/Select_by_polyline"
45
				action-command="SELPOLYLINE"
46
				tooltip="select_by_polyline_info"
47
				icon="selection-select-by-polyline"
48
				position="301300000"/>
49
			<tool-bar name="Tools_Select" position="6">
50
				<selectable-tool icon="selection-select-by-polyline" action-command="SELPOLYLINE" tooltip="select_by_polyline" position="5"/>
51
			</tool-bar>
52
		</extension>		
53

  
54
 		<extension class-name="org.gvsig.selectiontools.app.extension.SelectByBufferExtension"
55
			description="Extension that allows select all geometries of the selected vectorial layers that intersect with a buffer around their previously selected geometries."
56
			active="true"
57
			priority="30">
58
			<menu text="Selection/Select_by_buffer"
59
				action-command="SELBUFFER"
60
				tooltip="select_by_buffer_info"
61
				icon="selection-select-by-buffer"
62
				position="300900000"/>
63
			<tool-bar name="Tools_Select" position="6">
64
				<action-tool icon="selection-select-by-buffer" action-command="SELBUFFER" tooltip="select_by_buffer" position="7"/>
65
			</tool-bar>
66
		</extension>
67
				
68
	</extensions>
69
</plugin-config>
0 70

  
tags/v2_0_0_Build_2051/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/SelectAllExtension.java
1
package org.gvsig.selectiontools.app.extension;
2

  
3
/* gvSIG. Geographic Information System of the Valencian Government
4
 *
5
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
6
 * of the Valencian Government (CIT)
7
 * 
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 * 
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *  
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
21
 * MA  02110-1301, USA.
22
 * 
23
 */
24

  
25
import org.gvsig.andami.IconThemeHelper;
26
import org.gvsig.andami.PluginServices;
27
import org.gvsig.andami.messages.NotificationManager;
28
import org.gvsig.andami.plugins.Extension;
29
import org.gvsig.andami.ui.mdiManager.IWindow;
30
import org.gvsig.app.project.documents.view.ViewDocument;
31
import org.gvsig.app.project.documents.view.gui.IView;
32
import org.gvsig.fmap.dal.exception.DataException;
33
import org.gvsig.fmap.dal.feature.FeatureStore;
34
import org.gvsig.fmap.mapcontext.MapContext;
35
import org.gvsig.fmap.mapcontext.layers.FLayer;
36
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
37
import org.gvsig.fmap.mapcontrol.MapControl;
38

  
39
/**
40
 * <p>
41
 * Extension to add support for selecting all the features of a vector layer.
42
 * </p>
43
 * 
44
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
45
 */
46
public class SelectAllExtension extends Extension {
47

  
48
    /*
49
     * @see com.iver.andami.plugins.IExtension#initialize()
50
     */
51
    public void initialize() {
52
    	IconThemeHelper.registerIcon("action", "selection-select-all", this);
53
    }
54

  
55
    /*
56
     * (non-Javadoc)
57
     * 
58
     * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
59
     */
60
    public void execute(String actionCommand) {
61
        if (actionCommand.equals("SELALL")) {
62
            IWindow view = PluginServices.getMDIManager().getActiveWindow();
63
            if (view instanceof IView) {
64
                MapControl mc = ((IView) view).getMapControl();
65
                FLayer[] activeLayers =
66
                    mc.getMapContext().getLayers().getActives();
67

  
68
                FLayer layer;
69

  
70
                for (int i = 0; i < activeLayers.length; i++) {
71
                    layer = activeLayers[i];
72

  
73
                    if ((layer.isAvailable()) && (layer instanceof FLyrVect)) {
74
                        FLyrVect lyrVect = (FLyrVect) layer;
75

  
76
                        try {
77
                            FeatureStore fs = lyrVect.getFeatureStore();
78
                            fs.getFeatureSelection().selectAll();
79
                        } catch (DataException e) {
80
                            NotificationManager.showMessageError("Data exception",
81
                                e);
82
                        }
83
                    }
84
                }
85
            }
86
        }
87
    }
88

  
89
    /*
90
     * @see com.iver.andami.plugins.IExtension#isVisible()
91
     */
92
    public boolean isVisible() {
93
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
94

  
95
        if (f == null) {
96
            return false;
97
        }
98

  
99
        if (f instanceof IView) {
100
            IView vista = (IView) f;
101
            ViewDocument viewDocument = vista.getViewDocument(); // .getModel();
102
            MapContext mapa = viewDocument.getMapContext();
103

  
104
            return mapa.getLayers().getLayersCount() > 0;
105
        }
106

  
107
        return false;
108
    }
109

  
110
    /*
111
     * @see com.iver.andami.plugins.IExtension#isEnabled()
112
     */
113
    public boolean isEnabled() {
114
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
115

  
116
        if (f == null) {
117
            return false;
118
        }
119

  
120
        if (f instanceof IView) {
121
            IView vista = (IView) f;
122
            ViewDocument viewDocument = vista.getViewDocument();
123
            MapContext mapa = viewDocument.getMapContext();
124

  
125
            FLayer layers[] = mapa.getLayers().getActives();
126
            FLayer layer;
127

  
128
            for (int i = 0; i < layers.length; i++) {
129
                layer = layers[i];
130

  
131
                if ((layer instanceof FLyrVect) && (layer.isAvailable())
132
                    && (layer.isActive()))
133
                    return true;
134
            }
135
        }
136

  
137
        return false;
138
    }
139
}
0 140

  
tags/v2_0_0_Build_2051/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/SelectByCircleExtension.java
1
package org.gvsig.selectiontools.app.extension;
2

  
3
import org.gvsig.andami.IconThemeHelper;
4
import org.gvsig.andami.PluginServices;
5
import org.gvsig.andami.plugins.Extension;
6
import org.gvsig.andami.ui.mdiManager.IWindow;
7
import org.gvsig.app.project.documents.view.ViewDocument;
8
import org.gvsig.app.project.documents.view.gui.IView;
9
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener;
10
import org.gvsig.fmap.mapcontext.MapContext;
11
import org.gvsig.fmap.mapcontext.layers.FLayer;
12
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
13
import org.gvsig.fmap.mapcontrol.MapControl;
14
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior;
15
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseMovementBehavior;
16
import org.gvsig.selectiontools.app.extension.tools.CircleSelectListener;
17
import org.gvsig.selectiontools.app.extension.tools.behavior.CircleSelectionBehavior;
18

  
19
/* gvSIG. Geographic Information System of the Valencian Government
20
 *
21
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
22
 * of the Valencian Government (CIT)
23
 * 
24
 * This program is free software; you can redistribute it and/or
25
 * modify it under the terms of the GNU General Public License
26
 * as published by the Free Software Foundation; either version 2
27
 * of the License, or (at your option) any later version.
28
 * 
29
 * This program is distributed in the hope that it will be useful,
30
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32
 * GNU General Public License for more details.
33
 *  
34
 * You should have received a copy of the GNU General Public License
35
 * along with this program; if not, write to the Free Software
36
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
37
 * MA  02110-1301, USA.
38
 * 
39
 */
40

  
41
/**
42
 * <p>
43
 * Extension to add support for selecting the geometries of the active vector
44
 * layers that intersect with a circle defined by the user.
45
 * </p>
46
 * 
47
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
48
 */
49
public class SelectByCircleExtension extends Extension {
50

  
51
    public static final String CIRCLE_SELECTION_TOOL_NAME = "circleSelection";
52

  
53
    /*
54
     * @see com.iver.andami.plugins.IExtension#initialize()
55
     */
56
    public void initialize() {
57
    	IconThemeHelper.registerIcon("action", "selection-select-by-circle", this);
58
    	IconThemeHelper.registerIcon("cursor", "cursor-select-by-circle", this);
59
    }
60

  
61
    /*
62
     * (non-Javadoc)
63
     * 
64
     * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
65
     */
66
    public void execute(String actionCommand) {
67
        if (actionCommand.equals("SELCIRCLE")) {
68
            IWindow window = PluginServices.getMDIManager().getActiveWindow();
69
            if (window instanceof IView) {
70
                IView view = (IView) window;
71
                // Selection by circle
72
                MapControl mc = view.getMapControl();
73

  
74
                // If current's view MapControl doesn't have the
75
                // "CircleSelection" tool, adds it
76
                if (!mc.getNamesMapTools()
77
                    .containsKey(CIRCLE_SELECTION_TOOL_NAME)) {
78
                    CircleSelectListener circleSelListener =
79
                        new CircleSelectListener(mc);
80
                    mc.addBehavior(CIRCLE_SELECTION_TOOL_NAME, new Behavior[] {
81
                        new CircleSelectionBehavior(circleSelListener),
82
                        new MouseMovementBehavior(new StatusBarListener(mc)) });
83
                }
84

  
85
                mc.setTool(CIRCLE_SELECTION_TOOL_NAME);
86
            }
87
        }
88
    }
89

  
90
    /*
91
     * @see com.iver.andami.plugins.IExtension#isVisible()
92
     */
93
    public boolean isVisible() {
94
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
95

  
96
        if (f == null) {
97
            return false;
98
        }
99

  
100
        if (f instanceof IView) {
101
            IView vista = (IView) f;
102
            ViewDocument model = vista.getViewDocument();
103
            MapContext mapa = model.getMapContext();
104

  
105
            return mapa.getLayers().getLayersCount() > 0;
106
        }
107

  
108
        return false;
109
    }
110

  
111
    /*
112
     * @see com.iver.andami.plugins.IExtension#isEnabled()
113
     */
114
    public boolean isEnabled() {
115
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
116

  
117
        if (f == null) {
118
            return false;
119
        }
120

  
121
        if (f instanceof IView) {
122
            IView vista = (IView) f;
123
            ViewDocument model = vista.getViewDocument();
124
            MapContext mapa = model.getMapContext();
125

  
126
            FLayer layers[] = mapa.getLayers().getActives();
127
            FLayer layer;
128

  
129
            for (int i = 0; i < layers.length; i++) {
130
                layer = layers[i];
131

  
132
                if ((layer instanceof FLyrVect) && (layer.isAvailable())
133
                    && (layer.isActive()))
134
                    return true;
135
            }
136
        }
137

  
138
        return false;
139
    }
140
}
0 141

  
tags/v2_0_0_Build_2051/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/tools/CircleSelectionListener.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.Toolkit;
28
import java.awt.event.MouseEvent;
29

  
30
import javax.swing.ImageIcon;
31

  
32
import org.gvsig.andami.IconThemeHelper;
33
import org.gvsig.andami.PluginServices;
34
import org.gvsig.andami.messages.NotificationManager;
35
import org.gvsig.fmap.dal.exception.DataException;
36
import org.gvsig.fmap.dal.feature.FeatureSelection;
37
import org.gvsig.fmap.dal.feature.FeatureSet;
38
import org.gvsig.fmap.geom.Geometry;
39
import org.gvsig.fmap.geom.GeometryLocator;
40
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
41
import org.gvsig.fmap.geom.Geometry.TYPES;
42
import org.gvsig.fmap.geom.GeometryManager;
43
import org.gvsig.fmap.geom.exception.CreateGeometryException;
44
import org.gvsig.fmap.geom.operation.GeometryOperationException;
45
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
46
import org.gvsig.fmap.geom.primitive.Point;
47
import org.gvsig.fmap.geom.primitive.Circle;
48
import org.gvsig.fmap.geom.primitive.GeneralPathX;
49
import org.gvsig.fmap.mapcontext.layers.FLayer;
50
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
51
import org.gvsig.fmap.mapcontrol.MapControl;
52
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
53
import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent;
54
import org.gvsig.fmap.mapcontrol.tools.Listeners.CircleListener;
55

  
56
/**
57
 * <p>
58
 * Listener that selects all features of the active, available and vector layers
59
 * which intersect with the defined circle area in the associated
60
 * {@link MapControl MapControl} object.
61
 * </p>
62
 * 
63
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
64
 */
65
public class CircleSelectionListener implements CircleListener {
66

  
67

  
68

  
69
    /**
70
     * The cursor used to work with this tool listener.
71
     * 
72
     * @see #getCursor()
73
     */
74
    private Cursor cur = null ; 
75

  
76
    /**
77
     * Reference to the <code>MapControl</code> object that uses.
78
     */
79
    private MapControl mapCtrl;
80

  
81
    /**
82
     * <p>
83
     * Creates a new listener for selecting circular areas.
84
     * </p>
85
     * 
86
     * @param mc
87
     *            the <code>MapControl</code> object where the measures are made
88
     */
89
    public CircleSelectionListener(MapControl mc) {
90
        this.mapCtrl = mc;
91
    }
92

  
93
    /*
94
     * (non-Javadoc)
95
     * 
96
     * @see
97
     * com.iver.cit.gvsig.fmap.tools.Listeners.CircleListener#circle(com.iver
98
     * .cit.gvsig.fmap.tools.Events.MeasureEvent)
99
     */
100
    public void circle(MeasureEvent event) throws BehaviorException {
101
        if (event.getEvent().getID() == MouseEvent.MOUSE_RELEASED) {
102
            FLayer[] activeLayers =
103
                mapCtrl.getMapContext().getLayers().getActives();
104

  
105
            FLayer layer;
106
            FLyrVect lyrVect;
107

  
108
            Geometry geom = null;
109
            GeometryManager manager = GeometryLocator.getGeometryManager();
110
            Point center;
111
            try {
112
                center = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D);
113
                center.setX(event.getXs()[0].doubleValue());
114
                center.setY(event.getYs()[0].intValue());
115

  
116
                Point point2;
117
                point2 = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D);
118
                point2.setX(event.getXs()[1].doubleValue());
119
                point2.setY(event.getYs()[1].intValue());
120

  
121
                double radious = center.distance(point2);
122

  
123
                Circle circle = null;
124
                circle = (Circle) manager.create(TYPES.CIRCLE, SUBTYPES.GEOM2D);
125
                circle.setPoints(center, radious);
126
                geom = circle;
127
            } catch (CreateGeometryException e) {
128
                NotificationManager.showMessageError(PluginServices.getText(null,
129
                "Failed_creating_geometry"),
130
                e);
131
            } catch (GeometryOperationNotSupportedException e) {
132
                NotificationManager.showMessageError(PluginServices.getText(null,
133
                "Operation_not_supported"),
134
                e);
135
            } catch (GeometryOperationException e) {
136
                NotificationManager.showMessageError(PluginServices.getText(null,
137
                "Failed_performing_the_operation"),
138
                e);
139
            }
140
            if (geom == null)
141
                return;
142

  
143
            double flatness;
144

  
145
            // Creates the geometry
146
            // If the scale is < 500 -> approximates the circle with a polyline
147
            // with more points, as many as
148
            // smaller would be the scale
149
            if (mapCtrl.getMapContext().getScaleView() < 500) {
150
                GeneralPathX gP = new GeneralPathX();
151
                flatness = manager.getFlatness(); // ?????
152
                flatness =
153
                    mapCtrl.getMapContext().getScaleView() * flatness
154
                    / (500 * 2); // The number 2 forces to create the double
155
                // of points
156
                gP.append(geom.getPathIterator(null, flatness), true);
157
                try {
158
                    geom = manager.createSurface(gP, SUBTYPES.GEOM2D);
159
                } catch (CreateGeometryException e) {
160
                    NotificationManager.showMessageError(PluginServices.getText(null,
161
                    "Failed_creating_geometry"),
162
                    e);
163
                }
164
            } else {
165
                // Bigger scale -> Smaller flatness
166
                GeneralPathX gP = new GeneralPathX();
167
                flatness = manager.getFlatness(); // ?????
168
                flatness =
169
                    flatness / (mapCtrl.getMapContext().getScaleView() * 2);
170
                // *2 to reduce the number of lines of the polygon
171

  
172
                gP.append(geom.getPathIterator(null, flatness), true);
173
                try {
174
                    geom = manager.createSurface(gP, SUBTYPES.GEOM2D);
175
                } catch (CreateGeometryException e) {
176
                    NotificationManager.showMessageError(PluginServices.getText(null,
177
                    "Failed_creating_geometry"),
178
                    e);
179
                }
180
            }
181

  
182
            for (int i = 0; i < activeLayers.length; i++) {
183
                layer = activeLayers[i];
184

  
185
                if ((layer.isAvailable()) && (layer instanceof FLyrVect)) {
186
                    lyrVect = (FLyrVect) layer;
187
                    FeatureSet newSelection = null;
188

  
189
                    try {
190
                        newSelection =
191
                            lyrVect.queryByGeometry(geom,
192
                                lyrVect.getFeatureStore()
193
                                .getDefaultFeatureType());
194

  
195
                        if (event.getEvent().isControlDown()) {
196
                            ((FeatureSelection) lyrVect.getDataStore()
197
                                .getSelection()).select(newSelection);
198
                        } else {
199
                            lyrVect.getFeatureStore()
200
                            .setSelection(newSelection);
201
                        }
202

  
203
                    } catch (DataException e) {
204
                        NotificationManager.showMessageError(PluginServices.getText(null,
205
                            "Failed_selecting_geometries"),
206
                            e);
207
                    } finally {
208
                        newSelection.dispose();
209
                    }
210
                }
211
            }
212
        }
213
    }
214

  
215
    /*
216
     * (non-Javadoc)
217
     * 
218
     * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
219
     */
220
	public Cursor getCursor() {
221
		if (cur == null) {
222
			cur = Toolkit.getDefaultToolkit().createCustomCursor(
223
					this.getImageCursor(), new java.awt.Point(16, 16), "");
224
		}
225
		return cur;
226
	}
227

  
228
    /*
229
     * (non-Javadoc)
230
     * 
231
     * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
232
     */
233
    public boolean cancelDrawing() {
234
        return false;
235
    }
236

  
237
    public Image getImageCursor() {
238
        return IconThemeHelper.getImage("cursor-select-by-circle");
239
    }
240
}
0 241

  
tags/v2_0_0_Build_2051/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/tools/behavior/CircleSelectionBehavior.java
1
package org.gvsig.selectiontools.app.extension.tools.behavior;
2

  
3
/* gvSIG. Geographic Information System of the Valencian Government
4
 *
5
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
6
 * of the Valencian Government (CIT)
7
 * 
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 * 
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *  
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
21
 * MA  02110-1301, USA.
22
 * 
23
 */
24

  
25
import java.awt.Color;
26
import java.awt.Graphics;
27
import java.awt.Graphics2D;
28
import java.awt.Point;
29
import java.awt.Rectangle;
30
import java.awt.event.MouseEvent;
31
import java.awt.geom.Arc2D;
32
import java.awt.geom.Point2D;
33
import java.awt.geom.Rectangle2D;
34
import java.awt.image.BufferedImage;
35

  
36
import org.gvsig.fmap.mapcontext.ViewPort;
37
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
38
import org.gvsig.fmap.mapcontrol.tools.Behavior.CircleBehavior;
39
import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent;
40
import org.gvsig.fmap.mapcontrol.tools.Listeners.CircleListener;
41

  
42
/**
43
 * 
44
 * 
45
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
46
 */
47
public class CircleSelectionBehavior extends CircleBehavior {
48

  
49
    /**
50
	 * 
51
	 */
52
    private CircleListener listener;
53

  
54
    /**
55
     * Auxiliary point that represents a corner selected in image coordinates.
56
     */
57
    private Point2D m_PointAnt;
58

  
59
    public CircleSelectionBehavior(CircleListener zili) {
60
        super(zili);
61

  
62
        listener = zili;
63
    }
64

  
65
    /*
66
     * (non-Javadoc)
67
     * 
68
     * @see
69
     * com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#paintComponent(java.awt
70
     * .Graphics)
71
     */
72
    public void paintComponent(Graphics g) {
73
        double radio;
74
        BufferedImage img = getMapControl().getImage();
75
        g.drawImage(img, 0, 0, null);
76
        g.setColor(Color.black);
77
        g.setXORMode(Color.white);
78
        if ((m_FirstPoint != null) && (m_LastPoint != null)) {
79
            radio = m_LastPoint.distance(m_FirstPoint);
80
            Arc2D.Double arc =
81
                new Arc2D.Double(m_FirstPoint.getX() - radio,
82
                    m_FirstPoint.getY() - radio,
83
                    2 * radio,
84
                    2 * radio,
85
                    0,
86
                    360,
87
                    Arc2D.OPEN);
88

  
89
            ((Graphics2D) g).draw(arc);
90
        }
91
    }
92

  
93
    /*
94
     * (non-Javadoc)
95
     * 
96
     * @see
97
     * com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mousePressed(java.awt
98
     * .event.MouseEvent)
99
     */
100
    public void mousePressed(MouseEvent e) {
101

  
102
        Point pScreen = e.getPoint();
103
        m_PointAnt = pScreen;
104

  
105
        if ((!isClicked) && (e.getButton() == MouseEvent.BUTTON1)) {
106
            m_PointAnt = pScreen;
107
            m_FirstPoint = m_PointAnt;
108
            isClicked = true;
109
        }
110

  
111
        if (listener.cancelDrawing()) {
112
            getMapControl().cancelDrawing();
113
            isClicked = false;
114
        }
115
        getMapControl().repaint();
116
    }
117

  
118
    /*
119
     * (non-Javadoc)
120
     * 
121
     * @see
122
     * com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseReleased(java.awt
123
     * .event.MouseEvent)
124
     */
125
    public void mouseReleased(MouseEvent e) throws BehaviorException {
126
        if ((m_FirstPoint == null) || (m_LastPoint == null))
127
            return;
128

  
129
        Point2D p1;
130
        Point2D p2;
131
        Point pScreen = e.getPoint();
132

  
133
        ViewPort vp = getMapControl().getMapContext().getViewPort();
134

  
135
        p1 = vp.toMapPoint(m_FirstPoint);
136
        p2 = vp.toMapPoint(pScreen);
137

  
138
        // Fijamos el nuevo extent
139
        Rectangle2D.Double r = new Rectangle2D.Double();
140
        r.setFrameFromDiagonal(p1, p2);
141

  
142
        Rectangle2D rectPixel = new Rectangle();
143
        rectPixel.setFrameFromDiagonal(m_FirstPoint, pScreen);
144

  
145
        Double[] x = new Double[2];
146
        Double[] y = new Double[2];
147
        x[0] = new Double(p1.getX());
148
        x[1] = new Double(p2.getX());
149
        y[0] = new Double(p1.getY());
150
        y[1] = new Double(p2.getY());
151
        MeasureEvent event = new MeasureEvent(x, y, e);
152
        listener.circle(event);
153
        getMapControl().repaint();
154

  
155
        m_FirstPoint = null;
156
        m_LastPoint = null;
157
        isClicked = false;
158
    }
159

  
160
    /*
161
     * (non-Javadoc)
162
     * 
163
     * @see
164
     * com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseDragged(java.awt
165
     * .event.MouseEvent)
166
     */
167
    public void mouseDragged(MouseEvent e) throws BehaviorException {
168
        mouseMoved(e);
169
    }
170

  
171
    /*
172
     * (non-Javadoc)
173
     * 
174
     * @see
175
     * com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseMoved(java.awt.event
176
     * .MouseEvent)
177
     */
178
    public void mouseMoved(MouseEvent e) throws BehaviorException {
179
        if (!isClicked)
180
            return;
181

  
182
        m_LastPoint = e.getPoint();
183

  
184
        if (m_FirstPoint == null)
185
            return;
186
        Point2D p1;
187
        Point2D p2;
188
        Point pScreen = e.getPoint();
189

  
190
        ViewPort vp = getMapControl().getMapContext().getViewPort();
191

  
192
        p1 = vp.toMapPoint(m_FirstPoint);
193
        p2 = vp.toMapPoint(pScreen);
194

  
195
        // Fijamos el nuevo extent
196
        Rectangle2D.Double r = new Rectangle2D.Double();
197
        r.setFrameFromDiagonal(p1, p2);
198

  
199
        Rectangle2D rectPixel = new Rectangle();
200
        rectPixel.setFrameFromDiagonal(m_FirstPoint, pScreen);
201

  
202
        Double[] x = new Double[2];
203
        Double[] y = new Double[2];
204
        x[0] = new Double(p1.getX());
205
        x[1] = new Double(p2.getX());
206
        y[0] = new Double(p1.getY());
207
        y[1] = new Double(p2.getY());
208
        MeasureEvent event = new MeasureEvent(x, y, e);
209
        listener.circle(event);
210
        getMapControl().repaint();
211
    }
212
}
0 213

  
tags/v2_0_0_Build_2051/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/tools/PolyLineSelectListener.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

  
23
package org.gvsig.selectiontools.app.extension.tools;
24

  
25
import org.gvsig.andami.PluginServices;
26
import org.gvsig.fmap.mapcontrol.MapControl;
27
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
28
import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent;
29

  
30
/**
31
 * 
32
 * @version 06/04/2009
33
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
34
 */
35
public class PolyLineSelectListener extends PolyLineSelectionListener {
36

  
37
    public PolyLineSelectListener(MapControl mc) {
38
        super(mc);
39
    }
40

  
41
    public void polylineFinished(MeasureEvent event) throws BehaviorException {
42
        super.polylineFinished(event);
43
        PluginServices.getMainFrame().enableControls();
44
    }
45
}
0 46

  
tags/v2_0_0_Build_2051/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/tools/CircleSelectListener.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

  
23
package org.gvsig.selectiontools.app.extension.tools;
24

  
25
import org.gvsig.andami.PluginServices;
26
import org.gvsig.fmap.mapcontrol.MapControl;
27
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
28
import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent;
29

  
30
/**
31
 * 
32
 * @version 06/04/2009
33
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
34
 */
35
public class CircleSelectListener extends CircleSelectionListener {
36

  
37
    public CircleSelectListener(MapControl mc) {
38
        super(mc);
39
    }
40

  
41
    public void circle(MeasureEvent event) throws BehaviorException {
42
        super.circle(event);
43
        PluginServices.getMainFrame().enableControls();
44
    }
45
}
0 46

  
tags/v2_0_0_Build_2051/extensions/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.extension/src/main/java/org/gvsig/selectiontools/app/extension/tools/PolyLineSelectionListener.java
1
package org.gvsig.selectiontools.app.extension.tools;
2

  
3
/* gvSIG. Geographic Information System of the Valencian Government
4
 *
5
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
6
 * of the Valencian Government (CIT)
7
 * 
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 * 
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *  
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
21
 * MA  02110-1301, USA.
22
 * 
23
 */
24

  
25
import java.awt.Cursor;
26
import java.awt.Image;
27
import java.awt.Point;
28
import java.awt.Toolkit;
29

  
30
import javax.swing.ImageIcon;
31

  
32
import org.gvsig.andami.IconThemeHelper;
33
import org.gvsig.andami.PluginServices;
34
import org.gvsig.andami.messages.NotificationManager;
35
import org.gvsig.fmap.dal.feature.FeatureSelection;
36
import org.gvsig.fmap.dal.feature.FeatureSet;
37
import org.gvsig.fmap.geom.Geometry;
38
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
39
import org.gvsig.fmap.geom.Geometry.TYPES;
40
import org.gvsig.fmap.geom.GeometryLocator;
41
import org.gvsig.fmap.geom.GeometryManager;
42
import org.gvsig.fmap.geom.exception.CreateGeometryException;
43
import org.gvsig.fmap.geom.primitive.GeneralPathX;
44
import org.gvsig.fmap.geom.primitive.Surface;
45
import org.gvsig.fmap.mapcontext.layers.FLayer;
46
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
47
import org.gvsig.fmap.mapcontrol.MapControl;
48
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
49
import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent;
50
import org.gvsig.fmap.mapcontrol.tools.Listeners.PolylineListener;
51

  
52
/**
53
 * <p>
54
 * Listener that selects all features of the active and vector layers which
55
 * intersect with the defined polyline in the associated {@link MapControl
56
 * MapControl} object.
57
 * </p>
58
 * 
59
 * <p>
60
 * The selection will be produced after user finishes the creation of the
61
 * polyline.
62
 * </p>
63
 * 
64
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
65
 */
66
public class PolyLineSelectionListener implements PolylineListener {
67

  
68
    /**
69
     * The image to display when the cursor is active.
70
     */
71
//    private final Image img = PluginServices.getIconTheme().get("cursor-select-by-polygon").getImage();
72

  
73
    /**
74
     * The cursor used to work with this tool listener.
75
     * 
76
     * @see #getCursor()
77
     */
78
    private Cursor cur = null;
79

  
80
    /**
81
     * Reference to the <code>MapControl</code> object that uses.
82
     */
83
    private MapControl mapCtrl;
84

  
85
    /**
86
     * <p>
87
     * Creates a new <code>PolygonSelectionListener</code> object.
88
     * </p>
89
     * 
90
     * @param mc
91
     *            the <code>MapControl</code> where is drawn the polyline
92
     */
93
    public PolyLineSelectionListener(MapControl mc) {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff