Changeset 28954 in osm for applications/editors/josm/plugins/ImportImagePlugin/src
- Timestamp:
- 2012-11-18T22:21:44+01:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/ImportImagePlugin
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/ImportImagePlugin
- Property svn:ignore
-
old new 1 1 build 2 bin
-
- Property svn:ignore
-
applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImageLayer.java
r26517 r28954 11 11 12 12 import javax.media.jai.PlanarImage; 13 import javax.swing.AbstractAction; 13 14 import javax.swing.Action; 14 import javax.swing.AbstractAction;15 15 import javax.swing.Icon; 16 16 import javax.swing.ImageIcon; … … 29 29 import org.openstreetmap.josm.data.ProjectionBounds; 30 30 import org.openstreetmap.josm.data.coor.EastNorth; 31 import org.openstreetmap.josm.data.coor.LatLon;32 31 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 33 32 import org.openstreetmap.josm.gui.ExtendedDialog; … … 208 207 209 208 // Draw picture 210 g.drawImage(image, 0, 0, null); 209 try { 210 g.drawImage(image, 0, 0, null); 211 } catch (ArrayIndexOutOfBoundsException e) { 212 // TODO: prevents this to happen when displaying GeoTIFF images (see #7902) 213 e.printStackTrace(); 214 } 211 215 212 216 } else { -
applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImportImagePlugin.java
r26452 r28954 87 87 } 88 88 89 /* Change class path:90 * Use java reflection methods to add URLs to the class-path.91 * Changes take effect when calling methods of other plugin classes92 * (new threads)93 * */94 URLClassLoader sysLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();95 String[] libraryNames = pluginProps.getProperty("libraries").split(",");96 Class<URLClassLoader> sysclass = URLClassLoader.class;97 Method method = sysclass.getDeclaredMethod("addURL", new Class[]{URL.class});98 method.setAccessible(true);99 for (int i = 0; i < libraryNames.length; i++) {100 File library = new File(PLUGINLIBRARIES_DIR + "/" + libraryNames[i]);101 method.invoke(sysLoader, new Object[]{library.toURI().toURL()});102 }103 104 105 89 // load information about supported reference systems 106 90 PluginOperations.loadCRSData(pluginProps); … … 113 97 Main.main.menu.fileMenu.insert(loadFileAction, 8); 114 98 Main.main.menu.fileMenu.insertSeparator(9); 115 116 99 117 100 } catch (Exception e) { … … 125 108 126 109 logger.info("Plugin successfully loaded."); 127 128 110 } 129 111 … … 136 118 private void checkInstallation() throws IOException 137 119 { 138 139 120 // check plugin resource state 140 121 boolean isInstalled = true; … … 186 167 } 187 168 188 189 // Copy all needed JAR files to $PLUGIN_DIR$/lib/190 String[] libStrings = pluginProps.getProperty("libraries").split(",");191 192 for (int i = 0; i < libStrings.length; i++) {193 194 URL url = pluginClassLoader.getResource("lib/" + libStrings[i]);195 196 FileOutputStream out = null;197 198 try{199 out = new FileOutputStream(new File(libDir, libStrings[i]));200 } catch (FileNotFoundException e) {201 break;202 }203 204 BufferedInputStream in = null;205 try206 {207 in = new BufferedInputStream(url.openStream());208 209 byte[] buffer = new byte[1024];210 while (true)211 {212 int count = in.read(buffer);213 if (count == -1)214 break;215 out.write(buffer, 0, count);216 }217 }218 finally219 {220 if (in != null)221 in.close();222 }223 }224 169 logger.debug("Plugin successfully installed"); 225 170 } -
applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/PluginOperations.java
r26452 r28954 19 19 import org.geotools.coverage.grid.GridCoverage2D; 20 20 import org.geotools.coverage.grid.GridCoverageFactory; 21 import org.geotools.coverage.processing. DefaultProcessor;21 import org.geotools.coverage.processing.CoverageProcessor; 22 22 import org.geotools.data.DataSourceException; 23 23 import org.geotools.data.WorldFileReader; … … 25 25 import org.geotools.gce.geotiff.GeoTiffReader; 26 26 import org.geotools.geometry.Envelope2D; 27 import org.geotools.image.jai.Registry;28 27 import org.geotools.referencing.CRS; 29 import org.geotools.referencing.crs.DefaultGeographicCRS;30 import org.opengis.metadata.content.ImageDescription;31 28 import org.opengis.parameter.ParameterValueGroup; 32 29 import org.opengis.referencing.FactoryException; … … 34 31 import org.opengis.referencing.crs.CRSAuthorityFactory; 35 32 import org.opengis.referencing.crs.CoordinateReferenceSystem; 36 import org.opengis.referencing.cs.CoordinateSystemAxis;37 33 import org.opengis.util.InternationalString; 38 39 40 34 41 35 /** … … 84 78 GridCoverage2D destination = null; 85 79 86 DefaultProcessor processor = new DefaultProcessor(null); 87 ParameterValueGroup resampleParams = processor.getOperation("Resample") 88 .getParameters(); 80 CoverageProcessor processor = new CoverageProcessor(); 81 ParameterValueGroup resampleParams = processor.getOperation("Resample").getParameters(); 89 82 90 83 // set parameters 91 84 resampleParams.parameter("Source").setValue(coverage); 92 resampleParams.parameter("CoordinateReferenceSystem").setValue( 93 targetCrs); 85 resampleParams.parameter("CoordinateReferenceSystem").setValue(targetCrs); 94 86 95 87 // resample coverage with given parameters … … 380 372 CRSAuthorityFactory fac = CRS.getAuthorityFactory(false); 381 373 382 for (Iterator iterator = supportedCodes.iterator(); iterator.hasNext();) { 374 for (Iterator<String> iterator = supportedCodes.iterator(); iterator.hasNext();) { 383 375 String string = (String) iterator.next(); 384 376 try { … … 387 379 } 388 380 InternationalString desc = fac.getDescriptionText("EPSG:" + string); 389 390 381 String description = desc.toString() + " [-EPSG:" + string + "-]"; 391 392 382 crsDescriptions.add(description); 393 394 383 if(defaultcrsString != null && defaultcrsString.equalsIgnoreCase("EPSG:" + string)){ 395 384 boolean isEastingFirst = Boolean.valueOf(pluginProps.getProperty("default_crs_eastingfirst")); … … 397 386 defaultSourceCRSDescription = description; 398 387 } 399 } catch (NoSuchAuthorityCodeException e) { 400 logger.error("Error while loading EPSG data: " + e.getMessage()); 388 401 389 } catch (FactoryException e) { 402 390 logger.error("Error while loading EPSG data: " + e.getMessage()); … … 404 392 } 405 393 } 406 407 394 }
Note:
See TracChangeset
for help on using the changeset viewer.