Changeset 30734 in osm for applications/editors/josm/plugins/geotools/src/org/openstreetmap
- Timestamp:
- 2014-10-18T16:48:52+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/geotools/src/org/openstreetmap/josm/plugins/geotools/GeoToolsPlugin.java
r30569 r30734 17 17 import com.sun.media.jai.imageioimpl.ImageReadWriteSpi; 18 18 19 /** 20 * GeoTools plugin, bringing this library to other JOSM plugins. 21 */ 19 22 public class GeoToolsPlugin extends Plugin { 23 24 /** 25 * Constructs a new {@code GeoToolsPlugin}. 26 * @param info plugin information 27 */ 20 28 public GeoToolsPlugin(PluginInformation info) { 21 29 super(info); … … 29 37 // See https://www.java.net/node/666373 30 38 System.setProperty("com.sun.media.jai.disableMediaLib", "true"); 31 39 32 40 // As the JAI jars are bundled in the geotools plugin, JAI initialization does not work, 33 41 // so we need to perform the tasks described here ("Initialization and automatic loading of registry objects"): … … 35 43 OperationRegistry registry = JAI.getDefaultInstance().getOperationRegistry(); 36 44 if (registry == null) { 37 System.err.println("geotools: error in JAI initialization. Cannot access default operation registry");45 Main.error("geotools: error in JAI initialization. Cannot access default operation registry"); 38 46 } else { 39 47 // Update registry with com.sun.media.jai.imageioimpl.ImageReadWriteSpi (only class listed javax.media.jai.OperationRegistrySpi) 40 // it would be safer to parse this file instead, but a JAI update is very unlikely as it has not been modified since 2005 48 // it would be safer to parse this file instead, but a JAI update is very unlikely as it has not been modified since 2005 41 49 new ImageReadWriteSpi().updateRegistry(registry); 42 50 43 // Update registry with GeoTools registry file 44 InputStream in = GeoToolsPlugin.class.getResourceAsStream("/META-INF/registryFile.jai"); 45 if (in == null) { 46 System.err.println("geotools: error in JAI initialization. Cannot access META-INF/registryFile.jai"); 47 } else { 48 try { 51 // Update registry with GeoTools registry file 52 try (InputStream in = GeoToolsPlugin.class.getResourceAsStream("/META-INF/registryFile.jai")) { 53 if (in == null) { 54 Main.error("geotools: error in JAI initialization. Cannot access META-INF/registryFile.jai"); 55 } else { 49 56 registry.updateFromStream(in); 50 } catch (IOException e) {51 System.err.println("geotools: error in JAI initialization. Cannot update default operation registry");52 57 } 53 try { 54 in.close(); 55 } catch (IOException e) { 56 System.err.println("geotools: error in JAI initialization. Cannot close input stream"); 57 } 58 } catch (IOException e) { 59 Main.error("geotools: error in JAI initialization: "+e.getMessage()); 58 60 } 59 60 // Print JAI registry contents61 //for (String mode : RegistryMode.getModeNames()) {62 // System.out.println("geotools: JAI mode "+mode+": "+Arrays.toString(registry.getDescriptorNames(mode)));63 //}64 61 } 65 62 } 66 63 67 64 private void initGeoTools() { 68 65 // Force Axis order. Fix #8248
Note:
See TracChangeset
for help on using the changeset viewer.