Index: applications/editors/josm/plugins/ImportImagePlugin/.classpath
===================================================================
--- applications/editors/josm/plugins/ImportImagePlugin/.classpath	(revision 28807)
+++ applications/editors/josm/plugins/ImportImagePlugin/.classpath	(revision 28954)
@@ -2,30 +2,30 @@
 <classpath>
 	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="lib" path="lib/commons-beanutils-1.7.0.jar"/>
-	<classpathentry kind="lib" path="lib/commons-pool-1.5.3.jar"/>
-	<classpathentry kind="lib" path="lib/geoapi-2.3-M1.jar"/>
-	<classpathentry kind="lib" path="lib/geoapi-pending-2.3-M1.jar"/>
-	<classpathentry kind="lib" path="lib/geoapi.jar"/>
-	<classpathentry kind="lib" path="lib/gt-api-2.6.0.jar"/>
-	<classpathentry kind="lib" path="lib/gt-coverage-2.6.0.jar"/>
-	<classpathentry kind="lib" path="lib/gt-epsg-extension-2.6.0.jar"/>
-	<classpathentry kind="lib" path="lib/gt-epsg-hsql-2.6.0.jar"/>
-	<classpathentry kind="lib" path="lib/gt-geotiff-2.6.0.jar"/>
-	<classpathentry kind="lib" path="lib/gt-main-2.6.0.jar"/>
-	<classpathentry kind="lib" path="lib/gt-metadata-2.6.0.jar"/>
-	<classpathentry kind="lib" path="lib/gt-referencing-2.6.0.jar"/>
-	<classpathentry kind="lib" path="lib/hsqldb-1.8.0.7.jar"/>
-	<classpathentry kind="lib" path="lib/imageio-ext-tiff-1.0.4.jar"/>
-	<classpathentry kind="lib" path="lib/imageio-ext-utilities-1.0.4.jar"/>
-	<classpathentry kind="lib" path="lib/jai_codec-1.1.3.jar"/>
-	<classpathentry kind="lib" path="lib/jai_core.jar"/>
-	<classpathentry kind="lib" path="lib/jai_imageio-1.1.jar"/>
-	<classpathentry kind="lib" path="lib/jdom-1.0.jar"/>
-	<classpathentry kind="lib" path="lib/jsr-275-1.0-beta-2.jar"/>
-	<classpathentry kind="lib" path="lib/jts-1.10.jar"/>
-	<classpathentry kind="lib" path="lib/log4j-1.2.12.jar"/>
-	<classpathentry kind="lib" path="lib/vecmath-1.3.2.jar"/>
+	<classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/JOSM"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/JOSM-GeoTools"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/JOSM-jts"/>
+	<classpathentry kind="lib" path="/JOSM-GeoTools/lib/commons-beanutils-1.7.0.jar"/>
+	<classpathentry kind="lib" path="/JOSM-GeoTools/lib/commons-pool-1.5.4.jar"/>
+	<classpathentry kind="lib" path="/JOSM-GeoTools/lib/hsqldb-1.8.0.7.jar"/>
+	<classpathentry kind="lib" path="/JOSM-GeoTools/lib/jai_codec-1.1.3.jar"/>
+	<classpathentry kind="lib" path="/JOSM-GeoTools/lib/jai_core-1.1.3.jar"/>
+	<classpathentry kind="lib" path="/JOSM-GeoTools/lib/jai_imageio-1.1.jar"/>
+	<classpathentry kind="lib" path="/JOSM-GeoTools/lib/jdom-1.0.jar"/>
+	<classpathentry kind="lib" path="/JOSM-GeoTools/lib/jsr-275-1.0-beta-2.jar"/>
+	<classpathentry kind="lib" path="/JOSM-GeoTools/lib/vecmath-1.3.2.jar"/>
+	<classpathentry kind="lib" path="/JOSM-jts/lib/jts-1.12.jar"/>
+	<classpathentry kind="lib" path="/JOSM-GeoTools/lib/gt-api-8.3.jar"/>
+	<classpathentry kind="lib" path="/JOSM-GeoTools/lib/gt-coverage-8.3.jar"/>
+	<classpathentry kind="lib" path="/JOSM-GeoTools/lib/gt-epsg-extension-8.3.jar"/>
+	<classpathentry kind="lib" path="/JOSM-GeoTools/lib/gt-epsg-hsql-8.3.jar"/>
+	<classpathentry kind="lib" path="/JOSM-GeoTools/lib/gt-geotiff-8.3.jar"/>
+	<classpathentry kind="lib" path="/JOSM-GeoTools/lib/gt-main-8.3.jar"/>
+	<classpathentry kind="lib" path="/JOSM-GeoTools/lib/gt-metadata-8.3.jar"/>
+	<classpathentry kind="lib" path="/JOSM-GeoTools/lib/gt-referencing-8.3.jar"/>
+	<classpathentry kind="lib" path="/JOSM-GeoTools/lib/imageio-ext-tiff-1.1.5.jar"/>
+	<classpathentry kind="lib" path="/JOSM-GeoTools/lib/imageio-ext-utilities-1.1.5.jar"/>
+	<classpathentry kind="lib" path="/JOSM-GeoTools/lib/gt-opengis-8.3.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
Index: applications/editors/josm/plugins/ImportImagePlugin/.project
===================================================================
--- applications/editors/josm/plugins/ImportImagePlugin/.project	(revision 28807)
+++ applications/editors/josm/plugins/ImportImagePlugin/.project	(revision 28954)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-	<name>ImportImagePlugin</name>
+	<name>JOSM-ImportImage</name>
 	<comment></comment>
 	<projects>
Index: applications/editors/josm/plugins/ImportImagePlugin/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- applications/editors/josm/plugins/ImportImagePlugin/.settings/org.eclipse.jdt.core.prefs	(revision 28954)
+++ applications/editors/josm/plugins/ImportImagePlugin/.settings/org.eclipse.jdt.core.prefs	(revision 28954)
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+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.6
Index: applications/editors/josm/plugins/ImportImagePlugin/build.xml
===================================================================
--- applications/editors/josm/plugins/ImportImagePlugin/build.xml	(revision 28807)
+++ applications/editors/josm/plugins/ImportImagePlugin/build.xml	(revision 28954)
@@ -45,5 +45,5 @@
 	<!-- this is the directory where the plugin jar is copied to -->
 	<property name="plugin.dist.dir"        value="../../dist"/>
-	<property name="ant.build.javac.target" value="1.5"/>
+	<property name="ant.build.javac.target" value="1.6"/>
 	<property name="plugin.dist.dir"        value="../../dist"/>
 	<property name="plugin.jar"             value="${plugin.dist.dir}/${ant.project.name}.jar"/>
@@ -65,8 +65,14 @@
 	<target name="compile" depends="init">
 		<echo message="compiling sources for  ${plugin.jar} ... "/>
-		<javac srcdir="src" classpath="${josm}" debug="true" destdir="${plugin.build.dir}">
+		<javac srcdir="src" classpath="${josm}" debug="true" destdir="${plugin.build.dir}" includeantruntime="false">
             <classpath>
                 <pathelement location="${josm}"/>
                 <fileset dir="lib">
+                    <include name="**/*.jar"/>
+                </fileset>
+                <fileset dir="../jts/lib">
+                    <include name="**/*.jar"/>
+                </fileset>
+                <fileset dir="../geotools/lib">
                     <include name="**/*.jar"/>
                 </fileset>
@@ -85,12 +91,5 @@
 		<echo message="creating ${ant.project.name}.jar ... "/>
 		
-		<copy todir="${plugin.build.dir}/lib">
-			<fileset dir="lib">
-				  <not>
-				    <filename name="log4j-1.2.12.jar"/>
-				  </not>
-			</fileset>
-		</copy>
-        <unjar src="lib/log4j-1.2.12.jar" dest="${plugin.build.dir}"/>
+        <unjar src="lib/log4j-1.2.17.jar" dest="${plugin.build.dir}"/>
 		<copy todir="${plugin.build.dir}/images">
 			<fileset dir="images"/>
@@ -124,4 +123,5 @@
                 <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/wiki/JOSM/Plugins/ImportImagePlugin"/>
                 <attribute name="Plugin-Mainversion" value="${plugin.main.version}"/>
+                <attribute name="Plugin-Requires" value="geotools"/>
                 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
 			</manifest>
@@ -273,23 +273,3 @@
 	</target>
 	
-	<target name="unjar-test" >
-        <!--unjar dest="C:/Workspace_2/geotoolstest/lib/unjartest">
-            <fileset dir="lib"/>
-        </unjar-->
-        
-        		<jar destfile="C:/Workspace_2/geotoolstest/lib/unjartest/${ant.project.name}.jar" basedir="C:/Workspace_2/geotoolstest/lib/unjartest">
-
-			<manifest>
-                <attribute name="Author" value="Christoph Beekmans, Fabian Kowitz, Anna Robaszkiewicz, Oliver Kuhn, Martin Ulitzny"/>
-                <attribute name="Plugin-Class" value="org.openstreetmap.josm.plugins.CoveragePlugin.CoveragePlugin"/>
-                <attribute name="Plugin-Date" value="${version.entry.commit.date}"/>
-                <attribute name="Plugin-Description" value="Plugin for importing spatial referenced images"/>
-                <attribute name="Plugin-Link" value="..."/>
-                <attribute name="Plugin-Mainversion" value=".."/>
-                <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
-                <attribute name="Class-path" value=" . CoveragePlugin/lib/commons-beanutils-1.7.0.jar CoveragePlugin/lib/commons-pool-1.5.3.jar CoveragePlugin/lib/geoapi-2.3-M1.jar CoveragePlugin/lib/geoapi-pending-2.3-M1.jar CoveragePlugin/lib/geoapi.jar CoveragePlugin/lib/gt-api-2.6.0.jar CoveragePlugin/lib/gt-coverage-2.6.0.jar CoveragePlugin/lib/gt-epsg-extension-2.6.0.jar CoveragePlugin/lib/gt-epsg-hsql-2.6.0.jar CoveragePlugin/lib/gt-geotiff-2.6.0.jar CoveragePlugin/lib/gt-main-2.6.0.jar CoveragePlugin/lib/gt-metadata-2.6.0.jar CoveragePlugin/lib/gt-referencing-2.6.0.jar CoveragePlugin/lib/hsqldb-1.8.0.7.jar CoveragePlugin/lib/imageio-ext-tiff-1.0.4.jar CoveragePlugin/lib/imageio-ext-utilities-1.0.4.jar CoveragePlugin/lib/jai_codec-1.1.3.jar CoveragePlugin/lib/jai_core.jar CoveragePlugin/lib/jai_imageio-1.1.jar CoveragePlugin/lib/jdom-1.0.jar CoveragePlugin/lib/jsr-275-1.0-beta-2.jar CoveragePlugin/lib/jts-1.10.jar CoveragePlugin/lib/log4j-1.2.12.jar CoveragePlugin/lib/vecmath-1.3.2.jar" />
-			</manifest>
-		</jar>
-	</target>
-	
 </project>
Index: applications/editors/josm/plugins/ImportImagePlugin/resources/pluginProperties.properties
===================================================================
--- applications/editors/josm/plugins/ImportImagePlugin/resources/pluginProperties.properties	(revision 28807)
+++ applications/editors/josm/plugins/ImportImagePlugin/resources/pluginProperties.properties	(revision 28954)
@@ -1,3 +1,2 @@
 default_crs_srid=EPSG\:31467
 default_crs_eastingfirst=true
-libraries=commons-beanutils-1.7.0.jar,commons-pool-1.5.3.jar,geoapi-2.3-M1.jar,geoapi-pending-2.3-M1.jar,gt-api-2.6.0.jar,gt-coverage-2.6.0.jar,gt-epsg-hsql-2.6.0.jar,gt-geotiff-2.6.0.jar,gt-main-2.6.0.jar,gt-metadata-2.6.0.jar,gt-referencing-2.6.0.jar,hsqldb-1.8.0.7.jar,imageio-ext-tiff-1.0.4.jar,imageio-ext-utilities-1.0.4.jar,jai_codec-1.1.3.jar,jai_core.jar,jai_imageio-1.1.jar,jdom-1.0.jar,jsr-275-1.0-beta-2.jar,jts-1.10.jar,vecmath-1.3.2.jar
Index: applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImageLayer.java
===================================================================
--- applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImageLayer.java	(revision 28807)
+++ applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImageLayer.java	(revision 28954)
@@ -11,6 +11,6 @@
 
 import javax.media.jai.PlanarImage;
+import javax.swing.AbstractAction;
 import javax.swing.Action;
-import javax.swing.AbstractAction;
 import javax.swing.Icon;
 import javax.swing.ImageIcon;
@@ -29,5 +29,4 @@
 import org.openstreetmap.josm.data.ProjectionBounds;
 import org.openstreetmap.josm.data.coor.EastNorth;
-import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
 import org.openstreetmap.josm.gui.ExtendedDialog;
@@ -208,5 +207,10 @@
 
             // Draw picture
-            g.drawImage(image, 0, 0, null);
+            try {
+                g.drawImage(image, 0, 0, null);
+            } catch (ArrayIndexOutOfBoundsException e) {
+                // TODO: prevents this to happen when displaying GeoTIFF images (see #7902)
+                e.printStackTrace();
+            }
 
         } else {
Index: applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImportImagePlugin.java
===================================================================
--- applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImportImagePlugin.java	(revision 28807)
+++ applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImportImagePlugin.java	(revision 28954)
@@ -87,20 +87,4 @@
             }
 
-            /* Change class path:
-             * Use java reflection methods to add URLs to the class-path.
-             * Changes take effect when calling methods of other plugin classes
-             * (new threads)
-             * */
-            URLClassLoader sysLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
-            String[] libraryNames = pluginProps.getProperty("libraries").split(",");
-            Class<URLClassLoader> sysclass = URLClassLoader.class;
-            Method method = sysclass.getDeclaredMethod("addURL", new Class[]{URL.class});
-            method.setAccessible(true);
-            for (int i = 0; i < libraryNames.length; i++) {
-                File library = new File(PLUGINLIBRARIES_DIR + "/" + libraryNames[i]);
-                method.invoke(sysLoader, new Object[]{library.toURI().toURL()});
-            }
-
-
             // load information about supported reference systems
             PluginOperations.loadCRSData(pluginProps);
@@ -113,5 +97,4 @@
             Main.main.menu.fileMenu.insert(loadFileAction, 8);
             Main.main.menu.fileMenu.insertSeparator(9);
-
 
         } catch (Exception e) {
@@ -125,5 +108,4 @@
 
         logger.info("Plugin successfully loaded.");
-
     }
 
@@ -136,5 +118,4 @@
     private void checkInstallation() throws IOException
     {
-
         // check plugin resource state
         boolean isInstalled = true;
@@ -186,40 +167,4 @@
             }
 
-
-            // Copy all needed JAR files to $PLUGIN_DIR$/lib/
-            String[] libStrings = pluginProps.getProperty("libraries").split(",");
-
-            for (int i = 0; i < libStrings.length; i++) {
-
-                URL url = pluginClassLoader.getResource("lib/" + libStrings[i]);
-
-                FileOutputStream out = null;
-
-                try{
-                    out = new FileOutputStream(new File(libDir, libStrings[i]));
-                } catch (FileNotFoundException e) {
-                    break;
-                }
-
-                BufferedInputStream in = null;
-                try
-                {
-                    in = new BufferedInputStream(url.openStream());
-
-                    byte[] buffer = new byte[1024];
-                    while (true)
-                    {
-                        int count = in.read(buffer);
-                        if (count == -1)
-                            break;
-                        out.write(buffer, 0, count);
-                    }
-                }
-                finally
-                {
-                    if (in != null)
-                        in.close();
-                }
-            }
             logger.debug("Plugin successfully installed");
         }
Index: applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/PluginOperations.java
===================================================================
--- applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/PluginOperations.java	(revision 28807)
+++ applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/PluginOperations.java	(revision 28954)
@@ -19,5 +19,5 @@
 import org.geotools.coverage.grid.GridCoverage2D;
 import org.geotools.coverage.grid.GridCoverageFactory;
-import org.geotools.coverage.processing.DefaultProcessor;
+import org.geotools.coverage.processing.CoverageProcessor;
 import org.geotools.data.DataSourceException;
 import org.geotools.data.WorldFileReader;
@@ -25,8 +25,5 @@
 import org.geotools.gce.geotiff.GeoTiffReader;
 import org.geotools.geometry.Envelope2D;
-import org.geotools.image.jai.Registry;
 import org.geotools.referencing.CRS;
-import org.geotools.referencing.crs.DefaultGeographicCRS;
-import org.opengis.metadata.content.ImageDescription;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.referencing.FactoryException;
@@ -34,8 +31,5 @@
 import org.opengis.referencing.crs.CRSAuthorityFactory;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.opengis.util.InternationalString;
-
-
 
 /**
@@ -84,12 +78,10 @@
         GridCoverage2D destination = null;
 
-        DefaultProcessor processor = new DefaultProcessor(null);
-        ParameterValueGroup resampleParams = processor.getOperation("Resample")
-                .getParameters();
+        CoverageProcessor processor = new CoverageProcessor();
+        ParameterValueGroup resampleParams = processor.getOperation("Resample").getParameters();
 
         // set parameters
         resampleParams.parameter("Source").setValue(coverage);
-        resampleParams.parameter("CoordinateReferenceSystem").setValue(
-                targetCrs);
+        resampleParams.parameter("CoordinateReferenceSystem").setValue(targetCrs);
 
         // resample coverage with given parameters
@@ -380,5 +372,5 @@
         CRSAuthorityFactory fac = CRS.getAuthorityFactory(false);
 
-        for (Iterator iterator = supportedCodes.iterator(); iterator.hasNext();) {
+        for (Iterator<String> iterator = supportedCodes.iterator(); iterator.hasNext();) {
             String string = (String) iterator.next();
             try {
@@ -387,9 +379,6 @@
                 }
                 InternationalString desc = fac.getDescriptionText("EPSG:" + string);
-
                 String description = desc.toString() + " [-EPSG:" + string + "-]";
-
                 crsDescriptions.add(description);
-
                 if(defaultcrsString != null && defaultcrsString.equalsIgnoreCase("EPSG:" + string)){
                     boolean isEastingFirst = Boolean.valueOf(pluginProps.getProperty("default_crs_eastingfirst"));
@@ -397,6 +386,5 @@
                     defaultSourceCRSDescription = description;
                 }
-            } catch (NoSuchAuthorityCodeException e) {
-                logger.error("Error while loading EPSG data: " + e.getMessage());
+
             } catch (FactoryException e) {
                 logger.error("Error while loading EPSG data: " + e.getMessage());
@@ -404,4 +392,3 @@
         }
     }
-
 }
