Improve GIS support
authorMathieu Baudier <mbaudier@argeo.org>
Fri, 7 May 2010 19:20:56 +0000 (19:20 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Fri, 7 May 2010 19:20:56 +0000 (19:20 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@3573 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

22 files changed:
demo/slc_gis_position.properties [new file with mode: 0644]
modules/gis/org.argeo.slc.gis.position.gpsbabel/.project [new file with mode: 0644]
modules/gis/org.argeo.slc.gis.position.gpsbabel/.settings/org.eclipse.pde.core.prefs [new file with mode: 0644]
modules/gis/org.argeo.slc.gis.position.gpsbabel/META-INF/MANIFEST.MF [new file with mode: 0644]
modules/gis/org.argeo.slc.gis.position.gpsbabel/META-INF/spring/gpsbabel-osgi.xml [new file with mode: 0644]
modules/gis/org.argeo.slc.gis.position.gpsbabel/META-INF/spring/gpsbabel.xml [new file with mode: 0644]
modules/gis/org.argeo.slc.gis.position.gpsbabel/build.properties [new file with mode: 0644]
modules/gis/org.argeo.slc.gis.position.ui/.project [new file with mode: 0644]
modules/gis/org.argeo.slc.gis.position.ui/.settings/org.eclipse.pde.core.prefs [new file with mode: 0644]
modules/gis/org.argeo.slc.gis.position.ui/META-INF/MANIFEST.MF [new file with mode: 0644]
modules/gis/org.argeo.slc.gis.position.ui/META-INF/registryFile.jai [new file with mode: 0644]
modules/gis/org.argeo.slc.gis.position.ui/META-INF/spring/ui-osgi.xml [new file with mode: 0644]
modules/gis/org.argeo.slc.gis.position.ui/META-INF/spring/ui.xml [new file with mode: 0644]
modules/gis/org.argeo.slc.gis.position.ui/build.properties [new file with mode: 0644]
runtime/org.argeo.slc.support.gis/.settings/org.eclipse.jdt.core.prefs
runtime/org.argeo.slc.support.gis/build.properties
runtime/org.argeo.slc.support.gis/pom.xml
runtime/org.argeo.slc.support.gis/src/main/java/org/argeo/slc/geotools/Quickstart.java [deleted file]
runtime/org.argeo.slc.support.gis/src/main/java/org/argeo/slc/geotools/SimpleGisFieldViewer.java [new file with mode: 0644]
runtime/org.argeo.slc.support.gis/src/main/java/org/argeo/slc/geotools/WorldFileTest.java [new file with mode: 0644]
runtime/org.argeo.slc.support.gis/src/main/java/org/argeo/slc/geotools/swing/VersatileZoomTool.java [new file with mode: 0644]
runtime/org.argeo.slc.support.gis/src/main/java/org/argeo/slc/gpsbabel/GpsBabelPositionProvider.java

diff --git a/demo/slc_gis_position.properties b/demo/slc_gis_position.properties
new file mode 100644 (file)
index 0000000..559f5c3
--- /dev/null
@@ -0,0 +1,4 @@
+argeo.osgi.start=\
+org.springframework.osgi.extender,\
+org.argeo.slc.gis.position.gpsbabel,\
+org.argeo.slc.gis.position.ui
diff --git a/modules/gis/org.argeo.slc.gis.position.gpsbabel/.project b/modules/gis/org.argeo.slc.gis.position.gpsbabel/.project
new file mode 100644 (file)
index 0000000..8ea04f8
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.gis.position.gpsbabel</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+       </natures>
+</projectDescription>
diff --git a/modules/gis/org.argeo.slc.gis.position.gpsbabel/.settings/org.eclipse.pde.core.prefs b/modules/gis/org.argeo.slc.gis.position.gpsbabel/.settings/org.eclipse.pde.core.prefs
new file mode 100644 (file)
index 0000000..c3f2329
--- /dev/null
@@ -0,0 +1,4 @@
+#Fri May 07 11:03:14 CEST 2010
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/modules/gis/org.argeo.slc.gis.position.gpsbabel/META-INF/MANIFEST.MF b/modules/gis/org.argeo.slc.gis.position.gpsbabel/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..1578038
--- /dev/null
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SLC GIS Position GpsBabel
+Bundle-SymbolicName: org.argeo.slc.gis.position.gpsbabel
+Bundle-Version: 1.0.0.qualifier
+Import-Package: org.argeo.slc.gpsbabel;version="0.12.2.SNAPSHOT-r3562",
+ org.argeo.slc.jts;version="0.12.2.SNAPSHOT-r3562"
diff --git a/modules/gis/org.argeo.slc.gis.position.gpsbabel/META-INF/spring/gpsbabel-osgi.xml b/modules/gis/org.argeo.slc.gis.position.gpsbabel/META-INF/spring/gpsbabel-osgi.xml
new file mode 100644 (file)
index 0000000..40b7d86
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
+       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
+       http://www.springframework.org/schema/beans   \r
+       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+       <service ref="gpsBabelPositionProvider" interface="org.argeo.slc.jts.PositionProvider" />\r
+\r
+</beans:beans>
\ No newline at end of file
diff --git a/modules/gis/org.argeo.slc.gis.position.gpsbabel/META-INF/spring/gpsbabel.xml b/modules/gis/org.argeo.slc.gis.position.gpsbabel/META-INF/spring/gpsbabel.xml
new file mode 100644 (file)
index 0000000..4ef2af7
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+       <bean id="gpsBabelPositionProvider" class="org.argeo.slc.gpsbabel.GpsBabelPositionProvider">\r
+               <property name="inputFormat" value="garmin,get_posn" />\r
+       </bean>\r
+</beans>
\ No newline at end of file
diff --git a/modules/gis/org.argeo.slc.gis.position.gpsbabel/build.properties b/modules/gis/org.argeo.slc.gis.position.gpsbabel/build.properties
new file mode 100644 (file)
index 0000000..5f22cdd
--- /dev/null
@@ -0,0 +1 @@
+bin.includes = META-INF/
diff --git a/modules/gis/org.argeo.slc.gis.position.ui/.project b/modules/gis/org.argeo.slc.gis.position.ui/.project
new file mode 100644 (file)
index 0000000..19e593f
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.gis.position.ui</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+       </natures>
+</projectDescription>
diff --git a/modules/gis/org.argeo.slc.gis.position.ui/.settings/org.eclipse.pde.core.prefs b/modules/gis/org.argeo.slc.gis.position.ui/.settings/org.eclipse.pde.core.prefs
new file mode 100644 (file)
index 0000000..3ef6632
--- /dev/null
@@ -0,0 +1,4 @@
+#Fri May 07 16:28:04 CEST 2010
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/modules/gis/org.argeo.slc.gis.position.ui/META-INF/MANIFEST.MF b/modules/gis/org.argeo.slc.gis.position.ui/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..c911e9d
--- /dev/null
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Ui
+Bundle-SymbolicName: org.argeo.slc.gis.position.ui
+Bundle-Version: 1.0.0.qualifier
+Import-Package: org.argeo.slc.geotools;version="0.12.2.SNAPSHOT-r3562",
+ org.argeo.slc.jts;version="0.12.2.SNAPSHOT-r3562",
+ org.springframework.osgi.util;version="1.2.1"
diff --git a/modules/gis/org.argeo.slc.gis.position.ui/META-INF/registryFile.jai b/modules/gis/org.argeo.slc.gis.position.ui/META-INF/registryFile.jai
new file mode 100644 (file)
index 0000000..76e43bb
--- /dev/null
@@ -0,0 +1,225 @@
+#
+# The registry file for Geotools Grid Coverage implementation. This file should be automatically
+# parsed by JAI under initialization. If it is not, then Registry.registerServices(...) can parse
+# it. This may happen if this file is unreachable from the JAI class loader.
+#
+# If this file is updated, remember to update Registry.registerServices(...) accordingly.
+#
+# Version: $Id: registryFile.jai 34781 2010-01-13 11:56:07Z simonegiannecchini $
+#
+##################################################################################################
+#
+# Each line can be in one of the formats described below. Space or tab characters separate
+# keywords in each line. The comment character is '#'; on each line all characters following
+# the first comment character are ignored. The file must be encoded in UTF-8.
+#
+# 1. To register descriptors :
+#
+#      descriptor <descriptor-class-name>
+#
+# 2. To register factory objects under a product against a specific mode :
+#
+#      <registry-mode-name>  <factory-class-name>  <product-name>  <descriptor-name>  <local-name>
+#
+#    The <local-name> is (only) used later on in this file to set preferences
+#    between factory objects, if wanted.
+#
+##################################################################################################
+#
+# Image operation descriptors :
+#
+descriptor  org.geotools.image.jai.CombineDescriptor
+descriptor  org.geotools.image.jai.HysteresisDescriptor
+descriptor  org.geotools.image.jai.NodataFilterDescriptor
+descriptor  org.geotools.image.palette.ColorReductionDescriptor
+descriptor  org.geotools.image.palette.ColorInversionDescriptor
+
+
+#
+# "rendered" factory objects
+#
+rendered  org.geotools.image.jai.CombineCRIF                   org.geotools  org.geotools.Combine       Combine
+rendered  org.geotools.image.jai.HysteresisCRIF                org.geotools  org.geotools.Hysteresis    Hysteresis
+rendered  org.geotools.image.jai.NodataFilterCRIF              org.geotools  org.geotools.NodataFilter  NodataFilter
+rendered  org.geotools.image.palette.ColorReductionCRIF        org.geotools  org.geotools.ColorReduction ColorReduction
+rendered  org.geotools.image.palette.ColorInversionCRIF        org.geotools  org.geotools.ColorInversion ColorInversion
+#
+# The registry file for Geotools Grid Coverage implementation. This file should be automatically
+# parsed by JAI under initialization. If it is not, then Registry.registerServices(...) can parse
+# it. This may happen if this file is unreachable from the JAI class loader.
+#
+# If this file is updated, remember to update Registry.registerServices(...) accordingly.
+#
+# Version: $Id: registryFile.jai 34781 2010-01-13 11:56:07Z simonegiannecchini $
+#
+##################################################################################################
+#
+# Each line can be in one of the formats described below. Space or tab characters separate
+# keywords in each line. The comment character is '#'; on each line all characters following
+# the first comment character are ignored. The file must be encoded in UTF-8.
+#
+# 1. To register descriptors :
+#
+#      descriptor <descriptor-class-name>
+#
+# 2. To register factory objects under a product against a specific mode :
+#
+#      <registry-mode-name>  <factory-class-name>  <product-name>  <descriptor-name>  <local-name>
+#
+#    The <local-name> is (only) used later on in this file to set preferences
+#    between factory objects, if wanted.
+#
+##################################################################################################
+#
+# Image operation descriptors :
+#
+descriptor  org.geotools.image.jai.CombineDescriptor
+descriptor  org.geotools.image.jai.HysteresisDescriptor
+descriptor  org.geotools.image.jai.NodataFilterDescriptor
+descriptor  org.geotools.image.palette.ColorReductionDescriptor
+descriptor  org.geotools.image.palette.ColorInversionDescriptor
+
+
+#
+# "rendered" factory objects
+#
+rendered  org.geotools.image.jai.CombineCRIF                   org.geotools  org.geotools.Combine       Combine
+rendered  org.geotools.image.jai.HysteresisCRIF                org.geotools  org.geotools.Hysteresis    Hysteresis
+rendered  org.geotools.image.jai.NodataFilterCRIF              org.geotools  org.geotools.NodataFilter  NodataFilter
+rendered  org.geotools.image.palette.ColorReductionCRIF        org.geotools  org.geotools.ColorReduction ColorReduction
+rendered  org.geotools.image.palette.ColorInversionCRIF        org.geotools  org.geotools.ColorInversion ColorInversion
+#
+# The registry file for Geotools Grid Coverage implementation. This file should be automatically
+# parsed by JAI under initialization. If it is not, then Registry.registerServices(...) can parse
+# it. This may happen if this file is unreachable from the JAI class loader.
+#
+# If this file is updated, remember to update Registry.registerServices(...) accordingly.
+#
+# Version: $Id: registryFile.jai 34781 2010-01-13 11:56:07Z simonegiannecchini $
+#
+##################################################################################################
+#
+# Each line can be in one of the formats described below. Space or tab characters separate
+# keywords in each line. The comment character is '#'; on each line all characters following
+# the first comment character are ignored. The file must be encoded in UTF-8.
+#
+# 1. To register descriptors :
+#
+#      descriptor <descriptor-class-name>
+#
+# 2. To register factory objects under a product against a specific mode :
+#
+#      <registry-mode-name>  <factory-class-name>  <product-name>  <descriptor-name>  <local-name>
+#
+#    The <local-name> is (only) used later on in this file to set preferences
+#    between factory objects, if wanted.
+#
+##################################################################################################
+#
+# Image operation descriptors :
+#
+descriptor  org.geotools.image.jai.CombineDescriptor
+descriptor  org.geotools.image.jai.HysteresisDescriptor
+descriptor  org.geotools.image.jai.NodataFilterDescriptor
+descriptor  org.geotools.image.palette.ColorReductionDescriptor
+descriptor  org.geotools.image.palette.ColorInversionDescriptor
+
+
+#
+# "rendered" factory objects
+#
+rendered  org.geotools.image.jai.CombineCRIF                   org.geotools  org.geotools.Combine       Combine
+rendered  org.geotools.image.jai.HysteresisCRIF                org.geotools  org.geotools.Hysteresis    Hysteresis
+rendered  org.geotools.image.jai.NodataFilterCRIF              org.geotools  org.geotools.NodataFilter  NodataFilter
+rendered  org.geotools.image.palette.ColorReductionCRIF        org.geotools  org.geotools.ColorReduction ColorReduction
+rendered  org.geotools.image.palette.ColorInversionCRIF        org.geotools  org.geotools.ColorInversion ColorInversion
+#
+# The registry file for Geotools Grid Coverage implementation. This file should be automatically
+# parsed by JAI under initialization. If it is not, then Registry.registerServices(...) can parse
+# it. This may happen if this file is unreachable from the JAI class loader.
+#
+# If this file is updated, remember to update Registry.registerServices(...) accordingly.
+#
+# Version: $Id: registryFile.jai 34781 2010-01-13 11:56:07Z simonegiannecchini $
+#
+##################################################################################################
+#
+# Each line can be in one of the formats described below. Space or tab characters separate
+# keywords in each line. The comment character is '#'; on each line all characters following
+# the first comment character are ignored. The file must be encoded in UTF-8.
+#
+# 1. To register descriptors :
+#
+#      descriptor <descriptor-class-name>
+#
+# 2. To register factory objects under a product against a specific mode :
+#
+#      <registry-mode-name>  <factory-class-name>  <product-name>  <descriptor-name>  <local-name>
+#
+#    The <local-name> is (only) used later on in this file to set preferences
+#    between factory objects, if wanted.
+#
+##################################################################################################
+#
+# Image operation descriptors :
+#
+descriptor  org.geotools.image.jai.CombineDescriptor
+descriptor  org.geotools.image.jai.HysteresisDescriptor
+descriptor  org.geotools.image.jai.NodataFilterDescriptor
+descriptor  org.geotools.image.palette.ColorReductionDescriptor
+descriptor  org.geotools.image.palette.ColorInversionDescriptor
+
+
+#
+# "rendered" factory objects
+#
+rendered  org.geotools.image.jai.CombineCRIF                   org.geotools  org.geotools.Combine       Combine
+rendered  org.geotools.image.jai.HysteresisCRIF                org.geotools  org.geotools.Hysteresis    Hysteresis
+rendered  org.geotools.image.jai.NodataFilterCRIF              org.geotools  org.geotools.NodataFilter  NodataFilter
+rendered  org.geotools.image.palette.ColorReductionCRIF        org.geotools  org.geotools.ColorReduction ColorReduction
+rendered  org.geotools.image.palette.ColorInversionCRIF        org.geotools  org.geotools.ColorInversion ColorInversion
+#
+# The registry file for Geotools Grid Coverage implementation. This file should be automatically
+# parsed by JAI under initialization. If it is not, then Registry.registerServices(...) can parse
+# it. This may happen if this file is unreachable from the JAI class loader.
+#
+# If this file is updated, remember to update Registry.registerServices(...) accordingly.
+#
+# Version: $Id: registryFile.jai 34781 2010-01-13 11:56:07Z simonegiannecchini $
+#
+##################################################################################################
+#
+# Each line can be in one of the formats described below. Space or tab characters separate
+# keywords in each line. The comment character is '#'; on each line all characters following
+# the first comment character are ignored. The file must be encoded in UTF-8.
+#
+# 1. To register descriptors :
+#
+#      descriptor <descriptor-class-name>
+#
+# 2. To register factory objects under a product against a specific mode :
+#
+#      <registry-mode-name>  <factory-class-name>  <product-name>  <descriptor-name>  <local-name>
+#
+#    The <local-name> is (only) used later on in this file to set preferences
+#    between factory objects, if wanted.
+#
+##################################################################################################
+#
+# Image operation descriptors :
+#
+descriptor  org.geotools.image.jai.CombineDescriptor
+descriptor  org.geotools.image.jai.HysteresisDescriptor
+descriptor  org.geotools.image.jai.NodataFilterDescriptor
+descriptor  org.geotools.image.palette.ColorReductionDescriptor
+descriptor  org.geotools.image.palette.ColorInversionDescriptor
+
+
+#
+# "rendered" factory objects
+#
+rendered  org.geotools.image.jai.CombineCRIF                   org.geotools  org.geotools.Combine       Combine
+rendered  org.geotools.image.jai.HysteresisCRIF                org.geotools  org.geotools.Hysteresis    Hysteresis
+rendered  org.geotools.image.jai.NodataFilterCRIF              org.geotools  org.geotools.NodataFilter  NodataFilter
+rendered  org.geotools.image.palette.ColorReductionCRIF        org.geotools  org.geotools.ColorReduction ColorReduction
+rendered  org.geotools.image.palette.ColorInversionCRIF        org.geotools  org.geotools.ColorInversion ColorInversion
diff --git a/modules/gis/org.argeo.slc.gis.position.ui/META-INF/spring/ui-osgi.xml b/modules/gis/org.argeo.slc.gis.position.ui/META-INF/spring/ui-osgi.xml
new file mode 100644 (file)
index 0000000..c8691ff
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
+       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
+       http://www.springframework.org/schema/beans   \r
+       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+       <reference id="positionProvider" interface="org.argeo.slc.jts.PositionProvider" />\r
+\r
+       <bundle id="geotools" symbolic-name="org.argeo.dep.osgi.geotools" />\r
+       <bundle id="jai.imageio" symbolic-name="org.argeo.dep.osgi.jai.imageio" />\r
+</beans:beans>
\ No newline at end of file
diff --git a/modules/gis/org.argeo.slc.gis.position.ui/META-INF/spring/ui.xml b/modules/gis/org.argeo.slc.gis.position.ui/META-INF/spring/ui.xml
new file mode 100644 (file)
index 0000000..195d9dc
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+       <bean id="ui" class="org.argeo.slc.geotools.SimpleGisFieldViewer"\r
+               init-method="run">\r
+               <property name="positionProvider" ref="positionProvider" />\r
+               <property name="jaiImageIoClassLoader">\r
+                       <bean class="org.springframework.osgi.util.BundleDelegatingClassLoader"\r
+                               factory-method="createBundleClassLoaderFor">\r
+                               <constructor-arg>\r
+                                       <ref bean="jai.imageio" />\r
+                                       <!--\r
+                                               <bean factory-bean="bundleContext" factory-method="getBundle" />\r
+                                       -->\r
+                               </constructor-arg>\r
+                       </bean>\r
+               </property>\r
+       </bean>\r
+</beans>
\ No newline at end of file
diff --git a/modules/gis/org.argeo.slc.gis.position.ui/build.properties b/modules/gis/org.argeo.slc.gis.position.ui/build.properties
new file mode 100644 (file)
index 0000000..5f22cdd
--- /dev/null
@@ -0,0 +1 @@
+bin.includes = META-INF/
index 4e4b533eff2c4236372f6ad9005b444c3a70b712..d91f6199085fd81e24e8c0e7b41dcb97e82423d4 100644 (file)
@@ -1,8 +1,12 @@
-#Thu May 06 12:24:28 CEST 2010
+#Fri May 07 21:03:36 CEST 2010
 eclipse.preferences.version=1
 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
 org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
 org.eclipse.jdt.core.compiler.source=1.5
index 73ed796e9d9c984bde7d9855e2afa9f14916f7de..8c835be67da118b4b4b9e4bf0eff8a1bfe93da37 100644 (file)
@@ -11,4 +11,7 @@ additional.bundles = com.springsource.slf4j.api,\
                      org.argeo.dep.osgi.jsr275,\
                      org.argeo.dep.osgi.java3d,\
                      org.argeo.dep.osgi.jts,\
-                     com.springsource.org.apache.commons.beanutils
+                     com.springsource.org.apache.commons.beanutils,\
+                     com.springsource.javax.media.jai.codec,\
+                     com.springsource.javax.media.jai.core,\
+                     org.argeo.dep.osgi.jai.imageio
index 8a5b14c5acf4bb598cf17a0691666a20fd04c49f..c689f28299bf284353b94d737cc844163812010b 100644 (file)
                        <groupId>org.apache.commons</groupId>
                        <artifactId>com.springsource.org.apache.commons.beanutils</artifactId>
                </dependency>
+               <!-- JAI -->
+               <dependency>
+                       <groupId>javax.media.jai</groupId>
+                       <artifactId>com.springsource.javax.media.jai.core</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>javax.media.jai</groupId>
+                       <artifactId>com.springsource.javax.media.jai.codec</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.dep.osgi</groupId>
+                       <artifactId>org.argeo.dep.osgi.jai.imageio</artifactId>
+               </dependency>
+
        </dependencies>
        <repositories>
                <repository>
diff --git a/runtime/org.argeo.slc.support.gis/src/main/java/org/argeo/slc/geotools/Quickstart.java b/runtime/org.argeo.slc.support.gis/src/main/java/org/argeo/slc/geotools/Quickstart.java
deleted file mode 100644 (file)
index 48ff7d0..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- *    GeoTools - The Open Source Java GIS Tookit
- *    http://geotools.org
- *
- *    (C) 2006-2008, Open Source Geospatial Foundation (OSGeo)
- *
- *    This file is hereby placed into the Public Domain. This means anyone is
- *    free to do whatever they wish with this file. Use it well and enjoy!
- */
-package org.argeo.slc.geotools;
-
-import java.awt.Color;
-import java.awt.event.MouseWheelEvent;
-import java.awt.event.MouseWheelListener;
-import java.io.File;
-import java.util.Iterator;
-
-import javax.swing.SwingUtilities;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.gpsbabel.GpsBabelPositionProvider;
-import org.argeo.slc.jts.PositionProvider;
-import org.geotools.data.FileDataStoreFactorySpi;
-import org.geotools.data.FileDataStoreFinder;
-import org.geotools.feature.DefaultFeatureCollection;
-import org.geotools.feature.FeatureCollection;
-import org.geotools.feature.simple.SimpleFeatureBuilder;
-import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
-import org.geotools.geometry.jts.ReferencedEnvelope;
-import org.geotools.map.DefaultMapContext;
-import org.geotools.map.DefaultMapLayer;
-import org.geotools.map.MapContext;
-import org.geotools.map.MapLayer;
-import org.geotools.referencing.crs.DefaultGeographicCRS;
-import org.geotools.styling.SLD;
-import org.geotools.styling.Style;
-import org.geotools.swing.JMapFrame;
-import org.geotools.swing.JMapPane;
-import org.opengis.feature.simple.SimpleFeature;
-import org.opengis.feature.simple.SimpleFeatureType;
-
-import com.vividsolutions.jts.geom.Point;
-
-/**
- * GeoTools Quickstart demo application. Prompts the user for a shapefile and
- * displays its contents on the screen in a map frame
- * 
- * @source $URL:
- *         http://svn.osgeo.org/geotools/trunk/demo/example/src/main/java/org
- *         /geotools/demo/Quickstart.java $
- */
-public class Quickstart {
-       private final static Log log = LogFactory.getLog(Quickstart.class);
-
-       /**
-        * GeoTools Quickstart demo application. Prompts the user for a shapefile
-        * and displays its contents on the screen in a map frame
-        */
-       public static void main(String[] args) throws Exception {
-               Iterator<FileDataStoreFactorySpi> ps = FileDataStoreFinder
-                               .getAvailableDataStores();
-               log.debug("Available datastores:");
-               while (ps.hasNext()) {
-                       log.debug(ps.next());
-               }
-
-               // display a data store file chooser dialog for shapefiles
-               // File file = JFileDataStoreChooser.showOpenFile("shp", null);
-               // if (file == null) {
-               // return;
-               // }
-               File dir = new File(
-                               "/home/mbaudier/gis/projects/100122-EasternBalkans2010/data");
-
-               // FeatureSource<SimpleFeatureType, SimpleFeature> featureSource =
-               // FileDataStoreFinder
-               // .getDataStore(new File(dir, "countries-EuroMed-NEarth.shp"))
-               // .getFeatureSource();
-
-               // Create a map context and add our shapefile to it
-               MapContext mapContext = new DefaultMapContext();
-               mapContext.setTitle("Quickstart");
-
-               // Now display the map
-               // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
-
-               final JMapFrame frame = new JMapFrame(mapContext);
-               frame.enableStatusBar(true);
-               frame.enableToolBar(true);
-               frame.enableLayerTable(true);
-               frame.initComponents();
-
-               frame.setSize(800, 600);
-
-               final double clickToZoom = 0.1; // 1 wheel click is 10% zoom
-               final JMapPane mapPane = frame.getMapPane();
-               mapPane.addMouseWheelListener(new MouseWheelListener() {
-
-                       public void mouseWheelMoved(MouseWheelEvent ev) {
-                               int clicks = ev.getWheelRotation();
-                               // -ve means wheel moved up, +ve means down
-                               int sign = (clicks < 0 ? -1 : 1);
-
-                               ReferencedEnvelope env = mapPane.getDisplayArea();
-                               double width = env.getWidth();
-                               double delta = width * clickToZoom * sign;
-
-                               env.expandBy(delta);
-                               mapPane.setDisplayArea(env);
-                               mapPane.repaint();
-                       }
-               });
-               // mapPane.addMouseListener(new MapMouseAdapter() {
-               // // wheel event handler
-               // public void handleMouseWheelEvent(MouseWheelEvent ev) {
-               // int clicks = ev.getWheelRotation();
-               // // -ve means wheel moved up, +ve means down
-               // int sign = (clicks < 0 ? -1 : 1);
-               //
-               // ReferencedEnvelope env = mapPane.getDisplayArea();
-               // double width = env.getWidth();
-               // double delta = width * clickToZoom * sign;
-               //
-               // env.expandBy(delta);
-               // mapPane.setDisplayArea(env);
-               // mapPane.repaint();
-               // }
-               // });
-
-               SwingUtilities.invokeLater(new Runnable() {
-                       public void run() {
-                               frame.setVisible(true);
-                       }
-               });
-
-               // Create position type
-               SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
-               builder.setName("Position");
-               builder.setNamespaceURI("http://localhost/");
-               builder.setCRS(DefaultGeographicCRS.WGS84);
-
-               // add attributes in order
-               builder.add("Location", Point.class);
-               builder.add("ID", Integer.class);
-               builder.add("Name", String.class);
-
-               // build the type
-               final SimpleFeatureType POSITION = builder.buildFeatureType();
-
-               PositionProvider positionProvider = new GpsBabelPositionProvider();
-
-               // FeatureSource<SimpleFeatureType, SimpleFeature> fs =
-               // FileDataStoreFinder
-               // .getDataStore(new File(dir, "countries-EuroMed-NEarth.shp"))
-               // .getFeatureSource();
-
-               // mapContext.addLayer(FileDataStoreFinder.getDataStore(
-               // new File(dir, "cities-EuroMed-NEarth.shp")).getFeatureSource(),
-               // null);
-               mapContext.addLayer(FileDataStoreFinder.getDataStore(
-                               new File(dir, "countries-EuroMed-NEarth.shp"))
-                               .getFeatureSource(), null);
-                mapContext.addLayer(FileDataStoreFinder.getDataStore(
-                new File(dir, "highways-EastBalkan-OSM.shp"))
-                .getFeatureSource(), null);
-
-               MapLayer mapLayer = null;
-               while (true) {
-                       SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(
-                                       POSITION);
-
-                       // add the attributes
-                       featureBuilder.add(positionProvider.currentPosition());
-                       featureBuilder.add(12);
-                       featureBuilder.add("My Name");
-
-                       // build the feature
-                       SimpleFeature feature = featureBuilder.buildFeature("Flag.12");
-                       FeatureCollection<SimpleFeatureType, SimpleFeature> collection = new DefaultFeatureCollection(
-                                       "testCollection", POSITION);
-                       collection.add(feature);
-                       if (mapLayer != null)
-                               mapContext.removeLayer(mapLayer);
-                       Style style = SLD.createSimpleStyle(POSITION, Color.RED);
-                       mapLayer = new DefaultMapLayer(collection, style, "");
-                       mapContext.addLayer(mapLayer);
-                       // mapContext.addLayer(collection,null);
-
-                       Thread.sleep(1000);
-               }
-       }
-
-}
\ No newline at end of file
diff --git a/runtime/org.argeo.slc.support.gis/src/main/java/org/argeo/slc/geotools/SimpleGisFieldViewer.java b/runtime/org.argeo.slc.support.gis/src/main/java/org/argeo/slc/geotools/SimpleGisFieldViewer.java
new file mode 100644 (file)
index 0000000..29832cf
--- /dev/null
@@ -0,0 +1,222 @@
+/*
+ *    GeoTools - The Open Source Java GIS Tookit
+ *    http://geotools.org
+ *
+ *    (C) 2006-2008, Open Source Geospatial Foundation (OSGeo)
+ *
+ *    This file is hereby placed into the Public Domain. This means anyone is
+ *    free to do whatever they wish with this file. Use it well and enjoy!
+ */
+package org.argeo.slc.geotools;
+
+import java.awt.Color;
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.media.jai.JAI;
+import javax.swing.SwingUtilities;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.geotools.swing.VersatileZoomTool;
+import org.argeo.slc.jts.PositionProvider;
+import org.geotools.data.FileDataStoreFactorySpi;
+import org.geotools.data.FileDataStoreFinder;
+import org.geotools.data.WorldFileReader;
+import org.geotools.feature.DefaultFeatureCollection;
+import org.geotools.feature.FeatureCollection;
+import org.geotools.feature.simple.SimpleFeatureBuilder;
+import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
+import org.geotools.gce.image.WorldImageFormat;
+import org.geotools.map.DefaultMapContext;
+import org.geotools.map.DefaultMapLayer;
+import org.geotools.map.MapContext;
+import org.geotools.map.MapLayer;
+import org.geotools.referencing.crs.DefaultGeographicCRS;
+import org.geotools.styling.RasterSymbolizer;
+import org.geotools.styling.SLD;
+import org.geotools.styling.Style;
+import org.geotools.styling.StyleBuilder;
+import org.geotools.swing.JMapFrame;
+import org.geotools.swing.JMapPane;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.simple.SimpleFeatureType;
+
+import com.vividsolutions.jts.geom.Point;
+
+/**
+ * GeoTools Quickstart demo application. Prompts the user for a shapefile and
+ * displays its contents on the screen in a map frame
+ * 
+ * @source $URL:
+ *         http://svn.osgeo.org/geotools/trunk/demo/example/src/main/java/org
+ *         /geotools/demo/Quickstart.java $
+ */
+public class SimpleGisFieldViewer implements Runnable {
+       private final static Log log = LogFactory
+                       .getLog(SimpleGisFieldViewer.class);
+
+       private PositionProvider positionProvider;
+
+       private ClassLoader jaiImageIoClassLoader;
+
+       public static void main(String[] args) throws Exception {
+               new SimpleGisFieldViewer().run();
+       }
+
+       public void run() {
+               Iterator<FileDataStoreFactorySpi> ps = FileDataStoreFinder
+                               .getAvailableDataStores();
+               log.debug("Available datastores:");
+               while (ps.hasNext()) {
+                       log.debug(ps.next());
+               }
+
+               // display a data store file chooser dialog for shapefiles
+               // File file = JFileDataStoreChooser.showOpenFile("shp", null);
+               // if (file == null) {
+               // return;
+               // }
+               File dir = new File(
+                               "/home/mbaudier/gis/projects/100122-EasternBalkans2010/data");
+
+               // FeatureSource<SimpleFeatureType, SimpleFeature> featureSource =
+               // FileDataStoreFinder
+               // .getDataStore(new File(dir, "countries-EuroMed-NEarth.shp"))
+               // .getFeatureSource();
+
+               // Create a map context and add our shapefile to it
+               MapContext mapContext = new DefaultMapContext();
+               mapContext.setTitle("Quickstart");
+
+               // Now display the map
+               // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+
+               final JMapFrame frame = new JMapFrame(mapContext);
+               frame.enableStatusBar(true);
+               frame.enableToolBar(false);
+               frame.enableLayerTable(false);
+               frame.initComponents();
+
+               frame.setSize(800, 600);
+
+               final JMapPane mapPane = frame.getMapPane();
+               mapPane.setCursorTool(new VersatileZoomTool());
+
+               SwingUtilities.invokeLater(new Runnable() {
+                       public void run() {
+                               frame.setVisible(true);
+                       }
+               });
+
+               // Create position type
+               SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
+               builder.setName("Position");
+               builder.setNamespaceURI("http://localhost/");
+               builder.setCRS(DefaultGeographicCRS.WGS84);
+
+               // add attributes in order
+               builder.add("Location", Point.class);
+               builder.add("ID", Integer.class);
+               builder.add("Name", String.class);
+
+               // build the type
+               final SimpleFeatureType POSITION = builder.buildFeatureType();
+
+               // PositionProvider positionProvider = new GpsBabelPositionProvider();
+
+               try {
+                       // FeatureSource<SimpleFeatureType, SimpleFeature> fs =
+                       // FileDataStoreFinder
+                       // .getDataStore(new File(dir, "countries-EuroMed-NEarth.shp"))
+                       // .getFeatureSource();
+
+                       // mapContext.addLayer(FileDataStoreFinder.getDataStore(
+                       // new File(dir, "cities-EuroMed-NEarth.shp")).getFeatureSource(),
+                       // null);
+
+                       // Raster
+                       if (jaiImageIoClassLoader != null) {
+                               Thread.currentThread().setContextClassLoader(
+                                               jaiImageIoClassLoader);
+                               JAI.getDefaultInstance().getOperationRegistry()
+                                               .registerServices(
+                                                               WorldFileReader.class.getClassLoader());
+//                             OperationDescriptor odesc = (OperationDescriptor) JAI
+//                                             .getDefaultInstance().getOperationRegistry()
+//                                             .getDescriptor("rendered", "ImageRead");
+                       }
+
+                       // Raster style
+                       StyleBuilder styleBuilder = new StyleBuilder();
+                       RasterSymbolizer rasterSymbolizer = styleBuilder
+                                       .createRasterSymbolizer();
+                       rasterSymbolizer.setGeometryPropertyName("geom");
+                       Style rasterStyle = styleBuilder.createStyle(rasterSymbolizer);
+                       WorldImageFormat worldImageFormat = new WorldImageFormat();
+
+                       File rasterDir = new File("/home/mbaudier/gis/data/100501-Poehali");
+                       mapContext.addLayer(worldImageFormat.getReader(
+                                       new File(rasterDir, "500k--l36-1--(1984).gif")).read(null),
+                                       rasterStyle);
+                       mapContext.addLayer(worldImageFormat.getReader(
+                                       new File(rasterDir, "500k--l35-4--(1978).gif")).read(null),
+                                       rasterStyle);
+                       mapContext.addLayer(worldImageFormat.getReader(
+                                       new File(rasterDir, "500k--l35-2--(1980).gif")).read(null),
+                                       rasterStyle);
+                       mapContext.addLayer(worldImageFormat.getReader(
+                                       new File(rasterDir, "100k--l36-050--(1982).gif")).read(null),
+                                       rasterStyle);
+
+                       mapContext.addLayer(FileDataStoreFinder.getDataStore(
+                                       new File(dir, "countries-EuroMed-NEarth.shp"))
+                                       .getFeatureSource(), null);
+                       // mapContext.addLayer(FileDataStoreFinder.getDataStore(
+                       // new File(dir, "highways-EastBalkan-OSM.shp"))
+                       // .getFeatureSource(), null);
+               } catch (IOException e1) {
+                       throw new SlcException("Cannot load sta stores", e1);
+               }
+
+               MapLayer mapLayer = null;
+               while (true) {
+                       SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(
+                                       POSITION);
+
+                       // add the attributes
+                       featureBuilder.add(positionProvider.currentPosition());
+                       featureBuilder.add(12);
+                       featureBuilder.add("My Name");
+
+                       // build the feature
+                       SimpleFeature feature = featureBuilder.buildFeature("Flag.12");
+                       FeatureCollection<SimpleFeatureType, SimpleFeature> collection = new DefaultFeatureCollection(
+                                       "testCollection", POSITION);
+                       collection.add(feature);
+                       if (mapLayer != null)
+                               mapContext.removeLayer(mapLayer);
+                       Style style = SLD.createSimpleStyle(POSITION, Color.RED);
+                       mapLayer = new DefaultMapLayer(collection, style, "");
+                       mapContext.addLayer(mapLayer);
+                       // mapContext.addLayer(collection,null);
+
+                       try {
+                               Thread.sleep(1000);
+                       } catch (InterruptedException e) {
+                               e.printStackTrace();
+                       }
+               }
+       }
+
+       public void setPositionProvider(PositionProvider positionProvider) {
+               this.positionProvider = positionProvider;
+       }
+
+       public void setJaiImageIoClassLoader(ClassLoader classLoader) {
+               this.jaiImageIoClassLoader = classLoader;
+       }
+
+}
\ No newline at end of file
diff --git a/runtime/org.argeo.slc.support.gis/src/main/java/org/argeo/slc/geotools/WorldFileTest.java b/runtime/org.argeo.slc.support.gis/src/main/java/org/argeo/slc/geotools/WorldFileTest.java
new file mode 100644 (file)
index 0000000..05e5e6b
--- /dev/null
@@ -0,0 +1,21 @@
+package org.argeo.slc.geotools;
+
+import java.io.File;
+
+import org.geotools.coverage.grid.GridCoverage2D;
+import org.geotools.gce.image.WorldImageFormat;
+import org.geotools.gce.image.WorldImageReader;
+
+public class WorldFileTest {
+
+       @SuppressWarnings("restriction")
+       public static void main(String[] args) throws Exception {
+               File dir = new File("/home/mbaudier/gis/data/100501-Poehali");
+               WorldImageFormat worldImageFormat = new WorldImageFormat();
+               WorldImageReader worldImageReader = worldImageFormat
+                               .getReader(new File(dir, "500k--l36-1--(1984).gif"));
+               GridCoverage2D gridCoverage2D = worldImageReader.read(null);
+               gridCoverage2D.show();
+       }
+
+}
diff --git a/runtime/org.argeo.slc.support.gis/src/main/java/org/argeo/slc/geotools/swing/VersatileZoomTool.java b/runtime/org.argeo.slc.support.gis/src/main/java/org/argeo/slc/geotools/swing/VersatileZoomTool.java
new file mode 100644 (file)
index 0000000..862e0a8
--- /dev/null
@@ -0,0 +1,247 @@
+package org.argeo.slc.geotools.swing;
+
+import java.awt.Color;
+import java.awt.Cursor;
+import java.awt.Graphics2D;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
+import java.awt.geom.Point2D;
+
+import javax.swing.SwingUtilities;
+import javax.swing.event.MouseInputAdapter;
+
+import org.geotools.geometry.DirectPosition2D;
+import org.geotools.geometry.Envelope2D;
+import org.geotools.geometry.jts.ReferencedEnvelope;
+import org.geotools.swing.JMapPane;
+import org.geotools.swing.event.MapMouseEvent;
+import org.geotools.swing.tool.AbstractZoomTool;
+
+public class VersatileZoomTool extends AbstractZoomTool {
+       // private Log log = LogFactory.getLog(VersatileZoomTool.class);
+
+       // private static final ResourceBundle stringRes = ResourceBundle
+       // .getBundle("org/geotools/swing/Text");
+
+       // Cursors
+       private Cursor zoomInCursor;
+       private Cursor panCursor;
+       private Cursor defaultCursor;
+
+       // Variable values
+       private Point2D startDragPos;
+       private Point panePos;
+       private boolean computingZoomBox;
+       private boolean panning;
+
+       /**
+        * Constructor
+        */
+       public VersatileZoomTool() {
+               // Toolkit tk = Toolkit.getDefaultToolkit();
+               // zoomInCursor = tk.createCustomCursor(new ImageIcon(getClass()
+               // .getResource("/org/geotools/swing/icons/mActionZoomIn.png"))
+               // .getImage(), new Point(14, 9), stringRes
+               // .getString("tool_name_zoom_in"));
+               zoomInCursor = new Cursor(Cursor.SE_RESIZE_CURSOR);
+               // panCursor = tk.createCustomCursor(new
+               // ImageIcon(getClass().getResource(
+               // "/org/geotools/swing/icons/mActionPan.png")).getImage(),
+               // new Point(15, 15), stringRes.getString("tool_name_pan"));
+               panCursor = new Cursor(Cursor.HAND_CURSOR);
+               defaultCursor = new Cursor(Cursor.CROSSHAIR_CURSOR);
+
+               startDragPos = new DirectPosition2D();
+               computingZoomBox = false;
+               panning = false;
+
+       }
+
+       /**
+        * Zoom in by the currently set increment, with the map centred at the
+        * location (in world coords) of the mouse click
+        * 
+        * @param e
+        *            map mapPane mouse event
+        */
+       @Override
+       public void onMouseClicked(MapMouseEvent e) {
+               centerMapToEvent(e);
+       }
+
+       protected void centerMapToEvent(MapMouseEvent e) {
+               Rectangle paneArea = getMapPane().getVisibleRect();
+               DirectPosition2D mapPos = e.getMapPosition();
+
+               double scale = getMapPane().getWorldToScreenTransform().getScaleX();
+               // double newScale = scale * zoom;
+               //
+               DirectPosition2D corner = new DirectPosition2D(mapPos.getX() - 0.5d
+                               * paneArea.getWidth() / scale, mapPos.getY() + 0.5d
+                               * paneArea.getHeight() / scale);
+
+               Envelope2D newMapArea = new Envelope2D();
+               newMapArea.setFrameFromCenter(mapPos, corner);
+               getMapPane().setDisplayArea(newMapArea);
+       }
+
+       /**
+        * Records the map position of the mouse event in case this button press is
+        * the beginning of a mouse drag
+        * 
+        * @param ev
+        *            the mouse event
+        */
+       @Override
+       public void onMousePressed(MapMouseEvent ev) {
+               if (SwingUtilities.isLeftMouseButton(ev)) {
+                       startDragPos = new DirectPosition2D();
+                       startDragPos.setLocation(ev.getMapPosition());
+               } else if (SwingUtilities.isMiddleMouseButton(ev)) {
+                       panePos = ev.getPoint();
+                       panning = true;
+               }
+       }
+
+       /**
+        * Records that the mouse is being dragged
+        * 
+        * @param ev
+        *            the mouse event
+        */
+       @Override
+       public void onMouseDragged(MapMouseEvent ev) {
+               if (SwingUtilities.isLeftMouseButton(ev)) {
+                       computingZoomBox = true;
+               } else if (panning) {
+                       Point pos = ev.getPoint();
+                       if (!pos.equals(panePos)) {
+                               getMapPane().moveImage(pos.x - panePos.x, pos.y - panePos.y);
+                               panePos = pos;
+                       }
+               }
+               getMapPane().setCursor(getCursor());
+       }
+
+       /**
+        * If the mouse was dragged, determines the bounds of the box that the user
+        * defined and passes this to the mapPane's
+        * {@link org.geotools.swing.JMapPane#setDisplayArea(org.opengis.geometry.Envelope) }
+        * method
+        * 
+        * @param ev
+        *            the mouse event
+        */
+       @Override
+       public void onMouseReleased(MapMouseEvent ev) {
+               if (computingZoomBox && !ev.getPoint().equals(startDragPos)) {
+                       Envelope2D env = new Envelope2D();
+                       env.setFrameFromDiagonal(startDragPos, ev.getMapPosition());
+                       computingZoomBox = false;
+                       getMapPane().setDisplayArea(env);
+               } else if (panning) {
+                       panning = false;
+                       getMapPane().repaint();
+               }
+               getMapPane().setCursor(getCursor());
+       }
+
+       /**
+        * Get the mouse cursor for this tool
+        */
+       @Override
+       public Cursor getCursor() {
+               if (computingZoomBox)
+                       return zoomInCursor;
+               else if (panning)
+                       return panCursor;
+               else
+                       return defaultCursor;
+       }
+
+       /**
+        * We use a custom drag box
+        */
+       @Override
+       public boolean drawDragBox() {
+               return false;
+       }
+
+       @Override
+       public void setMapPane(JMapPane pane) {
+               super.setMapPane(pane);
+               VariableDragBox dragBox = new VariableDragBox();
+               getMapPane().addMouseListener(dragBox);
+               getMapPane().addMouseMotionListener(dragBox);
+               getMapPane().addMouseWheelListener(new MouseWheelListener() {
+                       private double clickToZoom = 0.1; // 1 wheel click is 10% zoom
+
+                       public void mouseWheelMoved(MouseWheelEvent ev) {
+                               int clicks = ev.getWheelRotation();
+                               // -ve means wheel moved up, +ve means down
+                               int sign = (clicks < 0 ? -1 : 1);
+
+                               ReferencedEnvelope env = getMapPane().getDisplayArea();
+                               double width = env.getWidth();
+                               double delta = width * clickToZoom * sign;
+
+                               env.expandBy(delta);
+                               getMapPane().setDisplayArea(env);
+                               getMapPane().repaint();
+                       }
+               });
+       }
+
+       /**
+        * Custom drag box (hacked from JMapPane) so that we can change the behavior
+        * depending on whether we pan or zoom.
+        */
+       private class VariableDragBox extends MouseInputAdapter {
+
+               private Point startPos;
+               private Rectangle rect;
+               private boolean dragged;
+
+               VariableDragBox() {
+                       rect = new Rectangle();
+                       dragged = false;
+               }
+
+               @Override
+               public void mousePressed(MouseEvent e) {
+                       startPos = new Point(e.getPoint());
+               }
+
+               @Override
+               public void mouseDragged(MouseEvent e) {
+                       if (computingZoomBox) {
+                               Graphics2D g2D = (Graphics2D) getMapPane().getGraphics();
+                               g2D.setColor(Color.WHITE);
+                               g2D.setXORMode(Color.RED);
+                               if (dragged) {
+                                       g2D.drawRect(rect.x, rect.y, rect.width, rect.height);
+                               }
+
+                               rect.setFrameFromDiagonal(startPos, e.getPoint());
+                               g2D.drawRect(rect.x, rect.y, rect.width, rect.height);
+
+                               dragged = true;
+                       }
+               }
+
+               @Override
+               public void mouseReleased(MouseEvent e) {
+                       if (dragged) {
+                               Graphics2D g2D = (Graphics2D) getMapPane().getGraphics();
+                               g2D.setColor(Color.WHITE);
+                               g2D.setXORMode(Color.RED);
+                               g2D.drawRect(rect.x, rect.y, rect.width, rect.height);
+                               dragged = false;
+                       }
+               }
+       }
+
+}
index 8e1a8f79c512725b62b4f9fa7a9295ec4564c0c0..b77a71c5236c09a7356e982c526705f3e9ceea8f 100644 (file)
@@ -34,4 +34,12 @@ public class GpsBabelPositionProvider implements PositionProvider {
                return position;
        }
 
+       public void setInputFormat(String inputFormat) {
+               this.inputFormat = inputFormat;
+       }
+
+       public void setInputFile(String inputFile) {
+               this.inputFile = inputFile;
+       }
+
 }