Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/pom.xml
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/pom.xml	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/pom.xml	(revision 38283)
@@ -0,0 +1,176 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+                      http://maven.apache.org/xsd/maven-4.0.0.xsd">
+                      
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>org.gvsig.fmap.control</artifactId>
+	<packaging>jar</packaging>
+	<version>2.0-SNAPSHOT</version>
+	<name>libFMap_controls</name>
+	<parent>
+		<groupId>org.gvsig</groupId>
+		<artifactId>gvsig-base-library-pom</artifactId>
+		<version>2.0-SNAPSHOT</version>
+	</parent>	
+	<properties>
+		<build-dir>${basedir}/../build</build-dir>
+        <eclipse.project.name>libFMap_controls</eclipse.project.name>
+	</properties>
+	<dependencies>
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.tools.lib</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.tools.swing.api</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.tools.swing.impl</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.tools.swing.spi</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.tools.swing.serv.field</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.tools.swing.serv.jform</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.tools.swing.serv.jlist</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+		<dependency>
+			<groupId>org.gvsig</groupId>
+			<artifactId>org.gvsig.utils</artifactId>
+            <scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.gvsig</groupId>
+			<artifactId>org.gvsig.fmap.dal</artifactId>
+            <scope>compile</scope>
+		</dependency>
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.fmap.geometry</artifactId>
+            <scope>compile</scope>
+        </dependency>        
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.fmap.geometry</artifactId>
+            <classifier>operation</classifier>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
+            <scope>compile</scope>
+        </dependency>        
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.projection</artifactId>
+            <scope>compile</scope>
+        </dependency>
+		<dependency>
+    		<!-- TODO: remove -->
+			<groupId>org.gvsig</groupId>
+			<artifactId>org.gvsig.fmap.dal</artifactId>
+			<classifier>impl</classifier>
+            <scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.gvsig</groupId>
+			<artifactId>org.gvsig.fmap.mapcontext</artifactId>
+            <scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.gvsig</groupId>
+			<artifactId>org.gvsig.fmap.mapcontext</artifactId>
+			<classifier>operation</classifier>
+            <scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.gvsig</groupId>
+			<artifactId>org.gvsig.tools.lib</artifactId>
+			<type>test-jar</type>
+			<scope>test</scope>
+		</dependency>
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.i18n</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.vividsolutions</groupId>
+            <artifactId>jts</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.tools.swing.api</artifactId>
+            <scope>compile</scope>
+        </dependency>
+		<!-- TODO: uncomment when mapcontexts tests work again 
+		<dependency>
+			<groupId>org.gvsig</groupId>
+			<artifactId>org.gvsig.fmap.mapcontext</artifactId>
+            <type>test-jar</type>
+			<scope>test</scope>
+		</dependency>
+		 -->
+	    <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.timesupport.lib.api</artifactId>
+            <scope>compile</scope>
+        </dependency>
+	</dependencies>
+	<build>
+		<sourceDirectory>src</sourceDirectory>
+		<testSourceDirectory>src-test</testSourceDirectory>
+		<resources>
+			<resource>
+				<filtering>false</filtering>
+				<directory>${basedir}/resources</directory>
+			</resource>
+		</resources>
+
+		<!-- TODO: MAKE TESTS WORK AND REMOVE THIS OPTION -->
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-surefire-plugin</artifactId>
+				<configuration>
+					<skipTests>true</skipTests>
+				</configuration>
+			</plugin>
+      		<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<testExcludes>
+						<exclude>**</exclude>
+					</testExcludes>
+				</configuration>
+			</plugin>		
+		</plugins>
+	</build>
+</project>
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/META-INF/services/org.gvsig.tools.library.Library
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/META-INF/services/org.gvsig.tools.library.Library	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/META-INF/services/org.gvsig.tools.library.Library	(revision 38283)
@@ -0,0 +1,2 @@
+org.gvsig.fmap.mapcontrol.MapControlLibrary
+org.gvsig.fmap.mapcontrol.impl.DefaultMapControlLibrary
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_ca.properties
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_ca.properties	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_ca.properties	(revision 38283)
@@ -0,0 +1 @@
+registros_seleccionados_total=Total registres seleccionats
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_pt.properties
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_pt.properties	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_pt.properties	(revision 38283)
@@ -0,0 +1 @@
+registros_seleccionados_total=Total de registos seleccionados
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_cs.properties
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_cs.properties	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_cs.properties	(revision 38283)
@@ -0,0 +1 @@
+registros_seleccionados_total=Celkem zvolen\u00fdch z\u00e1znam\u016f
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_fr.properties
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_fr.properties	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_fr.properties	(revision 38283)
@@ -0,0 +1 @@
+registros_seleccionados_total=Total registres s\u00e9lectionn\u00e9s
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_de.properties
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_de.properties	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_de.properties	(revision 38283)
@@ -0,0 +1 @@
+registros_seleccionados_total=Alle ausgew\u00e4hlten register
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_eu.properties
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_eu.properties	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_eu.properties	(revision 38283)
@@ -0,0 +1 @@
+registros_seleccionados_total=Hautatutako erregistroak guztira
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_it.properties
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_it.properties	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_it.properties	(revision 38283)
@@ -0,0 +1 @@
+registros_seleccionados_total=Totale registri selezionati
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text.properties
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text.properties	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text.properties	(revision 38283)
@@ -0,0 +1,19 @@
+Visible=Visible
+Nombre=Nombre
+Alias=Alias
+
+Error_editar_geometria=Error al editar la geometría
+Geometria_no_editable_WKT=Geometría no editable en formato WKT, valor demasiado grande.
+
+geometry_to_wkt_exception=Error al convertir la geometría de la celda a formato WKT
+features_data_reload_exception=Error al recargar los fenómenos (features)
+get_feature_at_exception=Error al obtener el fenómeno de la fila = %(rowIndex)
+get_row_count_exception=Error al obtener el número total de filas en la tabla
+set_feature_value_exception=Error al establecer el valor de la celda en la fila = %(rowIndex) y columna = %(columnIndex) con el valor = %(value)
+wkt_to_geometry_exception=Error al convertir a geometría el valor en WKT: %(wkt)
+table_selection_change_exception=Error al cambiar la selección en la tabla de fenómenos (features)
+
+registros_seleccionados_total=Total registros seleccionados
+up=Subir
+down=Bajar
+remove=Eliminar
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_zh.properties
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_zh.properties	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_zh.properties	(revision 38283)
@@ -0,0 +1 @@
+registros_seleccionados_total=\u5df2\u9009\u5b9a\u8bb0\u5f55\u603b\u6570
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_en.properties
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_en.properties	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_en.properties	(revision 38283)
@@ -0,0 +1,19 @@
+Visible=Visible
+Nombre=Name
+Alias=Alias
+
+Error_editar_geometria=Error while editing the geometry
+Geometria_no_editable_WKT=Geometry not editable on WKT format, text value too big.
+
+geometry_to_wkt_exception=Error getting the geometry value of the cell as WKT
+features_data_reload_exception=Error reloading the features
+get_feature_at_exception=Error getting the feature at row = %(rowIndex)
+get_row_count_exception=Error getting the total table row count
+set_feature_value_exception=Error setting the value of the cell at row = %(rowIndex) and column = %(columnIndex) with the value = %(value)
+wkt_to_geometry_exception=Error getting the geometry value of the WKT value %(wkt)
+table_selection_change_exception=Error while changing the selection on the list of Features
+
+registros_seleccionados_total=Total of selected records
+up=Up
+down=Down
+c
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_gl.properties
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_gl.properties	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_gl.properties	(revision 38283)
@@ -0,0 +1 @@
+registros_seleccionados_total=Total rexistros seleccionados
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/FenceCursor.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/FenceCursor.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/RectangleCursor.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/RectangleCursor.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/PoligonCursor.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/PoligonCursor.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/ZoomPixelCursor.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/ZoomPixelCursor.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/PointSelectCursor.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/PointSelectCursor.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/RulerCursor.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/RulerCursor.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/MagnifyCursor.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/MagnifyCursor.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/waiting_ovr.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/waiting_ovr.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/InfoCursor.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/InfoCursor.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/RectSelectCursor.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/RectSelectCursor.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/LinkCursor.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/LinkCursor.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/CruxCursor.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/CruxCursor.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/map_ico_ok.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/map_ico_ok.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/map_ico_ko.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/map_ico_ko.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/AreaCursor.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/AreaCursor.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/icolayerRaster.PNG
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/icolayerRaster.PNG
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/icolayerVect.PNG
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/icolayerVect.PNG
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/ZoomInCursor.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/ZoomInCursor.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/Hand.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/Hand.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/ZoomOutCursor.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/images/ZoomOutCursor.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src-test/org/gvsig/fmap/mapcontrol/tools/AreaListenerTest.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src-test/org/gvsig/fmap/mapcontrol/tools/AreaListenerTest.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src-test/org/gvsig/fmap/mapcontrol/tools/AreaListenerTest.java	(revision 38283)
@@ -0,0 +1,45 @@
+package org.gvsig.fmap.mapcontrol.tools;
+
+import java.awt.geom.Point2D;
+
+import org.cresques.cts.IProjection;
+import org.gvsig.fmap.crs.CRSFactory;
+import org.gvsig.fmap.mapcontext.MapContext;
+import org.gvsig.fmap.mapcontext.ViewPort;
+import org.gvsig.fmap.mapcontrol.MapControl;
+import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
+
+
+public class AreaListenerTest extends AbstractLibraryAutoInitTestCase {
+	private IProjection projectionUTM = CRSFactory.getCRS("EPSG:23030");
+	private IProjection projectionGeo = CRSFactory.getCRS("EPSG:4230");
+		
+	@Override
+	protected void doSetUp() throws Exception {
+		// Nothing to do	
+	}
+
+	public void test1() {
+		AreaListenerImpl areaListenerUTM=new AreaListenerImpl(newMapControlUTM());
+		AreaListenerImpl areaListenerGeo=new AreaListenerImpl(newMapControlGeo());
+		Double[] xsUTM=new Double[] {new Double(731292),new Double(731901),new Double(730138)};
+		Double[] ysUTM=new Double[] {new Double(4351223),new Double(4350768),new Double(4349232)};
+		double areaUTM=areaListenerUTM.returnCoordsArea(xsUTM,ysUTM,new Point2D.Double(730138,4349232));
+		Double[] xsGeo=new Double[] {new Double(-0.31888183),new Double(-0.31173131),new Double(-0.33268401)};
+		Double[] ysGeo=new Double[] {new Double(39.27871741),new Double(39.27464327),new Double(39.26117368)};
+		double areaGeo=areaListenerGeo.returnGeoCArea(xsGeo,ysGeo,new Point2D.Double(-0.33268401,39.26117368));
+		assertTrue("Area UTM igual a Geo",areaUTM<(areaGeo+1000)&& areaUTM>(areaGeo-1000));
+	}
+	private MapControl newMapControlUTM() {
+		ViewPort vp = new ViewPort(projectionUTM);
+		MapControl mc=new MapControl();
+		mc.setMapContext(new MapContext(vp));
+		return mc;
+	}
+	private MapControl newMapControlGeo() {
+		ViewPort vp = new ViewPort(projectionGeo);
+		MapControl mc=new MapControl();
+		mc.setMapContext(new MapContext(vp));
+		return mc;
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/app/gui/JComboBoxUnits.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/app/gui/JComboBoxUnits.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/app/gui/JComboBoxUnits.java	(revision 38283)
@@ -0,0 +1,141 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.app.gui;
+
+import org.gvsig.fmap.mapcontext.MapContext;
+import org.gvsig.i18n.Messages;
+import org.gvsig.utils.swing.JComboBox;
+
+
+/**
+ * <p>Class representing a JComboBox with the measure units handled by the application.
+ * It takes values from Attributes.NAMES and Attributes.CHANGE static fields. So, to
+ * add more measure units, you must edit Attributes class and change will be automatically
+ * reflected in the combo box.</p>
+ *
+ * <p>The internatiolanization of the field is automatically handled by the system</p>
+ * @author jaume dominguez faus - jaume.dominguez@iver.es
+ */
+public class JComboBoxUnits extends JComboBox {
+	private static final long serialVersionUID = 8015263853737441433L;
+
+	/**
+	 * Creates a new instance of JUnitComboBox including "pixel" units and
+	 * setting them as automatically pre-selected.
+	 */
+	public JComboBoxUnits() {
+		this(true);
+	}
+
+	/**
+	 *
+	 * Creates a new instance of JUnitComboBox. If includePixel is true
+	 * then pixel units are included in the list and they are automatically
+	 * pre-selected. Otherwise, meters are preselected.
+	 *
+	 */
+	public JComboBoxUnits(boolean includePixel) {
+		super();
+		String[] names=MapContext.getDistanceNames();
+
+		for (int i = 0; i < names.length; i++) {
+			super.addItem(Messages.getText(names[i]));
+		}
+		if (includePixel) {
+			super.addItem(Messages.getText("pixels"));
+			setSelectedItem(Messages.getText("pixels"));
+		} else {
+			setSelectedIndex(1);
+		}
+		setMaximumRowCount(10);
+	}
+
+
+	/**
+	 * Returns the conversion factor from the <b>unit selected in the combo box</b>
+	 * to <b>meters</b> or <b>0</b> if pixels have been selected as the size unit.
+	 * @return
+	 */
+	public double getUnitConversionFactor() {
+			double unitFactor;
+			try {
+				unitFactor = MapContext.getDistanceTrans2Meter()[getSelectedIndex()];
+			} catch (ArrayIndexOutOfBoundsException aioobEx) { //jijiji
+				unitFactor = 0; // which represents size in pixel
+			}
+			return unitFactor;
+
+	}
+
+	/**
+	 * the use of this method is not allowed in this combo box.
+	 * @deprecated
+	 */
+	public void addItem(Object anObject) {
+		throw new Error("Operation not allowed");
+	}
+
+	/**
+	 * the use of this method is not allowed for this combo box.
+	 * @deprecated
+	 */
+	public void removeAllItems() {
+		throw new Error("Operation not allowed");
+	}
+
+	public int getSelectedUnitIndex() {
+		int i = getSelectedIndex();
+		if (i>MapContext.getDistanceNames().length-1)
+			return -1;
+		else return i;
+	}
+
+	public void setSelectedUnitIndex(int unitIndex) {
+		if (unitIndex == -1) {
+			setSelectedIndex(getItemCount()-1);
+		} else {
+			setSelectedIndex(unitIndex);
+		}
+	}
+
+
+
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlCreationException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlCreationException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlCreationException.java	(revision 38283)
@@ -0,0 +1,42 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+* 
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+* 
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+* 
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+* MA  02110-1301, USA.
+* 
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2009 {Iver T.I.}   {Task}
+*/
+ 
+package org.gvsig.fmap.mapcontrol;
+/**
+ * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
+ */
+public class MapControlCreationException extends MapControlException {
+	private static final long serialVersionUID = -7886043430856453161L;
+	private static final String KEY = "mapcontrol_creatioon_exception";
+	private static final String MESSAGE = "Error creating a MapControl";
+    
+	public MapControlCreationException(Throwable cause) {
+		super(MESSAGE, cause, KEY, serialVersionUID);
+	}
+
+}
+

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlCreationException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlLocator.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlLocator.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlLocator.java	(revision 38283)
@@ -0,0 +1,93 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+* 
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+* 
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+* 
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+* MA  02110-1301, USA.
+* 
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2009 {Iver T.I.}   {Task}
+*/
+ 
+package org.gvsig.fmap.mapcontrol;
+
+import org.gvsig.tools.locator.AbstractLocator;
+import org.gvsig.tools.locator.Locator;
+import org.gvsig.tools.locator.LocatorException;
+
+/**
+ * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
+ */
+public class MapControlLocator extends AbstractLocator {
+	private static final String LOCATOR_NAME = "MapContolLocator";
+	
+	/**
+	 * MapControlManager name used by the locator to access the instance
+	 */
+	public static final String MAPCONTROL_MANAGER_NAME = "MapControlManager";
+	private static final String MAPCONTROL_MANAGER_DESCRIPTION = "MapControlManager of gvSIG";
+
+	/**
+	 * Unique instance.
+	 */
+	private static final MapControlLocator instance = new MapControlLocator();
+	
+	/* (non-Javadoc)
+	 * @see org.gvsig.tools.locator.Locator#getLocatorName()
+	 */
+	public String getLocatorName() {
+		return LOCATOR_NAME;
+	}
+	
+	/**
+	 * Return a reference to {@link MapControlManager}.
+	 *
+	 * @return a reference to MapControlManager
+	 * @throws LocatorException
+	 *             if there is no access to the class or the class cannot be
+	 *             instantiated
+	 * @see Locator#get(String)
+	 */
+	public static MapControlManager getMapControlManager() throws LocatorException {
+		return (MapControlManager) getInstance().get(MAPCONTROL_MANAGER_NAME);
+	}
+	
+	/**
+	 * Return the singleton instance.
+	 *
+	 * @return the singleton instance
+	 */
+	public static MapControlLocator getInstance() {
+		return instance;
+	}
+	
+	/**
+	 * Registers the Class implementing the {@link MapControlManager} interface.
+	 *
+	 * @param clazz
+	 *            implementing the MapControlManager interface
+	 */
+	public static void registerMapControlManager(Class clazz) {
+		getInstance().register(MAPCONTROL_MANAGER_NAME, 
+				MAPCONTROL_MANAGER_DESCRIPTION,
+				clazz);
+	}
+}
+
+

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlLocator.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlDrawer.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlDrawer.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlDrawer.java	(revision 38283)
@@ -0,0 +1,160 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2009 {Iver T.I.}   {Task}
+ */
+
+package org.gvsig.fmap.mapcontrol;
+
+import java.awt.Color;
+import java.awt.Composite;
+import java.awt.Image;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
+
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.handler.Handler;
+import org.gvsig.fmap.mapcontext.ViewPort;
+import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
+
+/**
+ * <p>
+ * Represents a class that can write objects in a map like a raster image, a
+ * {@link Geometry} or other graphical objects. This class doesn't depend of the
+ * dimension of the map (2D or 3D).
+ * </p>
+ * <p>
+ * The Map Control has to have an instance of this class that can be accessed
+ * using the {@link MapControl#getMapControlDrawer()} method. When a Map Control
+ * is created some tools are added to this component using the
+ * {@link MapControl#addBehavior(String, org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior)}
+ * method. Some of these tools need to draw some objects in the map and they use
+ * the MapControlDrawer class to do that.
+ * </p>
+ * 
+ * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
+ */
+public interface MapControlDrawer extends PrimitivesDrawer {
+
+    /**
+     * The <code>ViewPort</code> is used to transform the map
+     * coordinates in the screen coordinates.
+     * 
+     * @param viewPort
+     *            The <code>ViewPort</code>
+     */
+    public void setViewPort(ViewPort viewPort);
+
+    /**
+     * It draws a <code>Geometry</code> on the map using the color
+     * specified using the {@link #setColor(Color)} method.
+     * 
+     * @param geometry
+     *            The <code>Geometry</code> to draw.
+     */
+    public void draw(Geometry geometry);
+
+    /**
+     * It draws a <code>Geometry</code> on the map using a concrete
+     * symbol.
+     * 
+     * @param geometry
+     *            The <code>Geometry</code> to draw.
+     * @param symbol
+     *            The symbol used to draw the geometry.
+     */
+    public void draw(Geometry geometry, ISymbol symbol);
+
+    /**
+     * It draws the <code>Handler</code>'s that compose a geometry
+     * on the map.
+     * 
+     * @param handlers
+     *            An array of <code>Handler</code>'s.
+     * @param at
+     *            A transformation that has to be applied to the
+     *            <code>Handler</code>'s.
+     * @param symbol
+     *            The symbol used to draw the handlers.
+     */
+    public void drawHandlers(Handler[] handlers, AffineTransform at,
+        ISymbol symbol);
+
+    /**
+     * It draws a line using a concrete symbol.
+     * 
+     * @param firstPoint
+     *            The first point of the line.
+     * @param endPoint
+     *            The end point of the line.
+     * @param symbol
+     *            The symbol used to draw the line.
+     */
+    public void drawLine(Point2D firstPoint, Point2D endPoint, ISymbol symbol);
+
+    /**
+     * It draws an image on a map in a concrete position.
+     * 
+     * @param img
+     *            The image to draw.
+     * @param x
+     *            The X coordinate,
+     * @param y
+     *            The Y coordinate.
+     */
+    public void drawImage(Image img, int x, int y);
+
+    /**
+     * It draws image, applying a transform from image space
+     * into user space before drawing.
+     * 
+     * @param img
+     *            The image to draw.
+     * @param xform
+     *            The transform to apply.
+     */
+    public void drawImage(Image img, AffineTransform xform);
+
+    /**
+     * It draws a <code>Handler</code> on the map.
+     * 
+     * @param handler
+     *            The <code>Handler</code> to draw.
+     * @param at
+     *            A transformation that has to be applied to the
+     *            <code>Handler</code>.
+     */
+    public void drawHandler(Handler handler, AffineTransform at);
+
+    /**
+     * @param at
+     */
+    public void transform(AffineTransform at);
+
+    /**
+     * @param instance
+     */
+    public void setComposite(Composite instance);
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlDrawer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlLibrary.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlLibrary.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlLibrary.java	(revision 38283)
@@ -0,0 +1,63 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2009 {DiSiD Technologies}  {Create Library class to initialize the MapControls library}
+ */
+package org.gvsig.fmap.mapcontrol;
+
+import java.util.Locale;
+
+import org.gvsig.fmap.mapcontext.MapContextLibrary;
+import org.gvsig.i18n.Messages;
+import org.gvsig.tools.library.AbstractLibrary;
+import org.gvsig.tools.library.LibraryException;
+
+/**
+ * Initialization of the MapControls library.
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class MapControlLibrary extends AbstractLibrary {
+
+    @Override
+    public void doRegistration() {
+        registerAsAPI(MapControlLibrary.class);
+        require(MapContextLibrary.class);
+    }
+
+	@Override
+	protected void doInitialize() throws LibraryException {
+		if (!Messages.hasLocales()) {
+			Messages.addLocale(Locale.getDefault());
+		}
+		Messages.addResourceFamily(
+				"org.gvsig.fmap.mapcontrol.i18n.text",
+				MapControlLibrary.class.getClassLoader(),
+				MapControlLibrary.class.getClass().getName());
+	}
+	
+	@Override
+	protected void doPostInitialize() throws LibraryException {
+	}
+}
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/LayersDynObjectSetComponent.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/LayersDynObjectSetComponent.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/LayersDynObjectSetComponent.java	(revision 38283)
@@ -0,0 +1,36 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.fmap.mapcontrol.swing.dynobject;
+
+import org.gvsig.tools.dispose.Disposable;
+import org.gvsig.tools.swing.api.Component;
+
+/**
+ * Interface for components to show information of a list of layers.
+ * 
+ * @author gvSIG Team
+ * @version $Id$
+ */
+public interface LayersDynObjectSetComponent extends Component, Disposable {
+
+
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/impl/LayersDynObjectSetComponentModel.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/impl/LayersDynObjectSetComponentModel.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/impl/LayersDynObjectSetComponentModel.java	(revision 38283)
@@ -0,0 +1,79 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.fmap.mapcontrol.swing.dynobject.impl;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.swing.AbstractListModel;
+
+import org.gvsig.fmap.mapcontrol.swing.dynobject.LayersDynObjectSetComponent;
+import org.gvsig.tools.dispose.Disposable;
+import org.gvsig.tools.dynobject.DynObjectSet;
+
+/**
+ * Model for a {@link LayersDynObjectSetComponent}.
+ * 
+ * @author gvSIG Team
+ * @version $Id$
+ */
+public class LayersDynObjectSetComponentModel extends AbstractListModel
+    implements Disposable {
+
+    private static final long serialVersionUID = -7978388308830573063L;
+
+    private final Map<String, DynObjectSet> layerName2InfoByPoint;
+    private final String[] layerNames;
+
+    public LayersDynObjectSetComponentModel(
+        Map<String, DynObjectSet> layerName2InfoByPoint) {
+        this.layerName2InfoByPoint = layerName2InfoByPoint;
+        Set<String> keyset = layerName2InfoByPoint.keySet();
+        layerNames = keyset.toArray(new String[keyset.size()]);
+    }
+
+    public String[] getLayerNames() {
+        Set<String> keyset = layerName2InfoByPoint.keySet();
+        return keyset.toArray(new String[keyset.size()]);
+    }
+
+    public DynObjectSet getLayerInfoByPoint(String layerName) {
+        return layerName2InfoByPoint.get(layerName);
+    }
+
+    public int getSize() {
+        return layerName2InfoByPoint.size();
+    }
+
+    public Object getElementAt(int index) {
+        return layerNames[index];
+    }
+
+    public void dispose() {
+        for (Iterator<DynObjectSet> iterator =
+            layerName2InfoByPoint.values().iterator(); iterator.hasNext();) {
+            iterator.next().dispose();
+        }
+        layerName2InfoByPoint.clear();
+    }
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/impl/DefaultLayersDynObjectSetComponent.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/impl/DefaultLayersDynObjectSetComponent.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/impl/DefaultLayersDynObjectSetComponent.java	(revision 38283)
@@ -0,0 +1,146 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.fmap.mapcontrol.swing.dynobject.impl;
+
+import java.awt.BorderLayout;
+import java.util.Map;
+
+import javax.swing.JComponent;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.gvsig.fmap.mapcontrol.swing.dynobject.LayersDynObjectSetComponent;
+import org.gvsig.tools.dynobject.DynObjectSet;
+import org.gvsig.tools.exception.BaseException;
+import org.gvsig.tools.swing.api.ToolsSwingLocator;
+import org.gvsig.tools.swing.api.dynobject.set.JDynObjectSetComponent;
+
+/**
+ * @author gvSIG Team
+ * @version $Id$
+ * 
+ */
+public class DefaultLayersDynObjectSetComponent extends JPanel implements
+    LayersDynObjectSetComponent, ListSelectionListener {
+
+    private static final long serialVersionUID = 5864674721657215264L;
+
+    private static final Logger LOG = LoggerFactory
+        .getLogger(DefaultLayersDynObjectSetComponent.class);
+
+    private final LayersDynObjectSetComponentModel model;
+
+    private JDynObjectSetComponent component;
+
+    private JList layersList;
+
+    private final boolean writable;
+
+    /**
+     * Creates a new {@link DefaultLayersDynObjectSetComponent} with the given
+     * information for a list of layers.
+     */
+    public DefaultLayersDynObjectSetComponent(
+        Map<String, DynObjectSet> layerName2InfoByPoint) {
+        this(layerName2InfoByPoint, true);
+    }
+
+    /**
+     * @param isDoubleBuffered
+     */
+    public DefaultLayersDynObjectSetComponent(
+        Map<String, DynObjectSet> layerName2InfoByPoint,
+ boolean writable) {
+        super(new BorderLayout());
+        this.writable = writable;
+        model = new LayersDynObjectSetComponentModel(layerName2InfoByPoint);
+        initializeUI();
+    }
+
+    private void initializeUI() {
+        addLayerList();
+    }
+
+    private void addLayerList() {
+        layersList = new JList(model);
+        layersList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+        layersList.setLayoutOrientation(JList.VERTICAL);
+        // list.setVisibleRowCount(20);
+        layersList.addListSelectionListener(this);
+
+        add(layersList, BorderLayout.WEST);
+
+        layersList.setSelectedIndex(0);
+    }
+
+    public void valueChanged(ListSelectionEvent e) {
+        if (!e.getValueIsAdjusting()) {
+            String layerName = (String) layersList.getSelectedValue();
+            setCurrentLayerInfoByPoint(layerName);
+        }
+    }
+
+    private void setCurrentLayerInfoByPoint(String layerName) {
+        JDynObjectSetComponent newComponent = null;
+
+        DynObjectSet dynObjectSet = model.getLayerInfoByPoint(layerName);
+        try {
+            newComponent =
+                ToolsSwingLocator.getDynObjectSwingManager()
+                    .createJDynObjectSetComponent(dynObjectSet, writable);
+        } catch (BaseException e) {
+            LOG.error("Error creating the JDynObjectSetComponent for "
+                + "the DynObjectSet: " + dynObjectSet, e);
+        }
+
+        if (newComponent != null) {
+            removeCurrentDynObjectSetComponent();
+            component = newComponent;
+            add(component.asJComponent(), BorderLayout.CENTER);
+            revalidate();
+            repaint();
+        }
+    }
+
+    public JComponent asJComponent() {
+        return this;
+    }
+
+    public void dispose() {
+        removeCurrentDynObjectSetComponent();
+        model.dispose();
+    }
+
+    private void removeCurrentDynObjectSetComponent() {
+        if (component != null) {
+            remove(component.asJComponent());
+            component.dispose();
+        }
+    }
+
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/DynObjectViewer.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/DynObjectViewer.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/DynObjectViewer.java	(revision 38283)
@@ -0,0 +1,160 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+
+/*
+* AUTHORS (In addition to CIT):
+* 2009 IVER T.I. S.A.   {{Task}}
+*/
+
+package org.gvsig.fmap.mapcontrol.swing.dynobject;
+
+import java.awt.Color;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.cresques.cts.IProjection;
+
+import org.gvsig.i18n.Messages;
+import org.gvsig.tools.dynobject.DynClass;
+import org.gvsig.tools.dynobject.DynField;
+import org.gvsig.tools.dynobject.DynObject;
+
+
+public class DynObjectViewer extends JPanel {
+
+	/**
+	 *
+	 */
+	private static final long serialVersionUID = -5277036770491043233L;
+	private GridBagConstraints paramsListLabelConstraint;
+	private GridBagConstraints paramsListValueConstraint;
+	private GridBagConstraints paramsListFillConstraint;
+
+	public DynObjectViewer() {
+		super();
+		this.intialize();
+	}
+
+	private void intialize() {
+		this.setLayout(new GridBagLayout());
+
+		paramsListLabelConstraint = new GridBagConstraints();
+		paramsListValueConstraint = new GridBagConstraints();
+		paramsListFillConstraint = new GridBagConstraints();
+
+		paramsListLabelConstraint.ipadx = 3;
+		paramsListLabelConstraint.ipady = 3;
+		paramsListLabelConstraint.anchor = GridBagConstraints.FIRST_LINE_START;
+		paramsListLabelConstraint.gridwidth = GridBagConstraints.RELATIVE;
+		paramsListLabelConstraint.fill = GridBagConstraints.HORIZONTAL;
+		paramsListLabelConstraint.weightx = 0.5;
+
+		paramsListValueConstraint.ipadx = 3;
+		paramsListValueConstraint.ipady = 3;
+		paramsListValueConstraint.anchor = GridBagConstraints.FIRST_LINE_END;
+		paramsListValueConstraint.gridwidth = GridBagConstraints.REMAINDER;
+		paramsListValueConstraint.fill = GridBagConstraints.HORIZONTAL;
+		paramsListValueConstraint.weightx = 0.5;
+
+		paramsListFillConstraint.ipadx = 3;
+		paramsListFillConstraint.ipady = 3;
+		paramsListFillConstraint.anchor = GridBagConstraints.FIRST_LINE_END;
+		paramsListFillConstraint.gridwidth = GridBagConstraints.REMAINDER;
+		paramsListFillConstraint.fill = GridBagConstraints.BOTH;
+		paramsListFillConstraint.weightx = 1;
+		paramsListFillConstraint.weighty = 1;
+	}
+
+	private String getLocalizedText(String txt) {
+		try {
+			return Messages.getText(txt);
+		} catch (Exception e) {
+			return txt;
+		}
+	}
+
+	public void load(DynObject dynObj) {
+		this.removeAll();
+
+		if (dynObj == null) {
+			this.doLayout();
+			return;
+		}
+		DynClass dynClass = dynObj.getDynClass();
+
+		JTextField label;
+		JTextField text;
+		Object value;
+		String strValue;
+
+		//		label = new JLabel();
+		//		label.setText(getLocalizedText("parameter"));
+		//		label.setBackground(Color.LIGHT_GRAY);
+		//		this.add(label, paramsListLabelConstraint);
+
+		text = new JTextField();
+		text.setText(getLocalizedText("parameter"));
+		text.setEditable(false);
+		text.setBackground(Color.LIGHT_GRAY);
+		this.add(text, paramsListLabelConstraint);
+
+		text = new JTextField();
+		text.setText(getLocalizedText("value"));
+		text.setEditable(false);
+		text.setBackground(Color.LIGHT_GRAY);
+		this.add(text, paramsListValueConstraint);
+
+		for (DynField field : dynClass.getDynFields()) {
+			label = new JTextField();
+			label.setText(field.getDescription());
+			label.setEditable(false);
+			this.add(label, paramsListLabelConstraint);
+
+			strValue = "";
+			value = dynObj.getDynValue(field.getName());
+			if (value != null) {
+				if (value instanceof String) {
+					strValue = (String) value;
+				} else if (value instanceof IProjection) {
+					strValue = ((IProjection) value).getAbrev();
+				} else {
+					strValue = value.toString();
+				}
+
+			}
+			text = new JTextField();
+			text.setText(strValue);
+			text.setEditable(false);
+			this.add(text, paramsListValueConstraint);
+		}
+
+		this.add(new JLabel(), paramsListFillConstraint);
+
+		this.doLayout();
+		this.repaint();
+
+	}
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/DynObjectViewer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/DynObjectEditor.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/DynObjectEditor.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/DynObjectEditor.java	(revision 38283)
@@ -0,0 +1,196 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2008 IVER T.I. S.A.   {{Task}}
+ */
+
+/**
+ *
+ */
+package org.gvsig.fmap.mapcontrol.swing.dynobject;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.gvsig.i18n.Messages;
+import org.gvsig.tools.dynobject.DynObject;
+import org.gvsig.tools.service.ServiceException;
+import org.gvsig.tools.swing.api.ToolsSwingLocator;
+import org.gvsig.tools.swing.api.dynobject.JDynObjectComponent;
+import org.gvsig.tools.swing.api.windowmanager.WindowManager;
+
+/**
+ * Editor for a store parameters.
+ * 
+ * @author gvSIG Team
+ * @version $Id$
+ */
+public class DynObjectEditor extends JPanel implements ActionListener {
+
+    private static final long serialVersionUID = 23898787077741411L;
+
+    private static final Logger LOG = LoggerFactory
+        .getLogger(DynObjectEditor.class);
+    
+    private static final WindowManager WINDOW_MANAGER =
+        ToolsSwingLocator.getWindowManager();
+    
+    private String title;
+
+    private JButton botAcept;
+    private JButton botCancel;
+    private JButton botRestoreDefaults;
+    private JPanel panButtons;
+
+    private boolean modal;
+
+    private JDynObjectComponent component;
+
+    public DynObjectEditor(DynObject parameters) throws ServiceException {
+        component =
+            ToolsSwingLocator.getDynObjectSwingManager()
+                .createJDynObjectComponent(parameters, true);
+        this.setLayout(new BorderLayout());
+        this.add(component.asJComponent(), BorderLayout.CENTER);
+        this.add(getButtonsPanel(), BorderLayout.SOUTH);
+    }
+
+    private JPanel getButtonsPanel() {
+        if (this.panButtons == null) {
+            this.panButtons = new JPanel();
+            this.panButtons.setLayout(new GridBagLayout());
+            GridBagConstraints constr = new GridBagConstraints();
+            constr.anchor = GridBagConstraints.LAST_LINE_END;
+            constr.fill = GridBagConstraints.HORIZONTAL;
+            constr.weightx = 1;
+            constr.weighty = 0;
+            this.panButtons.add(new JLabel(), constr);
+
+            constr = this.getDefaultParametersConstraints();
+            constr.fill = GridBagConstraints.NONE;
+            constr.weightx = 0;
+            constr.weighty = 0;
+
+            this.panButtons.add(this.getAcceptButton(), constr);
+            this.panButtons.add(this.getCancelButton(), constr);
+            this.panButtons.add(this.getRestoreDefaults(), constr);
+        }
+        return this.panButtons;
+    }
+
+    private GridBagConstraints getDefaultParametersConstraints() {
+        GridBagConstraints constr = new GridBagConstraints();
+        constr.insets = new Insets(2, 2, 2, 2);
+        constr.ipadx = 2;
+        constr.ipady = 2;
+        constr.anchor = GridBagConstraints.PAGE_START;
+        return constr;
+
+    }
+
+    private JButton getRestoreDefaults() {
+        if (this.botRestoreDefaults == null) {
+            this.botRestoreDefaults =
+                ToolsSwingLocator.getUsabilitySwingManager().createJButton(
+                    Messages.getText("restoreDefaults"));
+            this.botRestoreDefaults.addActionListener(this);
+        }
+        return this.botRestoreDefaults;
+    }
+
+    private JButton getCancelButton() {
+        if (this.botCancel == null) {
+            this.botCancel =
+                ToolsSwingLocator.getUsabilitySwingManager().createJButton(
+                    Messages.getText("cancel"));
+            this.botCancel.addActionListener(this);
+        }
+        return this.botCancel;
+    }
+
+    private JButton getAcceptButton() {
+        if (this.botAcept == null) {
+            this.botAcept =
+                ToolsSwingLocator.getUsabilitySwingManager().createJButton(
+                    Messages.getText("accept"));
+            this.botAcept.addActionListener(this);
+        }
+        return this.botAcept;
+    }
+
+    public void actionPerformed(ActionEvent e) {
+        Component source = (Component) e.getSource();
+        if (source == this.botAcept) {
+            this.component.saveStatus();
+            this.closeWindow();
+
+        } else
+            if (source == this.botCancel) {
+                // TODO Close windows
+                this.closeWindow();
+            } else
+                if (source == this.botRestoreDefaults) {
+                    // TODO: implement
+                    // this.component.restore();
+
+                }
+    }
+
+    protected void closeWindow() {
+        LOG.debug("Closing window, values edited: ", component.getDynObject());
+        this.setVisible(false);       
+    }
+
+    public void editObject(boolean modal) {
+        this.modal = modal;
+        
+        WINDOW_MANAGER.showWindow(this, 
+            Messages.getText("explorer_parameters"), 
+            WindowManager.MODE.DIALOG);
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+  
+    public DynObject getParameters() {
+        return component.getDynObject();
+    }
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/DynObjectEditor.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlManager.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlManager.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlManager.java	(revision 38283)
@@ -0,0 +1,218 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+* 
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+* 
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+* 
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+* MA  02110-1301, USA.
+* 
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2009 {Iver T.I.}   {Task}
+*/
+ 
+package org.gvsig.fmap.mapcontrol;
+
+import java.util.Map;
+import java.util.prefs.Preferences;
+
+import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
+import org.gvsig.fmap.mapcontrol.swing.dynobject.LayersDynObjectSetComponent;
+import org.gvsig.fmap.mapcontrol.tools.snapping.snappers.ISnapper;
+import org.gvsig.tools.dynobject.DynObject;
+import org.gvsig.tools.dynobject.DynObjectSet;
+
+/**
+ * <p>
+ * This class is the manager of the MapControl library. It is used to
+ * manage all the properties related with the drawing of objects 
+ * in a map, including default symbols used to draw objects
+ * in a map, the tolerance used by the selection or edition tools...
+ * </p>
+ * <p>
+ * It also holds the implementations of the {@link MapControlDrawer}'s, 
+ * that is the responsible to draw graphical objects in a map.
+ * </p> 
+ * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
+ */
+public interface MapControlManager {
+
+	public MapControl createJMapControlPanel() throws MapControlCreationException;
+		
+	/**
+	 * Register a <code>MapControlDrawer</code> by name.
+	 * @param name
+	 * Name of the <code>MapControlDrawer</code>.
+	 * @param mapControolDrawerClass
+	 * Class used to draw graphical objects on a map.
+	 */
+	public void registerMapControlDrawer(String name, Class mapControolDrawerClass);
+	
+	/**
+	 * Creates a <code>MapControlDrawer</code> from a name.
+	 * @param name
+	 * Name of the <code>MapControlDrawer</code>.
+	 * @return
+	 * A <code>MapControlDrawer</code>.
+	 * @throws MapControlCreationException
+	 */
+	public MapControlDrawer createMapControlDrawer(String name) throws MapControlCreationException;
+	
+	/**
+	 * It registers the default implementation for the <code>MapControlDrawer</code>.
+	 * @param mapControlDrawerClass
+	 * A <code>MapControlDrawer</code>. 
+	 */
+	public void registerDefaultMapControlDrawer(Class mapControlDrawerClass);
+	
+	/**
+	 * It returns the default implementation for the <code>MapControlDrawer</code>.
+	 * @return
+	 * The default <code>MapControlDrawer</code>.
+	 * @throws MapControlCreationException
+	 */
+	public MapControlDrawer createDefaultMapControlDrawer() throws MapControlCreationException;
+	
+	/**
+	 * Returns a snapper in a concrete position;
+	 * @param index
+	 * Snapper position.
+	 * @return
+	 * A snapper. 
+	 */
+	public ISnapper getSnapperAt(int index);
+	
+	/**
+	 * Returns the number of registered snappers.
+	 * @return
+	 * The number of registered snappers.
+	 */
+	public int getSnapperCount();
+	
+	/**
+	 * Add a snapper.
+	 * @param snapper
+	 */
+	public void registerSnapper(String name, Class snapperClass);
+	
+	
+	public Preferences getEditionPreferences();
+	
+	/**
+	 * Tolerance (in pixels) that has to be used by the tools
+	 * that use snapping.
+	 * @return
+	 * The distance in pixels.
+	 */
+	public int getTolerance();
+	
+	/**
+	 * Sets the tolerance (in pixels) that has to be used by the
+	 * tools that use snapping.
+	 * @param tolerance
+	 * The tolerance to apply
+	 */
+	public void setTolerance(int tolerance);
+	
+	/**
+	 * Sets the symbol that has to be used to draw a geometry when
+	 * it is selected.
+	 * @param selectionSymbol
+	 * The symbol to apply.
+	 * @deprecated the symbol for edition is the selection symbol
+	 */
+	public void setSelectionSymbol(ISymbol selectionSymbol);
+	
+	/**
+	 * Gets the symbol used to draw the selected geometries.
+	 * @return
+	 * The symbol used to draw the selected geometries.
+	 * @deprecated the symbol for edition is the selection symbol
+	 */
+	public ISymbol getSelectionSymbol();
+	
+	/**
+	 * Sets the symbol that has to be used to draw a geometry that
+	 * represent the axis of a geometry.
+	 * @param axisReferencesSymbol
+	 * The symbol to apply.
+	 */
+	public void setAxisReferenceSymbol(ISymbol axisReferencesSymbol);
+	
+	/**
+	 * Gets the symbol used to draw the axis of a geometry.
+	 * @return
+	 * The symbol used to draw the axis of a geometry.
+	 */
+	public ISymbol getAxisReferenceSymbol();
+	
+	/**
+	 * Sets the symbol that has to be used to draw a geometry when
+	 * it is selected.
+	 * @param geometrySelectionSymbol
+	 * The symbol to apply.
+	 */
+	public void setGeometrySelectionSymbol(ISymbol geometrySelectionSymbol);
+	
+	/**
+	 * Gets the symbol used to draw the selected geometries.
+	 * @return
+	 * The symbol used to draw the selected geometries.
+	 */
+	public ISymbol getGeometrySelectionSymbol();
+	
+	/**
+	 * Sets the symbol that has to be used to draw the handlers.
+	 * @param handlerSymbol
+	 * The symbol to apply.
+	 */
+	public void setHandlerSymbol(ISymbol handlerSymbol);
+	
+	/**
+	 * Gets the symbol used to draw the handlers.
+	 * @return
+	 * The symbol used to draw the handlers.
+	 */
+	public ISymbol getHandlerSymbol();
+
+    /**
+     * Creates a readonly component to view information of a set of layers. The
+     * information must be provided as a set of {@link DynObject}s, through a
+     * {@link DynObjectSet}.
+     * 
+     * @param layerName2InfoByPoint
+     *            the map of {@link DynObjectSet} for each layer.
+     * @return the component to view the information
+     */
+    public LayersDynObjectSetComponent createLayersDynObjectSetComponent(
+        Map<String, DynObjectSet> layerName2InfoByPoint);
+
+    /**
+     * Creates a component to view information of a set of layers. The
+     * information must be provided as a set of {@link DynObject}s, through a
+     * {@link DynObjectSet}.
+     * 
+     * @param layerName2InfoByPoint
+     *            the map of {@link DynObjectSet} for each layer.
+     * @param writable
+     *            if the DynObjects loaded must be able to be edited
+     * @return the component to view the information
+     */
+    public LayersDynObjectSetComponent createLayersDynObjectSetComponent(
+        Map<String, DynObjectSet> layerName2InfoByPoint, boolean writable);
+}
+

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlManager.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlException.java	(revision 38283)
@@ -0,0 +1,54 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+* 
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+* 
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+* 
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+* MA  02110-1301, USA.
+* 
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2009 {Iver T.I.}   {Task}
+*/
+ 
+package org.gvsig.fmap.mapcontrol;
+
+import org.gvsig.tools.exception.BaseException;
+
+/**
+ * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
+ */
+public class MapControlException extends BaseException {
+	private static final long serialVersionUID = 981894833703125550L;
+
+	/**
+     * @see BaseException#BaseException(String, String, long)
+     */
+    public MapControlException(String message, String key, long code) {
+        super(message, key, code);
+    }
+
+    /**
+     * @see BaseException#BaseException(String, Throwable, String, long)
+     */
+    public MapControlException(String message, Throwable cause, String key,
+            long code) {
+        super(message, cause, key, code);
+    }
+}
+
+

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControl.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControl.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControl.java	(revision 38283)
@@ -0,0 +1,2633 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol;
+
+import java.awt.Color;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
+import java.awt.geom.Point2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.MemoryImageSource;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.prefs.Preferences;
+
+import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+import javax.swing.Timer;
+
+import org.cresques.cts.IProjection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.gvsig.fmap.crs.CRSFactory;
+import org.gvsig.fmap.dal.DataStoreNotification;
+import org.gvsig.fmap.dal.feature.FeatureStoreNotification;
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.Geometry.SUBTYPES;
+import org.gvsig.fmap.geom.GeometryLocator;
+import org.gvsig.fmap.geom.GeometryManager;
+import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
+import org.gvsig.fmap.geom.primitive.Envelope;
+import org.gvsig.fmap.geom.util.Converter;
+import org.gvsig.fmap.mapcontext.MapContext;
+import org.gvsig.fmap.mapcontext.ViewPort;
+import org.gvsig.fmap.mapcontext.events.AtomicEvent;
+import org.gvsig.fmap.mapcontext.events.listeners.AtomicEventListener;
+import org.gvsig.fmap.mapcontext.layers.FLayers;
+import org.gvsig.fmap.mapcontext.layers.LayerCollectionEvent;
+import org.gvsig.fmap.mapcontext.layers.LayerEvent;
+import org.gvsig.fmap.mapcontext.layers.SpatialCache;
+import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
+import org.gvsig.fmap.mapcontext.layers.vectorial.GraphicLayer;
+import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
+import org.gvsig.fmap.mapcontrol.tools.CompoundBehavior;
+import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
+import org.gvsig.fmap.mapcontrol.tools.grid.Grid;
+import org.gvsig.fmap.mapcontrol.tools.snapping.snappers.ISnapper;
+import org.gvsig.fmap.mapcontrol.tools.snapping.snappers.ISnapperGeometriesVectorial;
+import org.gvsig.fmap.mapcontrol.tools.snapping.snappers.ISnapperRaster;
+import org.gvsig.fmap.mapcontrol.tools.snapping.snappers.ISnapperVectorial;
+import org.gvsig.tools.observer.Observable;
+import org.gvsig.tools.observer.Observer;
+import org.gvsig.tools.task.Cancellable;
+import org.gvsig.utils.exceptionHandling.ExceptionHandlingSupport;
+import org.gvsig.utils.exceptionHandling.ExceptionListener;
+
+/**
+ * <p>
+ * A component that includes a {@link MapContext MapContext} with support for
+ * use it as a particular {@link Behavior Behavior}.
+ * </p>
+ * 
+ * <p>
+ * A developer can register a set of <code>Behavior</code>, but only one (that
+ * can be a composition of several) of them can be active. The active one
+ * defines the way to work and access with its <code>MapContext</code>'s layers.
+ * The active behavior, in combination with the appropriate {@link ToolListener
+ * ToolListener} will allow user work with a particular <i>tool</i>.
+ * </p>
+ * 
+ * <p>
+ * All mouse events produced on this component will be delegated to the current
+ * active behavior, the <i>currentMapTool</i>.
+ * </p>
+ * 
+ * <p>
+ * <b>Drawing process:</b>
+ * </p>
+ * 
+ * <p>
+ * Uses a double buffer for the drawing process of <code>MapContext</code>'s
+ * information.
+ * </p>
+ * 
+ * <p>
+ * If the double buffer wasn't created, creates a new one.
+ * </p>
+ * 
+ * <p>
+ * Paints the component according the following algorithm: <br>
+ * &nbsp If <i>status</i> is <i>UPDATED</i>:<br>
+ * &nbsp &nbsp If there is a <i>double buffer</i>:<br>
+ * &nbsp &nbsp &nbsp If there is a <i>behavior</i> for managing the
+ * <code>MapControl</code> instance, delegates the drawing process to that
+ * behavior, calling: <code><i>behavior_instance</i>.paintComponent(g)</code>.<br>
+ * &nbsp &nbsp &nbsp Else, repaints the current graphical information quickly
+ * calling: <code>g.drawImage(image,0,0,null)</code>.<br>
+ * &nbsp Else, (<i>status</i> is <i>OUTDATED</i>, or <i>ONLY_GRAPHICS</i>):
+ * executes a quickly repaint of the previous information calling
+ * <code>g.drawImage(image,0,0,null)</code>, and creates a <i>painting
+ * request</i> to delegate the heavy drawing process to the {@link Drawer2
+ * Drawer2}'s worker thread, according the <i>SingleWorketThread</i> pattern,
+ * starting a timer to update (invoking <code>repaint()</code>) the view every
+ * delay of <code>1000 / drawFrameRate</code> ms. during that heavy drawing
+ * process, and if its enabled <code>drawAnimationEnabled</code>. The
+ * <i>painting request</i> once is being attended, invokes
+ * <code>MapContext</code> to draw the layers:
+ * <code>mapContext.draw(image, g, cancel,mapContext.getScaleView());</code>
+ * <br>
+ * <p>
+ * Some notes:
+ * <ul>
+ * <li>The painting process can be cancelled calling {@link #cancelDrawing()
+ * #cancelDrawing()}.</li>
+ * <li>At last resort, the particular implementation of each layer in a
+ * <code>MapControl</code>'s <code>MapContrext</code> will be that one which
+ * will draw the graphical information, and, if supports, which could cancel its
+ * drawing subprocess.</li>
+ * <li>It's possible to force repaint all layers, calling
+ * {@link #drawMap(boolean doClear) #drawMap(boolean)}.</li>
+ * <li>It's possible repaint only the dirty layers, calling
+ * {@link #rePaintDirtyLayers() #rePaintDirtyLayers()}.</li>
+ * <li>It's possible repaint only the {@link GraphicLayer GraphicLayer}, calling
+ * {@link #drawGraphics() #drawGraphics()}.</li>
+ * </ul>
+ * </p>
+ * 
+ * <p>
+ * <b>Tools:</b>
+ * </p>
+ * 
+ * <p>
+ * A developer can:
+ * <ul>
+ * <li>Register each tool as:
+ * <ul>
+ * <li>A single behavior: {@link #addBehavior(String, Behavior)
+ * #addMapTool(String, Behavior)}.</li>
+ * <li>Or, a compound behavior: {@link #addBehavior(String, Behavior)
+ * #addMapTool(String, Behavior)}.</li>
+ * </ul>
+ * </li>
+ * <li>Get the current active tool: {@link #getCurrentMapTool()
+ * #getCurrentMapTool()}.</li>
+ * <li>Get the current active tool name: {@link #getCurrentTool()
+ * #getCurrentTool()}.</li>
+ * <li>Get a registered tool: {@link #getMapTool(String) #getMapTool(String)}.</li>
+ * <li>Get the name of all tools registered: {@link #getMapToolsKeySet()
+ * #getMapToolsKeySet()}.</li>
+ * <li>Get all tools registered, including the name they were registered:
+ * {@link #getNamesMapTools() #getNamesMapTools()}.</li>
+ * <li>Determine if has a tool registered: {@link #hasTool(String)
+ * #hasTool(String)}.</li>
+ * <li>Set as an active tool, one of the registered: {@link #setTool(String)
+ * #setTool(String)}.</li>
+ * <li>Set as active tool, the previous used: {@link #setPrevTool()
+ * #setPrevTool()}.</li>
+ * <li>Set the current tool: {@link #setCurrentMapTool(Behavior)
+ * #setCurrentMapTool(Behavior)}.</li>
+ * <li>Change the draw frame rate: {@link #setDrawFrameRate(int)
+ * #setDrawFrameRate(int)} and {@link #applyFrameRate() #applyFrameRate()}.</li>
+ * <li>Get the draw frame rate: {@link #getDrawFrameRate() #getDrawFrameRate()}.
+ * </li>
+ * <li>Determine if will repaint this component each time timer finishes:
+ * {@link #isDrawAnimationEnabled() #isDrawAnimationEnabled()}.</li>
+ * <li>Change if will repaint this component each time timer finishes:
+ * {@link #setDrawAnimationEnabled(boolean) #setDrawAnimationEnabled(boolean)}.</li>
+ * <li>Get the shared object that determines if a drawing process must be
+ * cancelled or can continue: {@link #getCanceldraw() #getCanceldraw()}.</li>
+ * <li>Get the combined tool: {@link #getCombinedTool() #getCombinedTool()}.</li>
+ * <li>Set a combined tool: {@link #setCombinedTool(Behavior)
+ * #setCombinedTool(Behavior)}.</li>
+ * <li>Remove the combined tool: {@link #removeCombinedTool()
+ * #removeCombinedTool()}.</li>
+ * </ul>
+ * </p>
+ * 
+ * <p>
+ * <b>Exception listener:</b>
+ * </p>
+ * 
+ * <p>
+ * Adding an <code>ExceptionListener</code>, can get notification about any
+ * exception produced:
+ * <ul>
+ * <li>Attending a <i>painting request</i>.</li>
+ * <li>Working with the active tool.</li>
+ * <li>Applying a <i>zoom in</i> or <i>zoom out</i> operation.</li>
+ * </ul>
+ * </p>
+ * 
+ * <p>
+ * <b>Other:</b>
+ * </p>
+ * 
+ * <p>
+ * Other useful capabilities of <code>MapControl</code>:
+ * <ul>
+ * <li>Cancel the current drawing process (notifying it also to the inner
+ * <code>MapContext</code> instance and its layers): {@link #cancelDrawing()
+ * #cancelDrawing()}.</li>
+ * <li>Applying a <i>zoom in</i> operation centered at mouse position (without a
+ * <code>ToolListener</code>): {@link #zoomIn() #zoomIn()}.</li>
+ * <li>Applying a <i>zoom out</i> operation centered at mouse position (without
+ * a <code>ToolListener</code>): {@link #zoomOut() #zoomOut()}.</li>
+ * </ul>
+ * </p>
+ * 
+ * @see CancelDraw
+ * @see Drawer
+ * @see MapContextListener
+ * @see MapToolListener
+ * 
+ * @author Fernando González Cortés
+ * @author Pablo Piqueras Bartolomé (pablo.piqueras@iver.es)
+ */
+public class MapControl extends JComponent implements ComponentListener,
+    Observer {
+
+    protected static final GeometryManager geomManager =
+        GeometryLocator.getGeometryManager();
+    protected static final Logger logger =
+        LoggerFactory.getLogger(GeometryManager.class);
+
+    /**
+     * <p>
+     * One of the possible status of <code>MapControl</code>. Determines that
+     * all visible information has been drawn and its updated.
+     * </p>
+     */
+    public static final int ACTUALIZADO = 0;
+
+    /**
+     * <p>
+     * One of the possible status of <code>MapControl</code>. Determines that
+     * not all visible information has been drawn or isn't updated.
+     * </p>
+     */
+    public static final int DESACTUALIZADO = 1;
+
+    /**
+     * <p>
+     * Determines if the drawer can update this <code>MapControl</code> instance
+     * when the timer launches an event.
+     * </p>
+     */
+    private static boolean drawAnimationEnabled = true;
+
+    /**
+     * <p>
+     * Inner model with the layers, event support for drawing them, and the
+     * <code>ViewPort</code> with information to adapt to the bounds available
+     * in <i>image coordinates</i>.
+     * </p>
+     * 
+     * @see #getMapContext()
+     * @see #setMapContext(MapContext)
+     */
+    private MapContext mapContext = null;
+
+    /**
+     * <p>
+     * All registered <code>Behavior</code> that can define a way to work with
+     * this <code>MapControl</code>.
+     * </p>
+     * 
+     * <p>
+     * Only one of them can be active at a given moment.
+     * </p>
+     * 
+     * @see #addBehavior(String, Behavior)
+     * @see #addBehavior(String, Behavior[])
+     * @see #getMapTool(String)
+     * @see #getMapToolsKeySet()
+     * @see #getNamesMapTools()
+     */
+    protected HashMap namesMapTools = new HashMap();
+
+    /**
+     * <p>
+     * Active {@link Behavior Behavior} that will generate events according a
+     * criterion, and then, with a {@link ToolListener ToolListener} associated,
+     * will simulate to user that works with this component as a particular
+     * tool.
+     * </p>
+     * 
+     * @see #getCurrentMapTool()
+     * @see #getCurrentTool()
+     * @see #setTool(String)
+     */
+    protected Behavior currentMapTool = null;
+
+    /**
+     * <p>
+     * Determines which's the current drawn status of this component:
+     * <ul>
+     * <li><b>OUTDATED</b>: all visible information has been drawn or isn't
+     * updated.</li>
+     * <li><b>UTDATED</b>: all visible information has been drawn and its
+     * updated.</li>
+     * <li><b>ONLY_GRAPHICS</b>: only the graphical layer must be drawn /
+     * updated.</li>
+     * </ul>
+     * </p>
+     * 
+     * <p>
+     * The <code>MapControl</code> drawing process will consider the value of
+     * this parameter to decide which elements will be updated or drawn.
+     * </p>
+     */
+    private int status = DESACTUALIZADO;
+
+    /**
+     * <p>
+     * Image with a buffer to accelerate the draw the changes of the graphical
+     * items in this component.
+     * </p>
+     * 
+     * <p>
+     * Firstly, information will be drawn in the buffer, and, when is outright
+     * drawn, that information will be displayed. Meanwhile, the previous image
+     * can be kept showed.
+     * </p>
+     * 
+     * @see BufferedImage
+     * 
+     * @see #getImage()
+     */
+    private BufferedImage image = null;
+
+    /**
+     * <p>
+     * Name of the tool used currently to interact with this component.
+     * </p>
+     * 
+     * @see #getCurrentTool()
+     * @see #setTool(String)
+     */
+    protected String currentTool;
+
+    /**
+     * <p>
+     * Object to store the flag that notifies a drawing thread task and
+     * <code>MapContext</code>'s layers, that must be canceled or can continue
+     * with the process.
+     * </p>
+     * 
+     * @see #cancelDrawing()
+     */
+    private CancelDraw canceldraw;
+
+    // private boolean isCancelled = true;
+
+    /**
+     * <p>
+     * Fires an action events after a specified delay.
+     * </p>
+     * 
+     * <p>
+     * <code>MapControl</code> will use the timer to update its visible
+     * graphical information during a drawing process, or allowing to cancel
+     * that process.
+     * </p>
+     * 
+     * <p>
+     * This is very useful to pretend faster interactivity to user when
+     * <code>MapControl</code> has lots of layers, and / or layers with heavy
+     * graphical elements, that need a long time to finish drawing all its data.
+     * </p>
+     */
+    private Timer timer;
+
+    /**
+     * <p>
+     * Reference to the {@link ViewPort ViewPort} of the {@link MapContext
+     * MapContext} of this component.
+     * </p>
+     * 
+     * <p>
+     * The view port once is created an instance of <code>MapControl</code>, is
+     * obtained from the <i>EPSG:23030</i> projection, that's the default
+     * projection for this component.
+     * </p>
+     * 
+     * <p>
+     * After, the view port will change adapting itself according the current
+     * projection and the extent.
+     * </p>
+     * 
+     * @see #getViewPort()
+     * 
+     * @see ViewPort
+     */
+    protected ViewPort vp;
+
+    /**
+     * <p>
+     * Manager of all <code>MapControl</code> painting requests.
+     * </p>
+     */
+    private Drawer drawer;
+
+    /**
+     * <p>
+     * Listener of all kind of mouse events produced in this component.
+     * </p>
+     * 
+     * <p>
+     * Delegates each mouse event to the current map tool.
+     * </p>
+     * 
+     * @see #addBehavior(String, Behavior)
+     * @see #addBehavior(String, Behavior[])
+     * @see #getMapTool(String)
+     * @see #getMapToolsKeySet()
+     * @see #getNamesMapTools()
+     * @see #setTool(String)
+     */
+    protected MapToolListener mapToolListener = new MapToolListener();
+
+    /**
+     * <p>
+     * Listener of all events produced in a this component's
+     * <code>MapContext</code> object during an atomic period of time.
+     * </p>
+     */
+    private MapContextListener mapContextListener = new MapContextListener();
+
+    /**
+     * <p>
+     * Group of <code>ExceptionListener</code> that, in whatever moment could be
+     * notified a Throwable Java error or exception.
+     * </p>
+     * 
+     * @see #addExceptionListener(ExceptionListener)
+     * @see #removeExceptionListener(ExceptionListener)
+     */
+    private ExceptionHandlingSupport exceptionHandlingSupport =
+        new ExceptionHandlingSupport();
+
+    /**
+     * <p>
+     * Name of the previous tool used.
+     * </p>
+     */
+    protected String prevTool;
+
+    /**
+     * <p>
+     * Tool that will be used combined with the current tool of this
+     * <code>MapControl</code>.
+     * </p>
+     */
+    private Behavior combinedTool = null;
+
+    /**
+     * Optional grid that could be applied on the <code>MapControl</code>'s view
+     * port.
+     * 
+     * @see #getGrid()
+     * @see #setAdjustGrid(boolean)
+     */
+    private Grid cadgrid = new Grid();
+    /**
+     * Represents the cursor's point selected in <i>screen coordinates</i>.
+     * 
+     * @see ViewPort#fromMapPoint(Point2D)
+     */
+    private Point2D adjustedPoint;
+    /**
+     * <p>
+     * Determines if the position of the snap of the mouse's cursor on the
+     * <code>MapControl</code> is within the area around a control point of a
+     * geometry.
+     * </p>
+     * 
+     * <p>
+     * The area is calculated as a circle centered at the control point and with
+     * radius the pixels tolerance defined in the preferences.
+     * </p>
+     */
+    private boolean bForceCoord = false;
+
+    /**
+     * Kind of geometry drawn to identify the kind of control point selected by
+     * the cursor's mouse.
+     */
+    private ISnapper usedSnap = null;
+
+    /**
+     * Determines if the snap tools are enabled or disabled.
+     * 
+     * @see #isRefentEnabled()
+     * @see #setRefentEnabled(boolean)
+     */
+    private boolean bRefent = true;
+
+    /**
+     * Stores the 2D map coordinates of the last point added.
+     */
+    private double[] previousPoint = null;
+
+    protected static MapControlManager mapControlManager =
+        MapControlLocator.getMapControlManager();
+
+    private static TreeMap selected = new TreeMap(new Comparator() {
+
+        public int compare(Object o1, Object o2) {
+            if (o1.getClass().equals(o2.getClass()))
+                return 0;
+            if (((ISnapper) o1).getPriority() > ((ISnapper) o2).getPriority())
+                return 1;
+            else
+                return -1;
+        }
+
+    });
+
+    /**
+     * Represents the cursor's point selected in <i>map coordinates</i>.
+     * 
+     * @see MapControl#toMapPoint
+     */
+    private Point2D mapAdjustedPoint;
+
+    /**
+     * Renderer used to draw the layers.
+     */
+    private MapControlDrawer mapControlDrawer = null;
+	private Cursor transparentCursor;
+
+    /**
+     * <p>
+     * Creates a new <code>MapControl</code> instance with the following
+     * characteristics:
+     * <ul>
+     * <li><i>Name</i>: MapControl .</li>
+     * <li>Disables the double buffer of <code>JComponent</code> .</li>
+     * <li>Sets opaque <i>(see {@link JComponent#setOpaque(boolean)} )</i>.</li>
+     * <li>Sets its status to <code>OUTDATED</code> .</li>
+     * <li>Creates a new {@link CancelDraw CancelDraw} object to notify
+     * <code>MapContext</code>'s layers if can continue processing the drawn or
+     * must cancel it.</li>
+     * <li>Creates a new {@link MapContext MapContext} with a new
+     * {@link ViewPort ViewPort} in the projection <i>"EPSG:23030"</i> .</li>
+     * <li>Creates a new {@link CommandListener CommandListener} for edition
+     * operations.</li>
+     * <li>Creates a new {@link MapToolListener MapToolListener}, and associates
+     * it as a listener of whatever kind of mouse events produced in this
+     * component.</li>
+     * <li>Creates a new {@link Drawer2 Drawer2} for managing the painting
+     * requests.</li>
+     * <li>Creates a new timer that will invoke refresh this component
+     * <code>drawFrameRate</code> per second, when is running a drawing process,
+     * and its enabled <code>drawAnimationEnabled</code>.</li>
+     * </ul>
+     * </p>
+     */
+    public MapControl() {
+        this.setName("MapControl");
+        Toolkit toolkit = Toolkit.getDefaultToolkit();
+        Image imageTransparentCursor = toolkit.createImage(new MemoryImageSource(16, 16, new int[16 * 16], 0,16));
+        transparentCursor =
+            toolkit.createCustomCursor(imageTransparentCursor, new Point(0, 0), "invisiblecursor");
+
+        setDoubleBuffered(false);
+        setOpaque(true);
+        status = DESACTUALIZADO;
+
+        // Clase usada para cancelar el dibujado
+        canceldraw = new CancelDraw();
+
+        // Modelo de datos y ventana del mismo
+        // TODO: Cuando creamos un mapControl, deberíamos asignar
+        // la projección por defecto con la que vayamos a trabajar.
+        // 23030 es el código EPSG del UTM30 elipsoide ED50
+        vp = new ViewPort(CRSFactory.getCRS("EPSG:23030"));
+        setMapContext(new MapContext(vp));
+
+        // eventos
+        this.addComponentListener(this);
+        this.addMouseListener(mapToolListener);
+        this.addMouseMotionListener(mapToolListener);
+        this.addMouseWheelListener(mapToolListener);
+
+        this.drawer = new Drawer();
+        // Timer para mostrar el redibujado mientras se dibuja
+        timer =
+            new Timer(1000 / MapContext.getDrawFrameRate(),
+                new ActionListener() {
+
+                    public void actionPerformed(ActionEvent e) {
+
+                        if (drawAnimationEnabled) {
+                            MapControl.this.repaint();
+                        }
+                    }
+                });
+        initializeGrid();
+    }
+
+    /**
+     * <p>
+     * Sets a <code>MapContext</code> to this component.
+     * </p>
+     * 
+     * <p>
+     * The <code>MapContext</code> has the <i>model</i>, and most of the
+     * <i>view</i>, and <i>control</i> logic of the layers of this component,
+     * including a {@link ViewPort ViewPort} to adapt the information to the
+     * projection, and to display it in the available area.
+     * </p>
+     * 
+     * <p>
+     * If <code>model</code> hadn't a <code>ViewPort</code>, assigns the current
+     * one to it, otherwise, use its <code>ViewPort</code>.
+     * </p>
+     * 
+     * <p>
+     * After assigning the <code>MapContext</code> and <code>ViewPort</code>,
+     * sets the same {@link MapContextListener MapContextListener} that was
+     * using, and changes the <i>status</i> to <code>OUTDATED</code>.
+     * </p>
+     * 
+     * @param model
+     *            this component's <code>MapContext</code>, that includes the
+     *            <code>ViewPort</code>.
+     * 
+     * @see MapContext
+     * 
+     * @see #getMapContext()
+     */
+    public void setMapContext(MapContext model) {
+        if (mapContext != null) {
+            mapContext.removeAtomicEventListener(mapContextListener);
+            mapContext.dispose();
+        }
+
+        mapContext = model;
+
+        if (mapContext.getViewPort() == null) {
+            mapContext.setViewPort(vp);
+        } else {
+            vp = mapContext.getViewPort();
+            cadgrid.setViewPort(vp);
+        }
+
+        mapContext.addAtomicEventListener(mapContextListener);
+
+        status = DESACTUALIZADO;
+    }
+
+    /**
+     * @return the mapControlDrawer
+     */
+    public MapControlDrawer getMapControlDrawer() {
+        return mapControlDrawer;
+    }
+
+    /**
+     * @param mapControlDrawer
+     *            the mapControlDrawer to set
+     */
+    public void setMapControlDrawer(MapControlDrawer mapControlDrawer) {
+        this.mapControlDrawer = mapControlDrawer;
+        this.mapControlDrawer.setViewPort(vp);
+    }
+
+    /**
+     * <p>
+     * Gets this component's {@link MapContext MapContext} projection.
+     * </p>
+     * 
+     * @return this component's {@link MapContext MapContext} projection
+     * 
+     * @see MapContext#getProjection()
+     * @see MapControl#setProjection(IProjection)
+     */
+    public IProjection getProjection() {
+        return getMapContext().getProjection();
+    }
+
+    /**
+     * <p>
+     * Sets the projection to this component's {@link MapContext MapContext}.
+     * </p>
+     * 
+     * @param proj
+     *            the kind of projection to this component's {@link MapContext
+     *            MapContext}
+     * 
+     * @see MapContext#setProjection(IProjection)
+     * @see MapControl#getProjection()
+     */
+    public void setProjection(IProjection proj) {
+        getMapContext().setProjection(proj);
+    }
+
+    /**
+     * <p>
+     * Gets this component's <code>MapContext</code>, with the <i>model</i>, and
+     * most of the <i>view</i>, and <i>control</i> logic of the layers of this
+     * component, including a {@link ViewPort ViewPort} to adapt the information
+     * to the projection, and display it in the available area.
+     * </p>
+     * 
+     * @return this component's <code>MapContext</code>, that includes the
+     *         <code>ViewPort</code> used to project the
+     *         graphical information, and display it in the available area
+     * 
+     * @see MapContext
+     * 
+     * @see MapControl#setMapContext(MapContext)
+     */
+    public MapContext getMapContext() {
+        return mapContext;
+    }
+
+    /**
+     * <p>
+     * Registers a new behavior to this component.
+     * </p>
+     * 
+     * <p>
+     * According the nature of the {@link Behavior Behavior}, different events
+     * will be generated. Those events can be caught by a particular
+     * {@link ToolListener ToolListener}, allowing user to interact with this
+     * <code>MapControl</code> object as a <i>tool</i>.
+     * </p>
+     * 
+     * @param name
+     *            name to identify the behavior to add
+     * @param tool
+     *            the behavior to add
+     * 
+     * @see #addBehavior(String, Behavior[])
+     * @see #getNamesMapTools()
+     * @see #getMapToolsKeySet()
+     * @see #hasTool(String)
+     */
+    public void addBehavior(String name, Behavior tool) {
+        namesMapTools.put(name, tool);
+        tool.setMapControl(this);
+    }
+
+    /**
+     * <p>
+     * Registers a new behavior to this component as a {@link CompoundBehavior
+     * CompoundBehavior} made up of <code>tools</code>.
+     * </p>
+     * 
+     * <p>
+     * According the nature of the behaviors registered, different events will
+     * be generated. Those events can be caught by a particular
+     * {@link ToolListener ToolListener}, allowing user to interact with this
+     * <code>MapControl</code> object as a <i>tool</i>.
+     * </p>
+     * 
+     * @param name
+     *            name to identify the compound behavior to add
+     * @param tools
+     *            the compound behavior to add
+     * 
+     * @see #addBehavior(String, Behavior)
+     * @see #getNamesMapTools()
+     * @see #getMapToolsKeySet()
+     * @see #hasTool(String)
+     */
+    public void addBehavior(String name, Behavior[] tools) {
+        CompoundBehavior tool = new CompoundBehavior(tools);
+        addBehavior(name, tool);
+    }
+
+    /**
+     * <p>
+     * Gets the <code>Behavior</code> registered in this component, identified
+     * by <code>name</code>.
+     * </p>
+     * 
+     * @param name
+     *            name of a registered behavior
+     * 
+     * @return tool the registered behavior in this component as
+     *         <code>name</code>, or <code>null</code> if
+     *         no one has that identifier
+     * 
+     * @see #addBehavior(String, Behavior)
+     * @see #addBehavior(String, Behavior[])
+     * @see #hasTool(String)
+     */
+    public Behavior getMapTool(String name) {
+        return (Behavior) namesMapTools.get(name);
+    }
+
+    /**
+     * <p>
+     * Returns a set view of the keys that identified the tools registered.
+     * </p>
+     * 
+     * @return a set view of the keys that identified the tools registered
+     * 
+     * @see HashMap#keySet()
+     * 
+     * @see #getNamesMapTools()
+     * @see #addBehavior(String, Behavior)
+     * @see #addBehavior(String, Behavior[])
+     */
+    public Set getMapToolsKeySet() {
+        return namesMapTools.keySet();
+    }
+
+    /**
+     * <p>
+     * Returns <code>true</code> if this component contains a tool identified by
+     * <code>toolName</code>.
+     * </p>
+     * 
+     * @param toolName
+     *            identifier of the tool
+     * 
+     * @return <code>true</code> if this component contains a tool identified by
+     *         <code>toolName</code>; otherwise <code>false</code>
+     * 
+     * @see #addBehavior(String, Behavior)
+     * @see #addBehavior(String, Behavior[])
+     */
+    public boolean hasTool(String toolName) {
+        return namesMapTools.containsKey(toolName);
+    }
+
+    /**
+     * <p>
+     * Sets as current active <code>Behavior</code> associated to this
+     * component, that one which is registered and identified by
+     * <code>toolName</code>.
+     * </p>
+     * 
+     * <p>
+     * Changing the current active behavior for this <code>MapControl</code>,
+     * implies also updating the previous <i>behavior</i> tool, and the current
+     * cursor.
+     * </p>
+     * 
+     * @param toolName
+     *            name of a registered behavior
+     * 
+     * @see #getCurrentMapTool()
+     * @see #getCurrentTool()
+     */
+    public void setTool(String toolName) {
+        prevTool = getCurrentTool();
+        Behavior mapTool = (Behavior) namesMapTools.get(toolName);
+        currentMapTool = mapTool;
+        currentTool = toolName;
+
+        if (combinedTool != null) {
+            if (mapTool instanceof CompoundBehavior) {
+                ((CompoundBehavior) mapTool).addMapBehavior(combinedTool, true);
+            } else {
+                currentMapTool =
+                    new CompoundBehavior(new Behavior[] { currentMapTool });
+                ((CompoundBehavior) currentMapTool).addMapBehavior(
+                    combinedTool, true);
+            }
+        }
+
+        // this.setCursor(mapTool.getCursor());
+    }
+
+    /**
+     * <p>
+     * Gets as current active <code>Behavior</code> associated to this
+     * component, that one which is registered and identified by
+     * <code>toolName</code>.
+     * </p>
+     * 
+     * <p>
+     * Changing the current active behavior for this <code>MapControl</code>,
+     * implies also updating the previous <i>behavior</i> tool, and the current
+     * cursor.
+     * </p>
+     * 
+     * @param toolName
+     *            name of a registered behavior
+     * 
+     * @see #getCurrentTool()
+     * @see #setTool(String)
+     */
+    public Behavior getCurrentMapTool() {
+        return currentMapTool;
+    }
+
+    /**
+     * <p>
+     * Returns the name of the current selected tool on this MapControl
+     * </p>
+     * 
+     * @return the name of the current's behavior tool associated to this
+     *         component
+     * 
+     * @see #getCurrentMapTool()
+     * @see #setTool(String)
+     */
+    public String getCurrentTool() {
+        return currentTool;
+    }
+
+    /**
+     * <p>
+     * Determines that current drawing process of <code>MapControl</code>'s
+     * <code>MapContext</code>'s data must be canceled.
+     * </p>
+     * 
+     * <p>
+     * It has no effects if now isn't drawing that graphical information.
+     * </p>
+     * 
+     * <p>
+     * At last resort, the particular implementation of each layer in this
+     * <code>MapControl</code>'s <code>MapContrext</code> will be that one which
+     * will draw the graphical information, and, if supports, which could cancel
+     * its drawing subprocess.
+     * </p>
+     */
+    public void cancelDrawing() {
+        /*
+         * if (drawer != null) {
+         * if (!drawer.isAlive()) {
+         * return;
+         * }
+         * }
+         */
+        canceldraw.setCanceled(true);
+
+        /*
+         * while (!isCancelled) {
+         * if (!drawer.isAlive()) {
+         * // Si hemos llegado aquí con un thread vivo, seguramente
+         * // no estamos actualizados.
+         * 
+         * break;
+         * }
+         * 
+         * }
+         * canceldraw.setCancel(false);
+         * isCancelled = false;
+         * drawerAlive = false;
+         */
+    }
+
+    /**
+     * <p>
+     * Creates a {@link BufferedImage BufferedImage} image if there was no
+     * buffered image, or if its viewport's image height or width is different
+     * from this component's size. Once has created a double-buffer, fills it
+     * with the vieport's background color, or with <i>white</i> if it had no
+     * background color.
+     * </p>
+     * 
+     * <p>
+     * If no double-buffered existed, creates a {@link BufferedImage
+     * BufferedImage} with the size of this component, and as an image with
+     * 8-bit RGBA color components packed into integer pixels. That image has a
+     * <code>DirectColorModel</code> with alpha. The color data in that image is
+     * considered not to be premultiplied with alpha.
+     * </p>
+     * 
+     * <p>
+     * Once has created and filled the new inner <code>MapControl</code>'s
+     * double-buffer, changes the status to <code>OUTDATED</code>.
+     * </p>
+     * 
+     * @return <code>true</code> if has created and filled a new double-buffer
+     *         for this <code>MapControl</code> instance; otherwise
+     *         <code>false</code>
+     */
+    private boolean adaptToImageSize() {
+        if ((image == null) || (vp.getImageWidth() != this.getWidth())
+            || (vp.getImageHeight() != this.getHeight())) {
+            image =
+                new BufferedImage(this.getWidth(), this.getHeight(),
+                    BufferedImage.TYPE_INT_ARGB);
+            // ESTILO MAC
+            // image = GraphicsEnvironment.getLocalGraphicsEnvironment()
+            // .getDefaultScreenDevice().getDefaultConfiguration()
+            // .createCompatibleImage(this.getWidth(), this.getHeight());
+            vp.setImageSize(new Dimension(getWidth(), getHeight()));
+            getMapContext().getViewPort().refreshExtent();
+
+            Graphics gTemp = image.createGraphics();
+            Color theBackColor = vp.getBackColor();
+            if (theBackColor == null) {
+                gTemp.setColor(Color.WHITE);
+            } else {
+                gTemp.setColor(theBackColor);
+            }
+
+            gTemp.fillRect(0, 0, getWidth(), getHeight());
+            gTemp.dispose();
+            status = DESACTUALIZADO;
+            // g.drawImage(image,0,0,null);
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * <p>
+     * Paints the graphical information of this component using a double buffer.
+     * </p>
+     * 
+     * <p>
+     * If the double buffer wasn't created, creates a new one.
+     * </p>
+     * 
+     * <p>
+     * Paints the component according the following algorithm: <br>
+     * &nbsp If <i>status</i> is <i>UPDATED</i>:<br>
+     * &nbsp &nbsp If there is no <i>double buffer</i>:<br>
+     * &nbsp &nbsp &nbsp If there is a <i>behavior</i> for managing the
+     * <code>MapControl</code> instance, delegates the drawing process to that
+     * behavior, calling:
+     * <code><i>behavior_instance</i>.paintComponent(g)</code> &nbsp .<br>
+     * &nbsp &nbsp &nbsp Else, repaints the current graphical information
+     * quickly calling: <code>g.drawImage(image,0,0,null)</code> &nbsp .<br>
+     * &nbsp Else, (<i>status</i> is <i>OUTDATED</i>, or <i>ONLY_GRAPHICS</i>):
+     * executes a quickly repaint of the previous information calling
+     * <code>g.drawImage(image,0,0,null)</code>, and creates a <i>painting
+     * request</i> to delegate the heavy drawing process to the {@link Drawer2
+     * Drawer2}'s worker thread, according the <i>SingleWorketThread</i>
+     * pattern, starting a timer to update (invoking <code>repaint()</code> that
+     * comprises invoke this method) the view every delay of 360 ms. during the
+     * the process drawing.
+     * </p>
+     * 
+     * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
+     * @see Drawer2
+     */
+    protected void paintComponent(Graphics g) {
+        adaptToImageSize();
+
+        try {
+            mapControlDrawer.startDrawing(this);
+        } catch (InterruptedException e) {
+            logger.error("Error locking the MapControlDrawer", e);
+        }
+        mapControlDrawer.setGraphics(g);
+        mapControlDrawer.stopDrawing(this);
+        mapControlDrawer.setViewPort(getMapContext().getViewPort());
+
+        if (status == ACTUALIZADO) {
+            /*
+             * Si hay un behaviour y la imagen es distinta de null se delega el
+             * dibujado
+             * en dicho behaviour
+             */
+            if (image != null) {
+                if (currentMapTool != null) {
+                    currentMapTool.paintComponent(mapControlDrawer);
+                } else {
+                    mapControlDrawer.drawImage(image, 0, 0);
+                }
+            }
+		} else if ((status == DESACTUALIZADO)) {
+
+			mapControlDrawer.drawImage(image, 0, 0);
+
+			drawer.put(new PaintingRequest());
+			timer.start();
+		}
+        cadgrid.drawGrid(mapControlDrawer);
+        drawCursor();
+    }
+
+    /**
+     * <p>
+     * Gets the {@link BufferedImage BufferedImage} used to accelerate the draw
+     * of new ''frames'' with changes, or new graphical items in this component.
+     * </p>
+     * 
+     * @return double buffered image used by this component to accelerate the
+     *         draw of its graphical information, or <code>null</code> if isn't
+     *         already created
+     * 
+     * @see BufferedImage
+     */
+    public BufferedImage getImage() {
+        return image;
+    }
+
+    /**
+     * <p>
+     * Forces repaint all visible graphical information in this component.
+     * </p>
+     * 
+     * <p>
+     * If <code>doClear == true</code>, before repainting, clears the background
+     * color, with the inner viewport's background color.
+     * </p>
+     * 
+     * @param doClear
+     *            <code>true</code> if needs clearing the background color
+     *            before drawing the map
+     * 
+     * @see #cancelDrawing()
+     * @see FLayers#setDirty(boolean)
+     */
+    public void drawMap(boolean doClear) {
+        cancelDrawing();
+        // System.out.println("drawMap con doClear=" + doClear);
+        status = DESACTUALIZADO;
+        if (doClear) {
+            // image = null; // Se usa para el PAN
+            if (image != null) {
+                Graphics2D g = image.createGraphics();
+                Color theBackColor = vp.getBackColor();
+                if (theBackColor == null) {
+                    g.setColor(Color.WHITE);
+                } else {
+                    g.setColor(theBackColor);
+                }
+                g.fillRect(0, 0, vp.getImageWidth(), vp.getImageHeight());
+                g.dispose();
+            }
+        }
+        repaint();
+    }
+
+    /**
+     * <p>
+     * Cancels any current drawing process, changing the status to
+     * <code>OUTDATED</code>, and forcing repaint only the layers dirty.
+     * </p>
+     * 
+     * @see #cancelDrawing()
+     */
+    public void rePaintDirtyLayers() {
+        cancelDrawing();
+        status = DESACTUALIZADO;
+        repaint();
+    }
+
+    /**
+     * @deprecated use {@link #drawMap(boolean)} instead, or even
+     * better {@link #getMapContext()}.invalidate().
+     */
+    public void drawGraphics() {
+        drawMap(false);
+    }
+
+    /**
+     * @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent)
+     */
+    public void componentHidden(ComponentEvent e) {
+    }
+
+    /**
+     * @see java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent)
+     */
+    public void componentMoved(ComponentEvent e) {
+    }
+
+    /**
+     * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
+     */
+    public void componentResized(ComponentEvent e) {
+        /*
+         * image = new BufferedImage(this.getWidth(), this.getHeight(),
+         * BufferedImage.TYPE_INT_ARGB);
+         * Graphics gTemp = image.createGraphics();
+         * gTemp.setColor(vp.getBackColor());
+         * gTemp.fillRect(0,0,getWidth(), getHeight());
+         * System.out.println("MapControl resized");
+         * // image = null;
+         * vp.setImageSize(new Dimension(getWidth(), getHeight()));
+         * getMapContext().getViewPort().setScale();
+         */
+        // drawMap(true);
+    }
+
+    /**
+     * @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent)
+     */
+    public void componentShown(ComponentEvent e) {
+    }
+
+    /**
+     * @see ExceptionHandlingSupport#addExceptionListener(ExceptionListener)
+     */
+    public void addExceptionListener(ExceptionListener o) {
+        exceptionHandlingSupport.addExceptionListener(o);
+    }
+
+    /**
+     * @see ExceptionHandlingSupport#removeExceptionListener(ExceptionListener)
+     */
+    public boolean removeExceptionListener(ExceptionListener o) {
+        return exceptionHandlingSupport.removeExceptionListener(o);
+    }
+
+    /**
+     * @see ExceptionHandlingSupport#throwException(Throwable)
+     */
+    protected void throwException(Throwable t) {
+        exceptionHandlingSupport.throwException(t);
+    }
+
+    /**
+     * <p>
+     * Represents each <code>MapControl</code>'s data painting request.
+     * </p>
+     * 
+     * <p>
+     * The request will be attended by a <code>Drawer2</code>, which will hold
+     * it since the <code>Drawer2</code>'s worker takes it, or arrives a new
+     * painting request, which will replace it.
+     * </p>
+     */
+    private class PaintingRequest {
+
+        /**
+         * <p>
+         * Creates a new <code>PaintingRequest
+         * </p>
+         * instance.</p>
+         */
+        public PaintingRequest() {
+        }
+
+        /**
+         * <p>
+         * <code>MapControl</code> paint process:
+         * </p>
+         * 
+         * <p>
+         * <ul>
+         * <li><i>1.- </i>Cancels all previous <code>MapControl</code>'s drawing
+         * processes.</li>
+         * <li><i>2.- </i>If <i>status</i> was OUTDATED:
+         * <ul>
+         * <li><i>2.1.- </i>Fills the background color with viewport's
+         * background color, or <i>white</i> if it was undefined.</li>
+         * <li><i>2.2.- </i>Notifies <i>MapContext</i> to be drawn invoking: <code>mapContext.draw(double-buffer, double-buffer's buffer, shared cancel-draw object, mapContext.getScaleView());</code>
+         * .</li>
+         * <li><i>2.3.- </i>If <code>canceldraw.isCanceled()</code>
+         * <ul>
+         * <li><i>2.3.1.- </i>Sets <i>status</i> to OUTDATED.</li>
+         * <li><i>2.3.2.- </i>Sets <i>dirty</i> all layers stored in
+         * <i>MapContext</i>.</li>
+         * </ul>
+         * </li>
+         * <li><i>2.4.- </i>Else, sets <i>status</i> to UPDATED.</li>
+         * </ul>
+         * </li>
+         * <li><i>3.- </i>Stops the <i>timer</i>.</li>
+         * <li><i>4.- </i>Repaints this component invoking:
+         * <code>repaint();</code></li>
+         * </ul>
+         * </p>
+         * 
+         * @see #cancelDrawing()
+         * @see MapContext#draw(BufferedImage, Graphics2D, Cancellable, double)
+         * @see MapContext#drawGraphics(BufferedImage, Graphics2D, Cancellable,
+         *      double)
+         * 
+         * @see ViewPort
+         */
+        public void paint() {
+            try {
+                canceldraw.setCanceled(false);
+                Graphics2D g = image.createGraphics();
+
+                ViewPort viewPort = mapContext.getViewPort();
+
+                if (status == DESACTUALIZADO) {
+                    Graphics2D gTemp = image.createGraphics();
+                    Color theBackColor = viewPort.getBackColor();
+                    if (theBackColor == null) {
+                        gTemp.setColor(Color.WHITE);
+                    } else {
+                        gTemp.setColor(theBackColor);
+                    }
+                    gTemp.fillRect(0, 0, viewPort.getImageWidth(), viewPort
+                        .getImageHeight());
+                    mapContext.draw(image, g, canceldraw, mapContext
+                        .getScaleView());
+                    if (!canceldraw.isCanceled()) {
+                        status = ACTUALIZADO;
+                    }
+				}
+
+                timer.stop();
+                repaint();
+
+            } catch (Throwable e) {
+                timer.stop();
+                e.printStackTrace();
+                throwException(e);
+            } 
+        }
+    }
+
+    /**
+     * <p>
+     * An instance of <code>Drawer2</code> could manage all
+     * <code>MapControl</code> painting requests.
+     * </p>
+     * 
+     * <p>
+     * Based on the <i>WorkerThread</i> software pattern, creates a worker
+     * thread that will attend sequentially the current waiting painting
+     * request, after finishing the previous (that could be by a cancel action).
+     * </p>
+     * 
+     * <p>
+     * All new {@link PaintingRequest PaintingRequest} generated will be stored
+     * as <i>waiting requests</i> since the worker attends it.
+     * </p>
+     * 
+     * <p>
+     * If a worker finished and there was no <i>painting request</i>, the worker
+     * would be set to wait until any <i>painting request</i> would be put.
+     * </p>
+     * 
+     * @author fjp
+     */
+    public class Drawer {
+
+        // Una mini cola de 2. No acumulamos peticiones de dibujado
+        // dibujamos solo lo último que nos han pedido.
+
+        /**
+         * <p>
+         * Painting request that's been attended by the <code>Drawer2</code>'s
+         * worker.
+         * </p>
+         * 
+         * @see #put(org.gvsig.fmap.mapcontrol.MapControl.PaintingRequest)
+         * @see #take()
+         */
+        private PaintingRequest paintingRequest;
+
+        /**
+         * <p>
+         * Painting request waiting to be attended by the <code>Drawer2</code>'s
+         * worker.
+         * </p>
+         * 
+         * @see #put(org.gvsig.fmap.mapcontrol.MapControl.PaintingRequest)
+         * @see #take()
+         */
+        private PaintingRequest waitingRequest;
+
+        /**
+         * <p>
+         * Determines that the <code>Drawer2</code>'s worker is busy attending a
+         * painting request.
+         * </p>
+         * 
+         * @see #put(org.gvsig.fmap.mapcontrol.MapControl.PaintingRequest)
+         * @see #take()
+         */
+        private boolean waiting;
+
+        /**
+         * <p>
+         * Notifies the <code>Drawer2</code>'s worker to finish or continue with
+         * its process.
+         * </p>
+         * 
+         * @see #setShutdown(boolean)
+         */
+        private boolean shutdown;
+
+        /**
+         * <p>
+         * Sets this <code>Drawer2</code>'s worker to finish or continue with
+         * its process.
+         * </p>
+         * 
+         * @param isShutdown
+         *            a boolean value
+         */
+        public void setShutdown(boolean isShutdown) {
+            shutdown = isShutdown;
+        }
+
+        /**
+         * <p>
+         * Creates a new drawer for managing all data painting requests in
+         * <code>MapControl</code>.
+         * </p>
+         * 
+         * <p>
+         * Includes the following steps:
+         * <ul>
+         * <li>By default, there is no <i>current painting request</i>.</li>
+         * <li>By default, there is no <i>waiting painting request</i>.</li>
+         * <li>By default, the worker thread is waiting no <i>painting
+         * request</i>.</li>
+         * <li>By default, the worker thread is running.</li>
+         * <li>Creates and starts a worker thread for attending the <i>painting
+         * requests</i>.</li>
+         * </ul>
+         * </p>
+         */
+        public Drawer() {
+            paintingRequest = null;
+            waitingRequest = null;
+            waiting = false;
+            shutdown = false;
+            new Thread(new Worker(), "MapControl Drawer Worker").start();
+        }
+
+        /**
+         * <p>
+         * Sets a <code>PaintingRequest</code> to be attended by the worker
+         * thread of this object. If this one was waiting, wakes up.
+         * </p>
+         * 
+         * <p>
+         * All waiting threads will be notified synchronized.
+         * </p>
+         * 
+         * @param newPaintRequest
+         * 
+         * @see #take()
+         */
+        public void put(PaintingRequest newPaintRequest) {
+            waitingRequest = newPaintRequest;
+            if (waiting) {
+                synchronized (this) {
+                    notifyAll();
+                }
+            }
+        }
+
+        /**
+         * <p>
+         * Used by this object's worker, returns the current waiting drawing
+         * request, causing current thread to wait until another thread invokes
+         * {@link #put(org.gvsig.fmap.mapcontrol.MapControl.PaintingRequest)
+         * #put(com.iver.cit.gvsig.fmap.MapControl.PaintingRequest)}, if there
+         * was no waiting request.
+         * </p>
+         * 
+         * <p>
+         * All threads will access synchronized to the waiting request.
+         * </p>
+         * 
+         * @return <code>PaintingRequest</code> that was waiting to be attended
+         * 
+         * @see #put(org.gvsig.fmap.mapcontrol.MapControl.PaintingRequest)
+         */
+        public PaintingRequest take() {
+            if (waitingRequest == null) {
+                synchronized (this) {
+                    waiting = true;
+                    try {
+                        wait();
+                    } catch (InterruptedException ie) {
+                        waiting = false;
+                    }
+                }
+            }
+            paintingRequest = waitingRequest;
+            waitingRequest = null;
+            return paintingRequest;
+        }
+
+        /**
+         * <p>
+         * Thread for attending painting requests.
+         * </p>
+         * 
+         * <p>
+         * If there was no double buffer, sets the status to
+         * <code>OUTDATED</code> and finishes, otherwise takes the painting
+         * request (it's probably that would wait some time), cancel the
+         * previous drawing process, and starts processing the request.
+         * </p>
+         * 
+         * @see Thread
+         */
+        private class Worker implements Runnable {
+
+            /*
+             * (non-Javadoc)
+             * 
+             * @see java.lang.Runnable#run()
+             */
+            public void run() {
+                while (!shutdown) {
+                    PaintingRequest p = take();
+                    // System.out.println("Pintando");
+                    if (image != null) {
+                        cancelDrawing();
+                        p.paint();
+                    } else {
+                        status = DESACTUALIZADO;
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * <p>
+     * An instance of <code>CancelDraw</code> will be shared by all this
+     * <code>MapControl</code>'s <code>MapContext</code> layers, allowing
+     * receive a notification that, when they're been drawn, to be cancelled.
+     * </p>
+     * 
+     * @see Cancellable
+     * 
+     * @author Fernando González Cortés
+     */
+    public class CancelDraw implements Cancellable {
+
+        /**
+         * <p>
+         * Determines if the drawing task must be canceled or not.
+         * </p>
+         * 
+         * @see #isCanceled()
+         * @see #setCanceled(boolean)
+         */
+        private boolean cancel = false;
+
+        /**
+         * Creates a new <code>CancelDraw</code> object.
+         */
+        public CancelDraw() {
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see com.iver.utiles.swing.threads.Cancellable#setCanceled(boolean)
+         */
+        public void setCanceled(boolean b) {
+            cancel = b;
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see com.iver.utiles.swing.threads.Cancellable#isCanceled()
+         */
+        public boolean isCanceled() {
+            return cancel;
+        }
+    }
+
+    /**
+     * <p>
+     * Listens all kind of mouse events produced in {@link MapControl
+     * MapControl}, and invokes its current map tool <i>(
+     * {@link MapControl#getCurrentMapTool() MapControl#getCurrentMapTool()}</i>
+     * to simulate a behavior.
+     * </p>
+     * 
+     * <p>
+     * Mouse wheel moved events produce a <i>zoom in</i> operation if wheel
+     * rotation is negative, or a <i>zoom out</i> if its positive. Both will be
+     * centered in the position of the mouse, but, meanwhile <i>zoom in</i>
+     * operation applies a factor of 0.9, <i>zoom out</i> operation applies a
+     * factor of 1.2
+     * </p>
+     * 
+     * <p>
+     * Mouse wheel moved events can be produced as much frequently, that between
+     * each one, the drawing process could hadn't finished. This is the reason
+     * that, in this situation, cancels always the previous drawing process
+     * before applying a <i>zoom</i> operation, and ignores all new mouse
+     * positions that are produced before 1 second.
+     * </p>
+     * 
+     * @author Fernando González Cortés
+     */
+    public class MapToolListener implements MouseListener, MouseWheelListener,
+        MouseMotionListener {
+
+        /**
+         * <p>
+         * Used to avoid mouse wheel move events closed.
+         * </p>
+         * 
+         * <p>
+         * If a mouse wheel move event is produced
+         */
+        long t1;
+
+        /**
+         * <p>
+         * Position of the mouse, in map coordinates.
+         * </p>
+         * 
+         * <p>
+         * This point coordinates will be used as center of the <i>zoom</i>
+         * operation.
+         * </p>
+         */
+        Point2D pReal;
+
+        /**
+         * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
+         * @see Behavior#mouseClicked(MouseEvent)
+         */
+        public void mouseClicked(MouseEvent e) {
+            try {
+                if (currentMapTool != null) {
+                    currentMapTool.mouseClicked(e);
+                }
+                Point2D p;
+
+                if (mapAdjustedPoint != null) {
+                    p = mapAdjustedPoint;
+                } else {
+                    p = vp.toMapPoint(adjustedPoint);
+                }            
+                previousPoint = new double[] { p.getX(), p.getY() };                
+            } catch (BehaviorException t) {
+                throwException(t);
+            }
+        }
+
+        /**
+         * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
+         * @see Behavior#mouseEntered(MouseEvent)
+         */
+        public void mouseEntered(MouseEvent e) {
+            setToolMouse();
+            try {
+                if (currentMapTool != null) {
+                    currentMapTool.mouseEntered(e);
+                }
+            } catch (BehaviorException t) {
+                throwException(t);
+            }
+        }
+
+        /**
+         * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
+         * @see Behavior#mouseExited(MouseEvent)
+         */
+        public void mouseExited(MouseEvent e) {
+            try {
+                if (currentMapTool != null) {
+                    currentMapTool.mouseExited(e);
+                }
+            } catch (BehaviorException t) {
+                throwException(t);
+            }
+            // Remove the snapping image if exist
+            usedSnap = null;
+            repaint();
+        }
+
+        /**
+         * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
+         * @see Behavior#mousePressed(MouseEvent)
+         */
+        public void mousePressed(MouseEvent e) {
+            try {
+                if (currentMapTool != null) {
+                    currentMapTool.mousePressed(e);
+                }
+            } catch (BehaviorException t) {
+                throwException(t);
+            }
+        }
+
+        /**
+         * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
+         * @see Behavior#mouseReleased(MouseEvent)
+         */
+        public void mouseReleased(MouseEvent e) {
+            try {
+                if (currentMapTool != null) {
+                    currentMapTool.mouseReleased(e);
+                }
+            } catch (BehaviorException t) {
+                throwException(t);
+            }
+        }
+
+        /**
+         * @see java.awt.event.MouseWheelListener#mouseWheelMoved(java.awt.event.MouseWheelEvent)
+         * @see Behavior#mouseWheelMoved(MouseWheelEvent)
+         */
+        public void mouseWheelMoved(MouseWheelEvent e) {
+            try {
+                if (currentMapTool == null) {
+                    return;
+                }
+
+                currentMapTool.mouseWheelMoved(e);
+
+                // Si el tool actual no ha consumido el evento
+                // entendemos que quiere el comportamiento por defecto.
+                if (!e.isConsumed()) {
+                    // Para usar el primer punto sobre el que queremos centrar
+                    // el mapa, dejamos pasar un segundo para considerar el
+                    // siguiente
+                    // punto como válido.
+                    if (t1 == 0) {
+                        t1 = System.currentTimeMillis();
+                        pReal = vp.toMapPoint(e.getPoint());
+                    } else {
+                        long t2 = System.currentTimeMillis();
+                        if ((t2 - t1) > 1000) {
+                            t1 = 0;
+                        }
+                    }
+                    cancelDrawing();
+                    ViewPort vp = getViewPort();
+
+                    /*
+                     * Point2D pReal = new
+                     * Point2D.Double(vp.getAdjustedExtent().getCenterX(),
+                     * vp.getAdjustedExtent().getCenterY());
+                     */
+                    int amount = e.getWheelRotation();
+                    double nuevoX;
+                    double nuevoY;
+                    double factor;
+
+                    if (amount < 0) // nos acercamos
+                    {
+                        factor = 0.9;
+                    } else // nos alejamos
+                    {
+                        factor = 1.2;
+                    }
+                    if (vp.getExtent() != null) {
+                        nuevoX =
+                            pReal.getX()
+                                - ((vp.getExtent().getWidth() * factor) / 2.0);
+                        nuevoY =
+                            pReal.getY()
+                                - ((vp.getExtent().getHeight() * factor) / 2.0);
+                        double x = nuevoX;
+                        double y = nuevoY;
+                        double width = vp.getExtent().getWidth() * factor;
+                        double height = vp.getExtent().getHeight() * factor;
+
+                        try {
+                            vp.setEnvelope(geomManager.createEnvelope(x, y, x
+                                + width, y + height, SUBTYPES.GEOM2D));
+                        } catch (CreateEnvelopeException e1) {
+                            logger.error("Error creating the envelope", e);
+                        }
+                    }
+
+                }
+            } catch (BehaviorException t) {
+                throwException(t);
+            }
+        }
+
+        /**
+         * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
+         * @see Behavior#mouseDragged(MouseEvent)
+         */
+        public void mouseDragged(MouseEvent e) {
+            calculateSnapPoint(e.getPoint());
+            try {
+                if (currentMapTool != null) {
+                    currentMapTool.mouseDragged(e);
+                }
+            } catch (BehaviorException t) {
+                throwException(t);
+            }
+            repaint();
+        }
+
+        /**
+         * @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent)
+         * @see Behavior#mouseMoved(MouseEvent)
+         */
+        public void mouseMoved(MouseEvent e) {
+            calculateSnapPoint(e.getPoint());
+            try {
+                if (currentMapTool != null) {
+                    currentMapTool.mouseMoved(e);
+                }
+            } catch (BehaviorException t) {
+                throwException(t);
+            }
+            repaint();
+        }
+    }
+
+    /**
+     * <p<code>MapContextListener</code> listens all events produced in a
+     * <code>MapControl</code>'s <code>MapContext</code> object during an atomic
+     * period of time, and sets it to dirty, <i>executing
+     * <code>drawMap(false)</code>, if any of the
+     * following conditions is accomplished</i>:
+     * <ul>
+     * <li>Any of the <code>LayerEvent</code> in the <code>AtomicEvent</code>
+     * parameter notifies a <i>visibility change</i>.</li>
+     * <li>There is at least one <code>ColorEvent</code> in the
+     * <code>AtomicEvent</code> parameter.</li>
+     * <li>There is at least one <code>ExtentEvent</code> in the
+     * <code>AtomicEvent</code> parameter.</li>
+     * <li>Any of the <code>LayerCollectionEvent</code> in the
+     * <code>AtomicEvent</code> parameter notifies that a driver's layer has
+     * reloaded it successfully.</li>
+     * <li>There is at least one <code>LegendEvent</code> in the
+     * <code>AtomicEvent</code> parameter.</li>
+     * <li>There is at least one <code>SelectionEvent</code> in the
+     * <code>AtomicEvent</code> parameter.</li>
+     * </ul>
+     * </p>
+     * 
+     * @author Fernando González Cortés
+     */
+    public class MapContextListener implements AtomicEventListener {
+
+        /**
+         * @see org.gvsig.fmap.mapcontext.events.listeners.AtomicEventListener#atomicEvent(org.gvsig.fmap.mapcontext.events.AtomicEvent)
+         */
+        public void atomicEvent(final AtomicEvent e) {
+            if (!SwingUtilities.isEventDispatchThread()) {
+                SwingUtilities.invokeLater(new Runnable() {
+
+                    public void run() {
+                        atomicEvent(e);
+                    }
+                });
+                return;
+            }
+            LayerEvent[] layerEvents = e.getLayerEvents();
+
+            for (int i = 0; i < layerEvents.length; i++) {
+                if (layerEvents[i].getProperty().equals("visible")) {
+                    drawMap(false);
+                    return;
+                } else
+                    if (layerEvents[i].getEventType() == LayerEvent.EDITION_CHANGED) {
+                        drawMap(false);
+                        return;
+                    }
+            }
+
+            if (e.getColorEvents().length > 0) {
+                drawMap(false);
+                return;
+            }
+
+            if (e.getExtentEvents().length > 0) {
+                drawMap(false);
+                return;
+            }
+
+            if (e.getProjectionEvents().length > 0) {
+                // redraw = true;
+            }
+
+            LayerCollectionEvent[] aux = e.getLayerCollectionEvents();
+            if (aux.length > 0) {
+                for (int i = 0; i < aux.length; i++) {
+                    if (aux[i].getAffectedLayer().getFLayerStatus()
+                        .isDriverLoaded()) {
+                        drawMap(false);
+                        return;
+                    }
+                }
+
+            }
+
+            if (e.getLegendEvents().length > 0) {
+                drawMap(false);
+                return;
+            }
+
+            if (e.getSelectionEvents().length > 0) {
+                drawMap(false);
+                return;
+            }
+        }
+    }
+
+    /**
+     * <p>
+     * Gets the <code>ViewPort</code> of this component's {@link MapContext
+     * MapContext} .
+     * </p>
+     * 
+     * @see MapContext#getViewPort()
+     */
+    public ViewPort getViewPort() {
+        return vp;
+    }
+
+    /**
+     * <p>
+     * Returns all registered <code>Behavior</code> that can define a way to
+     * work with this <code>MapControl</code>.
+     * </p>
+     * 
+     * @return registered <code>Behavior</code> to this <code>MapControl</code>
+     * 
+     * @see #addBehavior(String, Behavior)
+     * @see #addBehavior(String, Behavior[])
+     * @see #getMapToolsKeySet()
+     * @see #hasTool(String)
+     */
+    public HashMap getNamesMapTools() {
+        return namesMapTools;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * com.iver.cit.gvsig.fmap.edition.commands.CommandListener#commandRepaint()
+     */
+    public void commandRepaint() {
+        drawMap(false);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * com.iver.cit.gvsig.fmap.edition.commands.CommandListener#commandRefresh()
+     */
+    public void commandRefresh() {
+        // TODO Auto-generated method stub
+    }
+
+    /**
+     * <p>
+     * Equivalent operation to <i>undo</i>.
+     * </p>
+     * 
+     * <p>
+     * Exchanges the previous tool with the current one.
+     * </p>
+     * 
+     * @see #addBehavior(String, Behavior)
+     * @see #addBehavior(String, Behavior[])
+     * @see #setTool(String)
+     */
+    public void setPrevTool() {
+        setTool(prevTool);
+    }
+
+    /**
+     * <p>
+     * Executes a <i>zoom in</i> operation centered at the center of the extent.
+     * </p>
+     * 
+     * <p>
+     * This implementation is designed for being invoked outside a
+     * <code>Behavior</code>, for example by an action of pressing a button; and
+     * simulates that the event has been produced by releasing the <i>button
+     * 1</i> of the mouse using the registered <code>Behavior</code> in this
+     * <code>MapControl</code> object that's responsible for the <i>zoom in</i>
+     * operation.
+     * </p>
+     * 
+     * @see #zoomOut()
+     */
+    public void zoomIn() {
+        Behavior mapTool = (Behavior) namesMapTools.get("zoomIn");
+        ViewPort vp = getViewPort();
+        Envelope r = getViewPort().getAdjustedExtent();
+        Point2D pCenter = vp.fromMapPoint(r.getCenter(0), r.getCenter(1));
+        MouseEvent e =
+            new MouseEvent(this, MouseEvent.MOUSE_RELEASED,
+                MouseEvent.ACTION_EVENT_MASK, MouseEvent.BUTTON1, (int) pCenter
+                    .getX(), (int) pCenter.getY(), 1, true, MouseEvent.BUTTON1);
+        try {
+            mapTool.mousePressed(e);
+            mapTool.mouseReleased(e);
+        } catch (BehaviorException t) {
+            throwException(t);
+        }
+    }
+
+    /**
+     * <p>
+     * Executes a <i>zoom out</i> operation centered at the center of the
+     * extent.
+     * </p>
+     * 
+     * <p>
+     * This implementation is thought for being invoked outside a
+     * <code>Behavior</code>, for example by an action of pressing a button, and
+     * simulates that the event has been produced by releasing the <i>button
+     * 1</i> of the mouse using the registered <code>Behavior</code> in this
+     * <code>MapControl</code> object that's responsible for the <i>zoom out</i>
+     * operation.
+     * </p>
+     * 
+     * @see #zoomIn()
+     */
+    public void zoomOut() {
+        Behavior mapTool = (Behavior) namesMapTools.get("zoomOut");
+        ViewPort vp = getViewPort();
+        Envelope r = getViewPort().getAdjustedExtent();
+        Point2D pCenter = vp.fromMapPoint(r.getCenter(0), r.getCenter(1));
+        MouseEvent e =
+            new MouseEvent(this, MouseEvent.MOUSE_RELEASED,
+                MouseEvent.ACTION_EVENT_MASK, MouseEvent.BUTTON1, (int) pCenter
+                    .getX(), (int) pCenter.getY(), 1, true, MouseEvent.BUTTON1);
+        try {
+            mapTool.mousePressed(e);
+            mapTool.mouseReleased(e);
+        } catch (BehaviorException t) {
+            throwException(t);
+        }
+    }
+
+    /**
+     * <p>
+     * Returns the listener used to catch all mouse events produced in this
+     * <code>MapControl</code> instance and that redirects the calls to the
+     * current map tool.
+     * </p>
+     * 
+     * @return the map tool listener used
+     */
+    public MapToolListener getMapToolListener() {
+        return mapToolListener;
+    }
+
+    // mapTool can be null, for instance, in 3D's navigation tools
+    /**
+     * <p>
+     * Sets <code>mapTool</code> as this <code>MapControl</code>'s current map
+     * tool.
+     * 
+     * @param mapTool
+     *            a map tool, or <code>null</code> to disable the interaction
+     *            with the user
+     * 
+     * @see #getCurrentMapTool()
+     * @see #getCurrentTool()
+     * @see #setTool(String)
+     * @see #setPrevTool()
+     * @see #addBehavior(String, Behavior)
+     * @see #addBehavior(String, Behavior[])
+     */
+    public void setCurrentMapTool(Behavior mapTool) {
+        currentMapTool = mapTool;
+    }
+
+    /**
+     * <p>
+     * Sets the delay to the timer that refreshes this <code>MapControl</code>
+     * instance.
+     * </p>
+     * 
+     * <p>
+     * <code>Delay (in ms) = 1000 / getDrawFrameRate()</code>
+     * </p>
+     * 
+     * @see #getDrawFrameRate()
+     * @see #setDrawFrameRate(int)
+     */
+    public void applyFrameRate() {
+        if (MapContext.getDrawFrameRate() > 0) {
+            timer.setDelay(1000 / MapContext.getDrawFrameRate());
+        }
+    }
+
+    /**
+     * <p>
+     * Determines if its enabled the repaint that invokes the timer according to
+     * {@link #getDrawFrameRate() #getDrawFrameRate()}.
+     * </p>
+     * 
+     * @return <code>true</code> if its enabled; otherwise <code>false</code>
+     */
+    public static boolean isDrawAnimationEnabled() {
+        return drawAnimationEnabled;
+    }
+
+    /**
+     * <p>
+     * Sets if its enabled the repaint that invokes the timer according to
+     * {@link #getDrawFrameRate() #getDrawFrameRate()}.
+     * </p>
+     * 
+     * @param drawAnimationEnabled
+     *            <code>true</code> to enable the mode; otherwise
+     *            <code>false</code>
+     */
+    public static void setDrawAnimationEnabled(boolean drawAnimationEnabled) {
+        MapControl.drawAnimationEnabled = drawAnimationEnabled;
+    }
+
+    /**
+     * <p>
+     * Gets the shared object that determines if a drawing process must be
+     * cancelled or can continue.
+     * </p>
+     * 
+     * @return the shared object that determines if a drawing process must be
+     *         cancelled or can continue
+     */
+    public CancelDraw getCanceldraw() {
+        return canceldraw;
+    }
+
+    /**
+     * <p>
+     * Gets the tool used in combination with the current tool of this
+     * <code>MapControl</code>.
+     * </p>
+     * 
+     * @return the tool used in combination with the <code>currentMapTool</code>
+     *         ; <code>null</code> if there is
+     *         no combined tool
+     */
+    public Behavior getCombinedTool() {
+        return combinedTool;
+    }
+
+    /**
+     * <p>
+     * Sets a tool to be used in combination with the current tool of this
+     * <code>MapControl</code>.
+     * </p>
+     * 
+     * @param combinedTool
+     *            a tool to be used in combination with the current tool of
+     *            <code>MapControl</code>
+     */
+    public void setCombinedTool(Behavior combinedTool) {
+        this.combinedTool = combinedTool;
+
+        if (currentMapTool == null) {
+            return;
+        }
+
+        if (currentMapTool instanceof CompoundBehavior) {
+            ((CompoundBehavior) currentMapTool).addMapBehavior(combinedTool,
+                true);
+        } else {
+            currentMapTool =
+                new CompoundBehavior(new Behavior[] { currentMapTool });
+            ((CompoundBehavior) currentMapTool).addMapBehavior(combinedTool,
+                true);
+        }
+
+    }
+
+    /**
+     * <p>
+     * Adds a new tool as combined tool.
+     * </p>
+     * <p>
+     * The new tool will be stored with the previous combined tools, and will be
+     * combined with the current tool.
+     * </p>
+     * <p>
+     * If <code>tool</code> was already stored as a combined tool, doesn't adds
+     * it.
+     * </p>
+     * 
+     * @param tool
+     *            a new tool to be used combined with the current tool
+     */
+    public void addCombinedBehavior(Behavior tool) {
+        tool.setMapControl(this);
+        if (combinedTool == null) {
+            combinedTool = tool;
+        } else {
+            if (combinedTool instanceof CompoundBehavior) {
+                if (((CompoundBehavior) combinedTool).containsBehavior(tool)) {
+                    return;
+                }
+
+                ((CompoundBehavior) combinedTool).addMapBehavior(tool, true);
+            } else {
+                if (combinedTool.equals(tool)) {
+                    return;
+                }
+
+                combinedTool =
+                    new CompoundBehavior(new Behavior[] { combinedTool });
+                ((CompoundBehavior) combinedTool).addMapBehavior(tool, true);
+            }
+        }
+
+        if (currentMapTool == null) {
+            return;
+        }
+
+        if (currentMapTool instanceof CompoundBehavior) {
+            ((CompoundBehavior) currentMapTool).addMapBehavior(tool, true);
+        } else {
+            currentMapTool =
+                new CompoundBehavior(new Behavior[] { currentMapTool });
+            ((CompoundBehavior) currentMapTool).addMapBehavior(tool, true);
+        }
+    }
+
+    /**
+     * <p>
+     * Removes the tool <code>tool</code> used in combination with the current
+     * tool of this <code>MapControl</code>.
+     * </p>
+     */
+    public void removeCombinedTool(Behavior tool) {
+        if ((currentMapTool != null)
+            && (currentMapTool instanceof CompoundBehavior)) {
+            ((CompoundBehavior) currentMapTool).removeMapBehavior(tool);
+        }
+
+        if (combinedTool == null) {
+            return;
+        }
+
+        if (combinedTool instanceof CompoundBehavior) {
+            ((CompoundBehavior) combinedTool).removeMapBehavior(tool);
+        } else {
+            combinedTool = null;
+        }
+    }
+
+    /**
+     * <p>
+     * Updates the grid on the <code>ViewPort</code> of the associated
+     * <code>MapControl</code> object according the values in the
+     * {@link com.iver.cit.gvsig.gui.cad.CADToolAdapter.prefs.Preferences
+     * com.iver.cit.gvsig.gui.cad.CADToolAdapter.prefs.Preferences}.
+     * </p>
+     * 
+     * <p>
+     * The preferences are:
+     * <ul>
+     * <li>Show/hide the grid.</li>
+     * <li>Adjust or not the grid.</li>
+     * <li>Horizontal ( X ) line separation.</li>
+     * <li>Vertical ( Y ) line separation.</li>
+     * </ul>
+     * </p>
+     */
+    public void initializeGrid() {
+        Preferences prefs = mapControlManager.getEditionPreferences();
+        boolean showGrid =
+            prefs.getBoolean("grid.showgrid", cadgrid.isShowGrid());
+        boolean adjustGrid =
+            prefs.getBoolean("grid.adjustgrid", cadgrid.isAdjustGrid());
+
+        double dx = prefs.getDouble("grid.distancex", cadgrid.getGridSizeX());
+        double dy = prefs.getDouble("grid.distancey", cadgrid.getGridSizeY());
+
+        setGridVisibility(showGrid);
+        setAdjustGrid(adjustGrid);
+        cadgrid.setGridSizeX(dx);
+        cadgrid.setGridSizeY(dy);
+    }
+
+    public void setAdjustGrid(boolean adjustGrid) {
+        cadgrid.setAdjustGrid(adjustGrid);
+    }
+
+    public void setGridVisibility(boolean showGrid) {
+        cadgrid.setShowGrid(showGrid);
+        cadgrid.setViewPort(getViewPort());
+        this.repaint();
+    }
+
+    /**
+     * Uses like a mouse pointer the image that provides the
+     * selected tool.
+     * 
+     */
+
+    private Image lastImageCursor = null;
+    private Cursor lastCursor = null;
+
+    private void setToolMouse() {
+        Image imageCursor = getCurrentMapTool().getImageCursor();
+        if (imageCursor != null && imageCursor == lastImageCursor && lastCursor != null && lastCursor != transparentCursor) {
+            setCursor(lastCursor);
+            return;
+        }
+        lastImageCursor = imageCursor;
+        Toolkit toolkit = Toolkit.getDefaultToolkit();
+        Cursor c = toolkit.createCustomCursor(imageCursor, new Point(16, 16), "img");
+        setCursor(c);
+        lastCursor = c;
+    }
+
+    /**
+     * Makes the mouse pointer transparent.
+     */
+    private void setTransparentMouse() {
+        setCursor(transparentCursor);
+        lastCursor = transparentCursor;
+    }
+
+    /**
+     * <p>
+     * Draws a 31x31 pixels cross round the mouse's cursor with an small
+     * geometry centered:
+     * <ul>
+     * <li><i>an square centered</i>: if isn't over a <i>control point</i>.
+     * <li><i>an small geometry centered according to the kind of control
+     * point</i>: if it's over a control point. In this case, the small geometry
+     * is drawn by a {@link ISnapper ISnapper} type object.<br>
+     * On the other hand, a light-yellowed background tool tip text with the
+     * type of <i>control point</i> will be displayed.</li>
+     * </p>
+     * 
+     * @param g
+     *            <code>MapControl</code>'s graphics where the data will be
+     *            drawn
+     */
+    private void drawCursor() {
+        if (adjustedPoint == null) {
+            return;
+        }
+
+        if (usedSnap != null) {
+            usedSnap.draw(mapControlDrawer, adjustedPoint);
+            setTransparentMouse();
+        } else {
+            setToolMouse();
+        }
+    }
+
+    /**
+     * <p>
+     * Adjusts the <code>point</code> to the grid if its enabled, and sets
+     * <code>mapHandlerAdjustedPoint</code> with that new value.
+     * </p>
+     * 
+     * <p>
+     * The value returned is the distance between those points: the original and
+     * the adjusted one.
+     * </p>
+     * 
+     * @param point
+     *            point to adjust
+     * @param mapHandlerAdjustedPoint
+     *            <code>point</code> adjusted
+     * 
+     * @return distance from <code>point</code> to the adjusted one. If there is
+     *         no
+     *         adjustment, returns <code>Double.MAX_VALUE</code>.
+     */
+
+    private double adjustToHandler(Point2D point,
+        Point2D mapHandlerAdjustedPoint) {
+
+        if (!isRefentEnabled())
+            return Double.MAX_VALUE;
+
+        ArrayList layersToSnap = getMapContext().getLayersToSnap();
+
+        double mapTolerance =
+            vp.toMapDistance(mapControlManager.getTolerance());
+        double minDist = mapTolerance;
+        double middleTol = mapTolerance * 0.5;
+        Point2D mapPoint = point;
+        org.gvsig.fmap.geom.primitive.Envelope r;
+        com.vividsolutions.jts.geom.Envelope e = null;
+        try {
+            r =
+                geomManager.createEnvelope(mapPoint.getX() - middleTol,
+                    mapPoint.getY() - middleTol, mapPoint.getX() + middleTol,
+                    mapPoint.getY() + middleTol, SUBTYPES.GEOM2D);
+
+            e = Converter.convertEnvelopeToJTS(r);
+        } catch (CreateEnvelopeException e1) {
+            logger.error("Error creating the envelope", e1);
+        }
+
+        usedSnap = null;
+        Point2D lastPoint = null;
+        if (previousPoint != null) {
+            lastPoint = new Point2D.Double(previousPoint[0], previousPoint[1]);
+        }
+        for (int j = 0; j < layersToSnap.size(); j++) {
+            FLyrVect lyrVect = (FLyrVect) layersToSnap.get(j);
+            SpatialCache cache = lyrVect.getSpatialCache();
+            if (lyrVect.isVisible()) {
+                // La lista de snappers está siempre ordenada por prioridad. Los
+                // de mayor
+                // prioridad están primero.
+                List geoms = cache.query(e);
+                
+                for (int i = 0; i < mapControlManager.getSnapperCount(); i++)
+                {
+                    ISnapper theSnapper = mapControlManager.getSnapperAt(i);
+                    if (theSnapper instanceof ISnapperGeometriesVectorial)
+                    {
+                        ((ISnapperGeometriesVectorial)theSnapper).setGeometries(geoms);                        
+                    }
+                } 
+                
+                for (int n = 0; n < geoms.size(); n++) {
+                    Geometry geom = (Geometry) geoms.get(n);
+                    for (int i = 0; i < mapControlManager.getSnapperCount(); i++) {
+                        ISnapper theSnapper = mapControlManager.getSnapperAt(i);
+                        if (!theSnapper.isEnabled())
+                            continue;
+
+                        if (usedSnap != null) {
+                            // Si ya tenemos un snap y es de alta prioridad,
+                            // cogemos ese. (A no ser que en otra capa
+                            // encontremos un snapper mejor)
+                            if (theSnapper.getPriority() > usedSnap
+                                .getPriority())
+                                break;
+                        }
+                        // SnappingVisitor snapVisitor = null;
+                        Point2D theSnappedPoint = null;
+                        if (theSnapper instanceof ISnapperVectorial) {
+                            theSnappedPoint =
+                                ((ISnapperVectorial) theSnapper).getSnapPoint(
+                                    point, geom, mapTolerance, lastPoint);
+                        }
+                        if (theSnapper instanceof ISnapperRaster) {
+                            ISnapperRaster snapRaster =
+                                (ISnapperRaster) theSnapper;
+                            theSnappedPoint =
+                                snapRaster.getSnapPoint(this, point,
+                                    mapTolerance, lastPoint);
+                        }
+
+                        if (theSnappedPoint != null) {
+                            double distAux = theSnappedPoint.distance(point);
+                            if (minDist > distAux) {
+                                minDist = distAux;
+                                usedSnap = theSnapper;
+                                mapHandlerAdjustedPoint
+                                    .setLocation(theSnappedPoint);
+                            }
+                        }
+                    }
+                } // for n
+            } // visible
+        }
+        if (usedSnap != null)
+            return minDist;
+        return Double.MAX_VALUE;
+
+    }
+
+    /**
+     * Determines if snap tools are enabled or disabled.
+     * 
+     * @return <code>true</code> to enable the snap tools; <code>false</code> to
+     *         disable them
+     * 
+     * @see #setRefentEnabled(boolean)
+     */
+    public boolean isRefentEnabled() {
+        return bRefent;
+    }
+
+    /**
+     * <p>
+     * Tries to find the nearest geometry or grid control point by the position
+     * of the current snap tool.
+     * </p>
+     * 
+     * <p>
+     * Prioritizes the grid control points than the geometries ones.
+     * </p>
+     * 
+     * <p>
+     * If finds any near, stores the <i>map</i> and <i>pixel</i> coordinates for
+     * the snap, and enables the <code>bForceCoord</code> attribute for the next
+     * draw of the mouse's cursor.
+     * </p>
+     * 
+     * @param point
+     *            current mouse 2D position
+     */
+    public void calculateSnapPoint(Point point) {
+        // Se comprueba el ajuste a rejilla
+
+        Point2D gridAdjustedPoint = vp.toMapPoint(point);
+        double minDistance = Double.MAX_VALUE;
+
+        minDistance = cadgrid.adjustToGrid(gridAdjustedPoint);
+        if (minDistance < Double.MAX_VALUE) {
+            adjustedPoint = vp.fromMapPoint(gridAdjustedPoint);
+            mapAdjustedPoint = gridAdjustedPoint;
+        } else {
+            mapAdjustedPoint = null;
+        }
+
+        Point2D handlerAdjustedPoint = null;
+
+        // Se comprueba el ajuste a los handlers
+        if (mapAdjustedPoint != null) {
+            handlerAdjustedPoint = (Point2D) mapAdjustedPoint.clone(); // getMapControl().getViewPort().toMapPoint(point);
+        } else {
+            handlerAdjustedPoint = vp.toMapPoint(point);
+        }
+
+        Point2D mapPoint = new Point2D.Double();
+        double distance = adjustToHandler(handlerAdjustedPoint, mapPoint);
+
+        if (distance < minDistance) {
+            bForceCoord = true;
+            adjustedPoint = vp.fromMapPoint(mapPoint);
+            mapAdjustedPoint = mapPoint;
+            minDistance = distance;
+        }
+
+        // Si no hay ajuste
+        if (minDistance == Double.MAX_VALUE) {
+            adjustedPoint = point;
+            mapAdjustedPoint = null;
+        }
+    }
+
+    /**
+     * Sets the snap tools enabled or disabled.
+     * 
+     * @param activated
+     *            <code>true</code> to enable the snap tools; <code>false</code>
+     *            to disable them
+     * 
+     * @see #isRefentEnabled()
+     */
+    public void setRefentEnabled(boolean activated) {
+        bRefent = activated;
+    }
+
+    public Grid getGrid() {
+        return cadgrid;
+    }
+
+    public void update(Observable observable, Object notification) {
+        DataStoreNotification ddsn = (DataStoreNotification) notification;
+        String type = ddsn.getType();
+        if (type.equals(FeatureStoreNotification.AFTER_UNDO)
+            || type.equals(FeatureStoreNotification.AFTER_REDO)) {
+            repaint();
+        }
+    }
+
+    /**
+     * @return the adjustedPoint
+     */
+    public Point2D getAdjustedPoint() {
+        return adjustedPoint;
+    }
+
+    /**
+     * @return the mapAdjustedPoint
+     */
+    public Point2D getMapAdjustedPoint() {
+        return mapAdjustedPoint;
+    }
+
+    /**
+     * Gets the selected point. If the snapping is enabled
+     * it returns the selected point.
+     * 
+     * @return
+     *         The selected point
+     */
+    public Point2D getPoint() {
+        if (mapAdjustedPoint != null) {
+            return mapAdjustedPoint;
+        } else {
+            return getViewPort().toMapPoint(adjustedPoint);
+        }
+    }
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/PrimitivesDrawer.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/PrimitivesDrawer.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/PrimitivesDrawer.java	(revision 38283)
@@ -0,0 +1,102 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+* 
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+* 
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+* 
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+* MA  02110-1301, USA.
+* 
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2009 {Iver T.I.}   {Task}
+*/
+ 
+package org.gvsig.fmap.mapcontrol;
+
+import java.awt.Color;
+import java.awt.Graphics;
+
+/**
+ * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
+ */
+public interface PrimitivesDrawer {
+	
+	/**
+	 * This method is used to start a drawing process that needs to 
+	 * be synchronized.
+	 * @param obj
+	 * The object that locks the resource.
+	 * @throws InterruptedException
+	 */
+	public void startDrawing(Object obj) throws InterruptedException;
+	
+	/**
+	 * This method is used to finish a drawing process that needs to 
+	 * be synchronized. 
+	 * @param obj
+	 * The object that has locked the resource.
+	 */
+	public void stopDrawing(Object obj);
+	
+	/**
+	 * This method sets the <code>Graphics</code> where the 
+	 * <code>Drawer</code> has to draw all the objects. 
+	 * @param graphics
+	 * The component where the new objects has to be drawn. 
+	 */
+	public void setGraphics(Graphics graphics);
+	
+	/**
+	 * Sets the color that is used to draw the objects that don't 
+	 * have a symbol.
+	 * @param color
+	 * The color to use on the drawing operations.
+	 */
+	public void setColor(Color color);
+		
+	/**
+	 * It draws a rectangle on the map using the color 
+	 * specified using the {@link #setColor(Color)} method. 
+	 * @param x
+	 * The minimum X coordinate.
+	 * @param y
+	 * The minimum Y coordinate.
+	 * @param width
+	 * The rectangle width.
+	 * @param height
+	 * The rectangle height.
+	 */
+	public void drawRect(int x, int y, int width, int height);
+		
+	/**
+	 * It fills a rectangle on the map using the color 
+	 * specified using the {@link #setColor(Color)} method. 
+	 * @param x
+	 * The minimum X coordinate.
+	 * @param y
+	 * The minimum Y coordinate.
+	 * @param width
+	 * The rectangle width.
+	 * @param height
+	 * The rectangle height.
+	 */
+	public void fillRect(int x, int y, int width, int height);
+	
+	public void drawOval(int i, int j, int sizePixels, int sizePixels2);
+
+	public void drawLine(int x1, int y1, int x3, int y12);
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/PrimitivesDrawer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/swing/datastore/DataStoreParametersCreationPanel.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/swing/datastore/DataStoreParametersCreationPanel.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/swing/datastore/DataStoreParametersCreationPanel.java	(revision 38283)
@@ -0,0 +1,41 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.fmap.mapcontrol.dal.swing.datastore;
+
+import javax.swing.JPanel;
+
+import org.gvsig.fmap.dal.DataServerExplorer;
+import org.gvsig.fmap.dal.NewDataStoreParameters;
+
+
+/**
+ * @author gvSIG Team
+ * @version $Id$
+ *
+ */
+public abstract class DataStoreParametersCreationPanel extends JPanel {
+    private static final long serialVersionUID = 5265923639970241325L;
+
+    public abstract NewDataStoreParameters getDataStoreParameters();
+    
+    public abstract DataServerExplorer getDataServerExplorer();
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/swing/datastore/DataStoreParametersCreationPanel.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/swing/datastore/DefaultDataStoreParametersCreationPanel.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/swing/datastore/DefaultDataStoreParametersCreationPanel.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/swing/datastore/DefaultDataStoreParametersCreationPanel.java	(revision 38283)
@@ -0,0 +1,288 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.fmap.mapcontrol.dal.swing.datastore;
+
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.gvsig.fmap.dal.DALLocator;
+import org.gvsig.fmap.dal.DataManager;
+import org.gvsig.fmap.dal.DataServerExplorer;
+import org.gvsig.fmap.dal.DataServerExplorerParameters;
+import org.gvsig.fmap.dal.NewDataStoreParameters;
+import org.gvsig.fmap.dal.exception.InitializeException;
+import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
+import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
+import org.gvsig.fmap.mapcontrol.swing.dynobject.DynObjectEditor;
+import org.gvsig.tools.service.ServiceException;
+
+
+/**
+ * @author gvSIG Team
+ * @version $Id$
+ *
+ */
+public class DefaultDataStoreParametersCreationPanel extends DataStoreParametersCreationPanel implements ActionListener{   
+    private static final long serialVersionUID = -1453149638996485029L;
+
+    private static final Logger LOG =
+        LoggerFactory.getLogger(DefaultDataStoreParametersCreationPanel.class);
+
+    private static final DataManager DATA_MANAGER = DALLocator.getDataManager();
+
+    private static final int FORM_HEIGTH = 18;
+
+    private DataServerExplorer dataServerExplorer = null;
+    private DataServerExplorerParameters dataServerExplorerParameters = null;
+
+    private NewDataStoreParameters dataStoreParameters = null;
+
+    private JButton explorersButton;
+    private JComboBox explorersComboBox;
+    private JButton providersButton;
+    private JComboBox providersComboBox;
+
+    public DefaultDataStoreParametersCreationPanel() {
+        super(); 
+        initComponents();
+        populateExplorerCombo();
+        initListeners();
+        enableExplorerControls(false);
+    }     
+
+    private void initListeners() {
+        this.explorersComboBox.addActionListener(this);
+        this.explorersButton.addActionListener(this);
+        this.providersComboBox.addActionListener(this);
+        this.providersButton.addActionListener(this);        
+    }
+
+    @SuppressWarnings("rawtypes")
+    private void populateExplorerCombo(){
+        explorersComboBox.addItem(null);
+
+        Iterator it = DATA_MANAGER.getExplorerProviders().iterator();
+
+        while(it.hasNext()) {
+            String explorer = (String)it.next();
+            explorersComboBox.addItem(explorer);            
+        }
+    }   
+
+    private void initComponents() {
+        GridBagConstraints gridBagConstraints;
+
+        explorersComboBox = new JComboBox();
+        providersComboBox = new JComboBox();
+        explorersButton = new JButton();
+        providersButton = new JButton();
+
+        setLayout(new GridBagLayout());
+
+        explorersComboBox.setPreferredSize(new Dimension(0, FORM_HEIGTH));
+        gridBagConstraints = new GridBagConstraints();
+        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+        gridBagConstraints.weightx = 1.0;
+        gridBagConstraints.insets = new Insets(0, 2, 0, 2);
+        add(explorersComboBox, gridBagConstraints);
+
+        explorersButton.setText("...");
+        explorersButton.setPreferredSize(new Dimension(25, FORM_HEIGTH));
+        gridBagConstraints = new GridBagConstraints();
+        gridBagConstraints.gridx = 1;
+        gridBagConstraints.gridy = 0;
+        gridBagConstraints.insets = new Insets(0, 2, 0, 2);
+        add(explorersButton, gridBagConstraints);
+
+        providersComboBox.setPreferredSize(new Dimension(0, FORM_HEIGTH));
+        gridBagConstraints = new GridBagConstraints();
+        gridBagConstraints.gridx = 2;
+        gridBagConstraints.gridy = 0;
+        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+        gridBagConstraints.weightx = 1.0;
+        gridBagConstraints.insets = new Insets(0, 2, 0, 2);
+        add(providersComboBox, gridBagConstraints);      
+
+        providersButton.setText("...");
+        providersButton.setPreferredSize(new Dimension(25, FORM_HEIGTH));
+        gridBagConstraints = new GridBagConstraints();
+        gridBagConstraints.gridx = 3;
+        gridBagConstraints.gridy = 0;
+        gridBagConstraints.insets = new Insets(0, 2, 0, 2);
+        add(providersButton, gridBagConstraints);
+    }
+
+    @Override
+    public NewDataStoreParameters getDataStoreParameters(){       
+        return dataStoreParameters;
+    }
+
+    @Override
+    public DataServerExplorer getDataServerExplorer() {       
+        return dataServerExplorer;
+    }
+
+    public void actionPerformed(ActionEvent e) {       
+        if (e.getSource().equals(explorersButton)) {           
+            explorersButtonClicked();
+        }else if (e.getSource().equals(providersButton)) {
+            providersButtonClicked();
+        }else if (e.getSource().equals(explorersComboBox)) {           
+            explorersComboSelectionChanged();
+        }else if (e.getSource().equals(providersComboBox)) {
+            providersComboSelectionChanged();
+        }
+    }  
+
+    private void explorersComboSelectionChanged(){        
+        String explorerName = (String)explorersComboBox.getSelectedItem();
+        if (explorerName == null){
+            dataServerExplorerParameters = null;
+            dataServerExplorer = null;
+            removeProvidersCombo();
+            enableExplorerControls(false);
+        }else{
+            //Only update the explorer if the selection is different
+            if ((dataServerExplorer == null) || (!explorerName.equals(dataServerExplorer.getProviderName()))){        
+                dataServerExplorerParameters = null;
+
+                //Remove all the previous providers
+                removeProvidersCombo(); 
+
+                //Disable all the components and enable the explorer button
+                this.enableExplorerControls(false);
+                this.explorersButton.setEnabled(true);       
+                //Sometimes is possible to create an explorer without parameters (e.g: filesystem explorer"
+                try {                    
+                    dataServerExplorerParameters =
+                        DATA_MANAGER.createServerExplorerParameters(explorerName);
+                    dataServerExplorer = 
+                        DATA_MANAGER.openServerExplorer(explorerName, dataServerExplorerParameters);
+                    populateProvidersCombo();  
+                    this.providersComboBox.setEnabled(true);     
+                } catch (InitializeException e) {
+                    LOG.error("Error creating the explorer parameters", e);                    
+                } catch (ProviderNotRegisteredException e) {
+                    LOG.error("The explorer has not been registeger", e);                    
+                } catch (ValidateDataParametersException e) {
+                    LOG.error("Error creating the explorer", e);                  
+                }                
+            }
+        }
+    }
+
+    private void enableExplorerControls(boolean isEnabled){        
+        this.explorersButton.setEnabled(isEnabled);  
+        this.providersComboBox.setEnabled(isEnabled);    
+        this.providersButton.setEnabled(isEnabled);
+    }
+
+    private void enableProviderControls(boolean isEnabled){       
+        this.providersButton.setEnabled(isEnabled);  
+    }
+
+    private void explorersButtonClicked(){
+        dataServerExplorer = null;
+        String explorerName = (String)explorersComboBox.getSelectedItem();
+        if (explorerName != null){
+            try {
+                if ((dataServerExplorerParameters == null) || (!dataServerExplorerParameters.getExplorerName().equals(explorerName))){
+                    dataServerExplorerParameters =
+                        DATA_MANAGER.createServerExplorerParameters(explorerName);
+                }
+                DynObjectEditor dynObjectEditor = new DynObjectEditor(dataServerExplorerParameters);
+                dynObjectEditor.editObject(true);               
+                dataServerExplorer = 
+                    DATA_MANAGER.openServerExplorer(explorerName, dataServerExplorerParameters);
+                //Remove all the previous providers
+                removeProvidersCombo(); 
+                populateProvidersCombo();
+                this.providersComboBox.setEnabled(true);  
+            } catch (InitializeException e) {
+                LOG.error("Error creating the explorer parameters", e);
+            } catch (ProviderNotRegisteredException e) {
+                LOG.error("The explorer has not been registered", e);
+            } catch (ServiceException e) {
+                LOG.error("Error creating the explorer panel", e);
+            } catch (ValidateDataParametersException e) {
+                LOG.error("Error creating the explorer", e);
+            }    
+        }
+    }
+
+    @SuppressWarnings("rawtypes")
+    private void populateProvidersCombo(){       
+        providersComboBox.addItem(null);
+        if (dataServerExplorer != null){
+            List providerNames = dataServerExplorer.getDataStoreProviderNames();
+            for (int i=0 ; i<providerNames.size() ; i++){
+                providersComboBox.addItem(providerNames.get(i));         
+            }
+        }
+    }
+
+    private void removeProvidersCombo(){
+        providersComboBox.removeAllItems();
+    }
+
+    private void providersComboSelectionChanged(){
+        dataStoreParameters = null;
+        String providerName = (String)providersComboBox.getSelectedItem();   
+        if ((dataServerExplorer != null) && (providerName != null)){
+            enableProviderControls(true);
+        }else{
+            enableProviderControls(false);
+        }
+    }
+
+    private void providersButtonClicked(){
+        String providerName = (String)providersComboBox.getSelectedItem();       
+        if ((dataServerExplorer != null) && (providerName != null)){
+            try {
+                if ((dataStoreParameters == null) || (!dataStoreParameters.getDataStoreName().equals(providerName))){
+                    dataStoreParameters = 
+                        DATA_MANAGER.createNewStoreParameters(dataServerExplorer.getProviderName(), providerName);
+                }
+                DynObjectEditor dynObjectEditor = new DynObjectEditor(dataStoreParameters);
+                dynObjectEditor.editObject(true);             
+            } catch (InitializeException e) {
+                LOG.error("Error creating the store parameters", e);
+            } catch (ProviderNotRegisteredException e) {
+                LOG.error("The provider has not been registered", e);
+            } catch (ServiceException e) {
+                LOG.error("Error creating the store panel", e);
+            }
+        }
+    }  
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/swing/datastore/DefaultDataStoreParametersCreationPanel.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/SelectionChangeException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/SelectionChangeException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/SelectionChangeException.java	(revision 38283)
@@ -0,0 +1,58 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+* 
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+* 
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+* 
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+* MA  02110-1301, USA.
+* 
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2008 {DiSiD Technologies}  {{Task}}
+*/
+package org.gvsig.fmap.mapcontrol.dal.feature.swing;
+
+import org.gvsig.tools.exception.BaseRuntimeException;
+
+/**
+ * Exception thrown when there is an error while changing the selection in the
+ * table.
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class SelectionChangeException extends BaseRuntimeException {
+
+    private static final long serialVersionUID = -291196709262836214L;
+
+    private static final String KEY = "table_selection_change_exception";
+
+    private static final String MESSAGE = "Error while changing the selection on the list of Features";
+
+    /**
+     * Constructs a new TableSelectionChangeException with no parameters.
+     */
+    public SelectionChangeException() {
+        super(MESSAGE, KEY, serialVersionUID);
+    }
+
+    /**
+     * Constructs a new TableSelectionChangeException with the original cause.
+     */
+    public SelectionChangeException(Throwable cause) {
+        super(MESSAGE, cause, KEY, serialVersionUID);
+    }
+}
\ No newline at end of file

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/SelectionChangeException.java
___________________________________________________________________
Added: svn:mergeinfo

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/FeatureSelectionModel.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/FeatureSelectionModel.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/FeatureSelectionModel.java	(revision 38283)
@@ -0,0 +1,359 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2010 {}  {{Task}}
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing;
+
+import javax.swing.ListSelectionModel;
+import javax.swing.event.EventListenerList;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.feature.Feature;
+import org.gvsig.fmap.dal.feature.FeatureSelection;
+import org.gvsig.fmap.dal.feature.FeatureStore;
+import org.gvsig.fmap.dal.feature.FeatureStoreNotification;
+import org.gvsig.fmap.dal.feature.exception.ConcurrentDataModificationException;
+import org.gvsig.fmap.mapcontrol.dal.feature.swing.table.FeatureTableModel;
+import org.gvsig.tools.observer.Observable;
+import org.gvsig.tools.observer.Observer;
+
+/**
+ * @author 2010- César Ordiñana - gvSIG team
+ */
+public class FeatureSelectionModel implements ListSelectionModel, Observer {
+    private static Logger LOG = 
+        LoggerFactory.getLogger(FeatureSelectionModel.class);
+    
+	protected EventListenerList listenerList = new EventListenerList();
+
+	private final FeatureTableModel featureTableModel;
+
+	private int selectionMode = SINGLE_INTERVAL_SELECTION;
+
+	private boolean isAdjusting = false;
+
+	private int anchor = -1;
+
+	private int lead = -1;
+	
+	private int currentFirst = -1;
+	private int currentLast = -1;
+
+	/**
+	 * Creates a new {@link FeatureSelectionModel} with a
+	 * {@link FeatureTableModel} used to get the {@link Feature}s by position in
+	 * the table.
+	 * 
+	 * @param featureTableModel
+	 *            to get Features from
+	 * @throws DataException
+	 *             if there is an error getting the store selection
+	 */
+	public FeatureSelectionModel(FeatureTableModel featureTableModel)
+			throws DataException {
+		this.featureTableModel = featureTableModel;
+		this.featureTableModel.getFeatureStore().addObserver(this);
+	}
+
+	public int getAnchorSelectionIndex() {
+		return anchor;
+	}
+
+	public int getLeadSelectionIndex() {
+		return lead;
+	}
+
+	public int getMaxSelectionIndex() {
+		FeatureSelection selection = getFeatureSelection();
+		try {
+			if (!selection.isEmpty()) {
+				for (int i = featureTableModel.getRowCount() - 1; i >= 0; i--) {
+					if (selection.isSelected(featureTableModel.getFeatureAt(i))) {
+						return i;
+					}
+				}
+			}
+		} catch (DataException e) {
+			throw new SelectionChangeException(e);
+		}
+		return -1;
+	}
+
+	public int getMinSelectionIndex() {
+		FeatureSelection selection = getFeatureSelection();
+		try {
+			if (!selection.isEmpty()) {
+				for (int i = 0; i < featureTableModel.getRowCount(); i++) {
+					if (selection.isSelected(featureTableModel.getFeatureAt(i))) {
+						return i;
+					}
+				}
+			}
+		} catch (DataException e) {
+			throw new SelectionChangeException(e);
+		}
+		return -1;
+	}
+
+	public void insertIndexInterval(int index, int length, boolean before) {
+		// Nothing to do
+	}
+
+	public void removeIndexInterval(int index0, int index1) {
+		// Nothing to do
+	}
+
+	public void setAnchorSelectionIndex(int index) {
+		this.anchor = index;
+	}
+
+	public void setLeadSelectionIndex(int index) {
+		this.lead = index;
+	}
+
+	public void addSelectionInterval(int index0, int index1) {
+		doWithSelection(new FeatureSelectionOperation() {
+
+			public void doWithSelection(FeatureSelection selection, int first,
+					int last) throws DataException {
+				for (int i = first; i <= last; i++) {
+					Feature feature = getFeature(i);
+					if (!selection.isSelected(feature)) {
+						selection.select(feature);
+					}
+				}
+			}
+
+		}, index0, index1, true);
+	}
+
+	public void setSelectionInterval(int index0, int index1) {
+		doWithSelection(new FeatureSelectionOperation() {
+
+			public void doWithSelection(FeatureSelection selection, int first,
+					int last) throws DataException {
+				selection.deselectAll();
+				for (int i = first; i <= last; i++) {
+					Feature feature = getFeature(i);
+					selection.select(feature);
+				}
+			}
+
+		}, index0, index1, true);
+	}
+
+	public void removeSelectionInterval(int index0, int index1) {
+		doWithSelection(new FeatureSelectionOperation() {
+
+			public void doWithSelection(FeatureSelection selection, int first,
+					int last) throws DataException {
+				for (int i = first; i <= last; i++) {
+					Feature feature = getFeature(i);
+					if (selection.isSelected(feature)) {
+						selection.deselect(feature);
+					}
+				}
+			}
+
+		}, index0, index1, false);
+	}
+
+	public void clearSelection() {
+		try {
+			getFeatureSelection().deselectAll();
+		} catch (DataException e) {
+			throw new SelectionChangeException(e);
+		}
+	}
+
+	public boolean isSelectedIndex(int index) {
+		if (index == -1) {
+			return false;
+		}
+		Feature feature = featureTableModel.getFeatureAt(index);
+		return getFeatureSelection().isSelected(feature);
+	}
+
+	public boolean isSelectionEmpty() {
+		try {
+			return getFeatureSelection().isEmpty();
+		} catch (DataException ex) {
+			throw new SelectionChangeException(ex);
+		}
+	}
+
+	public boolean getValueIsAdjusting() {
+		return isAdjusting;
+	}
+
+	public void setValueIsAdjusting(boolean valueIsAdjusting) {
+		if (this.isAdjusting != valueIsAdjusting) {
+			this.isAdjusting = valueIsAdjusting;
+			if (this.isAdjusting) {
+				getFeatureSelection().beginComplexNotification();
+			} else {
+				getFeatureSelection().endComplexNotification();
+			}
+		}
+	}
+
+	public int getSelectionMode() {
+		return selectionMode;
+	}
+
+	public void setSelectionMode(int selectionMode) {
+		this.selectionMode = selectionMode;
+	}
+
+	public void addListSelectionListener(ListSelectionListener listener) {
+		listenerList.add(ListSelectionListener.class, listener);
+	}
+
+	public void removeListSelectionListener(ListSelectionListener listener) {
+		listenerList.remove(ListSelectionListener.class, listener);
+	}
+
+	public void update(Observable observable, Object notification) {
+		if (notification instanceof FeatureStoreNotification) {
+			FeatureStoreNotification fnotification =
+					(FeatureStoreNotification) notification;
+			if (!fnotification.getSource().equals(getFeatureStore())) {
+				return;
+			}
+			if (FeatureStoreNotification.SELECTION_CHANGE.equals(fnotification.getType())) {
+				try{
+				    fireValueChanged(-1, -1, false);
+				}catch(ConcurrentDataModificationException e){
+				    LOG.warn("The store has been updated and the selection can not be refreshed", e);
+				}
+			}
+		}
+	}
+
+	private FeatureSelection getFeatureSelection() {
+		try {
+			return (FeatureSelection) getFeatureStore().getSelection();
+		} catch (DataException ex) {
+			throw new SelectionChangeException(ex);
+		}
+	}
+
+	/**
+	 * @param operation
+	 * @param index0
+	 * @param index1
+	 */
+	private void doWithSelection(FeatureSelectionOperation operation,
+			int index0, int index1, boolean select) {
+		// Set the anchor and lead
+		anchor = index0;
+		lead = index1;
+
+		// As index0 <= index1 is no guaranteed, calculate the first and second
+		// values
+		int first = (index0 <= index1) ? index0 : index1;
+		int last = (index0 <= index1) ? index1 : index0;
+		
+		//If the new selection is not updated don't continue
+		if ((currentFirst == first) && (currentLast == last)){
+		    return;
+		}
+		currentFirst = first;
+		currentLast = last;
+
+		FeatureSelection selection = getFeatureSelection();
+
+		// Perform the selection operation into a complex notification
+		selection.beginComplexNotification();
+		try {
+			// Is a full select or deselect
+			if (first == 00 && last == featureTableModel.getRowCount() - 1) {
+				if (select) {
+					selection.selectAll();
+				} else {
+					selection.deselectAll();
+				}
+			} else {
+				operation.doWithSelection(selection, first, last);
+			}
+		} catch (DataException e) {
+			throw new SelectionChangeException(e);
+		} finally {
+			selection.endComplexNotification();
+		}
+
+		fireValueChanged(first, last, isAdjusting);
+	}
+
+	/**
+	 * Returns a Feature by table row position.
+	 */
+	private Feature getFeature(int index) {
+		return featureTableModel.getFeatureAt(index);
+	}
+
+	/**
+	 * Returns the FeatureStore.
+	 */
+	private FeatureStore getFeatureStore() {
+		return featureTableModel.getFeatureStore();
+	}
+
+	/**
+	 * @param firstIndex
+	 *            the first index in the interval
+	 * @param lastIndex
+	 *            the last index in the interval
+	 * @param isAdjusting
+	 *            true if this is the final change in a series of adjustments
+	 * @see EventListenerList
+	 */
+	protected void fireValueChanged(int firstIndex, int lastIndex,
+			boolean isAdjusting) {
+		Object[] listeners = listenerList.getListenerList();
+		ListSelectionEvent e = null;
+
+		for (int i = listeners.length - 2; i >= 0; i -= 2) {
+			if (listeners[i] == ListSelectionListener.class) {
+				if (e == null) {
+					e =
+							new ListSelectionEvent(this, firstIndex, lastIndex,
+									isAdjusting);
+				}
+				((ListSelectionListener) listeners[i + 1]).valueChanged(e);
+			}
+		}
+	}
+
+	private interface FeatureSelectionOperation {
+		void doWithSelection(FeatureSelection selection, int first, int last)
+				throws DataException;
+	}
+}
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/FeatureTable.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/FeatureTable.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/FeatureTable.java	(revision 38283)
@@ -0,0 +1,235 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2008 {DiSiD Technologies}  {Create a Table component for Features}
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing;
+
+import java.awt.Color;
+import java.awt.Component;
+
+import javax.swing.JTable;
+import javax.swing.event.TableModelEvent;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableColumn;
+import javax.swing.table.TableColumnModel;
+import javax.swing.table.TableModel;
+
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.feature.Feature;
+import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
+import org.gvsig.fmap.dal.feature.FeatureStoreNotification;
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.mapcontrol.dal.feature.swing.table.FeatureCellRenderer;
+import org.gvsig.fmap.mapcontrol.dal.feature.swing.table.FeatureTableModel;
+import org.gvsig.fmap.mapcontrol.dal.feature.swing.table.GeometryWKTCellEditor;
+import org.gvsig.fmap.mapcontrol.dal.feature.swing.table.GeometryWKTCellRenderer;
+import org.gvsig.fmap.mapcontrol.dal.feature.swing.table.JToggleButtonHeaderCellRenderer;
+import org.gvsig.fmap.mapcontrol.dal.feature.swing.table.notification.ColumnHeaderSelectionChangeNotification;
+import org.gvsig.tools.observer.Observable;
+import org.gvsig.tools.observer.Observer;
+
+/**
+ * Table extension to show Feature values.
+ *
+ * It's based on the usage of a FeatureTableModel, and adds renderers for
+ * Geometry and Feature cell values.
+ *
+ * Observers are notified about column header selection changes, with a
+ * {@link ColumnHeaderSelectionChangeNotification}.
+ *
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class FeatureTable extends JTable implements Observer, Observable {
+
+    /**
+     * Generated Serial UID
+     */
+    private static final long serialVersionUID = -6139395189283163964L;
+    private final FeatureTableModel featureTableModel;
+    private JToggleButtonHeaderCellRenderer headerCellRenderer;
+
+	private static final int COLUMN_HEADER_MARGIN = 8;
+
+	private static final int COLUMN_HEADER_MIN_WIDTH = 50;
+
+    /**
+     * Creates a new FeatureTable with a {@link FeatureTableModel}.
+     *
+     * @param featureTableModel
+     *            the table model to get data to be shown on the table
+     * @throws DataException
+     *             if there is an error while loading the Features to show
+     * @see JTable#JTable(TableModel)
+     */
+    public FeatureTable(FeatureTableModel featureTableModel)
+            throws DataException {
+        super(featureTableModel);
+        this.featureTableModel = featureTableModel;
+        init();
+    }
+
+    /**
+     * Creates a new FeatureTable with a {@link FeatureTableModel}.
+     *
+     * @param featureTableModel
+     *            the table model to get data to be shown on the table
+     * @param cm
+     *            the table column model to use
+     * @throws DataException
+     *             if there is an error while loading the Features to show
+     * @see JTable#JTable(TableModel, TableColumnModel)
+     */
+    public FeatureTable(FeatureTableModel featureTableModel, TableColumnModel cm)
+            throws DataException {
+        super(featureTableModel, cm);
+        this.featureTableModel = featureTableModel;
+        init();
+    }
+
+    public void update(Observable observable, Object notification) {
+        if (notification instanceof FeatureStoreNotification) {
+            FeatureStoreNotification fsNotification = (FeatureStoreNotification) notification;
+            String type = fsNotification.getType();
+            // If the selection has changed, repaint the table to show the new
+            // selected rows
+            if (FeatureStoreNotification.SELECTION_CHANGE.equals(type)) {
+                repaint();
+            }
+        }
+    }
+
+    /**
+     * Returns the FeatureAttributeDescriptor related to the selected columns.
+     *
+     * @return an array of FeatureAttributeDescriptor
+     *
+     * @see org.gvsig.fmap.mapcontrol.dal.feature.swing.table.JToggleButtonHeaderCellRenderer#getSelectedColumns()
+     */
+    public FeatureAttributeDescriptor[] getSelectedColumnsAttributeDescriptor() {
+        int[] columns = headerCellRenderer.getSelectedColumns();
+        FeatureAttributeDescriptor[] descriptors = new FeatureAttributeDescriptor[columns.length];
+
+        for (int i = 0; i < descriptors.length; i++) {
+            descriptors[i] = featureTableModel
+                    .getDescriptorForColumn(columns[i]);
+        }
+
+        return descriptors;
+    }
+
+    public void addObserver(Observer observer) {
+        headerCellRenderer.addObserver(observer);
+    }
+
+    public void deleteObserver(Observer observer) {
+        headerCellRenderer.deleteObserver(observer);
+    }
+
+    public void deleteObservers() {
+        headerCellRenderer.deleteObservers();
+    }
+
+	/**
+	 * Sets that the selected Features to be viewed first.
+	 */
+	public void setSelectionUp(boolean selectionUp) {
+		((FeatureTableModel) getModel()).setSelectionUp(selectionUp);
+		scrollRectToVisible(getCellRect(0, 0, true));
+	}
+
+    // @Override
+    // public void tableChanged(TableModelEvent e) {
+    // super.tableChanged(e);
+    // if (headerCellRenderer != null) {
+    // headerCellRenderer.deselectAll();
+    // }
+    // }
+
+    @Override
+    protected void initializeLocalVars() {
+        super.initializeLocalVars();
+        // Add a cell renderer for Geometries and Features
+        setDefaultRenderer(Geometry.class, new GeometryWKTCellRenderer());
+        setDefaultEditor(Geometry.class, new GeometryWKTCellEditor());
+        setDefaultRenderer(Feature.class, new FeatureCellRenderer());
+
+        // Set the selected row colors
+        setSelectionForeground(Color.blue);
+        setSelectionBackground(Color.yellow);
+    }
+
+    /**
+     * Initializes the table GUI.
+     */
+    private void init() throws DataException {
+		setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
+
+        featureTableModel.getFeatureStore().addObserver(this);
+        // Change the selection model to link with the FeatureStore selection
+        // through the FeatureTableModel
+        setRowSelectionAllowed(true);
+        setColumnSelectionAllowed(false);
+		setSelectionModel(new FeatureSelectionModel(featureTableModel));		
+
+		headerCellRenderer = new JToggleButtonHeaderCellRenderer(this);
+		getTableHeader().setDefaultRenderer(headerCellRenderer);
+
+		TableColumnModel tcmodel = getColumnModel();
+		for (int i = 0; i < tcmodel.getColumnCount(); i++) {
+			TableColumn col = tcmodel.getColumn(i);
+			// Get width of column header
+			TableCellRenderer renderer = col.getHeaderRenderer();
+			if (renderer == null) {
+				renderer = getTableHeader().getDefaultRenderer();
+			}
+			Component comp =
+					renderer.getTableCellRendererComponent(this,
+							col.getHeaderValue(), false, false, 0, i);
+			int width = comp.getPreferredSize().width;
+			width =
+					width < COLUMN_HEADER_MIN_WIDTH ? COLUMN_HEADER_MIN_WIDTH
+							: width;
+			col.setPreferredWidth(width + 2 * COLUMN_HEADER_MARGIN);
+		}
+    }
+
+    /**
+     * Returns the number of selected columns.
+     *
+     * @return the number of selected columns, 0 if no columns are selected
+     */
+    public int getSelectedColumnCount() {
+        return headerCellRenderer.getSelectedColumns().length;
+    }
+    
+    public void tableChanged(TableModelEvent e) {
+        // Clear the header selection
+        if (e != null && e.getFirstRow() == TableModelEvent.HEADER_ROW
+            && headerCellRenderer != null) {
+            headerCellRenderer.deselectAll();
+        }
+        super.tableChanged(e);
+    }
+}
\ No newline at end of file

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/FeatureTable.java
___________________________________________________________________
Added: svn:mergeinfo

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/FeatureTablePanel.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/FeatureTablePanel.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/FeatureTablePanel.java	(revision 38283)
@@ -0,0 +1,253 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2008 {DiSiD Technologies}  {Create a Table component for Features}
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing;
+
+import java.awt.BorderLayout;
+
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+
+import org.gvsig.fmap.dal.DataStoreNotification;
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.feature.Feature;
+import org.gvsig.fmap.dal.feature.FeatureQuery;
+import org.gvsig.fmap.dal.feature.FeatureStore;
+import org.gvsig.fmap.mapcontrol.dal.feature.swing.table.ConfigurableFeatureTableModel;
+import org.gvsig.fmap.mapcontrol.dal.feature.swing.table.FeatureTableConfigurationPanel;
+import org.gvsig.i18n.Messages;
+import org.gvsig.tools.exception.BaseException;
+import org.gvsig.tools.observer.Observable;
+import org.gvsig.tools.observer.Observer;
+
+/**
+ * Panel to show a table of Feature data.
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class FeatureTablePanel extends JPanel implements Observer {
+
+    private static final long serialVersionUID = -9199073063283531216L;
+
+    private ConfigurableFeatureTableModel tableModel;
+
+    private JScrollPane jScrollPane = null;
+
+    private FeatureTable table = null;
+    private JPanel selectionPanel;
+    private JLabel selectionLabel;
+
+    /**
+     * Constructs a Panel to show a table with the features of a FeatureStore.
+     * 
+     * @param featureStore
+     *            to extract the features from
+     * @throws BaseException
+     *             if there is an error reading data from the FeatureStore
+     */
+    public FeatureTablePanel(FeatureStore featureStore) throws BaseException {
+        this(featureStore, true);
+    }
+
+    /**
+     * Constructs a Panel to show a table with the features of a FeatureStore.
+     * 
+     * @param featureStore
+     *            to extract the features from
+     * @param isDoubleBuffered
+     *            a boolean, true for double-buffering, which uses additional
+     *            memory space to achieve fast, flicker-free updates
+     * @throws BaseException
+     *             if there is an error reading data from the FeatureStore
+     */
+    public FeatureTablePanel(FeatureStore featureStore, boolean isDoubleBuffered)
+        throws BaseException {
+        this(featureStore, null, isDoubleBuffered);
+    }
+
+    /**
+     * @throws BaseException
+     * 
+     */
+    public FeatureTablePanel(FeatureStore featureStore,
+        FeatureQuery featureQuery) throws BaseException {
+        this(featureStore, featureQuery, true);
+    }
+
+    /**
+     * @param isDoubleBuffered
+     * @throws BaseException
+     */
+    public FeatureTablePanel(FeatureStore featureStore,
+        FeatureQuery featureQuery, boolean isDoubleBuffered)
+        throws BaseException {
+        this(createModel(featureStore, featureQuery));
+    }
+
+    public FeatureTablePanel(ConfigurableFeatureTableModel tableModel)
+        throws DataException {
+        this(tableModel, true);
+    }
+
+    public FeatureTablePanel(ConfigurableFeatureTableModel tableModel,
+        boolean isDoubleBuffered) throws DataException {
+        super(isDoubleBuffered);
+        this.tableModel = tableModel;
+        this.setLayout(new BorderLayout());
+        this.add(getJScrollPane(), BorderLayout.CENTER);
+        this.add(getSelectionPanel(), BorderLayout.SOUTH);
+        tableModel.getFeatureStore().addObserver(this);
+    }
+
+    private JPanel getSelectionPanel() {
+        if (selectionPanel == null) {
+            selectionLabel = new JLabel();
+            selectionLabel.setText(getFeatureSelectionSize() + " / "
+                + getTableModel().getHelper().getTotalSize() + " "
+                + Messages.getText("registros_seleccionados_total") + ".");
+            selectionPanel = new JPanel();
+
+            selectionPanel.add(selectionLabel, BorderLayout.EAST);
+        }
+        return selectionPanel;
+    }
+
+    private void updateSelection() {
+        selectionLabel.setText(getFeatureSelectionSize() + " / "
+            + getTableModel().getRowCount() + " "
+            + Messages.getText("registros_seleccionados_total") + ".");
+    }
+
+    private long getFeatureSelectionSize() {
+        try {
+            return getFeatureStore().getFeatureSelection().getSize();
+        } catch (DataException e) {
+            throw new RuntimeException("Error updating selection information",
+                e);
+        }
+    }
+
+    public JPanel createConfigurationPanel() {
+        return new FeatureTableConfigurationPanel(tableModel);
+    }
+
+    /**
+     * Returns the internal Table Model for the Features of the FeatureStore.
+     * 
+     * @return the internal Table Model
+     */
+    public ConfigurableFeatureTableModel getTableModel() {
+        return tableModel;
+    }
+
+    /**
+     * Returns the {@link FeatureStore} of the {@link Feature}s being shown in
+     * the table.
+     * 
+     * @return the store of the features
+     */
+    public FeatureStore getFeatureStore() {
+        return getTableModel().getFeatureStore();
+    }
+
+    /**
+     * Returns the FeatureQuery used to get the Features.
+     * 
+     * @return the FeatureQuery
+     */
+    public FeatureQuery getFeatureQuery() {
+        return getTableModel().getFeatureQuery();
+    }
+
+    /**
+     * Sets that the selected Features to be viewed first.
+     */
+    public void setSelectionUp(boolean selectionUp) {
+        try {
+            getTable().setSelectionUp(selectionUp);
+        } catch (DataException e) {
+            throw new RuntimeException("Error setting the selection up", e);
+        }
+    }
+
+    private static ConfigurableFeatureTableModel createModel(
+        FeatureStore featureStore, FeatureQuery featureQuery)
+        throws BaseException {
+        FeatureQuery query =
+            featureQuery == null ? featureStore.createFeatureQuery()
+                : featureQuery;
+
+        return new ConfigurableFeatureTableModel(featureStore, query);
+    }
+
+    public FeatureTable getTable() throws DataException {
+        if (table == null) {
+            table = new FeatureTable(tableModel);
+            // Change the selection model to link with the FeatureStore
+            // selection
+            // through the FeatureTableModel
+            table.setRowSelectionAllowed(true);
+            table.setColumnSelectionAllowed(false);
+            // table.setSelectionModel(new FeatureSelectionModel(tableModel));
+        }
+        return table;
+    }
+
+    /**
+     * This method initializes jScrollPane
+     * 
+     * @return javax.swing.JScrollPane
+     * @throws DataException
+     */
+    private JScrollPane getJScrollPane() throws DataException {
+        if (jScrollPane == null) {
+            jScrollPane = new JScrollPane();
+            jScrollPane.setViewportView(getTable());
+        }
+        return jScrollPane;
+    }
+
+    public void update(Observable observable, Object notification) {
+        // If selection changes from nothing selected to anything selected
+        // or the reverse, update selection info
+        if (notification instanceof DataStoreNotification) {
+            String type = ((DataStoreNotification) notification).getType();
+            if (DataStoreNotification.SELECTION_CHANGE.equals(type)) {
+                updateSelection();
+            }
+        }
+    }
+    // public void valueChanged(ListSelectionEvent e) {
+    // updateSelection();
+    // updateUI();
+    // }
+    //
+    // public void tableChanged(TableModelEvent e) {
+    // updateSelection();
+    // updateUI();
+    // }
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/GetFeatureAtException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/GetFeatureAtException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/GetFeatureAtException.java	(revision 38283)
@@ -0,0 +1,87 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2008 {DiSiD Technologies}  {{Task}}
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.gvsig.tools.exception.BaseRuntimeException;
+
+/**
+ * Exception thrown when there is an error while getting a Feature in a
+ * position.
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class GetFeatureAtException extends BaseRuntimeException {
+
+    private static final long serialVersionUID = 3981212631490713671L;
+
+    private static final String KEY = "get_feature_at_exception";
+
+    private static final String MESSAGE = "Error getting the feature "
+            + "at row =  %(rowIndex)";
+
+    private int rowIndex;
+
+    /**
+     * Creates a new Exception when getting a Feature.
+     * 
+     * @param rowIndex
+     *            the position of the Feature
+     */
+    public GetFeatureAtException(int rowIndex) {
+        super(MESSAGE, KEY, serialVersionUID);
+        this.rowIndex = rowIndex;
+    }
+
+    /**
+     * Creates a new Exception when getting a Feature.
+     * 
+     * @param rowIndex
+     *            the position of the Feature
+     * @param cause
+     *            the original Throwable
+     */
+    public GetFeatureAtException(int rowIndex, Throwable cause) {
+        super(MESSAGE, cause, KEY, serialVersionUID);
+        this.rowIndex = rowIndex;
+    }
+
+    /**
+     * @return the rowIndex
+     */
+    public int getRowIndex() {
+        return rowIndex;
+    }
+
+    @Override
+    protected Map<String, ?> values() {
+        return Collections.singletonMap("rowIndex", getRowIndex());
+    }
+
+}
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/GetRowCountException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/GetRowCountException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/GetRowCountException.java	(revision 38283)
@@ -0,0 +1,70 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+* 
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+* 
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+* 
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+* MA  02110-1301, USA.
+* 
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2008 {DiSiD Technologies}  {{Task}}
+*/
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.gvsig.tools.exception.BaseRuntimeException;
+
+/**
+ * Exception thrown when getting the total row number, or the total number of
+ * Features, throws an error.
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class GetRowCountException extends BaseRuntimeException {
+
+    private static final String KEY = "get_row_count_exception";
+
+    private static final String MESSAGE = "Error getting the total table row count";
+
+    private static final long serialVersionUID = 7803270649446415844L;
+
+    /**
+     * Creates a new GetRowCountException.
+     */
+    public GetRowCountException() {
+        super(MESSAGE, KEY, serialVersionUID);
+    }
+
+    /**
+     * Creates a new GetRowCountException.
+     * 
+     * @param cause
+     *            the cause of the exception
+     */
+    public GetRowCountException(Throwable cause) {
+        super(MESSAGE, cause, KEY, serialVersionUID);
+    }
+
+    @Override
+    protected Map<String, ?> values() {
+        return Collections.emptyMap();
+    }
+
+}
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/ConfigurationTableModel.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/ConfigurationTableModel.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/ConfigurationTableModel.java	(revision 38283)
@@ -0,0 +1,134 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2008 {DiSiD Technologies}  {Create a JTable TableModel for a FeatureQuery}
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import javax.swing.table.AbstractTableModel;
+
+import org.gvsig.i18n.Messages;
+
+/**
+ * TableModel to configure a ConfigurableFeatureTableModel.
+ * 
+ * Allows to set Feature attributes as visible or not, and to set aliases for
+ * the Feature attribute names.
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class ConfigurationTableModel extends AbstractTableModel {
+
+    private static final long serialVersionUID = -825156698327593853L;
+
+    private static final int VISIBILITY_COLUMN = 0;
+    private static final int NAME_COLUMN = 1;
+    private static final int ALIAS_COLUMN = 2;
+
+    private ConfigurableFeatureTableModel configurable;
+
+    public ConfigurationTableModel(ConfigurableFeatureTableModel configurable) {
+        super();
+        this.configurable = configurable;
+    }
+
+    public int getColumnCount() {
+        // 1: visibility, 2: field name, 3: alias
+        return 3;
+    }
+
+    public int getRowCount() {
+        return configurable.getOriginalColumnCount();
+    }
+
+    public Object getValueAt(int rowIndex, int columnIndex) {
+        String name = configurable.getOriginalColumnName(rowIndex);
+        switch (columnIndex) {
+        case VISIBILITY_COLUMN:
+            return configurable.isVisible(name);
+        case NAME_COLUMN:
+            return name;
+        case ALIAS_COLUMN:
+            return configurable.getAliasForColumn(name);
+        default:
+            return null;
+        }
+    }
+
+    @Override
+    public void setValueAt(Object value, int rowIndex, int columnIndex) {
+        String name = configurable.getOriginalColumnName(rowIndex);
+        switch (columnIndex) {
+        case VISIBILITY_COLUMN:
+            configurable.setVisible(name, Boolean.TRUE.equals(value));
+            break;
+        case ALIAS_COLUMN:
+            configurable.setAlias(name, (String) value);
+            break;
+        }
+    }
+    
+    @Override
+    public boolean isCellEditable(int rowIndex, int columnIndex) {
+        switch (columnIndex) {
+        case VISIBILITY_COLUMN:
+        case ALIAS_COLUMN:
+            return true;
+        default:
+            return false;
+        }
+    }
+
+    @Override
+    public Class<?> getColumnClass(int columnIndex) {
+        switch (columnIndex) {
+        case VISIBILITY_COLUMN:
+            return Boolean.class;
+        case NAME_COLUMN:
+        case ALIAS_COLUMN:
+            return String.class;
+        default:
+            return Object.class;
+        }
+
+    }
+
+    @Override
+    public String getColumnName(int columnIndex) {
+        switch (columnIndex) {
+        case VISIBILITY_COLUMN:
+            return Messages.getText("Visible");
+        case NAME_COLUMN:
+            return Messages.getText("Nombre");
+        case ALIAS_COLUMN:
+            return Messages.getText("Alias");
+        default:
+            return "";
+        }
+    }
+
+	public static int getVisibilityColumn() {
+		return VISIBILITY_COLUMN;
+	}
+}
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/GeometryToWKTException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/GeometryToWKTException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/GeometryToWKTException.java	(revision 38283)
@@ -0,0 +1,63 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2008 {DiSiD Technologies}  {{Task}}
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import org.gvsig.tools.exception.BaseRuntimeException;
+
+/**
+ * Exception thrown when there is an error while converting a Geometry to WKT
+ * into a table cell.
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class GeometryToWKTException extends BaseRuntimeException {
+
+    private static final long serialVersionUID = 1414646041766565149L;
+
+    private static final String KEY = "geometry_to_wkt_exception";
+
+    private static final String MESSAGE = "Error getting the geometry value "
+            + "of the cell as WKT";
+
+    /**
+     * Creates a new Exception when getting a Geometry cell as WKT.
+     * 
+     */
+    public GeometryToWKTException() {
+        super(MESSAGE, KEY, serialVersionUID);
+    }
+
+    /**
+     * Creates a new Exception when getting a Geometry cell as WKT.
+     * 
+     * @param cause
+     *            the original Throwable
+     */
+    public GeometryToWKTException(Throwable cause) {
+        super(MESSAGE, cause, KEY, serialVersionUID);
+    }
+}
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/WKTToGeometryException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/WKTToGeometryException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/WKTToGeometryException.java	(revision 38283)
@@ -0,0 +1,84 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2008 {DiSiD Technologies}  {{Task}}
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.gvsig.tools.exception.BaseRuntimeException;
+
+/**
+ * Exception thrown when there is an error while converting a WKT text to a
+ * Geometry into a table cell.
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class WKTToGeometryException extends BaseRuntimeException {
+
+    private static final long serialVersionUID = 7450289270030694675L;
+
+    private static final String KEY = "wkt_to_geometry_exception";
+
+    private static final String MESSAGE = "Error getting the geometry value of "
+            + "the WKT value %(wkt)";
+
+    private String wkt;
+
+    /**
+     * Creates a new Exception when getting a Geometry cell as WKT.
+     * 
+     * @param wkt
+     *            the geometry in WKT format
+     */
+    public WKTToGeometryException(String wkt) {
+        super(MESSAGE, KEY, serialVersionUID);
+        this.wkt = wkt;
+    }
+
+    /**
+     * Creates a new Exception when getting a Geometry cell as WKT.
+     * 
+     * @param wkt
+     *            the geometry in WKT format
+     * @param cause
+     *            the original Throwable
+     */
+    public WKTToGeometryException(String wkt, Throwable cause) {
+        super(MESSAGE, cause, KEY, serialVersionUID);
+        this.wkt = wkt;
+    }
+
+    public Object getWKT() {
+        return wkt;
+    }
+
+    @Override
+    protected Map<String, ?> values() {
+        return Collections.singletonMap("wkt", getWKT());
+    }
+
+}
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/TextAreaCellRenderer.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/TextAreaCellRenderer.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/TextAreaCellRenderer.java	(revision 38283)
@@ -0,0 +1,181 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2008 {DiSiD Technologies}  {{Task}}
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import java.awt.Component;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.swing.JTable;
+import javax.swing.JTextArea;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableColumnModel;
+
+/**
+ * Renders a text value into a text area.
+ * <p>
+ * Taken and adapted from the Article <strong>"Multi-line cells in JTable in JDK
+ * 1.4+"</strong> by Dr. Heinz M. Kabutz:
+ * </p>
+ * <p>
+ * http://www.javaspecialists.eu/archive/Issue106.html
+ * </p>
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class TextAreaCellRenderer extends JTextArea implements TableCellRenderer {
+
+    private static final long serialVersionUID = 3269365116036190589L;
+
+    private final DefaultTableCellRenderer adaptee = new DefaultTableCellRenderer();
+    /** map from table to map of rows to map of column heights */
+    private final Map<JTable, Map<Integer, Map<Integer, Integer>>> cellSizes = new HashMap<JTable, Map<Integer, Map<Integer, Integer>>>();
+    
+    private int maxTxtLength = Integer.MAX_VALUE;
+    
+    private int maxRowHeight = Integer.MAX_VALUE;
+
+    /**
+     * Creates a new TextAreaRenderer.
+     */
+    public TextAreaCellRenderer() {
+        this(Integer.MAX_VALUE, Integer.MAX_VALUE);
+    }
+
+    /**
+     * Creates a new TextAreaRenderer.
+     * 
+     * @param maxTXTLength
+     *            the maximum text length to be rendered.
+     * @param maxRowHeight
+     *            the maximum row height for the rows with cells rendered with
+     *            this component
+     */
+    public TextAreaCellRenderer(int maxTxtLength, int maxRowHeight) {
+        setLineWrap(true);
+        setWrapStyleWord(true);
+        this.maxTxtLength = maxTxtLength;
+        this.maxRowHeight = maxRowHeight;
+    }
+
+    public Component getTableCellRendererComponent(
+            JTable table, Object obj, boolean isSelected, boolean hasFocus,
+            int row, int column) {
+        // set the colours, etc. using the standard for that platform
+        adaptee.getTableCellRendererComponent(table, obj, isSelected, hasFocus,
+                row, column);
+        setForeground(adaptee.getForeground());
+        setBackground(adaptee.getBackground());
+        setBorder(adaptee.getBorder());
+        setFont(adaptee.getFont());
+
+        String cellTxt = getCellText(obj, row, column);
+        if (cellTxt.length() > maxTxtLength) {
+            cellTxt = cellTxt.substring(0, maxTxtLength - 4).concat(" ...");
+        }
+
+        setText(cellTxt);
+
+        // This line was very important to get it working with JDK1.4
+        TableColumnModel columnModel = table.getColumnModel();
+        setSize(columnModel.getColumn(column).getWidth(), 100000);
+        int height_wanted = (int) getPreferredSize().getHeight();
+        
+        height_wanted = height_wanted > maxRowHeight ? maxRowHeight
+                : height_wanted;
+        
+        addSize(table, row, column, height_wanted);
+        height_wanted = findTotalMaximumRowSize(table, row);
+        if (height_wanted != table.getRowHeight(row)) {
+            table.setRowHeight(row, height_wanted);
+        }
+        return this;
+    }
+
+    /**
+     * Returns the text for the cell.
+     * 
+     * @param value
+     *            the cell object value
+     * @return the text to render on the cell
+     */
+    protected String getCellText(Object value, int row, int column) {
+        return adaptee.getText();
+    }
+
+    private void addSize(JTable table, int row, int column, int height) {
+        Map<Integer, Map<Integer, Integer>> rows = cellSizes.get(table);
+        if (rows == null) {
+            cellSizes.put(table,
+                    rows = new HashMap<Integer, Map<Integer, Integer>>());
+        }
+        Map<Integer, Integer> rowheights = rows.get(new Integer(row));
+        if (rowheights == null) {
+            rows.put(new Integer(row),
+                    rowheights = new HashMap<Integer, Integer>());
+        }
+        rowheights.put(new Integer(column), new Integer(height));
+    }
+
+    /**
+     * Look through all columns and get the renderer. If it is also a
+     * TextAreaRenderer, we look at the maximum height in its hash table for
+     * this row.
+     */
+    private int findTotalMaximumRowSize(JTable table, int row) {
+        int maximum_height = 0;
+        for (int column = 0; column < table.getColumnCount(); column++) {
+            TableCellRenderer cellRenderer = table.getCellRenderer(row, column);
+            if (cellRenderer instanceof TextAreaCellRenderer) {
+                TextAreaCellRenderer tar = (TextAreaCellRenderer) cellRenderer;
+                maximum_height = Math.max(maximum_height, tar
+                        .findMaximumRowSize(table, row));
+            }
+        }
+        return maximum_height;
+    }
+
+    private int findMaximumRowSize(JTable table, int row) {
+        Map<Integer, Map<Integer, Integer>> rows = cellSizes.get(table);
+        if (rows == null)
+            return 0;
+        Map<Integer, Integer> rowheights = rows.get(new Integer(row));
+        if (rowheights == null)
+            return 0;
+        int maximum_height = 0;
+        for (Iterator<Map.Entry<Integer, Integer>> it = rowheights.entrySet()
+                .iterator(); it.hasNext();) {
+            Map.Entry<Integer, Integer> entry = it.next();
+            int cellHeight = ((Integer) entry.getValue()).intValue();
+            maximum_height = Math.max(maximum_height, cellHeight);
+        }
+        return maximum_height;
+    }
+
+}
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/ConfigurableFeatureTableModel.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/ConfigurableFeatureTableModel.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/ConfigurableFeatureTableModel.java	(revision 38283)
@@ -0,0 +1,327 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2008 {DiSiD Technologies}  {Create a JTable TableModel for a FeatureQuery}
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import java.security.InvalidParameterException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.event.TableModelEvent;
+
+import org.gvsig.fmap.dal.DataTypes;
+import org.gvsig.fmap.dal.feature.EditableFeature;
+import org.gvsig.fmap.dal.feature.Feature;
+import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
+import org.gvsig.fmap.dal.feature.FeatureQuery;
+import org.gvsig.fmap.dal.feature.FeatureQueryOrder;
+import org.gvsig.fmap.dal.feature.FeatureStore;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.tools.exception.BaseException;
+
+/**
+ * Extends the FeatureTableModel to add more configurable options, like the
+ * visible columns, column name aliases and row order.
+ * 
+ * TODO: añadir la persistencia.
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class ConfigurableFeatureTableModel extends FeatureTableModel {
+
+    private static final long serialVersionUID = -8223987814719746492L;
+
+    private List<String> columnNames;
+
+    private List<String> visibleColumnNames;
+
+    private Map<String, String> name2Alias;
+
+    /**
+     * @see FeatureTableModel#FeatureTableModel(FeatureStore, FeatureQuery)
+     */
+    public ConfigurableFeatureTableModel(FeatureStore featureStore,
+        FeatureQuery featureQuery) throws BaseException {
+        super(featureStore, featureQuery);
+    }
+
+    /**
+     * @see FeatureTableModel#FeatureTableModel(FeatureStore, FeatureQuery, int)
+     */
+    public ConfigurableFeatureTableModel(FeatureStore featureStore,
+        FeatureQuery featureQuery, int pageSize) throws BaseException {
+        super(featureStore, featureQuery, pageSize);
+    }
+
+    @Override
+    public int getColumnCount() {
+        return visibleColumnNames.size();
+    }
+
+    public int getOriginalColumnCount() {
+        return super.getColumnCount();
+    }
+
+    @Override
+    public String getColumnName(int column) {
+        int originalIndex = getOriginalColumnIndex(column);
+        return getAliasForColumn(getOriginalColumnName(originalIndex));
+    }
+
+    @Override
+    public Class<?> getColumnClass(int columnIndex) {
+        int originalIndex = getOriginalColumnIndex(columnIndex);
+        return super.getColumnClass(originalIndex);
+    }
+
+    @Override
+    public FeatureAttributeDescriptor getDescriptorForColumn(int columnIndex) {
+        int originalIndex = getOriginalColumnIndex(columnIndex);
+        return super.getDescriptorForColumn(originalIndex);
+    }
+
+    /**
+     * Returns the original name of the column, ignoring the alias.
+     * 
+     * @param column
+     *            the original index of the column
+     * @return the original column name
+     */
+    public String getOriginalColumnName(int column) {
+        return super.getColumnName(column);
+    }
+
+    /**
+     * Sets the visibility of a table column.
+     * 
+     * @param columnIndex
+     *            the index of the column to update
+     * @param visible
+     *            if the column will be visible or not
+     */
+    public void setVisible(String name, boolean visible) {
+        // If we don't have already the column as visible,
+        // add to the list, without order, and recreate
+        // the visible columns list in the original order
+        if (!columnNames.contains(name)) {
+            throw new InvalidParameterException(name); // FIXME
+        }
+        if (visible && !visibleColumnNames.contains(name)) {
+            visibleColumnNames.add(name);
+            setVisibleColumns(visibleColumnNames);
+        } else {
+            visibleColumnNames.remove(name);
+            fireTableStructureChanged();
+        }
+
+    }
+
+    @Override
+    public void setFeatureType(FeatureType featureType) {
+        // Check if there is a new column name
+        List<String> newColumns = new ArrayList<String>();
+        @SuppressWarnings("unchecked")
+        Iterator<FeatureAttributeDescriptor> attrIter = featureType.iterator();
+        String colName;
+        while (attrIter.hasNext()) {
+            colName = attrIter.next().getName();
+            if (!columnNames.contains(colName)) {
+                newColumns.add(colName);
+            }
+        }
+
+        // Update column names
+        columnNames.clear();
+        @SuppressWarnings("unchecked")
+        Iterator<FeatureAttributeDescriptor> visibleAttrIter =
+            featureType.iterator();
+        while (visibleAttrIter.hasNext()) {
+            colName = visibleAttrIter.next().getName();
+            columnNames.add(colName);
+            //If the column is added has to be visible
+            if (!visibleColumnNames.contains(colName) && newColumns.contains(colName)) {
+                // Add new columns
+                visibleColumnNames.add(colName);
+            }
+        }
+
+        // remove from visible columns removed columns
+        visibleColumnNames.retainAll(columnNames);
+
+        // remove from alias map removed columns
+        name2Alias.keySet().retainAll(visibleColumnNames);
+
+        super.setFeatureType(featureType);
+
+    }
+
+    /**
+     * Sets the current visible columns list, in the original order.
+     * 
+     * @param names
+     *            the names of the columns to set as visible
+     */
+    public void setVisibleColumns(List<String> names) {
+        // Recreate the visible column names list
+        // to maintain the original order
+        visibleColumnNames = new ArrayList<String>(names.size());
+        for (int i = 0; i < columnNames.size(); i++) {
+            String columnName = columnNames.get(i);
+            if (names.contains(columnName)) {
+                visibleColumnNames.add(columnName);
+            }
+        }
+        fireTableStructureChanged();
+    }
+
+    /**
+     * Changes all columns to be visible.
+     */
+    public void setAllVisible() {
+        visibleColumnNames.clear();
+        visibleColumnNames.addAll(columnNames);
+        fireTableStructureChanged();
+    }
+
+    /**
+     * Sets the alias for a column.
+     * 
+     * @param name
+     *            the name of the column
+     * @param alias
+     *            the alias for the column
+     */
+    public void setAlias(String name, String alias) {
+        name2Alias.put(name, alias);
+        fireTableStructureChanged();
+    }
+
+    public void orderByColumn(String name, boolean ascending)
+        throws BaseException {
+        FeatureQueryOrder order = getHelper().getFeatureQuery().getOrder();
+        if (order == null) {
+            order = new FeatureQueryOrder();
+            getHelper().getFeatureQuery().setOrder(order);
+        }
+        order.clear();
+        order.add(name, ascending);
+        getHelper().reload();
+        fireTableChanged(new TableModelEvent(this, 0, getRowCount() - 1));
+    }
+
+    @Override
+    protected void initialize() {
+        super.initialize();
+
+        initializeVisibleColumns();
+        initializeAliases();
+    }
+
+    /**
+     * Returns if a column is visible.
+     * 
+     * @param name
+     *            the name of the column
+     * @return if the column is visible
+     */
+    public boolean isVisible(String name) {
+        return visibleColumnNames.contains(name);
+    }
+
+    /**
+     * Initializes the table name aliases.
+     */
+    private void initializeAliases() {
+        int columns = super.getColumnCount();
+        name2Alias = new HashMap<String, String>(columns);
+        //
+        // for (int i = 0; i < columns; i++) {
+        // String columnName = super.getColumnName(i);
+        // name2Alias.put(columnName, columnName);
+        // }
+    }
+
+    /**
+     * Initializes the table visible columns.
+     */
+    protected void initializeVisibleColumns() {
+        int columns = super.getColumnCount();
+        columnNames = new ArrayList<String>(columns);
+        visibleColumnNames = new ArrayList<String>(columns);
+
+        for (int i = 0; i < columns; i++) {
+            String columnName = super.getColumnName(i);
+            columnNames.add(columnName);
+
+            // By default, geometry columns will not be visible
+            FeatureAttributeDescriptor descriptor =
+                super.getDescriptorForColumn(i);
+            if (descriptor.getType() != DataTypes.GEOMETRY) {
+                visibleColumnNames.add(columnName);
+            }
+        }
+    }
+
+    /**
+     * Returns the alias for the name of a column.
+     * 
+     * @param name
+     *            of the column
+     * @return the alias
+     */
+    protected String getAliasForColumn(String name) {
+        String alias = name2Alias.get(name);
+        return alias == null ? name : alias;
+    }
+
+    /**
+     * Returns the original position of a column.
+     * 
+     * @param columnIndex
+     *            the current visible column index
+     * @return the original column index
+     */
+    protected int getOriginalColumnIndex(int columnIndex) {
+        String columnName = visibleColumnNames.get(columnIndex);
+        return columnNames.indexOf(columnName);
+    }
+
+    @Override
+    protected Object getFeatureValue(Feature feature, int columnIndex) {
+        int realColumnIndex = getOriginalColumnIndex(columnIndex);
+        return super.getFeatureValue(feature, realColumnIndex);
+    }
+
+    @Override
+    protected EditableFeature setFeatureValue(Feature feature, int columnIndex,
+        Object value) {
+        int realColumnIndex = getOriginalColumnIndex(columnIndex);
+        return super.setFeatureValue(feature, realColumnIndex, value);
+    }
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/notification/ColumnHeaderSelectionChangeNotification.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/notification/ColumnHeaderSelectionChangeNotification.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/notification/ColumnHeaderSelectionChangeNotification.java	(revision 38283)
@@ -0,0 +1,61 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2008 {DiSiD Technologies}  {{Task}}
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table.notification;
+
+import org.gvsig.fmap.mapcontrol.dal.feature.swing.FeatureTable;
+
+/**
+ * Notification fired when the column header selection has been changed.
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class ColumnHeaderSelectionChangeNotification implements
+        FeatureTableNotification {
+    
+    public static final String COLUMNHEADER_SELECTION_CHANGE = "Column_Header_Selection_Change";
+
+    private final FeatureTable featureTable;
+
+    /**
+     * Creates a new ColumnHeaderSelectionChangeNotification with the
+     * originating {@link FeatureTable}.
+     * 
+     * @param featureTable
+     *            origin of the notification
+     */
+    public ColumnHeaderSelectionChangeNotification(FeatureTable featureTable) {
+        this.featureTable = featureTable;
+    }
+
+    public FeatureTable getFeatureTable() {
+        return featureTable;
+    }
+    
+    public String getType() {
+        return COLUMNHEADER_SELECTION_CHANGE;
+    }
+}
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/notification/FeatureTableNotification.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/notification/FeatureTableNotification.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/notification/FeatureTableNotification.java	(revision 38283)
@@ -0,0 +1,51 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+* 
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+* 
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+* 
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+* MA  02110-1301, USA.
+* 
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2008 {DiSiD Technologies}  {{Task}}
+*/
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table.notification;
+
+import org.gvsig.fmap.mapcontrol.dal.feature.swing.FeatureTable;
+
+/**
+ * Notifications for Observers of the {@link FeatureTable}.
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public interface FeatureTableNotification {
+
+    /**
+     * Returns the {@link FeatureTable} originating the notification.
+     * 
+     * @return the {@link FeatureTable}
+     */
+    FeatureTable getFeatureTable();
+    
+    /**
+     * Returns the type of the notification.
+     * 
+     * @return the type
+     */
+    String getType();
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/GeometryWKTCellRenderer.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/GeometryWKTCellRenderer.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/GeometryWKTCellRenderer.java	(revision 38283)
@@ -0,0 +1,84 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2008 {DiSiD Technologies}  {Create a JTable TableModel for a FeatureCollection}
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.operation.towkt.ToWKT;
+
+/**
+ * Renderer for cells of type {@link Geometry}, showing it in WKT format.
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class GeometryWKTCellRenderer extends TextAreaCellRenderer {
+
+    private static final long serialVersionUID = -2470239399517077869L;
+    
+    public static final int DEFAULT_MAX_WKT_LENGTH = 800;
+    
+    public static final int DEFAULT_MAX_ROW_HEIGHT = 80;
+
+    /**
+     * Creates a new GeometryWKTCellRenderer, with the default MAX LENGTH fot
+     * the WKT Strings and the default MAX HEIGHT for rows.
+     */
+    public GeometryWKTCellRenderer() {
+        this(DEFAULT_MAX_WKT_LENGTH, DEFAULT_MAX_ROW_HEIGHT);
+    }
+
+    /**
+     * Creates a new GeometryWKTCellRenderer.
+     * 
+     * @param maxWKTLength
+     *            the maximum WTK length to be rendered.
+     * @param maxRowHeight
+     *            the maximum row height for the rows with cells rendered with
+     *            this component
+     */
+    public GeometryWKTCellRenderer(int maxWKTLength, int maxRowHeight) {
+        super(maxWKTLength, maxRowHeight);
+    }
+
+    @Override
+    protected String getCellText(Object value, int row, int column) {
+        if (value != null) {
+            try {
+                Geometry geometry = (Geometry) value;
+                String geomTxt = (String) geometry.invokeOperation(ToWKT.CODE,
+                        null);
+                if (geomTxt.length() > 200) {
+                    geomTxt = geomTxt.substring(0, 200);
+                }
+
+                return geomTxt;
+            } catch (Exception ex) {
+                throw new GeometryToWKTException(ex);
+            }
+        }
+        return "";
+    }
+}
\ No newline at end of file

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/GeometryWKTCellRenderer.java
___________________________________________________________________
Added: svn:mergeinfo

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureTypeListException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureTypeListException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureTypeListException.java	(revision 38283)
@@ -0,0 +1,56 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+* MA  02110-1301, USA.
+*
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2008 {DiSiD Technologies}  {{Task}}
+*/
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.tools.exception.BaseRuntimeException;
+
+/**
+ * Exception thrown when preparing the list of {@link FeatureType}s or selecting
+ * one of them.
+ * 
+ * @author 2009- <a href="cordinyana@gvsig.org">César Ordiñana</a> - gvSIG team
+ */
+public class FeatureTypeListException extends BaseRuntimeException {
+
+	private static final long serialVersionUID = 2761369014780787542L;
+
+	private static final String KEY = "_FeatureTypeListException";
+
+	private static final String MESSAGE =
+			"Error loading the list of feature types or selecting one of them";
+
+	/**
+	 * Constructs a new FeatureTypeLoadException.
+	 * 
+	 * @param cause
+	 *            the original exception cause
+	 */
+    public FeatureTypeListException(Throwable cause) {
+        super(MESSAGE, cause, KEY, serialVersionUID);
+    }
+}
\ No newline at end of file

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureTypeListException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureTypeListModel.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureTypeListModel.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureTypeListModel.java	(revision 38283)
@@ -0,0 +1,139 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import java.util.List;
+
+import javax.swing.AbstractListModel;
+
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.feature.FeatureQuery;
+import org.gvsig.fmap.dal.feature.FeatureStore;
+import org.gvsig.fmap.dal.feature.FeatureStoreNotification;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.tools.observer.Observable;
+import org.gvsig.tools.observer.Observer;
+
+/**
+ * Model to be used by components showing a list of {@link FeatureType}s.
+ * 
+ * @author gvSIG Team
+ * @version $Id$
+ */
+public class FeatureTypeListModel extends AbstractListModel implements Observer {
+
+    private static final long serialVersionUID = -4274815135770376868L;
+    private final FeatureStore featureStore;
+    private final FeatureQuery featureQuery;
+
+    /**
+     * Constructs a {@link FeatureTypeListModel}.
+     * 
+     * @param featureStore
+     *            to get the {@link FeatureType}s from
+     * @param featureQuery
+     *            to get the FeatureType to filter if any
+     */
+    public FeatureTypeListModel(FeatureStore featureStore,
+        FeatureQuery featureQuery) {
+        this.featureStore = featureStore;
+        this.featureQuery = featureQuery;
+        this.featureStore.addObserver(this);
+    }
+
+    /**
+     * Returns the number of {@link FeatureType} to show.
+     */
+    public int getSize() {
+        return queryHasFeatureType() ? 1 : getFeatureTypes().size();
+    }
+
+    /**
+     * Returns if the query has a {@link FeatureType} to filter with.
+     * 
+     * @return if the query has a {@link FeatureType} to filter with
+     */
+    private boolean queryHasFeatureType() {
+        return featureQuery != null && featureQuery.getFeatureTypeId() != null;
+    }
+
+    @SuppressWarnings("unchecked")
+    private List<FeatureType> getFeatureTypes() {
+        try {
+            return featureStore.getFeatureTypes();
+        } catch (DataException e) {
+            throw new RuntimeException(
+                "Error getting the feature types of the FeatureStore: "
+                    + featureStore, e);
+        }
+    }
+
+    public Object getElementAt(int index) {
+        return queryHasFeatureType() ? featureQuery.getFeatureTypeId()
+            : getFeatureTypes().get(index).getId();
+    }
+
+    public void update(Observable observable, Object notification) {
+        if (observable.equals(this.featureStore)
+            && notification instanceof FeatureStoreNotification) {
+            FeatureStoreNotification fsNotification =
+                (FeatureStoreNotification) notification;
+            String type = fsNotification.getType();
+
+            if (FeatureStoreNotification.AFTER_UPDATE_TYPE.equals(type)) {
+                if (queryHasFeatureType()) {
+                    fireContentsChanged(this, 0, 0);
+                } else {
+                    FeatureType featureType = fsNotification.getFeatureType();
+                    int index = getFeatureTypes().indexOf(featureType);
+                    fireContentsChanged(this, index, index);
+                }
+            }
+        }
+    }
+
+    /**
+     * 
+     * Returns the {@link FeatureStore}
+     * 
+     * @return the featureStore
+     */
+    public FeatureStore getFeatureStore() {
+        return featureStore;
+    }
+
+    /**
+     * Returns the {@link FeatureType} with the given identifier.
+     * 
+     * @param featureTypeId
+     *            identifier of the {@link FeatureType}
+     * @return a {@link FeatureType}
+     */
+    public FeatureType getFeatureType(String featureTypeId) {
+        try {
+            return featureStore.getFeatureType(featureTypeId);
+        } catch (DataException e) {
+            throw new FeatureTypeListException(e);
+        }
+    }
+
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureTableConfigurationPanel.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureTableConfigurationPanel.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureTableConfigurationPanel.java	(revision 38283)
@@ -0,0 +1,89 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2008 {DiSiD Technologies}  {Create a Table component for Features}
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import javax.swing.BoxLayout;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+
+
+/**
+ * Panel to configure a FeatureTable. Allows to configure visible columns and
+ * column aliases.
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class FeatureTableConfigurationPanel extends JPanel {
+
+    private static final long serialVersionUID = -4912657164727512361L;
+
+    private ConfigurationTableModel tableModel;
+
+    /**
+     * Creates a new FeatureTableConfigurationPanel.
+     * 
+     * @param configurableTableModel
+     *            the table model of the FeatureTable to configure.
+     */
+    public FeatureTableConfigurationPanel(
+            ConfigurableFeatureTableModel configurableTableModel) {
+        this(configurableTableModel, true);
+    }
+
+    /**
+     * Creates a new FeatureTableConfigurationPanel.
+     * 
+     * @param configurableTableModel
+     *            the table model of the FeatureTable to configure.
+     * @param isDoubleBuffered
+     *            a boolean, true for double-buffering, which uses additional
+     *            memory space to achieve fast, flicker-free updates
+     */
+    public FeatureTableConfigurationPanel(
+            ConfigurableFeatureTableModel configurableTableModel,
+            boolean isDoubleBuffered) {
+        super(isDoubleBuffered);
+        tableModel = new ConfigurationTableModel(configurableTableModel);
+        createGUI();
+    }
+
+    private void createGUI() {
+		setPreferredSize(new java.awt.Dimension(320, 160));
+
+		// TODO: set a fixed column width for the first column with the
+        // checkboxes
+        JTable table = new JTable(tableModel);
+		// Set the width of the "Visible" column
+		table.getColumnModel().getColumn(0).setPreferredWidth(
+				ConfigurationTableModel.getVisibilityColumn());
+
+        JScrollPane scrollPane = new JScrollPane(table);
+        setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+        add(scrollPane);
+    }
+}
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeaturesDataReloadException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeaturesDataReloadException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeaturesDataReloadException.java	(revision 38283)
@@ -0,0 +1,62 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2008 {DiSiD Technologies}  {{Task}}
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import org.gvsig.tools.exception.BaseRuntimeException;
+
+/**
+ * Exception thrown when there is an error while reloading the Features of a
+ * FeatureTable.
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class FeaturesDataReloadException extends BaseRuntimeException {
+
+    private static final long serialVersionUID = -7724873225152021219L;
+
+    private static final String KEY = "features_data_reload_exception";
+
+    private static final String MESSAGE = "Error reloading the features";
+
+    /**
+     * Creates a new Exception when setting a Feature value.
+     */
+    public FeaturesDataReloadException() {
+        super(MESSAGE, KEY, serialVersionUID);
+    }
+
+    /**
+     * Creates a new Exception when setting a Feature value.
+     * 
+     * @param cause
+     *            the original Throwable
+     */
+    public FeaturesDataReloadException(Throwable cause) {
+        super(MESSAGE, cause, KEY, serialVersionUID);
+    }
+
+}
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/SelectedFeatureTypeChangeListener.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/SelectedFeatureTypeChangeListener.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/SelectedFeatureTypeChangeListener.java	(revision 38283)
@@ -0,0 +1,47 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import org.gvsig.fmap.dal.feature.FeatureStore;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.tools.exception.BaseException;
+
+/**
+ * Listener for changes in the selected {@link FeatureType}.
+ * 
+ * @author gvSIG Team
+ * @version $Id$
+ */
+public interface SelectedFeatureTypeChangeListener {
+
+    /**
+     * Called when the selected {@link FeatureType} changes.
+     * 
+     * @param featureStore
+     *            where the {@link FeatureType}s belong to
+     * @param featureType
+     *            the new selected {@link FeatureType}
+     * @throws BaseException
+     */
+    void change(FeatureStore featureStore, FeatureType featureType);
+
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureCellRenderer.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureCellRenderer.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureCellRenderer.java	(revision 38283)
@@ -0,0 +1,56 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+* 
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+* 
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+* 
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+* MA  02110-1301, USA.
+* 
+*/
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2008 {DiSiD Technologies}  {Create a JTable TableModel for a FeatureCollection}
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import javax.swing.table.DefaultTableCellRenderer;
+
+import org.gvsig.fmap.dal.feature.Feature;
+
+/**
+ * Renderer for cells of type {@link Feature} .
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class FeatureCellRenderer extends DefaultTableCellRenderer {
+
+    /**
+     * Generated Serial UID.
+     */
+    private static final long serialVersionUID = 3547431185199502021L;
+
+    protected void setValue(Object value) {
+        // TODO: change the current dumb implementation with something
+        // more useful, as a link or button to show the Feature details
+        // or, maybe, a subRow
+        if (value == null) {
+            setText("");
+        } else {
+            Feature feature = (Feature) value;
+            setText(feature.toString());
+        }
+    }
+}
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/GeometryCellRenderer.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/GeometryCellRenderer.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/GeometryCellRenderer.java	(revision 38283)
@@ -0,0 +1,64 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2008 {DiSiD Technologies}  {Create a JTable TableModel for a FeatureCollection}
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import javax.swing.table.DefaultTableCellRenderer;
+
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.operation.GeometryOperationException;
+import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
+import org.gvsig.fmap.geom.operation.towkt.ToWKT;
+
+/**
+ * Simple renderer for cells of type {@link Geometry} .
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class GeometryCellRenderer extends DefaultTableCellRenderer {
+
+    private static final long serialVersionUID = -2470239399517077869L;
+
+    protected void setValue(Object value) {
+        if (value == null) {
+            setText("");
+        } else {
+            Geometry geometry = (Geometry) value;
+            try {
+                String geomTxt = (String) geometry.invokeOperation(ToWKT.CODE,
+                        null);
+                setText(geomTxt);
+            } catch (GeometryOperationNotSupportedException e) {
+                throw new RuntimeException(
+                    "Error getting as WKT the geometry: " + geometry, e);
+            } catch (GeometryOperationException e) {
+                throw new RuntimeException(
+                    "Error getting as WKT the geometry: " + geometry, e);
+            }
+            setToolTipText(geometry.getGeometryType().getName());
+        }
+    }
+}
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/SetFeatureValueException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/SetFeatureValueException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/SetFeatureValueException.java	(revision 38283)
@@ -0,0 +1,123 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2008 {DiSiD Technologies}  {{Task}}
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.gvsig.tools.exception.BaseRuntimeException;
+
+/**
+ * Exception thrown when there is an error while updating a Feature through a
+ * FeatureTableModel.
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class SetFeatureValueException extends BaseRuntimeException {
+
+    private static final String KEY = "set_feature_value_exception";
+
+    private static final String MESSAGE = "Error setting the value of the cell "
+            + "at row =  %(rowIndex) and column = %(columnIndex) "
+            + "with the value = %(value)";
+
+    private static final long serialVersionUID = -414675652211552543L;
+
+    private int rowIndex;
+
+    private int columnIndex;
+
+    private Object value;
+
+    /**
+     * Creates a new Exception when setting a Feature value.
+     * 
+     * @param rowIndex
+     *            the position of the Feature
+     * @param columnIndex
+     *            the position of the value into the Feature
+     * @param value
+     *            the value to set
+     */
+    public SetFeatureValueException(int rowIndex, int columnIndex, Object value) {
+        super(MESSAGE, KEY, serialVersionUID);
+        this.rowIndex = rowIndex;
+        this.columnIndex = columnIndex;
+        this.value = value;
+    }
+
+    /**
+     * Creates a new Exception when setting a Feature value.
+     * 
+     * @param rowIndex
+     *            the position of the Feature
+     * @param columnIndex
+     *            the position of the value into the Feature
+     * @param value
+     *            the value to set
+     * @param cause
+     *            the original Throwable
+     */
+    public SetFeatureValueException(int rowIndex, int columnIndex,
+            Object value, Throwable cause) {
+        super(MESSAGE, cause, KEY, serialVersionUID);
+        this.rowIndex = rowIndex;
+        this.columnIndex = columnIndex;
+        this.value = value;
+    }
+
+    /**
+     * @return the rowIndex
+     */
+    public int getRowIndex() {
+        return rowIndex;
+    }
+
+    /**
+     * @return the columnIndex
+     */
+    public int getColumnIndex() {
+        return columnIndex;
+    }
+
+    /**
+     * @return the value
+     */
+    public Object getValue() {
+        return value;
+    }
+
+    @Override
+    protected Map<String, ?> values() {
+        Map<String, Object> values = new HashMap<String, Object>(3);
+        values.put("rowIndex", getRowIndex());
+        values.put("columnIndex", getColumnIndex());
+        values.put("value", getValue());
+        return values;
+    }
+
+}
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/TextAreaCellEditor.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/TextAreaCellEditor.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/TextAreaCellEditor.java	(revision 38283)
@@ -0,0 +1,72 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2008 {DiSiD Technologies}  {{Task}}
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import javax.swing.*;
+
+/**
+ * <p>
+ * Taken and adapted from the Article <strong>"Multi-line cells in JTable in JDK
+ * 1.4+"</strong> by Dr. Heinz M. Kabutz:
+ * </p>
+ * <p>
+ * http://www.javaspecialists.eu/archive/Issue106.html
+ * </p>
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class TextAreaCellEditor extends DefaultCellEditor {
+
+    private static final long serialVersionUID = -5614806192749314509L;
+
+    private final JTextArea textArea;
+
+    @SuppressWarnings("serial")
+    public TextAreaCellEditor() {
+        super(new JTextField());
+        textArea = new JTextArea();
+        textArea.setWrapStyleWord(true);
+        textArea.setLineWrap(true);
+        JScrollPane scrollPane = new JScrollPane(textArea);
+        scrollPane.setBorder(null);
+        editorComponent = scrollPane;
+
+        delegate = new DefaultCellEditor.EditorDelegate() {
+            public void setValue(Object value) {
+                textArea.setText((value != null) ? value.toString() : "");
+            }
+
+            public Object getCellEditorValue() {
+                return textArea.getText();
+            }
+        };
+    }
+    
+    public JTextArea getTextArea() {
+        return textArea;
+    }
+}
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureTableModel.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureTableModel.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureTableModel.java	(revision 38283)
@@ -0,0 +1,438 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2008 {DiSiD Technologies}  {Create a JTable TableModel for a FeatureCollection}
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import javax.swing.event.TableModelEvent;
+import javax.swing.table.AbstractTableModel;
+
+import org.gvsig.fmap.dal.DALLocator;
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.feature.EditableFeature;
+import org.gvsig.fmap.dal.feature.Feature;
+import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
+import org.gvsig.fmap.dal.feature.FeatureQuery;
+import org.gvsig.fmap.dal.feature.FeatureSet;
+import org.gvsig.fmap.dal.feature.FeatureStore;
+import org.gvsig.fmap.dal.feature.FeatureStoreNotification;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper;
+import org.gvsig.tools.exception.BaseException;
+import org.gvsig.tools.observer.Observable;
+import org.gvsig.tools.observer.Observer;
+
+/**
+ * TableModel to access data of Features.
+ * 
+ * This table model can't handle a FeatureSet with more than Integer.MAX_VALUE
+ * elements. In that case, only the first Integer.MAX_VALUE elements will be
+ * shown.
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class FeatureTableModel extends AbstractTableModel implements Observer {
+
+    private static final long serialVersionUID = -2488157521902851301L;
+
+    private FeaturePagingHelper helper;
+
+    /** Used to know if a modification in the FeatureStore is created by us. */
+    private EditableFeature editableFeature;
+
+    /**
+     * Constructs a TableModel from the features of a FeatureStore, with the
+     * default page size.
+     * 
+     * @param featureStore
+     *            to extract the features from
+     * @param featureQuery
+     *            the query to get the features from the store
+     * @throws BaseException
+     *             if there is an error reading data from the FeatureStore
+     */
+    public FeatureTableModel(FeatureStore featureStore,
+        FeatureQuery featureQuery) throws BaseException {
+        this(featureStore, featureQuery, FeaturePagingHelper.DEFAULT_PAGE_SIZE);
+    }
+
+    /**
+     * Constructs a TableModel from the features of a FeatureStore, with the
+     * default page size.
+     * 
+     * @param featureStore
+     *            to extract the features from
+     * @param featureQuery
+     *            the query to get the features from the store
+     * @param pageSize
+     *            the number of elements per page data
+     * @throws BaseException
+     *             if there is an error reading data from the FeatureStore
+     */
+    public FeatureTableModel(FeatureStore featureStore,
+        FeatureQuery featureQuery, int pageSize) throws BaseException {
+        this(DALLocator.getDataManager().createFeaturePagingHelper(
+            featureStore, featureQuery, pageSize));
+    }
+
+    /**
+     * Constructs a TableModel from a FeatureCollection and a Paging helper.
+     * 
+     * @param featureCollection
+     *            to extract data from
+     * @param helper
+     *            the paging helper
+     * @throws DataException
+     *             if there is an error reading data from the FeatureStore
+     */
+    protected FeatureTableModel(FeaturePagingHelper helper) {
+        this.helper = helper;
+        initialize();
+    }
+
+    public int getColumnCount() {
+        // Return the number of fields of the Features
+        FeatureType featureType = getFeatureType();
+        return featureType.size();
+    }
+
+    public int getRowCount() {
+        // Return the total size of the collection
+        // If the size is bigger than INTEGER.MAX_VALUE, return that instead
+        long totalSize = getHelper().getTotalSize();
+        if (totalSize > Integer.MAX_VALUE) {
+            return Integer.MAX_VALUE;
+        } else {
+            return (int) totalSize;
+        }
+    }
+
+    public Object getValueAt(int rowIndex, int columnIndex) {
+        // Get the Feature at row "rowIndex", and return the value of the
+        // attribute at "columnIndex"
+        Feature feature = getFeatureAt(rowIndex);
+        return getFeatureValue(feature, columnIndex);
+    }
+
+    /**
+     * Returns the value for a row position.
+     * 
+     * @param rowIndex
+     *            the row position
+     * @return the Feature
+     */
+    public Feature getFeatureAt(int rowIndex) {
+        try {
+            return getHelper().getFeatureAt(rowIndex);
+        } catch (BaseException ex) {
+            throw new GetFeatureAtException(rowIndex, ex);
+        }
+    }
+
+    public Class<?> getColumnClass(int columnIndex) {
+        // Return the class of the FeatureAttributeDescriptor for the value
+        FeatureAttributeDescriptor attributeDesc =
+            internalGetFeatureDescriptorForColumn(columnIndex);
+        Class<?> clazz = attributeDesc.getObjectClass();
+        return (clazz == null ? super.getColumnClass(columnIndex) : clazz);
+    }
+
+    public String getColumnName(int column) {
+        // Return the Feature attribute name
+        FeatureAttributeDescriptor attributeDesc =
+            internalGetFeatureDescriptorForColumn(column);
+        return attributeDesc.getName();
+    }
+
+    @Override
+    public boolean isCellEditable(int rowIndex, int columnIndex) {
+        if (getFeatureStore().isEditing()) {
+            FeatureAttributeDescriptor attributeDesc =
+                internalGetFeatureDescriptorForColumn(columnIndex);
+            return !attributeDesc.isReadOnly();
+        }
+
+        return false;
+    }
+
+    @Override
+    public void setValueAt(Object value, int rowIndex, int columnIndex) {
+        // Get the feature at rowIndex
+        Feature feature = getFeatureAt(rowIndex);
+        // Only set the value if the feature exists
+        if (feature != null) {
+            // We only need to update if the value to set is not equal to the
+            // current value
+            Object currentValue = getFeatureValue(feature, columnIndex);
+            if (value != currentValue
+                && (value == null || !value.equals(currentValue))) {
+                try {
+                    // Store the editable feature to ignore the related store
+                    // change notification
+                    editableFeature =
+                        setFeatureValue(feature, columnIndex, value);
+                    this.getHelper().update(editableFeature);
+                    // We'll have already received the event, so we can forget
+                    // about it
+                    editableFeature = null;
+                    getHelper().reloadCurrentPage();
+                    fireTableCellUpdated(rowIndex, columnIndex);
+                } catch (BaseException ex) {
+                    throw new SetFeatureValueException(rowIndex, columnIndex,
+                        value, ex);
+                } finally {
+                    // Just in case
+                    editableFeature = null;
+                }
+            }
+        }
+    }
+
+    /**
+     * Returns a reference to the Paging Helper used to load the data from the
+     * DataStore.
+     * 
+     * @return the paging helper
+     */
+    public FeaturePagingHelper getHelper() {
+        return helper;
+    }
+
+    /**
+     * Sets the FeatureType to show in the table. Used for FeatureStores with
+     * many simultaneous FeatureTypes supported. Will cause a reload of the
+     * current data.
+     * 
+     * @param featureType
+     *            the FeatureType of the Features
+     * @throws DataException
+     *             if there is an error loading the data
+     */
+    public void setFeatureType(FeatureType featureType) {
+        getFeatureQuery().setFeatureType(featureType);
+        reloadFeatures();
+        fireTableStructureChanged();
+    }
+
+    /**
+     * Sets that the selected Features get returned first.
+     */
+    public void setSelectionUp(boolean selectionUp) {
+        getHelper().setSelectionUp(selectionUp);
+        fireTableChanged(new TableModelEvent(this, 0, getRowCount() - 1));
+    }
+
+    public void update(Observable observable, Object notification) {
+        if (observable.equals(getFeatureStore())
+            && notification instanceof FeatureStoreNotification) {
+            FeatureStoreNotification fsNotification =
+                (FeatureStoreNotification) notification;
+            String type = fsNotification.getType();
+
+            // If there are new, updated or deleted features
+            // reload the table data
+            if (FeatureStoreNotification.AFTER_DELETE.equals(type)
+                || FeatureStoreNotification.AFTER_INSERT.equals(type)) {
+
+                reloadIfFeatureCountChanged(fsNotification.getFeature());
+
+            } else if (FeatureStoreNotification.AFTER_UPDATE.equals(type)) {
+            	
+            	reloadIfFeatureUpdated(fsNotification.getFeature());
+            } else
+                if (FeatureStoreNotification.AFTER_UPDATE_TYPE.equals(type)) {
+
+                    reloadIfTypeChanged(fsNotification.getFeatureType());
+
+                } else
+                    if (FeatureStoreNotification.TRANSFORM_CHANGE.equals(type)) {
+                        reloadIfTypeTransformed();
+
+                    } else
+                        if (FeatureStoreNotification.AFTER_FINISHEDITING
+                            .equals(type)
+                            || FeatureStoreNotification.AFTER_CANCELEDITING
+                                .equals(type)) {
+                            reloadIfTypeTransformed();
+                        }
+
+        }
+    }
+
+    /**
+     * Returns the FeatureStore of the Collection.
+     * 
+     * @return the FeatureStore
+     */
+    public FeatureStore getFeatureStore() {
+        return getHelper().getFeatureStore();
+    }
+
+    /**
+     * Returns the descriptor of a Feature attribute for a table column.
+     * 
+     * @param columnIndex
+     *            the column index
+     */
+    public FeatureAttributeDescriptor getDescriptorForColumn(int columnIndex) {
+        return internalGetFeatureDescriptorForColumn(columnIndex);
+    }
+
+    /**
+     * @param columnIndex
+     * @return
+     */
+    protected FeatureAttributeDescriptor internalGetFeatureDescriptorForColumn(
+        int columnIndex) {
+        return getFeatureType().getAttributeDescriptor(columnIndex);
+    }
+
+    /**
+     * Initialize the TableModel
+     */
+    protected void initialize() {
+        // Add as observable to the FeatureStore, to detect data and selection
+        // changes
+        helper.getFeatureStore().addObserver(this);
+    }
+
+    /**
+     * Returns the value of a Feature attribute, at the given position.
+     * 
+     * @param feature
+     *            the feature to get the value from
+     * @param columnIndex
+     *            the Feature attribute position
+     * @return the value
+     */
+    protected Object getFeatureValue(Feature feature, int columnIndex) {
+        return feature.get(columnIndex);
+    }
+
+    /**
+     * Sets the value of an Feature attribute at the given position.
+     * 
+     * @param feature
+     *            the feature to update
+     * @param columnIndex
+     *            the attribute position
+     * @param value
+     *            the value to set
+     * @throws IsNotFeatureSettingException
+     *             if there is an error setting the value
+     */
+    protected EditableFeature setFeatureValue(Feature feature, int columnIndex,
+        Object value) {
+        EditableFeature editableFeature = feature.getEditable();
+        editableFeature.set(columnIndex, value);
+        return editableFeature;
+    }
+
+    /**
+     * Returns the FeatureSet used to get the data.
+     * 
+     * @return the FeatureSet
+     */
+    protected FeatureSet getFeatureSet() {
+        return getHelper().getFeatureSet();
+    }
+
+    /**
+     * Returns the FeatureQuery used to get the Features.
+     * 
+     * @return the FeatureQuery
+     */
+    public FeatureQuery getFeatureQuery() {
+        return getHelper().getFeatureQuery();
+    }
+
+    /**
+     * Returns the type of the features.
+     */
+    private FeatureType getFeatureType() {
+        return getHelper().getFeatureType();
+    }
+
+    /**
+     * Reloads the table data if a feature has been changed, not through the
+     * table.
+     */
+    private void reloadIfFeatureCountChanged(Feature feature) {
+        // Is any data is changed in the FeatureStore, notify the model
+        // listeners. Ignore the case where the updated feature is
+        // changed through us.
+        if (editableFeature == null || !editableFeature.equals(feature)) {
+            reloadFeatures();            
+            fireTableDataChanged();
+        }
+    }
+    
+    private void reloadIfFeatureUpdated(Feature feature) {
+        // Is any data is changed in the FeatureStore, notify the model
+        // listeners. Ignore the case where the updated feature is
+        // changed through us.
+        if (editableFeature == null || !editableFeature.equals(feature)) {
+            reloadFeatures();
+            fireTableChanged(new TableModelEvent(this, 0, getRowCount()));            
+        }
+    }
+
+    /**
+     * Reloads data and structure if the {@link FeatureType} of the features
+     * being shown has changed.
+     */
+    private void reloadIfTypeChanged(FeatureType updatedType) {
+        // If the updated featured type is the one currently being
+        // shown, reload the table.
+        if (updatedType != null
+            && updatedType.getId().equals(getFeatureType().getId())) {
+            setFeatureType(updatedType);
+        }
+    }
+
+    /**
+     * Reloads data and structure if the {@link FeatureType} of the features
+     * being shown has been transformed.
+     */
+    private void reloadIfTypeTransformed() {
+        try {
+            setFeatureType(getHelper().getFeatureStore().getFeatureType(
+                getHelper().getFeatureType().getId()));
+        } catch (DataException e) {
+            throw new FeaturesDataReloadException(e);
+        }
+    }
+
+    /**
+     * Reloads the features shown on the table.
+     */
+    private void reloadFeatures() {
+        try {
+            getHelper().reload();
+        } catch (BaseException ex) {
+            throw new FeaturesDataReloadException(ex);
+        }
+    }
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureTableModel.java
___________________________________________________________________
Added: svn:mergeinfo

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/JToggleButtonHeaderCellRenderer.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/JToggleButtonHeaderCellRenderer.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/JToggleButtonHeaderCellRenderer.java	(revision 38283)
@@ -0,0 +1,180 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2008 {DiSiD Technologies}  {{Task}}
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import java.awt.Component;
+import java.awt.Insets;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.util.BitSet;
+
+import javax.swing.JTable;
+import javax.swing.JToggleButton;
+import javax.swing.table.JTableHeader;
+import javax.swing.table.TableCellRenderer;
+
+import org.gvsig.fmap.mapcontrol.dal.feature.swing.FeatureTable;
+import org.gvsig.fmap.mapcontrol.dal.feature.swing.table.notification.ColumnHeaderSelectionChangeNotification;
+import org.gvsig.tools.observer.impl.BaseWeakReferencingObservable;
+
+/**
+ * A header cell renderer for JTables, which allows to select column headers by
+ * rendering a JToggleButton on each header cell.
+ *
+ * When the selection of column headers changes, Observers are notified through
+ * a {@link ColumnHeaderSelectionChangeNotification}.
+ *
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class JToggleButtonHeaderCellRenderer extends
+        BaseWeakReferencingObservable implements TableCellRenderer,
+        MouseListener {
+
+    private BitSet selectedColumns = new BitSet();
+
+    // Component to render on each header cell
+    private JToggleButton button;
+
+    private FeatureTable table;
+
+    /**
+     * Create a new JToggleButtonCellRenderer for a JTable.
+     */
+    public JToggleButtonHeaderCellRenderer(FeatureTable table) {
+        this.table = table;
+        JTableHeader header = table.getTableHeader();
+        header.addMouseListener(this);
+		button = new JToggleButton();
+
+        // Clone renderization of the default table header
+		// button.setBackground(header.getBackground());
+		// button.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 1, table
+		// .getGridColor()));
+		// button.setFont(header.getFont());
+		// button.setForeground(header.getForeground());
+        button.setMargin(new Insets(0, 0, 0, 0));
+    }
+
+    /**
+     * Returns the selected columns table model position.
+     *
+     * @return an array of selected column indices
+     */
+    public int[] getSelectedColumns() {
+        int[] columns = new int[selectedColumns.cardinality()];
+        int pos = 0;
+        for (int i = selectedColumns.nextSetBit(0); i >= 0; i = selectedColumns
+                .nextSetBit(i + 1)) {
+            columns[pos] = i;
+            pos++;
+        }
+        return columns;
+    }
+
+    public Component getTableCellRendererComponent(JTable table, Object value,
+            boolean isSelected, boolean hasFocus, int row, int column) {
+
+        // Get the the model position of the column being rendered
+        int columnModel = table.convertColumnIndexToModel(column);
+
+        // Set the column header text and selected status
+        button.setText(table.getColumnName(column));
+        button.setSelected(selectedColumns.get(columnModel));
+		// if (selectedColumns.get(columnModel)){
+		// button.setBackground(Color.gray);
+		// }else{
+		// button.setBackground(Color.lightGray);
+		// }
+        return button;
+    }
+
+    public void deselectAll() {
+        selectedColumns.clear();
+        notifyObservers(new ColumnHeaderSelectionChangeNotification(table));
+    }
+
+    public void mouseClicked(MouseEvent event) {
+        // Look for the clicked column
+        JTable jtable = ((JTableHeader) event.getSource()).getTable();
+        if (jtable.equals(table)) {
+            int columnViewIndex = table.columnAtPoint(event.getPoint());
+            if (columnViewIndex >= 0) {
+                int columnModelIndex =
+                    table.convertColumnIndexToModel(columnViewIndex);
+
+                // Set or add the selected column, depending on the CTRL key
+                // being
+                // pressed or not
+                if (ctrlKeyPressed(event)) {
+                    reverseSelection(columnModelIndex);
+                } else {
+                    setSelection(columnModelIndex);
+                }
+            }
+        }
+    }
+
+    public void mouseEntered(MouseEvent e) {
+        // Nothing to do
+    }
+
+    public void mouseExited(MouseEvent e) {
+        // Nothing to do
+    }
+
+    public void mousePressed(MouseEvent e) {
+        // Nothing to do
+    }
+
+    public void mouseReleased(MouseEvent e) {
+        // Nothing to do
+    }
+
+    private boolean ctrlKeyPressed(MouseEvent event) {
+        final int ctrlDownMask = MouseEvent.CTRL_DOWN_MASK;
+        return (event.getModifiersEx() & ctrlDownMask) == ctrlDownMask;
+    }
+
+    /**
+     * Sets the selection to only the given column.
+     */
+    private void setSelection(int column) {
+        selectedColumns.clear();
+        selectedColumns.set(column);
+
+        notifyObservers(new ColumnHeaderSelectionChangeNotification(table));
+    }
+
+    /**
+     * Reverses the selection of a column.
+     */
+    private void reverseSelection(int column) {
+        selectedColumns.flip(column);
+
+        notifyObservers(new ColumnHeaderSelectionChangeNotification(table));
+    }
+}
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/GeometryWKTCellEditor.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/GeometryWKTCellEditor.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/GeometryWKTCellEditor.java	(revision 38283)
@@ -0,0 +1,230 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2008 {DiSiD Technologies}  {{Task}}
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ItemEvent;
+import java.util.EventObject;
+
+import javax.swing.DefaultCellEditor;
+import javax.swing.JOptionPane;
+import javax.swing.JTable;
+
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.GeometryLocator;
+import org.gvsig.fmap.geom.GeometryManager;
+import org.gvsig.fmap.geom.Geometry.SUBTYPES;
+import org.gvsig.fmap.geom.exception.CreateGeometryException;
+import org.gvsig.fmap.geom.operation.fromwkt.FromWKT;
+import org.gvsig.fmap.geom.operation.fromwkt.FromWKTGeometryOperationContext;
+import org.gvsig.fmap.geom.operation.towkt.ToWKT;
+import org.gvsig.i18n.Messages;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Editor for cells of type Geometry in WKT format.
+ * <p>
+ * If the WKT to represent a Geometry is too big, editing is not allowed, as the
+ * rendering of that big text is too slow.
+ * </p>
+ * 
+ * @author <a href="mailto:cordin@disid.com">Cèsar Ordiñana</a>
+ */
+public class GeometryWKTCellEditor extends TextAreaCellEditor {
+	private static final GeometryManager geomManager = GeometryLocator.getGeometryManager();
+	private static final Logger logger = LoggerFactory.getLogger(GeometryWKTCellEditor.class);
+    public static final int DEFAULT_MAX_WKT_LENGTH = 10000;
+
+    private static final long serialVersionUID = -2296004227902843851L;
+    private Geometry nullGeometry = null;
+    
+    private int maxRowHeight;
+
+    /**
+     * Creates a new editor for Geometries in WKT format.
+     */
+    public GeometryWKTCellEditor() {
+        this(DEFAULT_MAX_WKT_LENGTH, 160);
+    }
+
+    /**
+     * Creates a new editor for Geometries in WKT format.
+     * 
+     * @param maxWKTLength
+     *            the maximum WTK length allowed to be edited.
+     * @param maxRowHeight
+     *            the maximum row height for the rows with cells rendered with
+     *            this component
+     */
+    public GeometryWKTCellEditor(int maxWKTLength, int maxRowHeight) {
+        super();
+        delegate = new GeometryToWKTDelegate(delegate, maxWKTLength);
+        this.maxRowHeight = maxRowHeight;
+        try {
+			nullGeometry = geomManager.createNullGeometry(SUBTYPES.GEOM2D);
+		} catch (CreateGeometryException e) {
+			logger.error("Error creating a null geometry", e);
+		}
+    }
+
+    @Override
+    public Object getCellEditorValue() {
+        String wkt = (String) super.getCellEditorValue();
+        FromWKTGeometryOperationContext context = new FromWKTGeometryOperationContext(
+                wkt, null);
+
+        try {
+            return nullGeometry.invokeOperation(FromWKT.CODE, context);
+        } catch (Exception ex) {
+            throw new WKTToGeometryException(wkt, ex);
+        }
+    }
+
+    @Override
+    public Component getTableCellEditorComponent(JTable table, Object value,
+            boolean isSelected, int row, int column) {
+        delegate.setValue(value);
+        if (((GeometryToWKTDelegate) delegate).isWtkTextTooLong()) {
+            JOptionPane
+                    .showMessageDialog(
+                            table.getParent(),
+                            Messages
+                    .getText("Geometria_no_editable_WKT"), Messages
+                    .getText("Error_editar_geometria"),
+                            JOptionPane.ERROR_MESSAGE);
+
+            return null;
+        } else {
+            int height_wanted = (int) getTextArea().getPreferredSize()
+                    .getHeight();
+
+            height_wanted = height_wanted > maxRowHeight ? maxRowHeight
+                    : height_wanted;
+
+            if (height_wanted > table.getRowHeight(row)) {
+                table.setRowHeight(row, height_wanted);
+            }
+
+            return editorComponent;
+        }
+    }
+
+    @SuppressWarnings("serial")
+    private class GeometryToWKTDelegate extends
+            DefaultCellEditor.EditorDelegate {
+        private DefaultCellEditor.EditorDelegate delegate;
+
+        private boolean wtkTextTooLong = false;
+
+        private int maxWKTLength;
+
+        public GeometryToWKTDelegate(DefaultCellEditor.EditorDelegate delegate,
+                int maxWKTLength) {
+            this.delegate = delegate;
+            this.maxWKTLength = maxWKTLength;
+        }
+
+        /**
+         * @return the wtkTextTooLong
+         */
+        public boolean isWtkTextTooLong() {
+            return wtkTextTooLong;
+        }
+
+        public void setValue(Object value) {
+            wtkTextTooLong = false;
+            String strValue = "";
+
+            if (value != null) {
+                try {
+                    Geometry geometry = (Geometry) value;
+                    strValue = (String) geometry.invokeOperation(ToWKT.CODE,
+                            null);
+
+                    if (strValue.length() > maxWKTLength) {
+                        wtkTextTooLong = true;
+                        delegate.setValue(null);
+                    } else {
+                        delegate.setValue(strValue);
+                    }
+                } catch (Exception ex) {
+                    throw new GeometryToWKTException(ex);
+                }
+            }
+        }
+
+        public Object getCellEditorValue() {
+            if (wtkTextTooLong) {
+                return null;
+            } else {
+                return delegate.getCellEditorValue();
+            }
+        }
+
+        public void actionPerformed(ActionEvent e) {
+            delegate.actionPerformed(e);
+        }
+
+        public void cancelCellEditing() {
+            delegate.cancelCellEditing();
+        }
+
+        public boolean equals(Object obj) {
+            return delegate.equals(obj);
+        }
+
+        public int hashCode() {
+            return delegate.hashCode();
+        }
+
+        public boolean isCellEditable(EventObject anEvent) {
+            return delegate.isCellEditable(anEvent);
+        }
+
+        public void itemStateChanged(ItemEvent e) {
+            delegate.itemStateChanged(e);
+        }
+
+        public boolean shouldSelectCell(EventObject anEvent) {
+            return delegate.shouldSelectCell(anEvent);
+        }
+
+        public boolean startCellEditing(EventObject anEvent) {
+            return delegate.startCellEditing(anEvent);
+        }
+
+        public boolean stopCellEditing() {
+            return delegate.stopCellEditing();
+        }
+
+        public String toString() {
+            return delegate.toString();
+        }
+    }
+}
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureStoreModel.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureStoreModel.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureStoreModel.java	(revision 38283)
@@ -0,0 +1,173 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.swing.table.TableModel;
+
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.feature.FeatureQuery;
+import org.gvsig.fmap.dal.feature.FeatureStore;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.mapcontrol.dal.feature.swing.FeatureTypesTablePanel;
+import org.gvsig.tools.exception.BaseException;
+
+/**
+ * A model for the {@link FeatureTypesTablePanel} which unifies the access
+ * to the different models needed by the components included into it.
+ * 
+ * @author gvSIG Team
+ * @version $Id$
+ */
+public class FeatureStoreModel {
+
+    private final FeatureStore featureStore;
+    private final FeatureQuery featureQuery;
+    private final FeatureTypeListModel featureTypeListModel;
+    private final Map<String, ConfigurableFeatureTableModel> type2TableModel =
+        new HashMap<String, ConfigurableFeatureTableModel>();
+    private String currentFeatureTypeId;
+
+    /**
+     * Constructor.
+     * 
+     * @param store
+     *            the FeatureStore to get data from
+     * @param query
+     *            the FeatureQuery to use to get data
+     * @throws DataException
+     *             if there is an error getting the default {@link FeatureType}
+     */
+    public FeatureStoreModel(FeatureStore store, FeatureQuery query)
+        throws DataException {
+        this.featureStore = store;
+        this.featureQuery = query;
+        this.featureTypeListModel = new FeatureTypeListModel(store, query);
+
+        this.currentFeatureTypeId =
+            query.getFeatureTypeId() == null ? store.getDefaultFeatureType()
+                .getId() : query.getFeatureTypeId();
+    }
+
+    /**
+     * Constructor.
+     * 
+     * @param store
+     *            the FeatureStore to get data from
+     * @throws DataException
+     *             if there is an error getting the default {@link FeatureType}
+     */
+    public FeatureStoreModel(FeatureStore store) throws DataException {
+        this(store, null);
+    }
+
+    /**
+     * Returns the {@link FeatureTypeListModel} to show a list of available
+     * {@link FeatureType}s.
+     * 
+     * @return the {@link FeatureTypeListModel} to show a list of available
+     *         {@link FeatureType}s
+     */
+    public FeatureTypeListModel getFeatureTypeListModel() {
+        return featureTypeListModel;
+    }
+
+    /**
+     * Returns the {@link TableModel} to use to show data of the current feature
+     * type.
+     * 
+     * @return the TableModel to use
+     */
+    public ConfigurableFeatureTableModel getCurrentFeatureTableModel() {
+        return getFeatureTableModel(this.currentFeatureTypeId);
+    }
+
+    /**
+     * Returns the {@link TableModel} to use to show data of a
+     * {@link FeatureType}.
+     * 
+     * @param type
+     *            to use to filter the data
+     * @return the TableModel to use
+     */
+    public ConfigurableFeatureTableModel getFeatureTableModel(FeatureType type) {
+        return getFeatureTableModel(type.getId());
+    }
+
+    /**
+     * Returns the {@link TableModel} to use to show data of a
+     * {@link FeatureType}.
+     * 
+     * @param typeId
+     *            the id of the {@link FeatureType} to use to filter the data
+     * @return the TableModel to use
+     */
+    public ConfigurableFeatureTableModel getFeatureTableModel(String typeId) {
+        ConfigurableFeatureTableModel tableModel = type2TableModel.get(typeId);
+        if (tableModel == null) {
+            try {
+                tableModel =
+                    new ConfigurableFeatureTableModel(featureStore,
+                        featureQuery);
+                type2TableModel.put(typeId, tableModel);
+            } catch (BaseException e) {
+                throw new RuntimeException("Error creating a table model", e);
+            }
+        }
+        return tableModel;
+    }
+
+    /**
+     * Sets the id of the current {@link FeatureType}.
+     * 
+     * @param currentFeatureTypeId
+     *            the id of the current {@link FeatureType}
+     */
+    public void setCurrentFeatureTypeId(String currentFeatureTypeId) {
+        this.currentFeatureTypeId = currentFeatureTypeId;
+    }
+
+    /**
+     * Returns the id of the current {@link FeatureType}.
+     * 
+     * @return the id of the current {@link FeatureType}
+     */
+    public String getCurrentFeatureTypeId() {
+        return currentFeatureTypeId;
+    }
+
+    /**
+     * @return the featureQuery
+     */
+    public FeatureQuery getFeatureQuery() {
+        return featureQuery;
+    }
+
+    /**
+     * @return the featureStore
+     */
+    public FeatureStore getFeatureStore() {
+        return featureStore;
+    }
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureTypeList.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureTypeList.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureTypeList.java	(revision 38283)
@@ -0,0 +1,166 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
+
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+import org.gvsig.fmap.dal.feature.FeatureQuery;
+import org.gvsig.fmap.dal.feature.FeatureStore;
+import org.gvsig.fmap.dal.feature.FeatureType;
+
+/**
+ * Shows a list of {@link FeatureType}s to allow the user to select one of them.
+ * 
+ * @author 2005- Vicente Caballero
+ * @author 2009- <a href="cordinyana@gvsig.org">César Ordiñana</a> - gvSIG team
+ */
+public class FeatureTypeList extends JPanel {
+
+    private static final long serialVersionUID = 6168364334623238504L;
+
+    private JScrollPane jScrollPane = null;
+    private JList jList = null;
+    private List<SelectedFeatureTypeChangeListener> featureTypeChangeListeners =
+        new ArrayList<SelectedFeatureTypeChangeListener>();
+
+    private final FeatureTypeListModel model;
+
+    /**
+     * Creates a new {@link FeatureTypeList} which loads the available
+     * {@link FeatureType}s from a {@link FeatureStore} and a
+     * {@link FeatureQuery}.
+     * 
+     * @param featureStore
+     *            the store to load the {@link FeatureType}s from
+     * @param featureQuery
+     *            the query to load the {@link FeatureType} from, if any
+     */
+    public FeatureTypeList(FeatureStore featureStore, FeatureQuery featureQuery) {
+        this(new FeatureTypeListModel(featureStore, featureQuery));
+    }
+
+    /**
+     * Creates a new {@link FeatureTypeList} which loads the available
+     * {@link FeatureType}s from a {@link FeatureTypeListModel}.
+     * 
+     * @param model
+     *            the model to get the {@link FeatureType}s from
+     */
+    public FeatureTypeList(FeatureTypeListModel model) {
+        this.model = model;
+        initialize();
+    }
+
+    private void initialize() {
+        GridBagConstraints gridBagConstraints = new GridBagConstraints();
+        gridBagConstraints.fill = GridBagConstraints.BOTH;
+        gridBagConstraints.gridy = 0;
+        gridBagConstraints.weightx = 1.0;
+        gridBagConstraints.weighty = 1.0;
+        gridBagConstraints.gridx = 0;
+        this.setLayout(new GridBagLayout());
+        this.setPreferredSize(new Dimension(146, 281));
+        this.add(getJScrollPane(), gridBagConstraints);
+    }
+
+    /**
+     * This method initializes jScrollPane
+     * 
+     * @return javax.swing.JScrollPane
+     */
+    private JScrollPane getJScrollPane() {
+        if (jScrollPane == null) {
+            jScrollPane = new JScrollPane();
+            jScrollPane.setViewportView(getJList());
+        }
+        return jScrollPane;
+    }
+
+    /**
+     * This method initializes jList
+     * 
+     * @return javax.swing.JList
+     */
+    private JList getJList() {
+        if (jList == null) {
+            jList = new javax.swing.JList();
+            jList.setModel(this.model);
+            jList.setSelectedIndex(0);
+            jList.addListSelectionListener(new ListSelectionListener() {
+
+                public void valueChanged(ListSelectionEvent e) {
+                    FeatureType fType = getSelectedFeatureType();
+                    for (int i = 0; i < featureTypeChangeListeners.size(); i++) {
+                        featureTypeChangeListeners.get(i).change(
+                            model.getFeatureStore(), fType);
+                    }
+                }
+            });
+        }
+
+        return jList;
+    }
+
+    public void addSelectedFeatureTypeChangeListener(
+        SelectedFeatureTypeChangeListener listener) {
+        featureTypeChangeListeners.add(listener);
+    }
+
+    public void removeSelectedFeatureTypeChangeListener(
+        SelectedFeatureTypeChangeListener listener) {
+        featureTypeChangeListeners.remove(listener);
+    }
+
+    /**
+     * Returns the currently selected {@link FeatureType}.
+     * 
+     * @return the currently selected {@link FeatureType}
+     */
+    public FeatureType getSelectedFeatureType() {
+        int index = jList.getSelectedIndex();
+        if (index >= 0) {
+            String typeId = (String) jList.getModel().getElementAt(index);
+            return model.getFeatureType(typeId);
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Returns the number of available {@link FeatureType}s.
+     * 
+     * @return the number of available {@link FeatureType}s
+     */
+    public int getFeatureTypesSize() {
+        return model.getSize();
+    }
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/FeatureTypesTablePanel.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/FeatureTypesTablePanel.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/FeatureTypesTablePanel.java	(revision 38283)
@@ -0,0 +1,222 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.fmap.mapcontrol.dal.feature.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+
+import javax.swing.JPanel;
+import javax.swing.JSplitPane;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.feature.Feature;
+import org.gvsig.fmap.dal.feature.FeatureQuery;
+import org.gvsig.fmap.dal.feature.FeatureStore;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.fmap.mapcontrol.dal.feature.swing.table.ConfigurableFeatureTableModel;
+import org.gvsig.fmap.mapcontrol.dal.feature.swing.table.FeatureStoreModel;
+import org.gvsig.fmap.mapcontrol.dal.feature.swing.table.FeatureTypeList;
+import org.gvsig.fmap.mapcontrol.dal.feature.swing.table.SelectedFeatureTypeChangeListener;
+import org.gvsig.tools.exception.BaseException;
+
+/**
+ * Panel to show a table of Features. It is able to take into account the
+ * availability of many FeatureTypes, and if it is the case, allows the user to
+ * select the {@link FeatureType} of the {@link Feature}s to show.
+ * 
+ * @author 2005- Vicente Caballero
+ * @author 2009- <a href="cordinyana@gvsig.org">César Ordiñana</a> - gvSIG team
+ */
+public class FeatureTypesTablePanel extends JPanel implements
+    SelectedFeatureTypeChangeListener {
+
+    private static final long serialVersionUID = 5857146295213412304L;
+    private static final Logger LOG = LoggerFactory
+        .getLogger(FeatureTypesTablePanel.class);
+    private FeatureTablePanel tablePanel;
+    private FeatureTypeList typesControl;
+    private JSplitPane jSplitPane = null;
+    private final FeatureStoreModel model;
+
+    /**
+     * Constructs a Panel to show a table with the features of a FeatureStore.
+     * 
+     * @param featureStore
+     *            to extract the features from
+     * @throws BaseException
+     *             if there is an error reading data from the FeatureStore
+     */
+    public FeatureTypesTablePanel(FeatureStore featureStore)
+        throws BaseException {
+        this(featureStore, true);
+    }
+
+    /**
+     * Constructs a Panel to show a table with the features of a FeatureStore.
+     * 
+     * @param featureStore
+     *            to extract the features from
+     * @param isDoubleBuffered
+     *            a boolean, true for double-buffering, which uses additional
+     *            memory space to achieve fast, flicker-free updates
+     * @throws BaseException
+     *             if there is an error reading data from the FeatureStore
+     */
+    public FeatureTypesTablePanel(FeatureStore featureStore,
+        boolean isDoubleBuffered) throws BaseException {
+        this(featureStore, null, isDoubleBuffered);
+    }
+
+    /**
+     * @throws BaseException
+     * 
+     */
+    public FeatureTypesTablePanel(FeatureStore featureStore,
+        FeatureQuery featureQuery) throws BaseException {
+        this(featureStore, featureQuery, true);
+    }
+
+    /**
+     * @param isDoubleBuffered
+     * @throws BaseException
+     */
+    public FeatureTypesTablePanel(FeatureStore featureStore,
+        FeatureQuery featureQuery, boolean isDoubleBuffered)
+        throws BaseException {
+        this(new FeatureStoreModel(featureStore, featureQuery),
+            isDoubleBuffered);
+    }
+
+    public FeatureTypesTablePanel(FeatureStoreModel model) throws DataException {
+        this(model, true);
+    }
+
+    public FeatureTypesTablePanel(FeatureStoreModel model,
+        boolean isDoubleBuffered) throws DataException {
+        super(isDoubleBuffered);
+        this.model = model;
+        typesControl =
+            new FeatureTypeList(model.getFeatureStore(),
+                model.getFeatureQuery());
+        this.initializeUI();
+        // Add a listener to change the selection
+        typesControl.addSelectedFeatureTypeChangeListener(this);
+    }
+
+    private boolean hasManyFeatureTypes() throws DataException {
+        return typesControl.getFeatureTypesSize() > 1;
+    }
+
+    /**
+     * @return
+     * @see org.gvsig.fmap.mapcontrol.dal.feature.swing.FeatureTablePanel#createConfigurationPanel()
+     */
+    public JPanel createConfigurationPanel() {
+        return tablePanel.createConfigurationPanel();
+    }
+
+    public void change(FeatureStore featureStore, FeatureType featureType) {
+        if (featureType != null) {
+            showFeatureTypeData(featureType);
+        }
+    }
+
+    private void showFeatureTypeData(FeatureType featureType) {
+        showFeatureTypeData(featureType.getId());
+    }
+
+    private void showFeatureTypeData(String typeId) {
+        this.model.setCurrentFeatureTypeId(typeId);
+        try {
+            tablePanel =
+                new FeatureTablePanel(this.model.getCurrentFeatureTableModel());
+        } catch (BaseException e) {
+            throw new RuntimeException(
+                "Error creating a new FeatureTablePanel to show "
+                    + "the selected FeatureType with id: " + typeId, e);
+        }
+        getJSplitPane().setRightComponent(tablePanel);
+    }
+
+    public FeatureTablePanel getTablePanel() {
+        return tablePanel;
+    }
+
+    public FeatureTypeList getTypesControl() {
+        return typesControl;
+    }
+
+    /**
+     * Sets that the selected Features to be viewed first.
+     */
+    public void setSelectionUp(boolean selectionUp) {
+        getTablePanel().setSelectionUp(selectionUp);
+    }
+
+    /**
+     * Returns the internal Table Model for the Features of the FeatureStore.
+     * 
+     * @return the internal Table Model
+     */
+    protected ConfigurableFeatureTableModel getTableModel() {
+        return getTablePanel().getTableModel();
+    }
+
+    /**
+     * This method initializes jPanel
+     * 
+     * @return javax.swing.JPanel
+     */
+    private void initializeUI() {
+        this.setLayout(new BorderLayout());
+        this.setSize(new Dimension(331, 251));
+        this.add(getJSplitPane(), BorderLayout.CENTER);
+        showFeatureTypeData(model.getCurrentFeatureTypeId());
+    }
+
+    /**
+     * This method initializes jSplitPane
+     * 
+     * @return javax.swing.JSplitPane
+     */
+    private JSplitPane getJSplitPane() {
+        if (jSplitPane == null) {
+            jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
+            jSplitPane.setLeftComponent(getTypesControl());
+            jSplitPane.setOneTouchExpandable(true);
+            try {
+                if (hasManyFeatureTypes()) {
+                    jSplitPane.setDividerLocation(0.2d);
+                } else {
+                    jSplitPane.setDividerLocation(0.0d);
+                }
+            } catch (DataException ex) {
+                LOG.error("Error getting the number of feature types", ex);
+            }
+        }
+        return jSplitPane;
+    }
+
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/IConfigurator.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/IConfigurator.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/IConfigurator.java	(revision 38283)
@@ -0,0 +1,50 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.snapping;
+
+import org.gvsig.fmap.mapcontrol.tools.snapping.snappers.ISnapper;
+
+public interface IConfigurator {
+	void setSnapper(ISnapper snapper);
+	ISnapper getSnapper();
+}
+
+
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/snappers/ISnapperVectorial.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/snappers/ISnapperVectorial.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/snappers/ISnapperVectorial.java	(revision 38283)
@@ -0,0 +1,54 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.snapping.snappers;
+
+import java.awt.geom.Point2D;
+
+import org.gvsig.fmap.geom.Geometry;
+
+public interface ISnapperVectorial extends ISnapper {
+
+	Point2D getSnapPoint(Point2D queryPoint, Geometry geomToSnap, double tolerance, Point2D lastPointEntered);
+
+
+}
+
+
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/snappers/ISnapperGeometriesVectorial.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/snappers/ISnapperGeometriesVectorial.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/snappers/ISnapperGeometriesVectorial.java	(revision 38283)
@@ -0,0 +1,59 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.snapping.snappers;
+
+import java.awt.geom.Point2D;
+import java.util.List;
+
+import org.gvsig.fmap.geom.Geometry;
+
+
+/**
+ * Snapper vectorial with geometries.
+ *
+ * @author Vicente Caballero Navarro
+ */
+public interface ISnapperGeometriesVectorial extends ISnapperVectorial {
+    Point2D getSnapPoint(Point2D queryPoint, Geometry geomToSnap,
+        double tolerance, Point2D lastPointEntered);
+
+    void setGeometries(List geoms);
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/snappers/ISnapper.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/snappers/ISnapper.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/snappers/ISnapper.java	(revision 38283)
@@ -0,0 +1,29 @@
+package org.gvsig.fmap.mapcontrol.tools.snapping.snappers;
+
+import java.awt.geom.Point2D;
+
+import org.gvsig.fmap.mapcontrol.PrimitivesDrawer;
+
+/**
+ * @author fjp
+ *
+ */
+public interface ISnapper {
+
+	void draw(PrimitivesDrawer primitivesDrawer, Point2D pPixels);
+
+	String getToolTipText();
+
+	/**
+	 * Implement this if you need a Snapper more important than the others.
+	 * Default value is 0 (no prority).
+	 * @return
+	 */
+	int getPriority();
+
+	boolean isEnabled();
+	public void setEnabled(boolean enabled);
+	public void setPriority(int priority);
+	Object getConfigurator();
+
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/snappers/impl/AbstractSnapper.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/snappers/impl/AbstractSnapper.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/snappers/impl/AbstractSnapper.java	(revision 38283)
@@ -0,0 +1,56 @@
+package org.gvsig.fmap.mapcontrol.tools.snapping.snappers.impl;
+
+import java.awt.Color;
+
+import org.gvsig.fmap.geom.GeometryLocator;
+import org.gvsig.fmap.geom.GeometryManager;
+import org.gvsig.fmap.mapcontrol.tools.snapping.snappers.ISnapper;
+
+public abstract class AbstractSnapper implements ISnapper {
+	private int sizePixels = 10;
+	private Color color = Color.MAGENTA;
+	private boolean enabled;
+	private int priority=10;
+
+	protected static GeometryManager geomManager = GeometryLocator.getGeometryManager();
+
+	public int getSizePixels() {
+		return sizePixels;
+	}
+
+	public void setSizePixels(int sizePixels) {
+		this.sizePixels = sizePixels;
+	}
+
+	public Color getColor() {
+		return color;
+	}
+
+	public void setColor(Color color) {
+		this.color = color;
+	}
+
+	public Object getConfigurator(){
+//		DefaultConfigurePanel configurePanel=new DefaultConfigurePanel();
+//		return configurePanel;
+		return null;
+	}
+
+	public boolean isEnabled() {
+		return enabled;
+	}
+
+	public void setEnabled(boolean enabled) {
+		this.enabled = enabled;
+	}
+	 /* (non-Javadoc)
+     * @see com.iver.cit.gvsig.gui.cad.snapping.ISnapper#getPriority()
+     */
+    public int getPriority() {
+        return priority;
+    }
+    
+	public void setPriority(int priority) {
+		this.priority=priority;
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/snappers/ISnapperRaster.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/snappers/ISnapperRaster.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/snappers/ISnapperRaster.java	(revision 38283)
@@ -0,0 +1,53 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.snapping.snappers;
+
+import java.awt.geom.Point2D;
+
+import org.gvsig.fmap.mapcontrol.MapControl;
+
+public interface ISnapperRaster extends ISnapper {
+
+	Point2D getSnapPoint(MapControl mapControl, Point2D point, double mapTolerance, Point2D lastPoint);
+
+}
+
+
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/SnappingVisitor.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/SnappingVisitor.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/SnappingVisitor.java	(revision 38283)
@@ -0,0 +1,62 @@
+package org.gvsig.fmap.mapcontrol.tools.snapping;
+
+import java.awt.geom.Point2D;
+
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.mapcontrol.tools.snapping.snappers.ISnapperVectorial;
+
+import com.vividsolutions.jts.index.ItemVisitor;
+
+/**
+ * @author fjp
+ *
+ * Visitor adecuado para recorrer el índice espacial de JTS y no obligar
+ * a dar 2 pasadas. En la misma pasada que se visita, se calcula la distancia
+ * mínima.
+ */
+public class SnappingVisitor implements ItemVisitor {
+
+	ISnapperVectorial snapper;
+	Point2D snapPoint = null;
+	Point2D queryPoint = null;
+	Point2D lastPointEntered = null;
+
+	double minDist = Double.MAX_VALUE;
+	double distActual;
+	double tolerance;
+
+	public SnappingVisitor(ISnapperVectorial snapper, Point2D queryPoint, double tolerance, Point2D lastPointEntered)
+	{
+		this.snapper = snapper;
+		this.tolerance = tolerance;
+		this.queryPoint = queryPoint;
+		this.lastPointEntered = lastPointEntered;
+		distActual = tolerance;
+		// snapper.setSnapPoint(null);
+	}
+
+	public void visitItem(Object item) {
+		Geometry geom = (Geometry) item;
+		Point2D aux  = snapper.getSnapPoint(queryPoint, geom, distActual, lastPointEntered);
+		if (aux != null)
+		{
+			snapPoint = aux;
+			minDist = snapPoint.distance(queryPoint);
+			distActual = minDist;
+			// snapper.setSnapPoint(snapPoint);
+		}
+
+	}
+
+
+	public Point2D getSnapPoint()
+	{
+
+		return snapPoint;
+	}
+
+//	public double getMinDist() {
+//		return minDist;
+//	}
+
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/GeometriesSnappingVisitor.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/GeometriesSnappingVisitor.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/snapping/GeometriesSnappingVisitor.java	(revision 38283)
@@ -0,0 +1,67 @@
+package org.gvsig.fmap.mapcontrol.tools.snapping;
+
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+
+import org.gvsig.fmap.geom.operation.tojts.ToJTS;
+import org.gvsig.fmap.mapcontrol.tools.snapping.snappers.ISnapperGeometriesVectorial;
+import org.gvsig.fmap.mapcontrol.tools.snapping.snappers.ISnapperVectorial;
+
+import com.vividsolutions.jts.geom.Coordinate;
+import com.vividsolutions.jts.geom.Geometry;
+import com.vividsolutions.jts.geom.GeometryFactory;
+import com.vividsolutions.jts.index.ItemVisitor;
+
+
+/**
+ * SnappingVisitor with geometries.
+ *
+ * @author Vicente Caballero Navarro
+ */
+public class GeometriesSnappingVisitor extends SnappingVisitor
+    implements ItemVisitor {
+    private ArrayList geometries = new ArrayList();
+    private GeometryFactory geometryFactory = new GeometryFactory();
+
+    public GeometriesSnappingVisitor(ISnapperVectorial snapper, Point2D point,
+        double mapTolerance, Point2D lastPointEntered) {
+        super(snapper, point, mapTolerance, lastPointEntered);
+    }
+
+    public void visitItem(Object item) {
+        try {
+	    	org.gvsig.fmap.geom.Geometry geom = (org.gvsig.fmap.geom.Geometry) item;
+
+	    	Geometry geometry = (Geometry)geom.invokeOperation(ToJTS.CODE,null);//toJTSGeometry();
+	        double distance = geometry.distance(geometryFactory.createPoint(
+	                    new Coordinate(queryPoint.getX(), queryPoint.getY())));
+
+	        if (distance < tolerance) {
+	            geometries.add(geom);
+	        }
+        }catch (Exception e) {
+		}
+    }
+
+    public Point2D getSnapPoint() {
+        if (geometries.isEmpty()) {
+            return null;
+        }
+
+        org.gvsig.fmap.geom.Geometry[] geoms = (org.gvsig.fmap.geom.Geometry[]) geometries.toArray(new Geometry[0]);
+//        ((ISnapperGeometriesVectorial) snapper).setGeometries(geoms);
+
+        Point2D result = null;
+
+        for (int i = 0; i < geoms.length; i++) {
+            result = snapper.getSnapPoint(queryPoint, geoms[i], tolerance,
+                    lastPointEntered);
+
+            if (result != null) {
+                return result;
+            }
+        }
+
+        return result;
+    }
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/AreaListenerImpl.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/AreaListenerImpl.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/AreaListenerImpl.java	(revision 38283)
@@ -0,0 +1,285 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools;
+
+import java.awt.Cursor;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.Toolkit;
+import java.awt.geom.Point2D;
+
+import javax.swing.ImageIcon;
+
+import org.cresques.cts.IProjection;
+import org.gvsig.fmap.crs.CRSFactory;
+import org.gvsig.fmap.mapcontext.MapContext;
+import org.gvsig.fmap.mapcontext.ViewPort;
+import org.gvsig.fmap.mapcontrol.MapControl;
+import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.PolylineListener;
+import org.gvsig.fmap.mapcontrol.tools.geo.Geo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+
+/**
+ * <p>Listener for calculating the area of a polygon, defined in the associated {@link MapControl MapControl}
+ *  object.</p>
+ *
+ * <p>If the view port of the associated <code>MapControl</code> isn't projected gets the area according the
+ *  geographical coordinates.</p>
+ *
+ * @author Vicente Caballero Navarro
+ */
+public class AreaListenerImpl implements PolylineListener {
+	private static final Logger logger = LoggerFactory.getLogger(AreaListenerImpl.class);
+
+	/**
+	 * The image to display when the cursor is active.
+	 */
+	private final Image iarea = new ImageIcon(MapControl.class.getClassLoader().getResource(
+				"org/gvsig/fmap/mapcontrol/images/AreaCursor.gif")).getImage();
+	
+	/**
+	 * Reference to the <code>MapControl</code> object that uses.
+	 */
+	protected MapControl mapCtrl;
+
+	/**
+	 * Information about all vertexes and {@link GeneralPathX GeneralPathX}s of the polyline.
+	 */
+	protected MeasureEvent event;
+
+	/**
+ 	 * <p>Creates a new listener for calculating the area of a polygon.</p>
+	 *
+	 * @param mc the <code>MapControl</code> where is calculated the area
+	 */
+	public AreaListenerImpl(MapControl mc) {
+		this.mapCtrl = mc;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#points(com.iver.cit.gvsig.fmap.tools.Events.MeasureEvent)
+	 */
+	public void points(MeasureEvent event) {
+		this.event = event;
+
+		double dist = 0;
+		double distAll = 0;
+
+		ViewPort vp = mapCtrl.getMapContext().getViewPort();
+
+		for (int i = 0; i < (event.getXs().length - 1); i++) {
+			dist = 0;
+
+			Point p = new Point(event.getXs()[i].intValue(),
+					event.getXs()[i].intValue());
+			Point p2 = new Point(event.getXs()[i + 1].intValue(),
+					event.getXs()[i + 1].intValue());
+
+			///dist = vp.toMapDistance((int) p.distance(p2));
+			dist = vp.distanceWorld(p, p2);
+			distAll += dist;
+		}
+		
+		logger.debug("Perimetro = {}, Area = {}.", 
+			distAll,
+			returnArea(vp.toMapPoint(
+					new Point2D.Double(
+						event.getXs()[event.getXs().length - 2].doubleValue(),
+						event.getYs()[event.getYs().length - 2].doubleValue()
+					)
+				)
+			)
+		);
+
+	}
+
+	/**
+	 * <p>Returns the area of the polygon, using {@link #returnCoordsArea(Double[], Double[], Point2D) returnCoordsArea}
+	 *  if the <code>ViewPort</code> of the associated <code>MapControl</code> is projected, or using
+	 *  {@link #returnGeoCArea(Double[], Double[], Point2D) returnGeoCArea} if isn't.</p>
+	 *
+	 * @param point unused parameter
+	 *
+	 * @return area from the vertexes stored at the measure event in real coordinates, or, if the <code>MapControl</code>
+	 *  isn't projected, in geographical coordinates
+	 *
+	 * @see #returnCoordsArea(Double[], Double[], Point2D)
+	 * @see #returnGeoCArea(Double[], Double[], Point2D)
+	 */
+	protected double returnArea(Point2D point) {
+		Double[] xs=event.getXs();
+		Double[] ys=event.getYs();
+		if (mapCtrl.getProjection().isProjected()) {
+			return returnCoordsArea(xs,ys,point);
+		}
+		return returnGeoCArea(xs,ys,point);
+	}
+
+	/**
+	 * <p>Returns the area of the polygon using <i>point</i> as initial, in
+	 *  real values with the current measure unit, according the projection in the <code>ViewPort</code>
+	 *  of the <code>MapControl</code>.</p>
+	 *
+	 * @param xs abscissa coordinate of all vertexes of the polygon
+	 * @param ys ordinate coordinate of all vertexes of the polygon
+	 * @param point point 2D used as first vertex in the calculation of the area
+	 *
+	 * @return the area of the polygon
+	 */
+	public double returnCoordsArea(Double[] xs,Double[] ys, Point2D point) {
+		Point2D aux=point;
+		double elArea = 0.0;
+		Point2D pPixel;
+		Point2D p = new Point2D.Double();
+		Point2D.Double pAnt = new Point2D.Double();
+		ViewPort vp = mapCtrl.getMapContext().getViewPort();
+		for (int pos = 0; pos < xs.length-1; pos++) {
+			pPixel = new Point2D.Double(xs[pos].doubleValue(),
+					ys[pos].doubleValue());
+			p = pPixel;//vp.toMapPoint(pPixel);
+			if (pos == 0) {
+				pAnt.x = aux.getX();
+				pAnt.y = aux.getY();
+			}
+			elArea = elArea + ((pAnt.x - p.getX()) * (pAnt.y + p.getY()));
+			pAnt.setLocation(p);
+		}
+
+		elArea = elArea + ((pAnt.x - aux.getX()) * (pAnt.y + aux.getY()));
+		elArea = Math.abs(elArea / 2.0);
+		return (elArea*(Math.pow(MapContext.getDistanceTrans2Meter()[vp.getMapUnits()],2)));
+	}
+	public static void main(String[] args) {
+		IProjection projectionUTM = CRSFactory.getCRS("EPSG:23030");
+		ViewPort vpUTM = new ViewPort(projectionUTM);
+		MapControl mcUTM=new MapControl();
+		mcUTM.setMapContext(new MapContext(vpUTM));
+		AreaListenerImpl areaListenerUTM=new AreaListenerImpl(mcUTM);
+		IProjection projectionGeo = CRSFactory.getCRS("EPSG:4230");
+		ViewPort vpGeo = new ViewPort(projectionGeo);
+		MapControl mcGeo=new MapControl();
+		mcGeo.setMapContext(new MapContext(vpGeo));
+		AreaListenerImpl areaListenerGeo=new AreaListenerImpl(mcGeo);
+
+		Double[] xsUTMCaseta=new Double[] {new Double(547508.77),new Double(547517.73),new Double(547512.65)};
+		Double[] ysUTMCaseta=new Double[] {new Double(4704333.97),new Double(4704331.3),new Double(4704315.2)};
+		double areaUTMCaseta=areaListenerUTM.returnCoordsArea(xsUTMCaseta,ysUTMCaseta,new Point2D.Double(547512.65,4704315.2));
+		Double[] xsGeoCaseta=new Double[] {new Double(-2.42192383),new Double(-2.42181545),new Double(-2.42187771)};
+		Double[] ysGeoCaseta=new Double[] {new Double(42.48914909),new Double(42.48912295),new Double(42.48897922)};
+		double areaGeoCCaseta=areaListenerGeo.returnGeoCArea(xsGeoCaseta,ysGeoCaseta,new Point2D.Double(-2.42187771,42.48897922));
+
+		System.out.println("AreaUTMCaseta = "+ areaUTMCaseta);
+		System.out.println("AreaGeoCCaseta = "+ areaGeoCCaseta);
+
+
+		Double[] xsUTM=new Double[] {new Double(731292),new Double(731901),new Double(730138)};
+		Double[] ysUTM=new Double[] {new Double(4351223),new Double(4350768),new Double(4349232)};
+		double areaUTM=areaListenerUTM.returnCoordsArea(xsUTM,ysUTM,new Point2D.Double(730138,4349232));
+		Double[] xsGeo=new Double[] {new Double(-0.31888183),new Double(-0.31173131),new Double(-0.33268401)};
+		Double[] ysGeo=new Double[] {new Double(39.27871741),new Double(39.27464327),new Double(39.26117368)};
+		double areaGeoC=areaListenerGeo.returnGeoCArea(xsGeo,ysGeo,new Point2D.Double(-0.33268401,39.26117368));
+
+		System.out.println("AreaUTM = "+ areaUTM);
+		System.out.println("AreaGeoC = "+ areaGeoC);
+
+		Double[] xsUTMspain=new Double[] {new Double(-12806),new Double(1025790),new Double(-31353.14)};
+		Double[] ysUTMspain=new Double[] {new Double(4793276.43),new Double(4719090.94),new Double(4125607.02)};
+		double areaUTMspain=areaListenerUTM.returnCoordsArea(xsUTMspain,ysUTMspain,new Point2D.Double(730138,4349232));
+		Double[] xsGeospain=new Double[] {new Double(-9.22743872),new Double(3.33087936),new Double(-9.01458587),new Double(-9.22743872)};
+		Double[] ysGeospain=new Double[] {new Double(43.02384666),new Double(42.38528811),new Double(37.06396689),new Double(43.02384666)};
+		double areaGeospainC=areaListenerGeo.returnGeoCArea(xsGeospain,ysGeospain,new Point2D.Double(-9.01458587,37.06396689));
+
+		System.out.println("AreaUTMSpain = "+ areaUTMspain);
+		System.out.println("AreaGeoSpainC = "+ areaGeospainC);
+	}
+
+	/**
+	 * <p>Returns the area in geographical coordinates of the polygon, according the
+	 *  <a href="http://en.wikipedia.org/wiki/Haversine_formula">Haversine function</a>.</p>
+	 *
+	 * @see Geo#sphericalPolyArea(double[], double[], int)
+	 */
+	public double returnGeoCArea(Double[] xs, Double[] ys, Point2D point) {
+		double[] lat = new double[xs.length];
+		double[] lon = new double[xs.length];
+		for (int K = 0; K < xs.length; K++) {
+			lon[K] = xs[K].doubleValue() / Geo.Degree;
+			lat[K] = ys[K].doubleValue() / Geo.Degree;
+		}
+		return (Geo.sphericalPolyArea(lat, lon, xs.length - 1) * Geo.SqM);// /1.29132441;//Esto
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getImageCursor()
+	 */
+	public Image getImageCursor() {
+		return iarea;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#pointFixed(com.iver.cit.gvsig.fmap.tools.Events.MeasureEvent)
+	 */
+	public void pointFixed(MeasureEvent event) {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#polylineFinished(com.iver.cit.gvsig.fmap.tools.Events.MeasureEvent)
+	 */
+	public void polylineFinished(MeasureEvent event) {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
+	 */
+	public boolean cancelDrawing() {
+		return false;
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/PolygonSelectionListener.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/PolygonSelectionListener.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/PolygonSelectionListener.java	(revision 38283)
@@ -0,0 +1,176 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools;
+
+import java.awt.Image;
+
+import javax.swing.ImageIcon;
+
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.feature.FeatureSelection;
+import org.gvsig.fmap.dal.feature.FeatureSet;
+import org.gvsig.fmap.dal.feature.exception.CreateGeometryException;
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.GeometryLocator;
+import org.gvsig.fmap.geom.GeometryManager;
+import org.gvsig.fmap.geom.Geometry.SUBTYPES;
+import org.gvsig.fmap.geom.Geometry.TYPES;
+import org.gvsig.fmap.geom.primitive.GeneralPathX;
+import org.gvsig.fmap.geom.primitive.Surface;
+import org.gvsig.fmap.mapcontext.layers.FLayer;
+import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
+import org.gvsig.fmap.mapcontrol.MapControl;
+import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.PolylineListener;
+import org.gvsig.tools.dispose.DisposeUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * <p>Listener that selects all features of the active and vector layers which intersect with the defined
+ *  polygon area in the associated {@link MapControl MapControl} object.</p>
+ *
+ * <p>The selection will be produced after user finishes the creation of the polyline.</p>
+ *
+ * @author Vicente Caballero Navarro
+ */
+public class PolygonSelectionListener implements PolylineListener {
+	private static final GeometryManager geomManager = GeometryLocator.getGeometryManager();
+	private static final Logger logger = LoggerFactory.getLogger(PolygonSelectionListener.class);
+	/**
+	 * The image to display when the cursor is active.
+	 */
+	private final Image img = new ImageIcon(MapControl.class.getClassLoader().getResource(
+				"org/gvsig/fmap/mapcontrol/images/PoligonCursor.png")).getImage();
+	
+	/**
+	 * The cursor used to work with this tool listener.
+	 *
+	 * @see #getCursor()
+	 */
+	private MapControl mapCtrl;
+
+	/**
+ 	 * <p>Creates a new <code>PolygonSelectionListener</code> object.</p>
+	 *
+	 * @param mc the <code>MapControl</code> where is drawn the polyline
+	 */
+	public PolygonSelectionListener(MapControl mc) {
+		this.mapCtrl = mc;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getImageCursor()
+	 */
+	public Image getImageCursor() {
+		return img;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
+	 */
+	public boolean cancelDrawing() {
+		return false;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#points(com.iver.cit.gvsig.fmap.tools.Events.MeasureEvent)
+	 */
+	public void points(MeasureEvent event) throws BehaviorException {
+		// TODO Auto-generated method stub
+
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#points(com.iver.cit.gvsig.fmap.tools.Events.MeasureEvent)
+	 */
+	public void pointFixed(MeasureEvent event) throws BehaviorException {
+		// TODO Auto-generated method stub
+
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#polylineFinished(com.iver.cit.gvsig.fmap.tools.Events.MeasureEvent)
+	 */
+	public void polylineFinished(MeasureEvent event) throws BehaviorException {
+		try {
+			GeometryManager geomManager = GeometryLocator.getGeometryManager();
+
+            GeneralPathX gp = event.getGP();
+            Surface geom = (Surface)geomManager.create(TYPES.SURFACE, SUBTYPES.GEOM2D);
+            geom.setGeneralPath(gp);           
+            FLayer[] actives = mapCtrl.getMapContext()
+                .getLayers().getActives();
+            for (int i=0; i < actives.length; i++)
+            {
+                if (actives[i] instanceof FLyrVect) {
+                    FLyrVect lyrVect = (FLyrVect) actives[i];
+                    FeatureSelection oldSelection = (FeatureSelection)lyrVect.getFeatureStore().getSelection();
+					FeatureSet newSelection = null;
+					try {
+						newSelection =
+								lyrVect.queryByGeometry(geom,
+										lyrVect.getFeatureStore()
+												.getDefaultFeatureType());
+						if (event.getEvent().isControlDown()) {
+							oldSelection.select(newSelection);
+						} else {
+							lyrVect.getDataStore().setSelection(newSelection);
+						}
+					} finally {
+						DisposeUtils.dispose(newSelection);
+                    }
+                }
+            }
+
+		} catch (DataException e) {
+			throw new BehaviorException("No se pudo hacer la selección", e);
+		} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
+			throw new BehaviorException("No se pudo hacer la selección", 
+					new CreateGeometryException(TYPES.SURFACE, SUBTYPES.GEOM2D, e));
+		}
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/ZoomInListenerImpl.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/ZoomInListenerImpl.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/ZoomInListenerImpl.java	(revision 38283)
@@ -0,0 +1,188 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools;
+
+import java.awt.Image;
+import java.awt.geom.Rectangle2D;
+import java.net.URL;
+
+import javax.swing.ImageIcon;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.gvsig.fmap.geom.Geometry.SUBTYPES;
+import org.gvsig.fmap.geom.GeometryLocator;
+import org.gvsig.fmap.geom.GeometryManager;
+import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
+import org.gvsig.fmap.geom.primitive.Envelope;
+import org.gvsig.fmap.mapcontext.MapContext;
+import org.gvsig.fmap.mapcontext.ViewPort;
+import org.gvsig.fmap.mapcontrol.MapControl;
+import org.gvsig.fmap.mapcontrol.tools.Events.EnvelopeEvent;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.RectangleListener;
+
+
+
+/**
+ * <p>Listener for doing a <i>zoom in</i> operation of the extent of the <code>ViewPort</code> of the associated {@link MapControl MapControl}
+ *  object, defining a rectangular area.</p>
+ *
+ * <p>If the area defined is smaller than 3 pixels x 3 pixels holds the zoom, otherwise, calculates the new extent <i>r</i>
+ *  with this equations:
+ *  <code><br>
+ *   double factor = 1/MapContext.ZOOMINFACTOR;<br>
+ *	 Rectangle2D rect = event.getWorldCoordRect();<br>
+ *   Rectangle2D.Double r = new Rectangle2D.Double();<br>
+ *   ViewPort vp = mapCtrl.getMapContext().getViewPort();<br>
+ *   double nuevoX = rect.getMaxX() - ((vp.getExtent().getWidth() * factor) / 2.0);<br>
+ *   double nuevoY = rect.getMaxY() - ((vp.getExtent().getHeight() * factor) / 2.0);<br>
+ *   Rectangle2D.Double r; // This will be the new extent<br>
+ *   r.x = nuevoX;<br>
+ *   r.y = nuevoY;<br>
+ *   r.width = vp.getExtent().getWidth() * factor;<br>
+ *   r.height = vp.getExtent().getHeight() * factor;<br>
+ *   vp.setExtent(r);
+ *  </code>
+ * </p>
+ *
+ * <p>The ultimately extent will be an adaptation from that, calculated by the <code>ViewPort</code>
+ *  bearing in mind the ratio of the available rectangle where display the graphical information.</p>
+ *
+ * @see MapContext#ZOOMINFACTOR
+ * @see ViewPort#setEnvelope(Envelope)
+ * @see ZoomOutListenerImpl
+ * @see ZoomOutRightButtonListener
+ *
+ * @author Vicente Caballero Navarro
+ */
+public class ZoomInListenerImpl implements RectangleListener {
+	private static final GeometryManager geomManager = GeometryLocator.getGeometryManager();
+	private static final Logger logger = LoggerFactory.getLogger(ZoomInListenerImpl.class);
+	
+	/**
+	 * The image to display when the cursor is active.
+	 */
+	private final Image izoomin;
+
+	/**
+	 * Reference to the <code>MapControl</code> object that uses.
+	 */
+	private MapControl mapCtrl;
+
+
+    /**
+     * 
+     */
+    public ZoomInListenerImpl() {
+        URL res = MapControl.class.getClassLoader().getResource("org/gvsig/fmap/mapcontrol/images/ZoomInCursor.gif");
+        if( res == null ) {
+            this.izoomin = new ImageIcon().getImage();
+            logger.error("Can't load icon 'org/gvsig/fmap/mapcontrol/images/ZoomInCursor.gif'");
+        } else {
+            this.izoomin = new ImageIcon(res).getImage();
+        }
+    }
+
+    /**
+ 	 * <p>Creates a new <code>ZoomInListenerImpl</code> object.</p>
+	 *
+	 * @param mapCtrl the <code>MapControl</code> where is defined the rectangle
+	 */
+	public ZoomInListenerImpl(MapControl mapCtrl) {
+	    this();
+		this.mapCtrl = mapCtrl;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.RectangleListener#rectangle(com.iver.cit.gvsig.fmap.tools.Events.RectangleEvent)
+	 */
+	public void rectangle(EnvelopeEvent event) {
+		Envelope rect = event.getWorldCoordRect();
+		Rectangle2D pixelRect = event.getPixelCoordRect();
+
+
+		ViewPort vp = mapCtrl.getMapContext().getViewPort();
+
+		if ((pixelRect.getWidth() < 3) && (pixelRect.getHeight() < 3))
+		{
+			if (vp.getExtent()!=null){
+				double factor = 1/MapContext.ZOOMINFACTOR;
+				double x = rect.getMaximum(0) -
+					((vp.getExtent().getWidth() * factor) / 2.0);
+				double y = rect.getMaximum(1) -
+					((vp.getExtent().getHeight() * factor) / 2.0);
+				double width = vp.getExtent().getWidth() * factor;
+				double height = vp.getExtent().getHeight() * factor;
+				Envelope r;
+				try {
+					r = geomManager.createEnvelope(x, y, x + width, y + height, SUBTYPES.GEOM2D);
+					vp.setEnvelope(r);
+				} catch (CreateEnvelopeException e) {
+					logger.error("Error creating the envelope", e);
+				}
+				
+			}
+		}
+		else
+		{
+		    vp.setEnvelope(event.getWorldCoordRect());
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getImageCursor()
+	 */
+	public Image getImageCursor() {
+		return izoomin;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
+	 */
+	public boolean cancelDrawing() {
+	    logger.debug("cancelDrawing true");
+		return true;
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/CompoundBehavior.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/CompoundBehavior.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/CompoundBehavior.java	(revision 38283)
@@ -0,0 +1,367 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools;
+
+import java.awt.Image;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
+import java.util.ArrayList;
+
+import org.gvsig.fmap.mapcontrol.MapControl;
+import org.gvsig.fmap.mapcontrol.MapControlDrawer;
+import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
+
+
+
+/**
+ * <p>Allows having multiple behaviors when user works with the associated
+ *  <code>MapControl</code>. Each one with its associated tool listener.</p>
+ *
+ * @author Fernando González Cortés
+ * @author Pablo Piqueras Bartolomé
+ */
+public class CompoundBehavior extends Behavior {
+	/**
+	 * List of all behaviors that compound this one.
+	 */
+	private ArrayList behaviors = new ArrayList(); //<Behavior>
+
+	/**
+	 * List that determines which behaviors of this one will be real-time painted.
+	 */
+	private ArrayList draws = new ArrayList(); //<Boolean>
+
+	/**
+	 * Static <code>behavior</code> that will be used for any <code>MapControl</code>.</p>
+	 */
+	private static Behavior behavior = null;
+
+	/**
+ 	 * <p>Creates a new behavior as a composition of others.</p>
+ 	 *
+	 * @param tools atomic behaviors that will compound this one</code>
+	 */
+	public CompoundBehavior(Behavior[] behaviors){
+		for (int i = 0; i < behaviors.length; i++) {
+			this.behaviors.add(behaviors[i]);
+
+			if (i == 0)
+				draws.add(Boolean.TRUE);
+			else
+				draws.add(Boolean.FALSE);
+		}
+	}
+
+	/**
+	 * <p>Adds a new behavior, setting if will be real-time (when user is working with it) drawn or not.</p>
+	 *
+	 * <p>When user works with a compound behavior, he/she will see on real-time the graphical changes produced at
+	 *  the associated <code>MapControl</code>, only by those which have their associated <i>draw</i> flag to <code>true</code>.</p>
+	 *
+	 * @param mt the new behavior
+	 * @param draw flag determining if will be real-time drawn or no
+	 */
+	public void addMapBehavior(Behavior mt, boolean draw){
+		behaviors.add(mt);
+		draws.add(new Boolean(draw));
+	}
+
+	/**
+	 * <p>Removes a <code>Behavior</code> that composes this one.</p>
+	 *
+	 * @param mt the <code>Behavior</code> to be removed
+	 */
+	public void removeMapBehavior(Behavior mt){
+		int index = behaviors.indexOf(mt);
+
+		if (index >= 0) {
+			behaviors.remove(index);
+			draws.remove(index);
+		}
+	}
+	/**
+	 * <p>Searches for <code>mt</code>, returning <code>true</code> if is contained.</p>
+	 *
+	 * @param mt the behavior to search
+	 *
+	 * @return <code>true</code> if is contained; otherwise <code>false</code>
+	 */
+	public boolean containsBehavior(Behavior mt) {
+		return behaviors.indexOf(mt) > -1;
+	}
+
+	/**
+	 * <p>Returns the first-level {@link Behavior Behavior} at the specified position.</p>
+	 *
+	 * @param index index of element to return
+	 *
+	 * @return the element at the specified position.
+	 */
+	public Behavior getBehavior(int index) {
+		return (Behavior)behaviors.get(index);
+	}
+
+	/**
+	 * <p>Returns if it's invoked the method <code>public void paintComponent(Graphics g)</code> of the
+	 *  first-level {@link Behavior Behavior} at the specified position, each time is painted this component.</p>
+	 *
+	 * @param index index of element
+	 *
+	 * @return <code>true</code>  if it's invoked the method <code>public void paintComponent(Graphics g)</code> of the
+	 *   first-level {@link Behavior Behavior} at the specified position, each time is painted this component, otherwise
+	 *   <code>false</code>.
+	 */
+	public boolean isDrawnBehavior(int index) {
+		return ((Boolean)draws.get(index)).booleanValue();
+	}
+
+	/**
+	 * <p>Sets if will be invoked the method <code>public void paintComponent(Graphics g)</code> of the
+	 *  first-level {@link Behavior Behavior} at the specified position, each time is painted this component.</p>
+	 *
+	 * @param index index of element
+	 * @param <code>true</code> if will be invoked the method <code>public void paintComponent(Graphics g)</code> of the
+	 *   first-level {@link Behavior Behavior} at the specified position, each time is painted this component, otherwise
+	 *   <code>false</code>.
+	 */
+	public void setDrawnBehavior(int index, boolean draw) {
+		draws.set(index, new Boolean(draw));
+	}
+
+	/**
+	 * <p>Returns the number of first-level {@link Behavior Behavior}s in this <code>CompoundBehavior</code>.</p>
+	 *
+	 * @return the number of first-level {@link Behavior Behavior}s in this <code>CompoundBehavior</code>
+	 */
+	public int size() {
+		return behaviors.size();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#getCursor()
+	 */
+	public Image getImageCursor() {
+		if (behaviors.size() > 0) {
+			return ((Behavior) behaviors.get(0)).getImageCursor();
+		} else {
+			return null;
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseClicked(java.awt.event.MouseEvent)
+	 */
+	public void mouseClicked(MouseEvent e) throws BehaviorException {
+		Behavior[] behaviors=(Behavior[])this.behaviors.toArray(new Behavior[0]);
+		for (int i=0;i<behaviors.length;i++ ) {
+			behaviors[i].mouseClicked(e);
+		}
+
+		if(behavior != null)
+			behavior.mouseClicked(e);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseDragged(java.awt.event.MouseEvent)
+	 */
+	public void mouseDragged(MouseEvent e) throws BehaviorException {
+		Behavior[] behaviors=(Behavior[])this.behaviors.toArray(new Behavior[0]);
+		for (int i=0;i<behaviors.length;i++ ) {
+			behaviors[i].mouseDragged(e);
+		}
+
+		if(behavior != null)
+			behavior.mouseDragged(e);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseEntered(java.awt.event.MouseEvent)
+	 */
+	public void mouseEntered(MouseEvent e) throws BehaviorException {
+		Behavior[] behaviors=(Behavior[])this.behaviors.toArray(new Behavior[0]);
+		for (int i=0;i<behaviors.length;i++ ) {
+			behaviors[i].mouseEntered(e);
+		}
+
+		if(behavior != null)
+			behavior.mouseEntered(e);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseExited(java.awt.event.MouseEvent)
+	 */
+	public void mouseExited(MouseEvent e) throws BehaviorException {
+		Behavior[] behaviors=(Behavior[])this.behaviors.toArray(new Behavior[0]);
+		for (int i=0;i<behaviors.length;i++ ) {
+			behaviors[i].mouseExited(e);
+		}
+
+		if(behavior != null)
+			behavior.mouseExited(e);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseMoved(java.awt.event.MouseEvent)
+	 */
+	public void mouseMoved(MouseEvent e) throws BehaviorException {
+		Behavior[] behaviors=(Behavior[])this.behaviors.toArray(new Behavior[0]);
+		for (int i=0;i<behaviors.length;i++ ) {
+			behaviors[i].mouseMoved(e);
+		}
+
+		if(behavior != null)
+			behavior.mouseMoved(e);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mousePressed(java.awt.event.MouseEvent)
+	 */
+	public void mousePressed(MouseEvent e) throws BehaviorException {
+		Behavior[] behaviors=(Behavior[])this.behaviors.toArray(new Behavior[0]);
+		for (int i=0;i<behaviors.length;i++ ) {
+			behaviors[i].mousePressed(e);
+		}
+
+		if(behavior != null)
+			behavior.mousePressed(e);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseReleased(java.awt.event.MouseEvent)
+	 */
+	public void mouseReleased(MouseEvent e) throws BehaviorException {
+		Behavior[] behaviors=(Behavior[])this.behaviors.toArray(new Behavior[0]);
+		for (int i=0;i<behaviors.length;i++ ) {
+			behaviors[i].mouseReleased(e);
+		}
+
+		if(behavior != null)
+			behavior.mouseReleased(e);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseWheelMoved(java.awt.event.MouseWheelEvent)
+	 */
+	public void mouseWheelMoved(MouseWheelEvent e) throws BehaviorException {
+		Behavior[] behaviors=(Behavior[])this.behaviors.toArray(new Behavior[0]);
+		for (int i=0;i<behaviors.length;i++ ) {
+			behaviors[i].mouseWheelMoved(e);
+		}
+
+		if(behavior != null)
+			behavior.mouseWheelMoved(e);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#paintComponent(java.awt.Graphics)
+	 */
+	public void paintComponent(MapControlDrawer renderer) {
+		for (int i = 0; i < behaviors.size(); i++) {
+			Behavior mapTool = (Behavior) behaviors.get(i);
+
+			if (((Boolean) draws.get(i)).booleanValue())
+				mapTool.paintComponent(renderer);
+		}
+	}
+
+	/**
+	 * Sets a tool listener to work with a <code>MapControl</code> instance using these behaviors.
+	 *
+	 * @param listener a <code>RectangleListener</code> object for this behavior
+	 */
+	public void setListener(ToolListener listener) {
+		if (listener != null) {
+			throw new RuntimeException(
+				"CompoundBehavior does not have listeners");
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#getListener()
+	 */
+	public ToolListener getListener() {
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#setMapControl(com.iver.cit.gvsig.fmap.MapControl)
+	 */
+	public void setMapControl(MapControl mc) {
+		Behavior[] behaviors=(Behavior[])this.behaviors.toArray(new Behavior[0]);
+		for (int i=0;i<behaviors.length;i++ ) {
+			behaviors[i].setMapControl(mc);
+		}
+
+		super.setMapControl(mc);
+	}
+
+	/**
+	 * <p>Sets the <code>Behavior</code> that will be used for any <code>MapControl</code>.</p>
+	 *
+	 * @param behavior the multi-view <code>Behavior</code>
+	 */
+	public static void setAllControlsBehavior(Behavior behavior) {
+		CompoundBehavior.behavior = behavior;
+	}
+
+	/**
+	 * <p>Gets the <code>Behavior</code> that will be used for any <code>MapControl</code>.</p>
+	 *
+	 * @return the multi-view <code>Behavior</code>
+	 */
+	public static Behavior getAllControlsBehavior() {
+		return CompoundBehavior.behavior;
+	}
+}
+
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/ZoomOutListenerImpl.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/ZoomOutListenerImpl.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/ZoomOutListenerImpl.java	(revision 38283)
@@ -0,0 +1,170 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools;
+
+import java.awt.Image;
+import java.awt.geom.Point2D;
+
+import javax.swing.ImageIcon;
+
+import org.gvsig.fmap.geom.GeometryLocator;
+import org.gvsig.fmap.geom.GeometryManager;
+import org.gvsig.fmap.geom.Geometry.SUBTYPES;
+import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
+import org.gvsig.fmap.geom.primitive.Envelope;
+import org.gvsig.fmap.geom.util.UtilFunctions;
+import org.gvsig.fmap.mapcontext.MapContext;
+import org.gvsig.fmap.mapcontext.ViewPort;
+import org.gvsig.fmap.mapcontrol.MapControl;
+import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.PointListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+/**
+ * <p>Listener for doing a <i>zoom out</i> operation on the extent of the <code>ViewPort</code> of the associated {@link MapControl MapControl}
+ *  object, selecting a point of the <code>MapControl</code> by a single click of any mouse's button.</p>
+ *
+ * <p>Calculates the new extent <i>r</i> with this equations:
+ *  <code><br>
+ *   ViewPort vp = mapControl.getMapContext().getViewPort();<br>
+ *   Point2D p2 = vp.toMapPoint(event.getPoint());<br>
+ *   double factor = 1/MapContext.ZOOMOUTFACTOR;<br>
+ *   Rectangle2D.Double r = new Rectangle2D.Double();<br>
+ *   double nuevoX = p2.getX() - ((vp.getExtent().getWidth() * factor) / 2.0);<br>
+ *   double nuevoY = p2.getY() - ((vp.getExtent().getHeight() * factor) / 2.0);<br>
+ *   r.x = nuevoX;<br>
+ *   r.y = nuevoY;<br>
+ *   r.width = vp.getExtent().getWidth() * factor;<br>
+ *   r.height = vp.getExtent().getHeight() * factor;<br>
+ *   vp.setExtent(r);
+ *  </code>
+ * </p>
+ *
+ * <p>The ultimately extent will be an adaptation from that, calculated by the <code>ViewPort</code>
+ *  bearing in mind the ratio of the available rectangle.</p>
+ *
+ * @see MapContext#ZOOMOUTFACTOR
+ * @see ViewPort#setEnvelope(Envelope)
+ * @see ZoomInListenerImpl
+ * @see ZoomOutRightButtonListener
+ *
+ * @author Vicente Caballero Navarro
+ */
+public class ZoomOutListenerImpl implements PointListener {
+	private static final GeometryManager geomManager = GeometryLocator.getGeometryManager();
+	private static final Logger logger = LoggerFactory.getLogger(ZoomOutListenerImpl.class);
+	
+	/**
+	 * The image to display when the cursor is active.
+	 */
+	private final Image izoomout = new ImageIcon(MapControl.class.getClassLoader().getResource(
+				"org/gvsig/fmap/mapcontrol/images/ZoomOutCursor.gif")).getImage();
+
+	/**
+	 * Reference to the <code>MapControl</code> object that uses.
+	 */
+	private MapControl mapControl;
+
+	/**
+	 * <p>Creates a new <code>ZoomOutListenerImpl</code> object.</p>
+	 *
+	 * @param mapControl the <code>MapControl</code> where will be applied the changes
+	 */
+	public ZoomOutListenerImpl(MapControl mapControl) {
+		this.mapControl = mapControl;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
+	 */
+	public void point(PointEvent event) {
+		ViewPort vp = mapControl.getMapContext().getViewPort();
+		Point2D p2 = vp.toMapPoint(event.getPoint());
+
+		double nuevoX;
+		double nuevoY;
+		double factor = 1/MapContext.ZOOMOUTFACTOR;
+
+		nuevoX = p2.getX() - ((vp.getExtent().getWidth() * factor) / 2.0);
+		nuevoY = p2.getY() - ((vp.getExtent().getHeight() * factor) / 2.0);
+		double x = nuevoX;
+		double y = nuevoY;
+		double width = vp.getExtent().getWidth() * factor;
+		double height = vp.getExtent().getHeight() * factor;
+
+		Envelope r;
+		try {
+			r = geomManager.createEnvelope(x,y, x+width, y+height, SUBTYPES.GEOM2D);
+			vp.setEnvelope(r);
+		} catch (CreateEnvelopeException e) {
+			logger.error("Error creating the envelope", e);
+		}		
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getImageCursor()
+	 */
+	public Image getImageCursor() {
+		return izoomout;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
+	 */
+	public boolean cancelDrawing() {
+	    logger.debug("cancelDrawing true");
+		return true;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#pointDoubleClick(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
+	 */
+	public void pointDoubleClick(PointEvent event) {
+		// TODO Auto-generated method stub
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/PointSelectionListener.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/PointSelectionListener.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/PointSelectionListener.java	(revision 38283)
@@ -0,0 +1,156 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools;
+
+import java.awt.Image;
+import java.awt.geom.Point2D;
+
+import javax.swing.ImageIcon;
+
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.feature.FeatureSelection;
+import org.gvsig.fmap.dal.feature.FeatureSet;
+import org.gvsig.fmap.mapcontext.layers.FLayer;
+import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
+import org.gvsig.fmap.mapcontrol.MapControl;
+import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.PointListener;
+
+/**
+ * <p>Listener that selects all features of the active, and vector layers of the associated <code>MapControl</code>
+ *  that their area intersects with the point selected by a single click of any button of the mouse.</p>
+ *
+ * @author Vicente Caballero Navarro
+ */
+public class PointSelectionListener implements PointListener {
+	/**
+	 * The image to display when the cursor is active.
+	 */
+	private final Image img = new ImageIcon(MapControl.class.getClassLoader().getResource(
+				"org/gvsig/fmap/mapcontrol/images/PointSelectCursor.gif")).getImage();
+
+	/**
+	 * Reference to the <code>MapControl</code> object that uses.
+	 */
+	protected MapControl mapCtrl;
+
+	/**
+	 * <p>Creates a new <code>PointSelectionListener</code> object.</p>
+	 *
+	 * @param mc the <code>MapControl</code> where will be applied the changes
+	 */
+	public PointSelectionListener(MapControl mc) {
+		this.mapCtrl = mc;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
+	 */
+	public void point(PointEvent event) throws BehaviorException {
+		try {
+			// mapCtrl.getMapContext().selectByPoint(event.getPoint(), 1);
+            Point2D p = event.getPoint();
+            Point2D mapPoint = mapCtrl.getViewPort().toMapPoint((int) p.getX(), (int) p.getY());
+
+            // Tolerancia de 3 pixels
+            double tol = mapCtrl.getViewPort().toMapDistance(3);
+            FLayer[] actives = mapCtrl.getMapContext()
+            .getLayers().getActives();
+            for (int i=0; i < actives.length; i++)
+            {
+                if (actives[i] instanceof FLyrVect) {
+                    FLyrVect lyrVect = (FLyrVect) actives[i];
+					FeatureSet newSelection = null;
+					try {
+						newSelection =
+								lyrVect.queryByPoint(mapPoint, tol,
+										lyrVect.getFeatureStore()
+												.getDefaultFeatureType());
+						if (event.getEvent().isControlDown()) {
+							((FeatureSelection) lyrVect.getDataStore()
+									.getSelection()).select(newSelection);
+						} else {
+							lyrVect.getFeatureStore()
+									.setSelection(newSelection);
+						}
+					} finally {
+						if (newSelection!=null){
+							newSelection.dispose();
+						}
+                    }
+
+
+                    mapCtrl.drawMap(false); // FIXME Esto debería sobrar (la capa debería de ser observada)
+                }
+            }
+
+		} catch (DataException e) {
+			throw new BehaviorException("No se pudo hacer la selección", e);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
+	 */
+	public Image getImageCursor() {
+		return img;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
+	 */
+	public boolean cancelDrawing() {
+		return false;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#pointDoubleClick(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
+	 */
+	public void pointDoubleClick(PointEvent event) throws BehaviorException {
+
+	}
+
+
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/grid/Grid.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/grid/Grid.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/grid/Grid.java	(revision 38283)
@@ -0,0 +1,201 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.grid;
+
+import java.awt.Color;
+import java.awt.geom.Point2D;
+
+import org.gvsig.fmap.geom.primitive.Envelope;
+import org.gvsig.fmap.mapcontext.ViewPort;
+import org.gvsig.fmap.mapcontrol.MapControlDrawer;
+
+
+/**
+ * Clase encargada de gestionar las diferentes operaciones que se realizan
+ * sobre el grid.
+ *
+ * @author Vicente Caballero Navarro
+ */
+public class Grid {
+	public static boolean DefaultShowGrid = false;
+	public static double DefaultGridSizeX = 1000;
+	public static double DefaultGridSizeY = 1000;
+	public static boolean DefaultAdjustGrid=false;
+
+	public static boolean SHOWGRID = false;
+	public static double GRIDSIZEX = 1000;
+	public static double GRIDSIZEY = 1000;
+	public static boolean ADJUSTGRID=false;
+
+	private boolean grid = SHOWGRID;
+	private double gridSizeX = GRIDSIZEX;
+	private double gridSizeY = GRIDSIZEY;
+	private ViewPort viewport=null;
+	private boolean adjustGrid=ADJUSTGRID;
+
+	/**
+	 * Inserta el viewPort.
+	 *
+	 * @param vp
+	 */
+	public void setViewPort(ViewPort vp) {
+		viewport = vp;
+
+//		if (gridSize == 0) {
+//			gridSize = viewport.toMapDistance(25);
+//		}
+	}
+
+	/**
+	 * Ajusta un punto de la imagen que se pasa como  parámetro al handler más
+	 * cercano si se encuentra lo suficientemente  cerca y devuelve la
+	 * distancia del punto original al punto ajustado
+	 *
+	 * @param point
+	 *
+	 * @return Distancia del punto que se pasa como parámetro al punto ajustado
+	 */
+	public double adjustToGrid(Point2D point) {
+		if (adjustGrid) {
+			Point2D auxp = new Point2D.Double(0, 0);
+			double x = ((point.getX() + gridSizeX) % gridSizeX) -
+				((auxp.getX()) % gridSizeX);
+			double y = ((point.getY() + gridSizeY) % gridSizeY) -
+				((auxp.getY()) % gridSizeY);
+			Point2D p = (Point2D) point.clone();
+			if (x>gridSizeX/2){
+				x=x-gridSizeX;
+			}
+			if (y>gridSizeY/2){
+				y=y-gridSizeY;
+			}
+			point.setLocation((point.getX() - x), (point.getY() - y));
+			return p.distance(point);
+		}
+		return Double.MAX_VALUE;
+	}
+
+	/**
+	 * Dibuja el grid sobre el graphics que se pasa como parámetro
+	 *
+	 * @param g Graphics sobre el que dibujar el grid.
+	 */
+	public void drawGrid(MapControlDrawer mapControlDrawer) {
+		if (!grid) {
+			return;
+		}
+		if (viewport.fromMapDistance(gridSizeX) > 3
+				&& viewport.fromMapDistance(gridSizeY) > 3) {
+			mapControlDrawer.setColor(Color.lightGray);
+
+			Envelope extent = viewport.getAdjustedExtent();
+			Point2D auxp = new Point2D.Double(0, 0);
+			if (extent==null)
+				return;
+			for (double i = extent.getMinimum(0); i < (extent.getMaximum(0) + gridSizeX); i += gridSizeX) {
+				for (double j = extent.getMinimum(0); j < (extent.getMaximum(1) + gridSizeY); j += gridSizeY) {
+					Point2D po = new Point2D.Double(i, j);
+					Point2D point = viewport.fromMapPoint(po);
+					double x = ((po.getX() + gridSizeX) % gridSizeX)
+							- ((auxp.getX()) % gridSizeX);
+					double y = ((po.getY() + gridSizeY) % gridSizeY)
+							- ((auxp.getY()) % gridSizeY);
+					x = (point.getX() - viewport.fromMapDistance(x));
+					y = (point.getY() + viewport.fromMapDistance(y));
+
+					mapControlDrawer.drawRect((int) x, (int) y, 1, 1);
+
+				}
+			}
+		}
+	}
+
+	/**
+	 * Inserta un boolean que indica si se utiliza o no el grid y de esta forma
+	 * dibujarse.
+	 *
+	 * @param b boolean
+	 */
+	public void setShowGrid(boolean b) {
+		grid = b;
+	}
+
+	/**
+	 * Devuelve true si se usa el grid.
+	 *
+	 * @return True si se usa el grid.
+	 */
+	public boolean isShowGrid() {
+		return grid;
+	}
+
+	/**
+	 * Inserta un boolean que indica si se ajusta o no al grid y de esta forma
+	 * dibujarse.
+	 *
+	 * @param b boolean
+	 */
+	public void setAdjustGrid(boolean b) {
+		adjustGrid = b;
+	}
+
+	/**
+	 * Devuelve true si se ha de ajustar al grid.
+	 *
+	 * @return True si se está ajustando al grid.
+	 */
+	public boolean isAdjustGrid() {
+		return adjustGrid;
+	}
+
+	public double getGridSizeX() {
+		return gridSizeX;
+	}
+	public double getGridSizeY() {
+		return gridSizeY;
+	}
+	public void setGridSizeX(double gridSize) {
+		this.gridSizeX = gridSize;
+	}
+	public void setGridSizeY(double gridSize) {
+		this.gridSizeY = gridSize;
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/PanListenerImpl.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/PanListenerImpl.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/PanListenerImpl.java	(revision 38283)
@@ -0,0 +1,137 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools;
+
+import java.awt.Image;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+import javax.swing.ImageIcon;
+
+import org.gvsig.fmap.geom.GeometryLocator;
+import org.gvsig.fmap.geom.GeometryManager;
+import org.gvsig.fmap.geom.Geometry.SUBTYPES;
+import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
+import org.gvsig.fmap.geom.primitive.Envelope;
+import org.gvsig.fmap.geom.util.UtilFunctions;
+import org.gvsig.fmap.mapcontext.ViewPort;
+import org.gvsig.fmap.mapcontrol.MapControl;
+import org.gvsig.fmap.mapcontrol.tools.Events.MoveEvent;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.PanListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+/**
+ * <p>Listener for moving the extent of the associated {@link MapControl MapControl} object
+ *  according the movement between the initial and final points of line determined by the movement
+ *  dragging with the third button of the mouse.</p>
+ *
+ * <p>Updates the extent of its <code>ViewPort</code> with the new position.</p>
+ *
+ * @author Vicente Caballero Navarro
+ */
+public class PanListenerImpl implements PanListener {
+	private static final GeometryManager geomManager = GeometryLocator.getGeometryManager();
+	private static final Logger logger = LoggerFactory.getLogger(PanListenerImpl.class);
+	/**
+	 * The image to display when the cursor is active.
+	 */
+	private final Image ipan = new ImageIcon(MapControl.class.getClassLoader().getResource(
+				"org/gvsig/fmap/mapcontrol/images/Hand.gif")).getImage();
+	
+	/**
+	 * Reference to the <code>MapControl</code> object that uses.
+	 */
+	private MapControl mapControl;
+
+	/**
+  	 * <p>Creates a new listener for changing the position of the extent of the associated {@link MapControl MapControl} object.</p>
+	 *
+	 * @param mapControl the <code>MapControl</code> where will be applied the changes
+	 */
+	public PanListenerImpl(MapControl mapControl) {
+		this.mapControl = mapControl;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PanListener#move(com.iver.cit.gvsig.fmap.tools.Events.MoveEvent)
+	 */
+	public void move(MoveEvent event) {
+		ViewPort vp = mapControl.getMapContext().getViewPort();
+
+		Point2D from = vp.toMapPoint(event.getFrom());
+		Point2D to = vp.toMapPoint(event.getTo());
+
+
+		Rectangle2D extent = vp.getExtent();
+		double x = extent.getX() - (to.getX() - from.getX());
+		double y = extent.getY() - (to.getY() - from.getY());
+		double width = extent.getWidth();
+		double height = extent.getHeight();
+		Envelope r;
+		try {
+			r = geomManager.createEnvelope(x, y, x+width, y+height, SUBTYPES.GEOM2D);
+			vp.setEnvelope(r);
+		} catch (CreateEnvelopeException e) {
+			logger.error("Error creating the envelope", e);
+		}
+		
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
+	 */
+	public Image getImageCursor() {
+		return ipan;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
+	 */
+	public boolean cancelDrawing() {
+		return true;
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/SelectImageListenerImpl.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/SelectImageListenerImpl.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/SelectImageListenerImpl.java	(revision 38283)
@@ -0,0 +1,122 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+*
+* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+*
+* For more information, contact:
+*
+*  Generalitat Valenciana
+*   Conselleria d'Infraestructures i Transport
+*   Av. Blasco Ibáñez, 50
+*   46010 VALENCIA
+*   SPAIN
+*
+*      +34 963862235
+*   gvsig@gva.es
+*      www.gvsig.gva.es
+*
+*    or
+*
+*   IVER T.I. S.A
+*   Salamanca 50
+*   46005 Valencia
+*   Spain
+*
+*   +34 963163400
+*   dac@iver.es
+*/
+package org.gvsig.fmap.mapcontrol.tools;
+
+import java.awt.Cursor;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.Toolkit;
+import java.awt.geom.Point2D;
+
+import javax.swing.ImageIcon;
+
+import org.gvsig.fmap.mapcontrol.MapControl;
+import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.PointListener;
+
+
+
+/**
+ * <p>Listener to select the upper layer with raster data, that has information in the associated <code>MapControl</code> object, down
+ *  the position selected by the mouse.</p>
+ *
+ * @deprecated
+ * @author Nacho Brodin <brodin_ign@gva.es>
+ */
+public class SelectImageListenerImpl implements PointListener {
+	/**
+	 * The image to display when the cursor is active.
+	 */
+	private final Image isaveraster = new ImageIcon(MapControl.class.getClassLoader().getResource(
+				"org/gvsig/fmap/mapcontrol/images/PointSelectCursor.gif")).getImage();
+
+	/**
+	 * Reference to the <code>MapControl</code> object that uses.
+	 */
+	protected MapControl mapCtrl;
+
+	/**
+	 * World equivalent coordinates of the point 2D
+	 */
+	protected Point2D wcPoint = null;
+
+	/**
+	 * <p>Creates a new <code>SelectImageListenerImpl</code> object.</p>
+	 *
+	 * @param mapCtrl the <code>MapControl</code> where are stored the layers
+	 */
+	public SelectImageListenerImpl(MapControl mapCtrl) {
+		this.mapCtrl = mapCtrl;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
+	 */
+	public void point(PointEvent event) {
+
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getImageCursor()
+	 */
+	public Image getImageCursor() {
+		return isaveraster;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
+	 */
+	public boolean cancelDrawing() {
+		return true;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#pointDoubleClick(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
+	 */
+	public void pointDoubleClick(PointEvent event) {
+		// TODO Auto-generated method stub
+
+	}
+}
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/MapTool.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/MapTool.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/MapTool.java	(revision 38283)
@@ -0,0 +1,44 @@
+/*
+ * Created on 28-oct-2004
+ */
+package org.gvsig.fmap.mapcontrol.tools;
+
+import java.awt.Cursor;
+import java.awt.Graphics;
+import java.awt.geom.Point2D;
+
+import org.gvsig.fmap.mapcontrol.MapControl;
+
+
+/**
+ * Herramienta del MapControl.
+ * Ejecuta acciones respondiendo a eventos, por delegación desde MapControl.
+ * 
+ * @author Luis W. Sevilla <sevilla_lui@gva.es>
+ */
+public abstract class MapTool {
+	protected MapControl mc = null;
+	protected Cursor cursor = null;
+	
+	public MapTool(MapControl mc) {
+		this.mc = mc;
+	}
+	/**
+	 * Recibe los eventos del ratón.
+	 */
+	abstract public void cmd(Point2D pt, int bt, int mouseEvent);
+	
+	
+    abstract public void paintComponent(Graphics g);
+	/**
+	 * Devuelve un Bitset con los eventos de raton que requiere.
+	 * @return eventsWanted (BitSet)
+	 * /
+	public int getEventsWanted() {
+		return eventsWanted;
+	}*/
+	
+	public Cursor getCursor() {
+		return cursor;
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/ZoomOutRightButtonListener.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/ZoomOutRightButtonListener.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/ZoomOutRightButtonListener.java	(revision 38283)
@@ -0,0 +1,175 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools;
+
+import java.awt.Image;
+import java.awt.event.MouseEvent;
+import java.awt.geom.Point2D;
+
+import javax.swing.ImageIcon;
+
+import org.gvsig.fmap.geom.GeometryLocator;
+import org.gvsig.fmap.geom.GeometryManager;
+import org.gvsig.fmap.geom.Geometry.SUBTYPES;
+import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
+import org.gvsig.fmap.geom.primitive.Envelope;
+import org.gvsig.fmap.geom.util.UtilFunctions;
+import org.gvsig.fmap.mapcontext.MapContext;
+import org.gvsig.fmap.mapcontext.ViewPort;
+import org.gvsig.fmap.mapcontrol.MapControl;
+import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.PointListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+/**
+ * <p>Listener for doing a <i>zoom out</i> operation on the extent of the <code>ViewPort</code> of the associated {@link MapControl MapControl}
+ *  object, selecting a point of the <code>MapControl</code> by a single click of the third button of the mouse.</p>
+ *
+ * <p>Calculates the new extent <i>r</i> with this equations:
+ *  <code><br>
+ *   ViewPort vp = mapControl.getMapContext().getViewPort();<br>
+ *   Point2D p2 = vp.toMapPoint(event.getPoint());<br>
+ *   double factor = 1/MapContext.ZOOMOUTFACTOR;<br>
+ *   Rectangle2D.Double r = new Rectangle2D.Double();<br>
+ *   double nuevoX = p2.getX() - ((vp.getExtent().getWidth() * factor) / 2.0);<br>
+ *   double nuevoY = p2.getY() - ((vp.getExtent().getHeight() * factor) / 2.0);<br>
+ *   r.x = nuevoX;<br>
+ *   r.y = nuevoY;<br>
+ *   r.width = vp.getExtent().getWidth() * factor;<br>
+ *   r.height = vp.getExtent().getHeight() * factor;<br>
+ *   vp.setExtent(r);
+ *  </code>
+ * </p>
+ *
+ * <p>The ultimately extent will be an adaptation from that, calculated by the <code>ViewPort</code>
+ *  bearing in mind the ratio of the available rectangle.</p>
+ *
+ * @see MapContext#ZOOMOUTFACTOR
+ * @see ViewPort#setEnvelope(Envelope)
+ * @see ZoomInListenerImpl
+ * @see ZoomOutListenerImpl
+ *
+ * @author Vicente Caballero Navarro
+ */
+public class ZoomOutRightButtonListener implements PointListener {
+	private static final GeometryManager geomManager = GeometryLocator.getGeometryManager();
+	private static final Logger logger = LoggerFactory.getLogger(ZoomOutRightButtonListener.class);
+	
+	/**
+	 * The image to display when the cursor is active.
+	 */
+	private final Image izoomout = new ImageIcon(MapControl.class.getClassLoader().getResource(
+	"org/gvsig/fmap/mapcontrol/images/ZoomOutCursor.gif")).getImage();
+	
+	/**
+	 * Reference to the <code>MapControl</code> object that uses.
+	 */
+	private MapControl mapControl;
+
+	/**
+	 * <p>Creates a new <code>ZoomOutRightButtonListener</code> object.</p>
+	 *
+	 * @param mapControl the <code>MapControl</code> where will be applied the changes
+	 */
+	public ZoomOutRightButtonListener(MapControl mapControl) {
+		this.mapControl = mapControl;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
+	 */
+	public void point(PointEvent event) {
+		if (event.getEvent().getButton() == MouseEvent.BUTTON3){
+			logger.debug("Zoom out botón derecho");
+			ViewPort vp = mapControl.getMapContext().getViewPort();
+			Point2D p2 = vp.toMapPoint(event.getPoint());
+
+			double nuevoX;
+			double nuevoY;
+			double factor = 1 / MapContext.ZOOMOUTFACTOR;
+			if (vp.getExtent() != null) {
+				nuevoX = p2.getX()
+						- ((vp.getExtent().getWidth() * factor) / 2.0);
+				nuevoY = p2.getY()
+						- ((vp.getExtent().getHeight() * factor) / 2.0);
+				double x = nuevoX;
+				double y = nuevoY;
+				double width = vp.getExtent().getWidth() * factor;
+				double height = vp.getExtent().getHeight() * factor;
+
+				try {
+					vp.setEnvelope(geomManager.createEnvelope(x, y ,x + width, y + height, SUBTYPES.GEOM2D));
+				} catch (CreateEnvelopeException e) {
+					logger.error("Error creating the envelope", e);
+				}
+			}
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getImageCursor()
+	 */
+	public Image getImageCursor() {
+		return izoomout;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
+	 */
+	public boolean cancelDrawing() {
+	    logger.debug("cancelDrawing true");
+		return true;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#pointDoubleClick(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
+	 */
+	public void pointDoubleClick(PointEvent event) {
+		// TODO Auto-generated method stub
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/BehaviorException.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/BehaviorException.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/BehaviorException.java	(revision 38283)
@@ -0,0 +1,67 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools;
+
+/**
+ * <p>Exception produced when fails the process that interacts with a {@link MapControl MapControl} object,
+ *  using some tool.</p>
+ *
+ * @author Vicente Caballero Navarro
+ */
+public class BehaviorException extends Exception {
+	/**
+	 * <p>Creates a new behavior exception with the specified detail message.</p>
+	 * 
+	 * @see Exception#Exception(String)
+	 */
+	public BehaviorException(String message) {
+		super(message);
+	}
+
+	/**
+	 * <p>Creates a new behavior exception with the specified detail message and cause.</p>
+	 * 
+	 * @see Exception#Exception(String, Throwable)
+	 */
+	public BehaviorException(String message, Throwable cause) {
+		super(message, cause);
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/MouseWheelBehavior.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/MouseWheelBehavior.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/MouseWheelBehavior.java	(revision 38283)
@@ -0,0 +1,94 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.fmap.mapcontrol.tools.Behavior;
+
+import java.awt.event.MouseWheelEvent;
+
+import org.gvsig.fmap.geom.Geometry.SUBTYPES;
+import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
+import org.gvsig.fmap.geom.primitive.Envelope;
+import org.gvsig.fmap.geom.primitive.Point;
+import org.gvsig.fmap.mapcontext.ViewPort;
+import org.gvsig.fmap.mapcontrol.MapControl;
+import org.gvsig.fmap.mapcontrol.MapControlDrawer;
+import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
+
+/**
+ * @author gvSIG Team
+ * @version $Id$
+ * 
+ */
+public class MouseWheelBehavior extends Behavior {
+
+    /**
+     * Constructor.
+     */
+    public MouseWheelBehavior() {
+    }
+
+    @Override
+    public ToolListener getListener() {
+        return null;
+    }
+
+    @Override
+    public void mouseWheelMoved(MouseWheelEvent event) throws BehaviorException {
+        MapControl control = getMapControl();
+        control.cancelDrawing();
+        super.mouseWheelMoved(event);
+        ViewPort viewPort = control.getViewPort();
+        Envelope envelope = viewPort.getEnvelope();
+        if (envelope != null) {
+            double factor = event.getWheelRotation() < 0 ? 0.9d : 1.2d;
+            Point mousePosition = viewPort.convertToMapPoint(event.getPoint());
+            Point envelopPoint1 = envelope.getLowerCorner();
+            Point envelopPoint2 = envelope.getUpperCorner();
+
+            double width1 = mousePosition.getX() - envelopPoint1.getX();
+            double heigth1 = mousePosition.getY() - envelopPoint1.getY();
+            double width2 = envelopPoint2.getX() - mousePosition.getX();
+            double heigth2 = envelopPoint2.getY() - mousePosition.getY();
+
+            double xmin = mousePosition.getX() - width1 * factor;
+            double ymin = mousePosition.getY() - heigth1 * factor;
+            double xmax = mousePosition.getX() + width2 * factor;
+            double ymax = mousePosition.getY() + heigth2 * factor;
+
+            try {
+                viewPort.setEnvelope(geomManager.createEnvelope(xmin, ymin,
+                    xmax, ymax, SUBTYPES.GEOM2D));
+            } catch (CreateEnvelopeException e) {
+                throw new BehaviorException(
+                    "Error changing the viewport envelope to (" + xmin + ","
+                        + ymin + "),(" + xmax + "," + ymax + ")", e);
+            }
+            getMapControl().drawMap(true);
+        }
+        event.consume();
+    }
+    
+    @Override
+    public void paintComponent(MapControlDrawer mapControlDrawer) {
+    	// Do nothing
+    }
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/Behavior.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/Behavior.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/Behavior.java	(revision 38283)
@@ -0,0 +1,337 @@
+/*
+ * Created on 28-oct-2004
+ */
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.Behavior;
+
+import java.awt.Image;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
+import java.awt.geom.Point2D;
+import java.awt.image.BufferedImage;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.gvsig.fmap.dal.feature.exception.CreateGeometryException;
+import org.gvsig.fmap.geom.Geometry.SUBTYPES;
+import org.gvsig.fmap.geom.Geometry.TYPES;
+import org.gvsig.fmap.geom.GeometryLocator;
+import org.gvsig.fmap.geom.GeometryManager;
+import org.gvsig.fmap.geom.primitive.Arc;
+import org.gvsig.fmap.geom.primitive.Circle;
+import org.gvsig.fmap.geom.primitive.Curve;
+import org.gvsig.fmap.geom.primitive.GeneralPathX;
+import org.gvsig.fmap.geom.primitive.Point;
+import org.gvsig.fmap.mapcontrol.MapControl;
+import org.gvsig.fmap.mapcontrol.MapControlDrawer;
+import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
+
+
+
+/**
+ * <p>When user is working with a tool on a {@link MapControl MapControl} instance, <code>Behavior</code> defines
+ *  the basic ways of interacting: selecting a point, a circle, a rectangle, or ...</p>
+ *
+ * <p>All events generated will be <code>MouseEvent</code>, and will depend on the nature of the
+ *  <i>behavior</i>, like the kind of tool for applying the changes.</p>
+ *
+ * <p><code>Behavior</code> defines the common and basic functionality for all kinds of interacting ways
+ *  with the <code>MapControl</code> object.</p>
+ *
+ * @see IBehavior
+ *
+ * @author Luis W. Sevilla
+ */
+public abstract class Behavior implements IBehavior {
+	/**
+	 * Reference to the <code>MapControl</code> object that uses.
+	 *
+	 * @see #getMapControl()
+	 * @see #setMapControl(MapControl)
+	 */
+	private MapControl mapControl;
+	
+    private static final Logger LOG = LoggerFactory.getLogger(Behavior.class);
+
+	protected GeometryManager geomManager = GeometryLocator.getGeometryManager();
+	
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#getListener()
+	 */
+	public abstract ToolListener getListener();
+
+	/*
+	 * <p>Draws as much of the associated <code>MapControl</code> image as is currently available. The image
+	 *  is drawn with its top-left corner at (0, 0) in this graphics context's coordinate space. Transparent
+	 *  pixels in the image do not affect whatever pixels are already there.</p>
+	 *
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#paintComponent(java.awt.Graphics)
+	 */
+	public void paintComponent(MapControlDrawer mapControlDrawer) {
+		BufferedImage img = getMapControl().getImage();
+
+		if (img != null) {
+			mapControlDrawer.drawImage(img, 0, 0);
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#setMapControl(com.iver.cit.gvsig.fmap.MapControl)
+	 */
+	public void setMapControl(MapControl mc) {
+		mapControl = mc;
+	}
+
+	/* (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#getImageCursor()
+	 */
+	public Image getImageCursor(){
+		return getListener().getImageCursor();
+	}
+
+	/* (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#getMapControl()
+	 */
+	public MapControl getMapControl() {
+		return mapControl;
+	}
+
+	/* (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseClicked(java.awt.event.MouseEvent)
+	 */
+	public void mouseClicked(MouseEvent e) throws BehaviorException {
+	}
+
+	/* (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseEntered(java.awt.event.MouseEvent)
+	 */
+	public void mouseEntered(MouseEvent e) throws BehaviorException {
+	}
+
+	/* (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseExited(java.awt.event.MouseEvent)
+	 */
+	public void mouseExited(MouseEvent e) throws BehaviorException {
+	}
+
+	/* (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mousePressed(java.awt.event.MouseEvent)
+	 */
+	public void mousePressed(MouseEvent e) throws BehaviorException {
+	}
+
+	/* (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseReleased(java.awt.event.MouseEvent)
+	 */
+	public void mouseReleased(MouseEvent e) throws BehaviorException {
+	}
+
+	/* (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseDragged(java.awt.event.MouseEvent)
+	 */
+	public void mouseDragged(MouseEvent e) throws BehaviorException {
+	}
+
+	/* (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseMoved(java.awt.event.MouseEvent)
+	 */
+	public void mouseMoved(MouseEvent e) throws BehaviorException {
+	}
+
+	/* (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseWheelMoved(java.awt.event.MouseWheelEvent)
+	 */
+	public void mouseWheelMoved(MouseWheelEvent e) throws BehaviorException {
+	}
+	
+	/**
+	 * Create point. If there is an
+	 * error return <code>null</code> and add the error
+	 * to the log
+	 * @param x
+	 * The X coordinate
+	 * @param y
+	 * The y coordinate
+	 * @return
+	 * The Point
+	 */
+	protected Point createPoint(double x, double y){
+		Point point = null;
+		try {
+			point = (Point)geomManager.create(TYPES.POINT, SUBTYPES.GEOM2D);
+			point.setX(x);
+			point.setY(y);
+		} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
+            LOG.error("Error creating a point with x=" + x + ", y=" + y,
+                new CreateGeometryException(TYPES.POINT, SUBTYPES.GEOM2D,
+                e));
+		}
+		return point;
+	}
+	
+	/**
+	 * Create an Arc. If there is an
+	 * error return <code>null</code> and add the error
+	 * to the log
+	 * @param p1
+	 * @param p2
+	 * @param p3
+	 * @return
+	 * The arc
+	 */
+	protected Arc createArc(Point2D p1, Point2D p2, Point2D p3){
+		return createArc(createPoint(p1), createPoint(p2), createPoint(p3));
+	}
+
+	/**
+	 * Create an arc. If there is an
+	 * error return <code>null</code> and add the error
+	 * to the log
+	 * @param p1
+	 * @param p2
+	 * @param p3
+	 * @return
+	 * The arc
+	 */
+	protected Arc createArc(Point p1, Point p2, Point p3){
+		Arc arc = null;
+		try {
+			arc = (Arc)geomManager.create(TYPES.ARC, SUBTYPES.GEOM2D);
+			arc.setPoints(p1, p2, p3);
+	    } catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
+            LOG.error("Error creating and arc with p1=" + p1 + ", p2=" + p2
+                + ",p3=" + p3, new CreateGeometryException(TYPES.ARC,
+                SUBTYPES.GEOM2D, e));
+		}
+	    return arc;
+	}
+	
+	/**
+	 * Create a curve point. If there is an
+	 * error return <code>null</code> and add the error
+	 * to the log
+	 * @param p1
+	 * The AWT point
+	 * @return
+	 * The gvSIG point
+	 */
+	protected Point createPoint(Point2D p1){
+		return createPoint(p1.getX(), p1.getY());
+	}
+	
+
+	/**
+	 * Create an arc. If there is an
+	 * error return <code>null</code> and add the error
+	 * to the log
+	 * @param centerX
+	 * @param centerY
+	 * @param angleStart
+	 * @param angleExtent
+	 * @return
+	 * The arc
+	 */
+	protected Arc createArc(double centerX, double centerY, double radious,
+			double angleStart, double angleExtent){
+		Arc arc = null;
+		try {
+			arc = (Arc)geomManager.create(TYPES.ARC, SUBTYPES.GEOM2D);
+			arc.setPoints(createPoint(centerX, centerY), radious, angleStart, angleExtent);
+	    } catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
+            LOG.error(
+                "Error creating an arc with centerX=" + centerX + ", centerY="
+                    + centerY + ", radious=" + radious + ", angleStart="
+                    + angleStart + ", angleExtent=" + angleExtent,
+                new CreateGeometryException(TYPES.ARC, SUBTYPES.GEOM2D, e));
+		}
+	    return arc;
+	}
+
+	/**
+	 * Create an circle. If there is an
+	 * error return <code>null</code> and add the error
+	 * to the log
+	 * @param centerX
+	 * @param centerY
+	 * @return
+	 * The arc
+	 */
+	protected Circle createCircle(double centerX, double centerY, double radious){
+		Circle circle = null;
+		try {
+			circle = (Circle)geomManager.create(TYPES.CIRCLE, SUBTYPES.GEOM2D);
+			circle.setPoints(createPoint(centerX, centerY), radious);
+	    } catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
+            LOG.error("Error creating circle with centerX=" + centerX
+                + ", centerY=" + centerY + ", radious=" + radious,
+                new CreateGeometryException(TYPES.CIRCLE,
+                SUBTYPES.GEOM2D, e));
+		}
+	    
+	    return circle;
+	}
+
+	/**
+	 * Create a lineString from a GeneralPath. If there is an
+	 * error return <code>null</code> and add the error
+	 * to the log
+	 * @param gpx
+	 * The GeneralPath
+	 * @return
+	 * The LineString
+	 */
+	protected Curve createLineString(GeneralPathX gpx){
+		Curve curve = null;
+		try {
+			curve = (Curve)geomManager.create(TYPES.CURVE, SUBTYPES.GEOM2D);
+			curve.setGeneralPath(gpx);
+		} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
+            LOG.error("Error creating lineString with GeneralPathX=" + gpx,
+                new CreateGeometryException(TYPES.CURVE, SUBTYPES.GEOM2D,
+                e));
+		}
+		return curve;
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/CircleBehavior.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/CircleBehavior.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/CircleBehavior.java	(revision 38283)
@@ -0,0 +1,216 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.Behavior;
+
+import java.awt.Color;
+import java.awt.Rectangle;
+import java.awt.event.MouseEvent;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+
+import org.gvsig.fmap.geom.primitive.Arc;
+import org.gvsig.fmap.mapcontext.ViewPort;
+import org.gvsig.fmap.mapcontrol.MapControlDrawer;
+import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
+import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.CircleListener;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.PolylineListener;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
+
+
+
+/**
+ * <p>Behavior that allows user to draw a circle on the image of the associated
+ *  <code>MapControl</code> using a {@link PolylineListener PolylineListener}.</p>
+ *
+ * @author Laura
+ * @author Pablo Piqueras Bartolomé
+ */
+public class CircleBehavior extends Behavior {
+	/**
+	 * First point set, that represents the center of the circle.
+	 */
+	protected Point2D m_FirstPoint;
+
+	/**
+	 * Second point set, that permits calculate the radius of the circle.
+	 */
+	protected Point2D m_LastPoint;
+
+	/**
+	 * Tool listener used to work with the <code>MapControl</code> object.
+	 *
+	 * @see #getListener()
+	 * @see #setListener(ToolListener)
+	 */
+	private CircleListener listener;
+
+	/**
+	 * Determines if user setting the radius of the circle (with one click of the button 1 of the mouse), or not.
+	 */
+	protected boolean isClicked = false;
+
+	/**
+	 * <p>Creates a new behavior for selecting circle areas.</p>
+	 *
+	 * @param zili listener used to permit this object to work with the associated <code>MapControl</code>
+	 */
+	public CircleBehavior(CircleListener zili) {
+		listener = zili;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#paintComponent(java.awt.Graphics)
+	 */
+	public void paintComponent(MapControlDrawer mapControlDrawer) {
+
+		double radio;
+		BufferedImage img = getMapControl().getImage();
+		mapControlDrawer.drawImage(img, 0, 0);
+		mapControlDrawer.setColor(Color.black);
+
+
+		if ((m_FirstPoint != null) && (m_LastPoint != null)) {
+			ViewPort vp = getMapControl().getMapContext().getViewPort();
+			Point2D p1 = vp.toMapPoint(m_FirstPoint);
+			Point2D p2 = vp.toMapPoint(m_LastPoint);
+
+			radio = p1.distance(p2);
+			if(radio!=0.0){
+				Arc arc = null;			
+					arc = createArc(p1.getX(), p1.getY(),
+							radio,
+							0,
+							Math.PI*2);
+					mapControlDrawer.draw(arc);
+			}
+
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mousePressed(java.awt.event.MouseEvent)
+	 */
+	public void mousePressed(MouseEvent e) {
+		if (e.getButton() == MouseEvent.BUTTON1) {
+			m_FirstPoint = e.getPoint();
+			isClicked = true;
+			getMapControl().repaint();
+		}
+
+		if (listener.cancelDrawing()) {
+			getMapControl().cancelDrawing();
+			isClicked = false;
+			getMapControl().repaint();
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseReleased(java.awt.event.MouseEvent)
+	 */
+	public void mouseReleased(MouseEvent e) throws BehaviorException {
+		m_FirstPoint = null;
+		m_LastPoint = null;
+		isClicked = false;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseDragged(java.awt.event.MouseEvent)
+	 */
+	public void mouseDragged(MouseEvent e) throws BehaviorException {
+		mouseMoved(e);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseMoved(java.awt.event.MouseEvent)
+	 */
+	public void mouseMoved(MouseEvent e)  throws BehaviorException {
+		if (m_FirstPoint == null) return;
+
+		m_LastPoint = e.getPoint();
+
+		ViewPort vp = getMapControl().getMapContext().getViewPort();
+
+		Point2D p1 = vp.toMapPoint(m_FirstPoint);
+		Point2D p2 = vp.toMapPoint(m_LastPoint);
+
+		//	Fijamos el nuevo extent
+		Rectangle2D.Double r = new Rectangle2D.Double();
+		r.setFrameFromDiagonal(p1, p2);
+
+		Rectangle2D rectPixel = new Rectangle();
+		rectPixel.setFrameFromDiagonal(m_FirstPoint, m_LastPoint);
+
+		Double[] x = new Double[2];
+		Double[] y = new Double[2];
+		x[0] = new Double(p1.getX());
+		x[1] = new Double(p2.getX());
+		y[0] = new Double(p1.getY());
+		y[1] = new Double(p2.getY());
+		MeasureEvent event = new MeasureEvent(x, y, e);
+		listener.circle(event);
+		getMapControl().repaint();
+	}
+
+	/**
+	 * <p>Sets a tool listener to work with the <code>MapControl</code> using this behavior.</p>
+	 *
+	 * @param listener a <code>CircleListener</code> object for this behavior
+	 */
+	public void setListener(ToolListener listener) {
+		this.listener = (CircleListener)listener;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#getListener()
+	 */
+	public ToolListener getListener() {
+		return listener;
+	}
+}
+
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/MouseMovementBehavior.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/MouseMovementBehavior.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/MouseMovementBehavior.java	(revision 38283)
@@ -0,0 +1,109 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.Behavior;
+
+import java.awt.event.MouseEvent;
+
+import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
+import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.PointListener;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
+
+
+
+/**
+ * <p>Behavior that permits user to move and drag the mouse on the image of the associated
+ *  <code>MapControl</code> instance using a {@link PointListener PointListener}.</p>
+ *
+ * @author Vicente Caballero Navarro
+ */
+public class MouseMovementBehavior extends Behavior {
+	/**
+	 * Tool listener used to work with the <code>MapControl</code> object.
+	 *
+	 * @see #getListener()
+	 * @see #setListener(ToolListener)
+	 */
+	protected PointListener listener;
+
+	/**
+	 * <p>Creates a new behavior for moving or dragging the mouse on the image of the associated <code>MapControl</code> instance.</p>
+	 *
+	 * @param mli listener used to permit this object to work with the associated <code>MapControl</code>
+	 */
+	public MouseMovementBehavior(PointListener mli) {
+		listener = mli;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseDragged(java.awt.event.MouseEvent)
+	 */
+	public void mouseDragged(MouseEvent e) throws BehaviorException {
+		mouseMoved(e);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseMoved(java.awt.event.MouseEvent)
+	 */
+	public void mouseMoved(MouseEvent e) throws BehaviorException {
+		PointEvent event = new PointEvent(e.getPoint(), e);
+		listener.point(event);
+	}
+
+	/**
+	 * <p>Sets a tool listener to work with the <code>MapControl</code> using this behavior.</p>
+	 *
+	 * @param listener a <code>PointListener</code> object for this behavior
+	 */
+	public void setListener(ToolListener listener) {
+		this.listener = (PointListener) listener;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#getListener()
+	 */
+	public ToolListener getListener() {
+		return listener;
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/RectangleBehavior.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/RectangleBehavior.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/RectangleBehavior.java	(revision 38283)
@@ -0,0 +1,224 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.Behavior;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.event.MouseEvent;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+
+import org.gvsig.fmap.geom.GeometryLocator;
+import org.gvsig.fmap.geom.GeometryManager;
+import org.gvsig.fmap.geom.Geometry.SUBTYPES;
+import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
+import org.gvsig.fmap.geom.primitive.Envelope;
+import org.gvsig.fmap.geom.util.UtilFunctions;
+import org.gvsig.fmap.mapcontext.ViewPort;
+import org.gvsig.fmap.mapcontrol.MapControlDrawer;
+import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
+import org.gvsig.fmap.mapcontrol.tools.Events.EnvelopeEvent;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.RectangleListener;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+/**
+ * <p>Behavior that permits user to select a rectangular area on the associated <code>MapControl</code> using
+ *  a {@link RectangleListener RectangleListener}.</p>
+ *
+ * @author Vicente Caballero Navarro
+ * @author Pablo Piqueras Bartolomé
+ */
+public class RectangleBehavior extends Behavior {
+	private static final GeometryManager geomManager = GeometryLocator.getGeometryManager();
+	private static final Logger logger = LoggerFactory.getLogger(RectangleBehavior.class);
+	
+	/**
+	 * First point of the rectangle area, that represents a corner.
+	 */
+	private Point2D m_FirstPoint;
+
+	/**
+	 * Second point of the rectangle area, that represents the opposite corner of the first,
+	 *  along the diagonal.
+	 */
+	private Point2D m_LastPoint;
+
+	/**
+	 * Tool listener used to work with the <code>MapControl</code> object.
+	 *
+	 * @see #getListener()
+	 * @see #setListener(ToolListener)
+	 */
+	private RectangleListener listener;
+
+	/**
+	 * <p>Creates a new behavior for selecting rectangle areas.</p>
+	 *
+	 * @param zili listener used to permit this object to work with the associated <code>MapControl</code>
+	 */
+	public RectangleBehavior(RectangleListener zili) {
+		listener = zili;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#paintComponent(java.awt.Graphics)
+	 */
+	public void paintComponent(MapControlDrawer mapControlDrawer) {
+		BufferedImage img = getMapControl().getImage();
+		mapControlDrawer.drawImage(img, 0, 0);
+		mapControlDrawer.setColor(Color.black);		
+
+		// Borramos el anterior
+		Rectangle r = new Rectangle();
+
+		// Dibujamos el actual
+		if ((m_FirstPoint != null) && (m_LastPoint != null)) {
+			r.setFrameFromDiagonal(m_FirstPoint, m_LastPoint);
+			mapControlDrawer.drawRect(r.x, r.y, r.width, r.height);
+		}		
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mousePressed(java.awt.event.MouseEvent)
+	 */
+	public void mousePressed(MouseEvent e) {
+		if (e.getButton() == MouseEvent.BUTTON1) {
+			m_FirstPoint = e.getPoint();
+			getMapControl().repaint();
+		}
+		if (listener.cancelDrawing()) {
+			getMapControl().cancelDrawing();
+			getMapControl().repaint();
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseReleased(java.awt.event.MouseEvent)
+	 */
+	public void mouseReleased(MouseEvent e) throws BehaviorException {
+	    if (m_FirstPoint == null) return;
+		Point2D p1;
+		Point2D p2;
+		Point pScreen = e.getPoint();
+
+		ViewPort vp = getMapControl().getMapContext().getViewPort();
+
+		p1 = vp.toMapPoint(m_FirstPoint);
+		p2 = vp.toMapPoint(pScreen);
+
+		if (e.getButton() == MouseEvent.BUTTON1) {
+			//	Fijamos el nuevo extent
+
+			double x=0;
+			double y=0;
+			double x1=0;
+			double y1=0;
+			if (p1.getX()<p2.getX()){
+				x=p1.getX();
+				x1=p2.getX();
+			}else{
+				x=p2.getX();
+				x1=p1.getX();
+			}
+			if (p1.getY()<p2.getY()){
+				y=p1.getY();
+				y1=p2.getY();
+			}else{
+				y=p2.getY();
+				y1=p1.getY();
+			}
+			Envelope r;
+			try {
+				r = geomManager.createEnvelope(x,y,x1,y1, SUBTYPES.GEOM2D);
+				Rectangle2D rectPixel = new Rectangle();
+				rectPixel.setFrameFromDiagonal(m_FirstPoint, pScreen);
+
+				EnvelopeEvent event = new EnvelopeEvent(r, e, rectPixel);
+				listener.rectangle(event);
+			} catch (CreateEnvelopeException e1) {
+				logger.error("Error creating the envelope", e);
+			}//Rectangle2D.Double();
+
+			//			r.setFrameFromDiagonal(p1, p2);
+
+			
+		}
+
+		m_FirstPoint = null;
+		m_LastPoint = null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseDragged(java.awt.event.MouseEvent)
+	 */
+	public void mouseDragged(MouseEvent e) {
+		m_LastPoint = e.getPoint();
+		getMapControl().repaint();
+	}
+
+	/**
+	 * <p>Sets a tool listener to work with the <code>MapControl</code> using this behavior.</p>
+	 *
+	 * @param listener a <code>RectangleListener</code> object for this behavior
+	 */
+	public void setListener(ToolListener listener) {
+		this.listener = (RectangleListener) listener;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#getListener()
+	 */
+	public ToolListener getListener() {
+		return listener;
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/MoveBehavior.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/MoveBehavior.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/MoveBehavior.java	(revision 38283)
@@ -0,0 +1,140 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+package org.gvsig.fmap.mapcontrol.tools.Behavior;
+
+import java.awt.AlphaComposite;
+import java.awt.event.MouseEvent;
+import java.awt.geom.Point2D;
+import java.awt.image.BufferedImage;
+
+import org.gvsig.fmap.mapcontrol.MapControlDrawer;
+import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
+import org.gvsig.fmap.mapcontrol.tools.Events.MoveEvent;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.PanListener;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
+
+/**
+ * <p>
+ * Behavior that permits user to move the image of the associated
+ * <code>MapControl</code> using a {@link PanListener PanListener}.
+ * </p>
+ * 
+ * @author Vicente Caballero Navarro
+ * @author Pablo Piqueras Bartolomé
+ */
+public class MoveBehavior extends Behavior {
+
+    /**
+     * First point of the path in image coordinates.
+     */
+    private Point2D m_FirstPoint;
+
+    /**
+     * Last point of the path in image coordinates.
+     */
+    private Point2D m_LastPoint;
+
+    /**
+     * Tool listener used to work with the <code>MapControl</code> object.
+     * 
+     * @see #getListener()
+     * @see #setListener(ToolListener)
+     */
+    private PanListener listener;
+    private boolean isButton1;
+
+    /**
+     * <p>
+     * Creates a new behavior for moving the mouse.
+     * </p>
+     * 
+     * @param pli
+     *            listener used to permit this object to work with the
+     *            associated <code>MapControl</code>
+     */
+    public MoveBehavior(PanListener pli) {
+        listener = pli;
+    }
+
+    public void paintComponent(MapControlDrawer renderer) {
+        super.paintComponent(renderer);
+        BufferedImage image = getMapControl().getImage();
+        if (image != null) {
+            if ((m_FirstPoint != null) && (m_LastPoint != null)) {
+                renderer.setComposite(AlphaComposite.getInstance(
+                    AlphaComposite.SRC_OVER, 0.5f));
+                renderer.drawImage(image,
+                    (int) (m_LastPoint.getX() - m_FirstPoint.getX()),
+                    (int) (m_LastPoint.getY() - m_FirstPoint.getY()));
+            }
+        }
+    }
+
+    public void mousePressed(MouseEvent e) {
+        if (e.getButton() == MouseEvent.BUTTON1) {
+            isButton1 = true;
+            m_FirstPoint = e.getPoint();
+        } else {
+            isButton1 = false;
+        }
+
+        if (listener.cancelDrawing()) {
+            getMapControl().cancelDrawing();
+        }
+    }
+
+    public void mouseReleased(MouseEvent e) throws BehaviorException {
+        if (e.getButton() == MouseEvent.BUTTON1 && m_FirstPoint != null) {
+            MoveEvent event = new MoveEvent(m_FirstPoint, e.getPoint(), e);
+            listener.move(event);
+
+            // System.out.println("mouseReleased");
+            getMapControl().drawMap(true);
+        }
+
+        m_FirstPoint = null;
+    }
+
+    public void mouseDragged(MouseEvent e) {
+        if (isButton1) {
+            m_LastPoint = e.getPoint();
+            getMapControl().repaint();
+        }
+    }
+
+    /**
+     * <p>
+     * Sets a tool listener to work with the <code>MapControl</code> using this
+     * behavior.
+     * </p>
+     * 
+     * @param listener
+     *            a <code>PanListener</code> object for this behavior
+     */
+    public void setListener(ToolListener listener) {
+        this.listener = (PanListener) listener;
+    }
+
+    public ToolListener getListener() {
+        return listener;
+    }
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/PolygonBehavior.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/PolygonBehavior.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/PolygonBehavior.java	(revision 38283)
@@ -0,0 +1,151 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.Behavior;
+
+import java.awt.Graphics;
+import java.awt.event.MouseEvent;
+import java.awt.geom.Point2D;
+
+import org.gvsig.fmap.mapcontrol.MapControlDrawer;
+import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
+import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.PolylineListener;
+
+
+
+/**
+ * <p>Behavior that permits user to draw a polygon by its vertexes on the image of the associated
+ *  <code>MapControl</code> using a {@link PolylineListener PolylineListener}.</p>
+ *
+ * @author Vicente Caballero Navarro
+ * @author Pablo Piqueras Bartolomé
+ */
+public class PolygonBehavior extends PolylineBehavior {
+	/**
+	 * <p>Creates a new behavior for drawing a polygon by its vertexes.</p>
+	 *
+	 * @param ali tool listener used to permit this object to work with the associated <code>MapControl</code>
+	 */
+	public PolygonBehavior(PolylineListener ali) {
+		super(ali);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#paintComponent(org.gvsig.fmap.mapcontrol.MapControlDrawer)
+	 */
+	public void paintComponent(MapControlDrawer mapControlDrawer) {
+		super.paintComponent(mapControlDrawer);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.PolylineBehavior#mousePressed(java.awt.event.MouseEvent)
+	 */
+	public void mousePressed(MouseEvent e) throws BehaviorException {
+		if (e.getClickCount() == 2) {
+			listener.polylineFinished(new MeasureEvent((Double[]) arrayX.toArray(new Double[arrayX.size()]), (Double[]) arrayY.toArray(new Double[arrayY.size()]), e));
+
+			arrayX.clear();
+			arrayY.clear();
+
+			isClicked = false;
+		} else {
+			isClicked = true;
+
+			if (arrayX.size() == 0) {
+				addPoint(getMapControl().getViewPort().toMapPoint(e.getPoint()));
+				addPoint(getMapControl().getViewPort().toMapPoint(e.getPoint()));
+				addPoint(getMapControl().getViewPort().toMapPoint(e.getPoint()));
+			} else {
+				addAntPoint(getMapControl().getViewPort().toMapPoint(e.getPoint()));
+			}
+
+			listener.pointFixed(new MeasureEvent((Double[]) arrayX.toArray(new Double[arrayX.size()]), (Double[]) arrayY.toArray(new Double[arrayY.size()]), e));
+		}
+	}
+
+	/**
+	 * <p>Adds a new vertex to the polygon.</p>
+	 *
+	 * @param p a new vertex to the polygon
+	 */
+	private void addAntPoint(Point2D p) {
+		arrayX.add(arrayX.size() - 1, new Double(p.getX()));
+		arrayY.add(arrayY.size() - 1, new Double(p.getY()));
+	}
+
+	/**
+	 * <p>Changes the last vertex added to the polygon.</p>
+	 *
+	 * @param p a new vertex to the polygon
+	 */
+	private void changeAntPoint(Point2D p) {
+		if (arrayX.size() > 2) {
+			arrayX.set(arrayX.size() - 2, new Double(p.getX()));
+			arrayY.set(arrayY.size() - 2, new Double(p.getY()));
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.PolylineBehavior#mouseMoved(java.awt.event.MouseEvent)
+	 */
+	public void mouseMoved(MouseEvent e) throws BehaviorException {
+		if (isClicked) {
+			changeAntPoint(getMapControl().getViewPort().toMapPoint(e.getPoint()));
+
+			MeasureEvent event = new MeasureEvent((Double[]) arrayX.toArray(new Double[arrayX.size()]), (Double[]) arrayY.toArray(new Double[arrayY.size()]), e);
+
+			listener.points(event);
+
+			getMapControl().repaint();
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.PolylineBehavior#mouseDragged(java.awt.event.MouseEvent)
+	 */
+	public void mouseDragged(MouseEvent e) throws BehaviorException {
+		mouseMoved(e);
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/IBehavior.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/IBehavior.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/IBehavior.java	(revision 38283)
@@ -0,0 +1,126 @@
+package org.gvsig.fmap.mapcontrol.tools.Behavior;
+
+import java.awt.Image;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
+
+import org.gvsig.fmap.mapcontrol.MapControl;
+import org.gvsig.fmap.mapcontrol.MapControlDrawer;
+import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
+
+
+/**
+ * <p>When a programmer needs to add a way to permit user to interact with the current object where the graphical
+ *  information is stored and represented, (see {@link MapControl MapControl}), must analyze and decide the basic
+ *  <i>behavior</i> nature of the interaction.</p>
+ *
+ * <p>That <i>behavior</i> will manage mouse events and generate information and <i>tool</i> events that the
+ *  associated {@link ToolListener ToolListener} will use to interact with the <code>MapControl</code> object ultimately.</p>
+ *
+ * <p>It will be possible also combine more than one <i>behavior</i> for a tool listener, for having a richness tool.</p>
+ */
+public interface IBehavior {
+	/**
+	 * <p>Gets the <code>ToolListener</code> used by this behavior to perform actions on the
+	 *  associated <code>MapControl</code> object.</p>
+	 *
+	 * @return the <code>ToolListener</code> used by this behavior
+	 */
+	public ToolListener getListener();
+
+	/**
+	 * <p>Method executed in real-time, when user is working with a tool on the associated <code>MapControl</code>
+	 *  object, repainting the <code>MapControl</code>'s image.</p>
+	 *
+	 * <p>Returns immediately in all cases, even if the complete image has not yet been loaded.</p>
+	 *
+	 * <p>This method will be implemented according to the specific nature of each behavior, and its
+	 *  extra and particular features.</p>
+	 *
+	 * @see Graphics#drawImage(java.awt.Image, int, int, java.awt.image.ImageObserver)
+	 */
+	public void paintComponent(MapControlDrawer renderer);
+
+	/**
+	 * <p>Associates this behavior to a <code>MapControl</code> object.</p>
+	 *
+	 * @param mc the <code>MapControl</code> object to associate
+	 *
+	 * @see #getMapControl()
+	 */
+	public void setMapControl(MapControl mc);
+
+	/**
+	 * <p>Gets the mouse cursor of the tool listener associated to this behavior.</p>
+	 *
+	 * @return the mouse cursor of the tool listener associated
+	 */
+	public Image getImageCursor();
+
+	/**
+	 * <p>Returns the reference to the <code>MapControl</code> object that this behavior uses.</p>
+	 *
+	 * @return the <code>MapControl</code> object used this behavior
+	 *
+	 * @see #setMapControl(MapControl)
+	 */
+	public MapControl getMapControl();
+
+	/**
+	 * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
+	 *
+	 * @throws BehaviorException any exception processing the action associated to a <i>mouse clicked event</i>, by the <code>IBehavior</code> object
+	 */
+	public void mouseClicked(MouseEvent e) throws BehaviorException;
+
+	/**
+	 * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
+	 *
+	 * @throws BehaviorException any exception processing the action associated to a <i>mouse entered event</i>, by the <code>IBehavior</code> object
+	 */
+	public void mouseEntered(MouseEvent e) throws BehaviorException;
+
+	/**
+	 * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
+	 *
+	 * @throws BehaviorException any exception processing the action associated to a <i>mouse exited event</i>, by the <code>IBehavior</code> object
+	 */
+	public void mouseExited(MouseEvent e) throws BehaviorException;
+
+	/**
+	 * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
+	 *
+	 * @throws BehaviorException any exception processing the action associated to a <i>mouse pressed event</i>, by the <code>IBehavior</code> object
+	 */
+	public void mousePressed(MouseEvent e) throws BehaviorException;
+
+	/**
+	 * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
+	 *
+	 * @throws BehaviorException any exception processing the action associated to a <i>mouse released event</i>, by the <code>IBehavior</code> object
+	 */
+	public void mouseReleased(MouseEvent e) throws BehaviorException;
+
+	/**
+	 * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
+	 *
+	 * @throws BehaviorException any exception processing the action associated to a <i>mouse dragged event</i>, by the <code>IBehavior</code> object
+	 */
+	public void mouseDragged(MouseEvent e) throws BehaviorException;
+
+	/**
+	 * @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent)
+	 *
+	 * @throws BehaviorException any exception processing the action associated to a <i>mouse moved event</i>, by the <code>IBehavior</code> object
+	 */
+	public void mouseMoved(MouseEvent e) throws BehaviorException;
+
+	/**
+	 * @see java.awt.event.MouseWheelListener#mouseWheelMoved(java.awt.event.MouseWheelEvent)
+	 *
+	 * @throws BehaviorException any exception processing the action associated to a <i>mouse wheel event</i>, by the <code>IBehavior</code> object
+	 */
+	public void mouseWheelMoved(MouseWheelEvent e) throws BehaviorException;
+
+}
\ No newline at end of file
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/PointBehavior.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/PointBehavior.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/PointBehavior.java	(revision 38283)
@@ -0,0 +1,123 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.Behavior;
+
+import java.awt.event.MouseEvent;
+
+import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
+import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.PointListener;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
+
+
+
+/**
+ * <p>Behavior that permits user to select a point with a double click mouse action, on the associated
+ *  <code>MapControl</code> using a {@link PointListener PointListener}.</p>
+ *
+ * @author Vicente Caballero Navarro
+ */
+public class PointBehavior extends Behavior {
+	/**
+	 * Tool listener used to work with the <<code>MapControl</code> object.
+	 *
+	 * @see #getListener()
+	 * @see #setListener(ToolListener)
+	 */
+	private PointListener listener;
+
+	/**
+	 * Flag that determines a double click user action.
+	 */
+	private boolean doubleClick=false;
+
+	/**
+ 	 * <p>Creates a new behavior for selecting a point.</p>
+ 	 *
+	 * @param l listener used to permit this object to work with the associated <code>MapControl</code>
+	 */
+	public PointBehavior(PointListener l) {
+		listener = l;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mousePressed(java.awt.event.MouseEvent)
+	 */
+	public void mousePressed(MouseEvent e) {
+		if (listener.cancelDrawing()) {
+			getMapControl().cancelDrawing();
+		}
+		if (e.getClickCount()==2){
+			doubleClick=true;
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseReleased(java.awt.event.MouseEvent)
+	 */
+	public void mouseReleased(MouseEvent e) throws BehaviorException {
+		PointEvent event = new PointEvent(e.getPoint(), e, this.getMapControl());
+		listener.point(event);
+		if (doubleClick){
+			listener.pointDoubleClick(event);
+			doubleClick=false;
+		}
+	}
+
+	/**
+	 * <p>Sets a tool listener to work with the <code>MapControl</code> using this behavior.</p>
+	 *
+	 * @param listener a <code>PointListener</code> object for this behavior
+	 */
+	public void setListener(ToolListener listener) {
+		this.listener = (PointListener) listener;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#getListener()
+	 */
+	public ToolListener getListener() {
+		return listener;
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/DraggerBehavior.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/DraggerBehavior.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/DraggerBehavior.java	(revision 38283)
@@ -0,0 +1,140 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.Behavior;
+
+import java.awt.Graphics;
+import java.awt.event.MouseEvent;
+import java.awt.geom.Point2D;
+
+import org.gvsig.fmap.mapcontrol.MapControlDrawer;
+import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
+import org.gvsig.fmap.mapcontrol.tools.Events.MoveEvent;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.PanListener;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
+
+
+
+/**
+ * <p>Behavior that permits user to drag the image of the associated
+ *  <code>MapControl</code> using a {@link PanListener PanListener}.</p>
+ *
+ * @author Vicente Caballero Navarro
+  * @author Pablo Piqueras Bartolomé
+ */
+public class DraggerBehavior extends Behavior {
+	/**
+	 * First point of the path in image coordinates.
+	 */
+	private Point2D m_FirstPoint;
+
+	/**
+	 * Tool listener used to work with the <code>MapControl</code> object.
+	 *
+	 * @see #getListener()
+	 * @see #setListener(ToolListener)
+	 */
+	private PanListener listener;
+
+	/**
+ 	 * <p>Creates a new behavior for dragging the mouse.</p>
+ 	 *
+	 * @param pli listener used to permit this object to work with the associated <code>MapControl</code>
+	 */
+	public DraggerBehavior(PanListener pli) {
+		listener = pli;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#paintComponent(org.gvsig.fmap.mapcontrol.MapControlDrawer)
+	 */
+	public void paintComponent(MapControlDrawer mapControlDrawer) {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mousePressed(java.awt.event.MouseEvent)
+	 */
+	public void mousePressed(MouseEvent e) {
+		if (e.getButton() == MouseEvent.BUTTON1) {
+			m_FirstPoint = e.getPoint();
+		}
+
+		if (listener.cancelDrawing()) {
+			getMapControl().cancelDrawing();
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseReleased(java.awt.event.MouseEvent)
+	 */
+	public void mouseReleased(MouseEvent e) throws BehaviorException {
+		m_FirstPoint = null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseDragged(java.awt.event.MouseEvent)
+	 */
+	public void mouseDragged(MouseEvent e) throws BehaviorException {
+		MoveEvent event = new MoveEvent(m_FirstPoint, e.getPoint(), e);
+		listener.move(event);
+		getMapControl().repaint();
+	}
+
+	/**
+	 * <p>Sets a tool listener to work with the <code>MapControl</code> using this behavior.</p>
+	 *
+	 * @param listener a <code>PanListener</code> object for this behavior
+	 */
+	public void setListener(ToolListener listener) {
+		this.listener = (PanListener) listener;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#getListener()
+	 */
+	public ToolListener getListener() {
+		return listener;
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/PolylineBehavior.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/PolylineBehavior.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/PolylineBehavior.java	(revision 38283)
@@ -0,0 +1,217 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.Behavior;
+
+import java.awt.Color;
+import java.awt.event.MouseEvent;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+
+import org.gvsig.fmap.geom.primitive.GeneralPathX;
+import org.gvsig.fmap.mapcontrol.MapControlDrawer;
+import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
+import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.PolylineListener;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
+
+
+
+/**
+ * <p>Behavior that allows user to draw a polyline by its vertexes on the image of the associated
+ *  <code>MapControl</code> using a {@link PolylineListener PolylineListener}.</p>
+ *
+ * @author Vicente Caballero Navarro
+ * @author Pablo Piqueras Bartolomé
+ */
+public class PolylineBehavior extends Behavior {
+	/**
+	 * The abscissa coordinate of all vertexes of the polyline.
+	 */
+	protected ArrayList arrayX = new ArrayList(); //<Double>
+
+	/**
+	 * The ordinate coordinate of all vertexes of the polyline.
+	 */
+	protected ArrayList arrayY = new ArrayList(); //<Double>
+
+	/**
+	 * Determines if user is setting the vertexes (with one click of the button 1 of the mouse), or not.
+	 */
+	protected boolean isClicked = false;
+
+	/**
+	 * Tool listener used to work with the <code>MapControl</code> object.
+	 *
+	 * @see #getListener()
+	 * @see #setListener(ToolListener)
+	 */
+	protected PolylineListener listener;
+
+	/**
+	 * <p>Creates a new behavior for drawing a polyline by its vertexes.</p>
+	 *
+	 * @param mli listener used to permit this object to work with the associated <code>MapControl</code>
+	 */
+	public PolylineBehavior(PolylineListener mli) {
+		listener = mli;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#paintComponent(java.awt.Graphics)
+	 */
+	public void paintComponent(MapControlDrawer mapControlDrawer) {
+		mapControlDrawer.drawImage(getMapControl().getImage(), 0, 0);
+		mapControlDrawer.setColor(Color.black);
+
+		if (!arrayX.isEmpty()) {
+			drawPolyLine(mapControlDrawer);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mousePressed(java.awt.event.MouseEvent)
+	 */
+	public void mousePressed(MouseEvent e) throws BehaviorException {
+		if (e.getClickCount() == 2) {
+			listener.polylineFinished(new MeasureEvent((Double[]) arrayX.toArray(new Double[arrayX.size()]), (Double[]) arrayY.toArray(new Double[arrayY.size()]), e));
+
+			arrayX.clear();
+			arrayY.clear();
+
+			isClicked = false;
+		} else {
+			//System.err.println("simpleclick");
+			isClicked = true;
+			Point2D point = getMapControl().getViewPort().toMapPoint(e.getPoint());
+			addPoint(point);
+
+			if (arrayX.size() < 2) {
+				addPoint(point);
+			}
+
+			listener.pointFixed(new MeasureEvent((Double[]) arrayX.toArray(new Double[arrayX.size()]), (Double[]) arrayY.toArray(new Double[arrayY.size()]), e));
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseDragged(java.awt.event.MouseEvent)
+	 */
+	public void mouseDragged(MouseEvent e) throws BehaviorException {
+		mouseMoved(e);
+	}
+
+	/**
+	 * <p>Changes the last point added of the polyline.</p>
+	 *
+	 * @param p a point which will replace the last added to the polyline
+	 */
+	protected void changeLastPoint(Point2D p) {
+		if (arrayX.size() > 0) {
+			arrayX.set(arrayX.size() - 1, new Double(p.getX()));
+			arrayY.set(arrayY.size() - 1, new Double(p.getY()));
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseMoved(java.awt.event.MouseEvent)
+	 */
+	public void mouseMoved(MouseEvent e) throws BehaviorException {
+		//System.err.println("moved antes de click");
+		if (isClicked) {
+			//System.err.println("moved despues de click");
+			changeLastPoint(getMapControl().getViewPort().toMapPoint(e.getPoint()));
+
+			MeasureEvent event = new MeasureEvent((Double[]) arrayX.toArray(new Double[arrayX.size()]), (Double[]) arrayY.toArray(new Double[arrayY.size()]), e);
+
+			listener.points(event);
+			getMapControl().repaint();
+		}
+	}
+
+	/**
+	 * <p>Draws the polyline in the <code>Graphics2D</code> of the associated <code>MapControl</code>.</p>
+	 *
+	 * @param g2 the 2D context that allows draw the polyline
+	 */
+	protected void drawPolyLine(MapControlDrawer mapControlDrawer) {
+		GeneralPathX polyline = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, arrayX.size());
+
+		polyline.moveTo(((Double) arrayX.get(0)).doubleValue(),
+				((Double) arrayY.get(0)).doubleValue());
+
+		for (int index = 0; index < arrayX.size(); index++) {
+		    polyline.lineTo(((Double) arrayX.get(index)).doubleValue(),((Double) arrayY.get(index)).doubleValue());
+		}
+
+		mapControlDrawer.draw(createLineString(polyline));
+	}
+
+	/**
+	 * <p>Adds a new point to the polyline.</p>
+	 *
+	 * @param p a new point to the polyline
+	 */
+	protected void addPoint(Point2D p) {
+		arrayX.add(new Double(p.getX()));
+		arrayY.add(new Double(p.getY()));
+	}
+
+	/**
+	 * <p>Sets a tool listener to work with the <code>MapControl</code> using this behavior.</p>
+	 *
+	 * @param listener a <code>PolylineListener</code> object for this behavior
+	 */
+	public void setListener(ToolListener listener) {
+		this.listener = (PolylineListener) listener;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#getListener()
+	 */
+	public ToolListener getListener() {
+		return listener;
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/RectangleSelectionListener.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/RectangleSelectionListener.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/RectangleSelectionListener.java	(revision 38283)
@@ -0,0 +1,136 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools;
+
+import java.awt.Image;
+
+import javax.swing.ImageIcon;
+
+import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.feature.FeatureSelection;
+import org.gvsig.fmap.dal.feature.FeatureSet;
+import org.gvsig.fmap.geom.primitive.Envelope;
+import org.gvsig.fmap.mapcontext.layers.FLayer;
+import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
+import org.gvsig.fmap.mapcontrol.MapControl;
+import org.gvsig.fmap.mapcontrol.tools.Events.EnvelopeEvent;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.RectangleListener;
+import org.gvsig.tools.dispose.DisposeUtils;
+
+/**
+ * <p>Listener that selects all features of the active and vector layers which intersect with the defined
+ *  rectangle area in the associated {@link MapControl MapControl} object.</p>
+ *
+ * @author Vicente Caballero Navarro
+ */
+public class RectangleSelectionListener implements RectangleListener {
+	/**
+	 * The image to display when the cursor is active.
+	 */
+	private final Image img = new ImageIcon(MapControl.class.getClassLoader().getResource(
+				"org/gvsig/fmap/mapcontrol/images/RectSelectCursor.gif")).getImage();
+
+	/**
+	 * Reference to the <code>MapControl</code> object that uses.
+	 */
+	private MapControl mapCtrl;
+
+	/**
+  	 * <p>Creates a new <code>RectangleSelectionListener</code> object.</p>
+	 *
+	 * @param mc the <code>MapControl</code> where is defined the rectangle
+	 */
+	public RectangleSelectionListener(MapControl mc) {
+		this.mapCtrl = mc;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.RectangleListener#rectangle(com.iver.cit.gvsig.fmap.tools.Events.RectangleEvent)
+	 */
+	public void rectangle(EnvelopeEvent event) throws BehaviorException {
+		try {
+			// mapCtrl.getMapContext().selectByRect(event.getWorldCoordRect());
+            Envelope rect = event.getWorldCoordRect();
+            FLayer[] actives = mapCtrl.getMapContext()
+                .getLayers().getActives();
+            for (int i=0; i < actives.length; i++){
+                if (actives[i] instanceof FLyrVect) {
+                    FLyrVect lyrVect = (FLyrVect) actives[i];
+                    FeatureSelection oldSelection = (FeatureSelection) lyrVect.getFeatureStore().getSelection();
+					FeatureSet newSelection = null;
+					try {
+						newSelection =
+								lyrVect.queryByEnvelope(rect,
+										lyrVect.getFeatureStore()
+												.getDefaultFeatureType());
+						if (event.getEvent().isControlDown()) {
+							oldSelection.select(newSelection);
+						} else {
+							lyrVect.getDataStore().setSelection(newSelection);
+						}
+					} finally {
+						DisposeUtils.dispose(newSelection);
+                    }
+                }
+            }
+
+		} catch (DataException e) {
+			throw new BehaviorException("No se pudo hacer la selección", e);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getImageCursor()
+	 */
+	public Image getImageCursor() {
+		return img;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
+	 */
+	public boolean cancelDrawing() {
+		return false;
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Events/MeasureEvent.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Events/MeasureEvent.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Events/MeasureEvent.java	(revision 38283)
@@ -0,0 +1,145 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.Events;
+
+import java.awt.event.MouseEvent;
+
+import org.gvsig.fmap.geom.primitive.GeneralPathX;
+
+/**
+ * <p><code>MeasureEvent</code> is used to notify the selection of a polyline.</p>
+ *
+ * <p>Stores the information about the 2D vertexes and the {@link GeneralPathX GeneralPathX}
+ *  between them.</p>
+ *
+ * @author Vicente Caballero Navarro
+ */
+public class MeasureEvent {
+	/**
+	 * The polyline, broken down in straight lines, and quadratic and cubic (Bézier) curves.
+	 */
+	private GeneralPathX gp;
+
+	/**
+	 * Vector with the X coordinates.
+	 */
+	private Double[] x;
+
+	/**
+	 * Vector with the Y coordinates.
+	 */
+	private Double[] y;
+
+	/**
+	 * Mouse event that has been the cause of creating this event.
+	 */
+	private MouseEvent event;
+
+	/**
+	 * <p>Creates a new <code>MeasureEvent</code> with all necessary data.</p>
+	 * <p>The general path is calculated according the enclosed regions of the path alternate between interior
+	 *  and exterior areas are traversed from the outside of the path towards a point inside the region.</p>
+	 *
+	 * @param x vector with the X coordinates
+	 * @param y vector with the Y coordinates
+	 * @param e event that has been the cause of creating this one
+	 */
+	public MeasureEvent(Double[] x, Double[] y, MouseEvent e) {
+		this.x = x;
+		this.y = y;
+		this.event = e;
+		gp = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, x.length);
+		gp.moveTo(x[0].doubleValue(), y[0].doubleValue());
+
+		for (int index = 1; index < x.length; index++) {
+			gp.lineTo(x[index].doubleValue(), y[index].doubleValue());
+		}
+	}
+
+	/**
+	 * <p>Gets the {@link GeneralPathX GeneralPathX} of the measurement.</p>
+	 *
+	 * @see GeneralPathX
+	 *
+	 * @return geometric path constructed from straight lines, and quadratic and cubic (Bézier) curves
+	 */
+	public GeneralPathX getGP() {
+		return gp;
+	}
+
+	/**
+	 * <p>Sets the {@link GeneralPathX GeneralPathX} of the measurement.</p>
+	 *
+	 * @see GeneralPathX
+	 *
+	 * @param gP geometric path constructed from straight lines, and quadratic and cubic (Bézier) curves
+	 */
+	public void setGP(GeneralPathX gp) {
+		this.gp = gp;
+	}
+
+	/**
+	 * <p>Gets a vector with the X coordinates.</p>
+	 *
+	 * @return vector with the X coordinates
+	 */
+	public Double[] getXs() {
+		return x;
+	}
+
+	/**
+	 * <p>Gets a vector with the Y coordinates.</p>
+	 *
+	 * @return vector with the Y coordinates
+	 */
+	public Double[] getYs() {
+		return y;
+	}
+
+	/**
+	 * <p>Gets the event that has been the cause of creating this one.</p>
+	 *
+	 * @return mouse event that has been the cause of creating this one
+	 */
+	public MouseEvent getEvent() {
+		return event;
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Events/MoveEvent.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Events/MoveEvent.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Events/MoveEvent.java	(revision 38283)
@@ -0,0 +1,107 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.Events;
+
+import java.awt.event.MouseEvent;
+import java.awt.geom.Point2D;
+
+
+/**
+ * <p><code>MoveEvent</code> is used to notify a movement of the mouse between two points 2D.</p>
+ *
+ * @author Vicente Caballero Navarro
+ */
+public class MoveEvent {
+	/**
+	 * <p>Initial position of the drag & drop movement.</p>
+	 */
+	private Point2D from;
+    
+    /**
+     * <p>Final position of the drag & drop movement.</p>
+     */
+	private Point2D to;
+    
+    /**
+     * <p>Mouse event that has been the cause of creating this one.</p> 
+     */
+	private MouseEvent event;
+
+    /**
+     * <p>Creates a new <code>MoveEvent</code> with all necessary data.</p>
+     *
+	 * @param from initial 2D position of the movement
+	 * @param to final 2D position of the movement
+	 * @param e mouse event that has been the cause of creating this one
+     */
+    public MoveEvent(Point2D from, Point2D to, MouseEvent e) {
+        this.from = from;
+        this.to = to;
+        event = e;
+    }
+
+	/**
+	 * <p>Gets the initial 2D position of the movement.</p>
+	 *
+	 * @return initial 2D position of the movement
+	 */
+    public Point2D getFrom() {
+        return from;
+    }
+
+	/**
+	 * <p>Gets the final 2D position of the movement.</p>
+	 *
+	 * @return final 2D position of the movement
+	 */
+    public Point2D getTo() {
+        return to;
+    }
+
+    /**
+	 * <p>Gets the event that has been the cause of creating this one.</p>
+	 * 
+	 * @return mouse event that has been the cause of creating this one
+     */
+    public MouseEvent getEvent() {
+		return event;
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Events/PointEvent.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Events/PointEvent.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Events/PointEvent.java	(revision 38283)
@@ -0,0 +1,128 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.Events;
+
+import java.awt.event.MouseEvent;
+import java.awt.geom.Point2D;
+
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.GeometryLocator;
+import org.gvsig.fmap.geom.GeometryManager;
+import org.gvsig.fmap.geom.exception.CreateGeometryException;
+import org.gvsig.fmap.geom.primitive.Point;
+import org.gvsig.fmap.mapcontrol.MapControl;
+
+
+/**
+ * <p><code>PointEvent</code> is used to notify a selection of a point with the mouse.</p>
+ *
+ * @author Vicente Caballero Navarro
+ */
+public class PointEvent {
+	/**
+	 * <p>The point 2D associated to this event.</p>
+	 */
+	private Point2D p;
+
+	/**
+	 * <p>The point 2D associated to this event.</p>
+	 */
+	private MouseEvent e;
+
+	private MapControl mapControl;
+
+	/**
+	 * <p>Creates a new <code>PointEvent</code> with all necessary data.</p>
+	 *
+	 * @param p the point 2D associated to this event
+	 * @param e event that has been the cause of creating this one
+	 */
+	public PointEvent(Point2D p, MouseEvent e) {
+		this.p = p;
+		this.e = e;
+		this.mapControl = null;
+	}
+
+	public PointEvent(Point2D p, MouseEvent e, MapControl mapControl) {
+		this(p, e);
+		this.mapControl = mapControl;
+	}
+	
+	/**
+	 * <p>Gets the point 2D in screen coordinates where this event was produced.</p>
+	 *
+	 * @return the point 2D associated to this event
+	 */
+	public Point2D getPoint() {
+		return p;
+	}
+
+	/**
+	 * Gets the Geometry point 2D in map coordinates where this event was produced.
+	 *
+	 * @return the Geometry point 2D associated to this event
+	 */
+	public Point getMapPoint() {
+		if( mapControl == null ) {
+			throw new UnsupportedOperationException();
+		}
+		return this.mapControl.getViewPort().convertToMapPoint(p);
+	}
+
+	
+	/**
+	 * <p>Sets the point 2D where this event was produced.</p>
+	 *
+	 * @param the point 2D associated to this event
+	 */
+	public void setPoint(Point2D p) {
+		this.p = p;
+	}
+
+    /**
+	 * <p>Gets the event that has been the cause of creating this one.</p>
+	 * 
+	 * @return mouse event that has been the cause of creating this one
+     */
+	public MouseEvent getEvent() {
+		return e;
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Events/EnvelopeEvent.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Events/EnvelopeEvent.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Events/EnvelopeEvent.java	(revision 38283)
@@ -0,0 +1,112 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.Events;
+
+import java.awt.event.MouseEvent;
+import java.awt.geom.Rectangle2D;
+
+import org.gvsig.fmap.geom.primitive.Envelope;
+
+
+/**
+ * <p><code>RectangleEvent</code> is used to notify a selection of a rectangular area in a view, with the mouse.</p>
+ *
+ * @author Vicente Caballero Navarro
+ */
+public class EnvelopeEvent {
+	/**
+	 * <p>Rectangle selected in world coordinates.</p>
+	 */
+	private Envelope rect;
+
+    /**
+     * <p>Rectangle selected in view (pixel) coordinates.</p>
+     */
+	private Rectangle2D pixRect;
+
+    /**
+	 * <p>Mouse event that has been the cause of creating this event.</p>
+     */
+	private MouseEvent event;
+
+	/**
+	 * <p>Creates a new <code>RectangleEvent</code> with all necessary data.</p>
+	 *
+	 * @param worldRect rectangle selected in world coordinates
+	 * @param pixelRect rectangle selected in view (pixel) coordinates
+	 * @param e mouse event that has been the cause of creating this event
+	 */
+    public EnvelopeEvent(Envelope worldRect, MouseEvent e, Rectangle2D pixelRect) {
+        rect = worldRect;
+        event = e;
+        pixRect = pixelRect;
+    }
+
+	/**
+	 * <p>Gets the rectangle selected in world coordinates.</p>
+	 *
+	 * @return rectangle selected in world coordinates
+	 */
+    public Envelope getWorldCoordRect() {
+        return rect;
+    }
+
+    /**
+     * <p>Gets the rectangle selected in pixel coordinates.</p>
+     *
+     * <p>This is useful for doing some verifications, like if rectangle is thinner than
+     *  3 pixels of width and height, keeping the zoom instead of reducing it.</p>
+     *
+     * @return rectangle selected in view (pixel) coordinates
+     */
+    public Rectangle2D getPixelCoordRect() {
+        return pixRect;
+    }
+
+    /**
+	 * <p>Gets the event that has been the cause of creating this one.</p>
+	 *
+	 * @return mouse event that has been the cause of creating this one
+     */
+	public MouseEvent getEvent() {
+		return event;
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/PolylineListener.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/PolylineListener.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/PolylineListener.java	(revision 38283)
@@ -0,0 +1,87 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.Listeners;
+
+import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
+import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent;
+
+
+
+/**
+ * <p>Interface for all tools that reply for a {@link MeasureEvent MeasureEvent} produced in the 
+ *  associated {@link MapControl MapControl} object, as a consequence of a 2D polyline drawn by the mouse.</p>
+ *
+ * @author Vicente Caballero Navarro
+ */
+public interface PolylineListener extends ToolListener {
+	/**
+	 * <p>Called when user moves the mouse after selecting a vertex of the polyline.</p>
+	 * <p>Each kind of polyline listener calculates different information with the data of the
+	 *  <code>MeasureEvent</code>, according its nature.</p>
+	 *
+	 * @param event information about the mouse event, and geometry data of the polyline
+	 *
+	 * @throws BehaviorException will be thrown when fails the process of this tool
+	 */
+	public void points(MeasureEvent event) throws BehaviorException;
+
+	/**
+	 * <p>Called when user executes a mouse click and selects a vertex of the polyline.</p>
+	 * 
+	 * @param event information about the mouse event, and geometry data of the polyline
+	 *
+	 * @throws BehaviorException will be thrown when fails the process of this tool
+	 */
+	public void pointFixed(MeasureEvent event) throws BehaviorException;
+
+	/**
+	 * <p>Called when user executes a double click with the mouse, finishing the 
+	 *  drawn of the polyline.</p>
+	 * 
+	 * <p>All features of the active and vector layers of the associated <code>MapControl</code> object that
+	 *  their area intersect with the polygonal area defined in the <i>event</i>, will be selected.</p> 
+	 *
+	 * @param event information about the mouse event, and geometry data of the polyline
+	 *
+	 * @throws BehaviorException will be thrown when fails the process of this tool
+	 */
+	public void polylineFinished(MeasureEvent event) throws BehaviorException;
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/AbstractPointListener.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/AbstractPointListener.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/AbstractPointListener.java	(revision 38283)
@@ -0,0 +1,12 @@
+package org.gvsig.fmap.mapcontrol.tools.Listeners;
+
+import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
+import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent;
+
+public abstract class AbstractPointListener extends AbstractToolListener implements PointListener {
+
+	public void pointDoubleClick(PointEvent event) throws BehaviorException {
+		// Do thing by default
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/AbstractPointListener.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/ToolListener.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/ToolListener.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/ToolListener.java	(revision 38283)
@@ -0,0 +1,77 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.Listeners;
+
+import java.awt.Image;
+
+import org.gvsig.fmap.mapcontrol.MapControl;
+import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior;
+
+
+/**
+ * <p>User can interact with a {@link MapControl MapControl} instance, working with a tool that applies changes on it
+ *  processing the events produced by the current {@link Behavior Behavior} of <code>MapControl</code>.</p>
+ *
+ * <p>The process that the tool applies on the <code>MapControl</code> is a consequence of the mouse actions
+ *  that user has done on that area.</p>
+ *
+ * <p>Only some tool listener can be cancelled.</p>
+ *
+ * @author Vicente Caballero Navarro
+ */
+public interface ToolListener {
+	/**
+	 * <p>Gets the <code>Cursor</code> associated to this tool.</p>
+	 *
+	 * @return component with the bitmap associated to this tool
+	 */
+	public Image getImageCursor();
+
+	/**
+	 * <p>Determines if the drawing process that this tool executes on the <code>MapControl</code>
+	 *  instance could be canceled or not.</p>
+	 *
+	 * @return <code>true</code> if is cancellable; otherwise returns <code>false</code>
+	 */
+	public boolean cancelDrawing();
+
+
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/PanListener.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/PanListener.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/PanListener.java	(revision 38283)
@@ -0,0 +1,66 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.Listeners;
+
+import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
+import org.gvsig.fmap.mapcontrol.tools.Events.MoveEvent;
+
+
+
+/**
+ * <p>Interface for all tools that reply for a {@link MoveEvent MoveEvent} produced in the 
+ *  associated {@link MapControl MapControl} object, as a consequence of a 2D drag and drop
+ *  movement of the mouse.</p>
+ *
+ * @author Vicente Caballero Navarro
+ */
+public interface PanListener extends ToolListener {
+	/**
+	 * <p>Called when user drags the mouse on the view.</p>
+	 * <p>Updates the extent coordinates according to the direction of the movement between
+	 *  the initial and final points of line determined by the move of the mouse.</p>
+	 *
+	 * @param event mouse event information about the initial and final positions of the movement 
+	 *
+	 * @throws BehaviorException will be thrown when fails the process of this tool
+	 */
+	public void move(MoveEvent event) throws BehaviorException;
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/AbstractToolListener.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/AbstractToolListener.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/AbstractToolListener.java	(revision 38283)
@@ -0,0 +1,23 @@
+package org.gvsig.fmap.mapcontrol.tools.Listeners;
+
+import java.awt.Image;
+
+import javax.swing.ImageIcon;
+
+import org.gvsig.fmap.mapcontrol.MapControl;
+
+public abstract class AbstractToolListener implements ToolListener {
+
+	private final Image img = new ImageIcon(MapControl.class.getResource(
+	"images/PointSelectCursor.gif")).getImage();
+
+
+	public boolean cancelDrawing() {
+		return false;
+	}
+
+	public Image getImageCursor() {
+		return this.img;
+	}
+
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/AbstractToolListener.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/CircleListener.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/CircleListener.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/CircleListener.java	(revision 38283)
@@ -0,0 +1,63 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.Listeners;
+
+import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
+import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent;
+
+
+
+/**
+ * <p>Interface for all tools that reply for a {@link MeasureEvent MeasureEvent} produced in the 
+ *  associated {@link MapControl MapControl} object, as a consequence of a circle area drawn by the mouse.</p>
+ * 
+ * @see ToolListener
+ */
+public interface CircleListener extends ToolListener {
+	/**
+	 * <p>Called when user defines a circular area.</p>
+	 *
+	 * @param event information about the mouse event, and geometry data related with the operation done
+	 *
+	 * @throws BehaviorException will be thrown when fails the process of this tool
+	 */
+	public void circle(MeasureEvent event) throws BehaviorException;
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/RectangleListener.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/RectangleListener.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/RectangleListener.java	(revision 38283)
@@ -0,0 +1,67 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.Listeners;
+
+import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
+import org.gvsig.fmap.mapcontrol.tools.Events.EnvelopeEvent;
+
+
+
+/**
+ * <p>Interface specialized for tools that reply for a {@link EnvelopeEvent RectangleEvent} produced in the 
+ *  associated {@link MapControl MapControl} object, as a consequence of a 2D rectangle drawn by the mouse.</p>
+ *
+ * @author Vicente Caballero Navarro
+ */
+public interface RectangleListener extends ToolListener {
+	/**
+	 * <p>Called when user executes a double click with the mouse, finishing the 
+	 *  drawn of the rectangle.</p>
+	 * 
+	 * <p>All features of the active and vector layers of the associated <code>MapControl</code> object that
+	 *  their area intersect with the polygonal area defined in the <i>event</i>, will be selected.</p> 
+	 *
+	 * @param event mouse event and information about the rectangle defined
+	 *
+	 * @throws BehaviorException will be thrown when fails the process of this tool
+	 */
+	public void rectangle(EnvelopeEvent event) throws BehaviorException;
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/PointListener.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/PointListener.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Listeners/PointListener.java	(revision 38283)
@@ -0,0 +1,74 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools.Listeners;
+
+import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
+import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent;
+
+
+
+/**
+ * <p>Interface for all tools that reply for a {@link PointEvent PointEvent} produced in the 
+ *  associated {@link MapControl MapControl} object, produced by a simple or double click of a button
+ *  of the mouse.</p>
+ *
+ * @author Vicente Caballero Navarro
+ */
+public interface PointListener extends ToolListener {
+	/**
+	 * <p>Called when one click is pressed on the associated <code>MapControl</code>, or the location of the cursor
+	 *  of the mouse has changed on it.</p>
+	 *
+	 * @param event mouse event with the coordinates of the point selected on the associated <code>MapControl</code>
+	 *
+	 * @throws BehaviorException will be thrown when fails the process of this tool
+	 */
+	public void point(PointEvent event) throws BehaviorException;
+
+	/**
+	 * <p>Called when a double click is pressed on the associated <code>MapControl</code>.</p>
+	 *
+	 * @param event mouse event and the coordinates of the point selected on the associated <code>MapControl</code>
+	 *
+	 * @throws BehaviorException will be thrown when fails the process of this tool
+	 */
+	public void pointDoubleClick(PointEvent event) throws BehaviorException;
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/MeasureListenerImpl.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/MeasureListenerImpl.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/MeasureListenerImpl.java	(revision 38283)
@@ -0,0 +1,141 @@
+/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
+ *
+ * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *  Generalitat Valenciana
+ *   Conselleria d'Infraestructures i Transport
+ *   Av. Blasco Ibáñez, 50
+ *   46010 VALENCIA
+ *   SPAIN
+ *
+ *      +34 963862235
+ *   gvsig@gva.es
+ *      www.gvsig.gva.es
+ *
+ *    or
+ *
+ *   IVER T.I. S.A
+ *   Salamanca 50
+ *   46005 Valencia
+ *   Spain
+ *
+ *   +34 963163400
+ *   dac@iver.es
+ */
+package org.gvsig.fmap.mapcontrol.tools;
+
+import java.awt.Image;
+import java.awt.Point;
+
+import javax.swing.ImageIcon;
+
+import org.gvsig.fmap.mapcontext.ViewPort;
+import org.gvsig.fmap.mapcontrol.MapControl;
+import org.gvsig.fmap.mapcontrol.tools.Events.MeasureEvent;
+import org.gvsig.fmap.mapcontrol.tools.Listeners.PolylineListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+/**
+ * <p>Listener for calculating the length of the segments of a polyline, defined in the associated {@link MapControl MapControl}
+ *  object.</p>
+ *
+ * @author Vicente Caballero Navarro
+ */
+public class MeasureListenerImpl implements PolylineListener {
+
+	private static final Logger logger = LoggerFactory.getLogger(MeasureListenerImpl.class);
+	/**
+	 * The image to display when the cursor is active.
+	 */
+	private final Image iruler = new ImageIcon(MapControl.class.getClassLoader().getResource(
+				"org/gvsig/fmap/mapcontrol/images/RulerCursor.gif")).getImage();
+
+	/**
+	 * Reference to the <code>MapControl</code> object that uses.
+	 */
+	protected MapControl mapCtrl;
+
+	/**
+	 * <p>Creates a new listener for calculating the length of a polyline.</p>
+	 *
+	 * @param mc the <code>MapControl</code> where is calculated the length
+	 */
+	public MeasureListenerImpl(MapControl mc) {
+		this.mapCtrl = mc;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#points(com.iver.cit.gvsig.fmap.tools.Events.MeasureEvent)
+	 */
+	public void points(MeasureEvent event) {
+		double dist = 0;
+		double distAll = 0;
+
+		ViewPort vp = mapCtrl.getMapContext().getViewPort();
+
+		for (int i = 0; i < (event.getXs().length - 1); i++) {
+			dist = 0;
+
+			Point p = new Point(event.getXs()[i].intValue(),
+					event.getXs()[i].intValue());
+			Point p2 = new Point(event.getXs()[i + 1].intValue(),
+					event.getXs()[i + 1].intValue());
+
+			///dist = vp.toMapDistance((int) p.distance(p2));
+			dist = vp.distanceWorld(p, p2);
+			distAll += dist;
+		}
+
+		logger.debug("Distancia = {}, Distancia Total = {}.",dist,distAll);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getImageCursor()
+	 */
+	public Image getImageCursor() {
+		return iruler;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#pointFixed(com.iver.cit.gvsig.fmap.tools.Events.MeasureEvent)
+	 */
+	public void pointFixed(MeasureEvent event) {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
+	 */
+	public boolean cancelDrawing() {
+		return false;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PolylineListener#polylineFinished(com.iver.cit.gvsig.fmap.tools.Events.MeasureEvent)
+	 */
+	public void polylineFinished(MeasureEvent event) {
+	}
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/geo/Geo.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/geo/Geo.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/geo/Geo.java	(revision 38283)
@@ -0,0 +1,150 @@
+package org.gvsig.fmap.mapcontrol.tools.geo;
+
+/**
+ * <p>Mathematical utilities to work with geographical data:
+ *  <ul>
+ *  <li>Geographical constants:
+ *   <ul>
+ *    <li>PI / 2.</li>
+ *    <li>Degrees per radian.</li>
+ *    <li>Square miles per spherical degree.</li>
+ *    <li>Square kilometres per spherical degree.</li>
+ *    <li>Square metres per spherical degree.</li>
+ *   </ul>
+ *  </li>
+ *  <li>Decimal degrees equivalent to <i>m</i> meters.</li>
+ *  <li>The area of a spherical polygon in spherical degrees, given the latitudes and longitudes 
+ *   of <i>n</i> points, according the <a href="http://en.wikipedia.org/wiki/Haversine_formula">Haversine function</a>.
+ *  </ul>
+ * </p> 
+ *
+ * @author Vicente Caballero Navarro
+ */
+public class Geo {
+	/**
+	 * <i>PI / 2</i>, having PI = 3.14159265358979323846
+	 */
+	public static double HalfPi = 1.5707963267948966192313;
+
+    /**
+     * Degrees per radian.
+     */
+	public static double Degree = 57.295779513082320876798; /* degrees per radian */
+
+    /**
+     *  Square miles per spherical degree.
+     */
+	public static double SqMi = 273218.4; /* Square mi per spherical degree. */
+
+    /**
+     * Square kilometres per spherical degree.
+     */
+	public static double SqKm = 707632.4; /* Square km per spherical degree. */
+
+    /**
+     * Square metres per spherical degree.
+     */
+	public static double SqM = 707632400000.0; /* Square M per spherical degree. */
+
+
+	/**
+	 * <p>Gets the decimal degrees equivalent to the <i>m</i> meters.</p>
+	 * <p>Uses this formula:</br>
+	 * <b><i>m * R * PI</i></b>, having R = Radius of the Earth at the equator
+	 * </p>
+	 * 
+	 * @param m distance value in meters
+	 * 
+	 * @return <i>m</i> * Radius at the equator
+	 */
+	public static double getDecimalDegrees(double m) {
+    	///(m*180)/ (6378137.0 * Math.PI)
+    	return (m*8.983152841195214E-6);
+    }
+
+    /**
+     * <p>Operation for calculate the <a href="http://en.wikipedia.org/wiki/Haversine_formula">Haversine function</a>:
+     *  <b><i>hav(x)= (1-cos(x))/2</i></b>.</p>
+     * 
+     * @param X length between the difference of a coordinate of two points
+     */
+	private static double hav(double X){
+        return (1.0 - Math.cos(X)) / 2.0;
+    }
+
+    /**
+     * <p>Returns the area of a spherical polygon in spherical degrees,
+     *  given the latitudes and longitudes in <i>lat</i> and <i>lon</i>, respectively.</p>
+     *
+     * <p>The <i>n</i> data points have indexes which range from 0 to N-1.</p>
+     *
+     * <p>Uses the <a href="http://en.wikipedia.org/wiki/Haversine_formula">Haversine function</a> for calculating the
+     *  spherical area of the polygon.</p>
+     *  
+     * @param lat latitude of the vertexes <i>(must be in radians)</i>
+     * @param lon longitude of the vertexes <i>(must be in radians)</i>
+     * @param n number of vertexes in the polygon
+     * 
+     * @return the area of a spherical polygon in spherical degrees
+     */
+    public static double sphericalPolyArea(double[] lat, double[] lon, int n) {
+        int j;
+        int k;
+        double lam1;
+        double lam2 = 0;
+        double beta1;
+        double beta2 = 0;
+        double cosB1;
+        double cosB2 = 0;
+        double havA;
+        double t;
+        double a;
+        double b;
+        double c;
+        double s;
+        double sum;
+        double excess;
+
+        sum = 0;
+
+        for (j = 0; j <= n; j++) {
+            k = j + 1;
+
+            if (j == 0) {
+                lam1 = lon[j];
+                beta1 = lat[j];
+                lam2 = lon[j + 1];
+                beta2 = lat[j + 1];
+                cosB1 = Math.cos(beta1);
+                cosB2 = Math.cos(beta2);
+            } else {
+                k = (j + 1) % (n + 1);
+                lam1 = lam2;
+                beta1 = beta2;
+                lam2 = lon[k];
+                beta2 = lat[k];
+                cosB1 = cosB2;
+                cosB2 = Math.cos(beta2);
+            }
+
+            if (lam1 != lam2) {
+                havA = hav(beta2 - beta1) + (cosB1 * cosB2 * hav(lam2 - lam1));
+                a = 2 * Math.asin(Math.sqrt(havA));
+                b = HalfPi - beta2;
+                c = HalfPi - beta1;
+                s = 0.5 * (a + b + c);
+                t = Math.tan(s / 2) * Math.tan((s - a) / 2) * Math.tan((s - b) / 2) * Math.tan((s -
+                        c) / 2);
+
+                excess = Math.abs(4 * Math.atan(Math.sqrt(Math.abs(t)))) * Degree;
+
+                if (lam2 < lam1) {
+                    excess = -excess;
+                }
+
+                sum = sum + excess;
+            }
+        }
+        return Math.abs(sum);
+    } /*        SphericalPolyArea. */
+}
Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/impl/DefaultPrimitivesDrawer.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/impl/DefaultPrimitivesDrawer.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/impl/DefaultPrimitivesDrawer.java	(revision 38283)
@@ -0,0 +1,100 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+package org.gvsig.fmap.mapcontrol.impl;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.gvsig.fmap.mapcontrol.PrimitivesDrawer;
+
+/**
+ * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
+ */
+public class DefaultPrimitivesDrawer implements PrimitivesDrawer {
+
+    private static final Logger LOG = LoggerFactory
+        .getLogger(DefaultPrimitivesDrawer.class);
+
+    protected Graphics2D graphics = null;
+    protected Color color = Color.BLACK;
+    protected Color xorColor = Color.WHITE;
+    private Object lockObject = null;
+
+    public DefaultPrimitivesDrawer() {
+        super();
+    }
+
+    public DefaultPrimitivesDrawer(Graphics2D graphics) {
+        super();
+        this.graphics = graphics;
+    }
+
+    public void drawLine(int x1, int y1, int x2, int y2) {
+        graphics.setXORMode(xorColor);
+        graphics.drawLine(x1, y1, x2, y2);
+        graphics.setPaintMode();
+    }
+
+    public void drawOval(int x, int y, int width, int height) {
+        graphics.setXORMode(xorColor);
+        graphics.drawOval(x, y, width, height);
+        graphics.setPaintMode();
+    }
+
+    public void drawRect(int x, int y, int width, int height) {
+        graphics.setXORMode(xorColor);
+        graphics.drawRect(x, y, width, height);
+        graphics.setPaintMode();
+    }
+
+    public void fillRect(int x, int y, int width, int height) {
+        graphics.setColor(color);
+        graphics.fillRect(x, y, width, height);
+    }
+
+    public void setColor(Color color) {
+        this.color = color;
+    }
+
+    public void setGraphics(Graphics graphics) {
+        this.graphics = (Graphics2D) graphics;
+    }
+
+    public void stopDrawing(Object obj) {
+        if (lockObject != obj) {
+            LOG.warn("Trying to unlock a resource that is not locked");
+            return;
+        }
+        lockObject = null;
+    }
+
+    public void startDrawing(Object obj) throws InterruptedException {
+        while ((lockObject != null) && (obj != lockObject)) {
+            Thread.sleep(100);
+        }
+        lockObject = obj;
+    }
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/impl/DefaultPrimitivesDrawer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/impl/DefaultMapControlLibrary.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/impl/DefaultMapControlLibrary.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/impl/DefaultMapControlLibrary.java	(revision 38283)
@@ -0,0 +1,67 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+*
+* Copyright (C) 2007-2008 Infrastructures and Transports Department
+* of the Valencian Government (CIT)
+* 
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+* 
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+* 
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+* MA  02110-1301, USA.
+* 
+*/
+
+/*
+* AUTHORS (In addition to CIT):
+* 2009 {Iver T.I.}   {Task}
+*/
+ 
+package org.gvsig.fmap.mapcontrol.impl;
+
+import org.gvsig.fmap.mapcontrol.MapControlLibrary;
+import org.gvsig.fmap.mapcontrol.MapControlLocator;
+import org.gvsig.fmap.mapcontrol.MapControlManager;
+import org.gvsig.tools.library.AbstractLibrary;
+import org.gvsig.tools.library.LibraryException;
+import org.gvsig.tools.locator.ReferenceNotRegisteredException;
+
+/**
+ * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
+ */
+public class DefaultMapControlLibrary extends AbstractLibrary{
+	
+    @Override
+    public void doRegistration() {
+        registerAsImplementationOf(MapControlLibrary.class);
+    }
+
+	@Override
+	protected void doInitialize() throws LibraryException {
+		MapControlLocator.registerMapControlManager(DefaultMapControlManager.class);
+	}
+
+	@Override
+	protected void doPostInitialize() throws LibraryException {
+		// Validate there is any implementation registered.
+		MapControlManager mapControlManager = MapControlLocator.getMapControlManager();
+		if (mapControlManager == null) {
+			throw new ReferenceNotRegisteredException(
+					MapControlLocator.MAPCONTROL_MANAGER_NAME, 
+					MapControlLocator.getInstance());
+		}
+		
+		//Register the default implementation for a view, that will be
+		//the 2D MapControlDrawer.
+		mapControlManager.registerDefaultMapControlDrawer(MapControlDrawer2D.class);
+	}
+}
+

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/impl/DefaultMapControlLibrary.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/impl/MapControlDrawer2D.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/impl/MapControlDrawer2D.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/impl/MapControlDrawer2D.java	(revision 38283)
@@ -0,0 +1,187 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2009 {Iver T.I.}   {Task}
+ */
+
+package org.gvsig.fmap.mapcontrol.impl;
+
+import java.awt.Color;
+import java.awt.Composite;
+import java.awt.Image;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
+
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.GeometryLocator;
+import org.gvsig.fmap.geom.GeometryManager;
+import org.gvsig.fmap.geom.handler.Handler;
+import org.gvsig.fmap.geom.operation.Draw;
+import org.gvsig.fmap.geom.operation.DrawOperationContext;
+import org.gvsig.fmap.geom.operation.GeometryOperationException;
+import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
+import org.gvsig.fmap.geom.primitive.Curve;
+import org.gvsig.fmap.geom.primitive.GeneralPathX;
+import org.gvsig.fmap.mapcontext.MapContextLocator;
+import org.gvsig.fmap.mapcontext.ViewPort;
+import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
+import org.gvsig.fmap.mapcontrol.MapControlDrawer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * MapControlDrawer for a 2D view.
+ * 
+ * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
+ */
+public class MapControlDrawer2D extends DefaultPrimitivesDrawer implements MapControlDrawer{
+    private static final Logger LOG = LoggerFactory.getLogger(MapControlDrawer2D.class);
+    
+	protected GeometryManager geomManager = GeometryLocator.getGeometryManager();
+	private ViewPort viewPort = null;
+
+	/**
+	 * @param graphics
+	 * @param viewPort
+	 */
+	public MapControlDrawer2D() {
+		super();		
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.tools.renderer.Renderer#draw(org.gvsig.fmap.geom.Geometry, org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol)
+	 */
+	public void draw(Geometry geometry, ISymbol symbol) {
+		if (geometry != null) {
+		    symbol.draw(graphics, viewPort.getAffineTransform(), geometry, null, null);             
+		}		
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.tools.renderer.Renderer#drawHandlers(org.gvsig.fmap.geom.Geometry, java.awt.geom.AffineTransform, org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol)
+	 */
+	public void drawHandlers(Handler[] handlers, AffineTransform at, ISymbol symbol) {
+		for (int i = 0; i < handlers.length; i++) {
+			Point2D point = handlers[i].getPoint();
+			at.transform(point, point);
+
+			graphics.setPaintMode();
+			graphics.setColor(symbol.getColor());
+			graphics.fillRect((int) (point.getX() - 3), (int) (point.getY() - 3), 7, 7);
+			graphics.drawRect((int) (point.getX() - 5), (int) (point.getY() - 5), 10, 10);
+			graphics.drawString( "" + i, (int) (point.getX() - 5), (int) (point.getY() - 5));
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.tools.renderer.Renderer#drawLine(java.awt.geom.Point2D, java.awt.geom.Point2D, org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol)
+	 */
+	public void drawLine(Point2D firstPoint, Point2D endPoint, ISymbol symbol) {
+		GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, 2);
+		elShape.moveTo(firstPoint.getX(), firstPoint.getY());
+		elShape.lineTo(endPoint.getX(), endPoint.getY());
+		DrawOperationContext doc = new DrawOperationContext();
+		doc.setGraphics(graphics);
+		doc.setViewPort(viewPort);
+		doc.setSymbol(symbol);
+		try {
+			Curve curve = (Curve)geomManager.create(Geometry.TYPES.CURVE, Geometry.SUBTYPES.GEOM2D);
+			curve.setGeneralPath(elShape);
+			curve.invokeOperation(Draw.CODE, doc);
+		} catch (GeometryOperationNotSupportedException e) {
+			e.printStackTrace();
+		} catch (GeometryOperationException e) {
+			e.printStackTrace();
+		} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
+			e.printStackTrace();
+		}		
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.tools.renderer.Renderer#drawImage(java.awt.Image, int, int)
+	 */
+	public void drawImage(Image img, int x, int y) {
+		if (img != null){
+			graphics.drawImage(img, x, y, null);
+		}		
+	}	
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlDrawer#drawHandler(org.gvsig.fmap.geom.handler.Handler, java.awt.geom.AffineTransform)
+	 */
+	public void drawHandler(Handler handler, AffineTransform at) {
+		Point2D point = handler.getPoint();
+		Point2D dest = (Point2D) point.clone();
+		at.transform(point, dest);
+		graphics.setColor(Color.black);
+		graphics.drawLine((int)dest.getX()-2,(int)dest.getY()-10,(int)dest.getX()-2,(int)dest.getY()+10);
+		graphics.drawLine((int)dest.getX()+2,(int)dest.getY()-10,(int)dest.getX()+2,(int)dest.getY()+10);
+		graphics.drawLine((int)dest.getX()-10,(int)dest.getY()-2,(int)dest.getX()+10,(int)dest.getY()-2);
+		graphics.drawLine((int)dest.getX()-10,(int)dest.getY()+2,(int)dest.getX()+10,(int)dest.getY()+2);
+		graphics.setColor(Color.red);
+		graphics.drawLine((int)dest.getX()-1,(int)dest.getY()-10,(int)dest.getX()-1,(int)dest.getY()+10);
+		graphics.drawLine((int)dest.getX()+1,(int)dest.getY()-10,(int)dest.getX()+1,(int)dest.getY()+10);
+		graphics.drawLine((int)dest.getX()-10,(int)dest.getY()-1,(int)dest.getX()+10,(int)dest.getY()-1);
+		graphics.drawLine((int)dest.getX()-10,(int)dest.getY()+1,(int)dest.getX()+10,(int)dest.getY()+1);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.tools.renderer.Renderer#drawImage(java.awt.Image, java.awt.geom.AffineTransform)
+	 */
+	public void drawImage(Image img, AffineTransform xform) {
+		graphics.drawImage(img, xform, null);		
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontext.rendering.Renderer#setViewPort(org.gvsig.fmap.mapcontext.ViewPort)
+	 */
+	public void setViewPort(ViewPort viewPort) {
+		this.viewPort = viewPort;		
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlDrawer#draw(org.gvsig.fmap.geom.Geometry)
+	 */
+	public void draw(Geometry geometry) {
+		draw(geometry, MapContextLocator.getSymbolManager().createSymbol(geometry.getType()));
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlDrawer#setComposite(java.awt.AlphaComposite)
+	 */
+	public void setComposite(Composite composite) {
+		graphics.setComposite(composite);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlDrawer#transform(java.awt.geom.AffineTransform)
+	 */
+	public void transform(AffineTransform at) {
+		graphics.transform(at);		
+	}
+
+}
+

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/impl/MapControlDrawer2D.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/impl/DefaultMapControlManager.java
===================================================================
--- tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/impl/DefaultMapControlManager.java	(revision 0)
+++ tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/impl/DefaultMapControlManager.java	(revision 38283)
@@ -0,0 +1,343 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ */
+
+/*
+ * AUTHORS (In addition to CIT):
+ * 2009 {Iver T.I.}   {Task}
+ */
+
+package org.gvsig.fmap.mapcontrol.impl;
+
+import java.awt.Color;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.prefs.Preferences;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.mapcontext.MapContextLocator;
+import org.gvsig.fmap.mapcontext.MapContextManager;
+import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
+import org.gvsig.fmap.mapcontrol.MapControl;
+import org.gvsig.fmap.mapcontrol.MapControlCreationException;
+import org.gvsig.fmap.mapcontrol.MapControlDrawer;
+import org.gvsig.fmap.mapcontrol.MapControlManager;
+import org.gvsig.fmap.mapcontrol.swing.dynobject.LayersDynObjectSetComponent;
+import org.gvsig.fmap.mapcontrol.swing.dynobject.impl.DefaultLayersDynObjectSetComponent;
+import org.gvsig.fmap.mapcontrol.tools.snapping.snappers.ISnapper;
+import org.gvsig.tools.ToolsLocator;
+import org.gvsig.tools.dynobject.DynObjectSet;
+import org.gvsig.tools.extensionpoint.ExtensionPoint;
+import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension;
+import org.gvsig.tools.extensionpoint.ExtensionPointManager;
+
+/**
+ * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
+ */
+public class DefaultMapControlManager implements MapControlManager{
+	private static final Logger logger = LoggerFactory.getLogger(MapControlManager.class);
+	private static final String MAPCONTROL_MANAGER_EXTENSION_POINT = "MapControlManagerExtensionPoint";
+	private static final String DEFAULT_MAPCONTROLMANAGER_NAME = null;
+	private static final String SNAPPING_EXTENSION_POINT = "Snapper";
+
+	private ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
+	private int snappingTolerance = 4;
+	private ISymbol selectionSymbol = null;	
+	private ISymbol axisReferencesSymbol = null;
+	private ISymbol geometrySelectionSymbol = null;
+	private ISymbol handlerSymbol = null;
+	private static MapContextManager mapContextManager = MapContextLocator
+	.getMapContextManager();
+	private Preferences prefs = Preferences.userRoot().node( "cadtooladapter" );
+	private static Preferences prefSnappers = Preferences.userRoot().node("snappers");
+	private ArrayList<ISnapper> snappers = null;	
+
+	public DefaultMapControlManager() {
+		super();
+		snappers = new ArrayList<ISnapper>();
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#createDefaultMapControlDrawer()
+	 */
+	public MapControlDrawer createDefaultMapControlDrawer() throws MapControlCreationException {
+		ExtensionPoint ep = extensionPoints.add(MAPCONTROL_MANAGER_EXTENSION_POINT);
+		try {
+			return (MapControlDrawer)ep.create(DEFAULT_MAPCONTROLMANAGER_NAME);			
+		} catch (Exception e) {
+			throw new MapControlCreationException(e);
+		}	
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#createMapControlDrawer(java.lang.String)
+	 */
+	public MapControlDrawer createMapControlDrawer(String name) throws MapControlCreationException {
+		ExtensionPoint ep = extensionPoints.add(MAPCONTROL_MANAGER_EXTENSION_POINT);
+		try {
+			return (MapControlDrawer)ep.create(name);			
+		} catch (Exception e) {
+			throw new MapControlCreationException(e);
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#registerDefaultMapControlDrawer(java.lang.Class)
+	 */
+	public void registerDefaultMapControlDrawer(Class mapControlDrawerClass) {
+		if (!MapControlDrawer.class.isAssignableFrom(mapControlDrawerClass)) {
+			throw new IllegalArgumentException(mapControlDrawerClass.getName()
+					+ " must implement the MapControlDrawer interface");
+		}
+
+		ExtensionPoint extensionPoint = extensionPoints.add(MAPCONTROL_MANAGER_EXTENSION_POINT, "");
+		extensionPoint.append(DEFAULT_MAPCONTROLMANAGER_NAME, "Default MapControl", mapControlDrawerClass);		
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#registerMapControlDrawer(int, java.lang.Class)
+	 */
+	public void registerMapControlDrawer(String name,
+			Class mapControlDrawerClass) {
+
+		if (!MapControlDrawer.class.isAssignableFrom(mapControlDrawerClass)) {
+			throw new IllegalArgumentException(mapControlDrawerClass.getName()
+					+ " must implement the MapControlDrawer interface");
+		}
+
+		ExtensionPoint extensionPoint = extensionPoints.add(MAPCONTROL_MANAGER_EXTENSION_POINT, "");
+		extensionPoint.append(name, "Default MapControl", mapControlDrawerClass);		
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#getSnappingTolerance()
+	 */
+	public int getTolerance() {
+		return snappingTolerance;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#setSnappingTolerance(int)
+	 */
+	public void setTolerance(int tolerance) {
+		snappingTolerance = tolerance;		
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#clearSnappers()
+	 */
+	public void clearSnappers() {
+		snappers.clear();		
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#getAxisReferenceSymbol()
+	 */
+	public ISymbol getAxisReferenceSymbol() {
+		if (axisReferencesSymbol == null){
+			axisReferencesSymbol =
+					mapContextManager.getSymbolManager()
+			.createSymbol(Geometry.TYPES.GEOMETRY,
+					new Color(100, 100, 100, 100));
+		}
+		return axisReferencesSymbol;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#getGeometrySelectionSymbol()
+	 */
+	public ISymbol getGeometrySelectionSymbol() {
+		if (geometrySelectionSymbol == null){
+			geometrySelectionSymbol =
+					mapContextManager.getSymbolManager()
+			.createSymbol(Geometry.TYPES.GEOMETRY, Color.RED);
+		}		
+		return geometrySelectionSymbol;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#getHandlerSymbol()
+	 */
+	public ISymbol getHandlerSymbol() {
+		if (handlerSymbol == null){
+			handlerSymbol =
+					mapContextManager.getSymbolManager().createSymbol(
+					Geometry.TYPES.GEOMETRY, Color.ORANGE);
+		}
+		return handlerSymbol;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#getSelectionSymbol()
+	 */
+	public ISymbol getSelectionSymbol() {
+		if (selectionSymbol == null){
+			selectionSymbol =
+					mapContextManager.getSymbolManager().createSymbol(
+					Geometry.TYPES.GEOMETRY, new Color(255, 0, 0, 100)); 
+		}
+		return selectionSymbol;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#setAxisReferenceSymbol(org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol)
+	 */
+	public void setAxisReferenceSymbol(ISymbol axisReferencesSymbol) {
+		this.axisReferencesSymbol = axisReferencesSymbol;		
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#setGeometrySelectionSymbol(org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol)
+	 */
+	public void setGeometrySelectionSymbol(ISymbol geometrySelectionSymbol) {
+		this.geometrySelectionSymbol = geometrySelectionSymbol;		
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#setHandlerSymbol(org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol)
+	 */
+	public void setHandlerSymbol(ISymbol handlerSymbol) {
+		this.handlerSymbol = handlerSymbol;		
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#setSelectionSymbol(org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol)
+	 */
+	public void setSelectionSymbol(ISymbol selectionSymbol) {
+		this.selectionSymbol = selectionSymbol;		
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#addSnapper(org.gvsig.fmap.mapcontrol.tools.snapping.snappers.ISnapper)
+	 */
+	public void registerSnapper(String name, Class snapperClass) {
+		if (!ISnapper.class.isAssignableFrom(snapperClass)) {
+			throw new IllegalArgumentException(snapperClass.getName()
+					+ " must implement the ISnapper interface");
+		}		
+
+		ExtensionPoint extensionPoint = extensionPoints.add(SNAPPING_EXTENSION_POINT, "");
+		Extension extension = extensionPoint.append(name, "", snapperClass);
+
+		ISnapper snapper;
+		try {
+			snapper = (ISnapper)extension.create();
+			snappers.add(snapper);
+            String nameClass=snapper.getClass().getName();
+	        nameClass=nameClass.substring(nameClass.lastIndexOf('.'));
+	        boolean select = prefSnappers.getBoolean("snapper_activated" + nameClass, false);
+	        int priority = prefs.getInt("snapper_priority" + nameClass,3);
+	        snapper.setPriority(priority);
+	        if (select){
+	          	snapper.setEnabled(select);   
+	        }           
+			
+		} catch (Exception e) {
+			logger.error("It is not possible to create the snapper");
+		}       
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#getSnapperAt(int)
+	 */
+	public ISnapper getSnapperAt(int index) {
+		return snappers.get(index);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#getSnapperCount()
+	 */
+	public int getSnapperCount() {
+		return snappers.size();
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#disableSnapping()
+	 */
+	public void disableSnapping() {
+		snappers.clear();		
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#enableSnapping()
+	 */
+	public void enableSnapping() {
+		ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
+		ExtensionPoint ep = extensionPoints.get(SNAPPING_EXTENSION_POINT);
+		Iterator iterator = ep.iterator();
+
+		while (iterator.hasNext()) {
+			try {
+				Extension obj= (Extension)iterator.next();
+				ISnapper snapper = (ISnapper) ep.create(obj.getName());
+				snappers.add(snapper);
+			} catch (Exception e) {
+				logger.error("Creating a snapper", e);
+			}
+		}
+
+		for (int n = 0; n < getSnapperCount(); n++) {
+			ISnapper snp = getSnapperAt(n);
+			String nameClass = snp.getClass().getName();
+			nameClass = nameClass.substring(nameClass.lastIndexOf('.'));
+			boolean select = prefs.getBoolean("snapper_activated" + nameClass, false);
+			if (select) {
+				snp.setEnabled(select);				
+			}
+			int priority = prefs.getInt("snapper_priority" + nameClass, 3);
+			snp.setPriority(priority);
+		}
+
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.mapcontrol.MapControlManager#getEditionPreferences()
+	 */
+	public Preferences getEditionPreferences() {
+		return prefs;
+	}
+
+	public MapControl createJMapControlPanel() throws MapControlCreationException {
+		MapControl mapControl = new MapControl();
+		mapControl.setMapControlDrawer(this.createDefaultMapControlDrawer());
+		return mapControl;
+	}
+
+    public LayersDynObjectSetComponent createLayersDynObjectSetComponent(
+        Map<String, DynObjectSet> layerName2InfoByPoint) {
+        return createLayersDynObjectSetComponent(layerName2InfoByPoint, false);
+    }
+
+    public LayersDynObjectSetComponent createLayersDynObjectSetComponent(
+        Map<String, DynObjectSet> layerName2InfoByPoint, boolean writable) {
+        return new DefaultLayersDynObjectSetComponent(layerName2InfoByPoint,
+            writable);
+    }
+}

Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/impl/DefaultMapControlManager.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain


Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls/src/org/gvsig/fmap/data/feature/swing/table
___________________________________________________________________
Added: svn:mergeinfo


Property changes on: tags/v2_0_0_Build_2047/libraries/libFMap_controls
___________________________________________________________________
Added: svn:ignore
   + .classpath 
.project 
.settings 
maven-eclipse.xml
target
bin
hs_err_pid*
.externalToolBuilders
.settings
.classpath
.project


