Changeset 33916 in osm for applications/editors/josm
- Timestamp:
- 2017-11-26T15:38:01+01:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/osmarender
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/osmarender/build.xml
r32680 r33916 5 5 <property name="commit.message" value="Fixed #4360 - osmarender plugin does not load"/> 6 6 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 7 <property name="plugin.main.version" value="1 0580"/>7 <property name="plugin.main.version" value="13007"/> 8 8 9 9 <property name="stylesheets" location="./stylesheets"/> -
applications/editors/josm/plugins/osmarender/src/org/openstreetmap/josm/plugins/osmarender/OsmarenderPlugin.java
r32501 r33916 8 8 import java.io.BufferedReader; 9 9 import java.io.File; 10 import java.io.FileInputStream; 10 11 import java.io.FileOutputStream; 11 import java.io.FileReader;12 12 import java.io.IOException; 13 import java.io.InputStreamReader; 13 14 import java.io.OutputStreamWriter; 14 15 import java.io.PrintWriter; 16 import java.nio.charset.StandardCharsets; 15 17 import java.util.HashSet; 16 18 import java.util.Set; … … 33 35 import org.openstreetmap.josm.data.osm.Relation; 34 36 import org.openstreetmap.josm.data.osm.Way; 37 import org.openstreetmap.josm.gui.MainApplication; 35 38 import org.openstreetmap.josm.gui.MainMenu; 36 39 import org.openstreetmap.josm.gui.MapFrame; 40 import org.openstreetmap.josm.gui.MapView; 37 41 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 38 42 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; … … 44 48 import org.openstreetmap.josm.plugins.PluginInformation; 45 49 import org.openstreetmap.josm.tools.GBC; 50 import org.openstreetmap.josm.tools.Logging; 46 51 import org.openstreetmap.josm.tools.PlatformHookWindows; 47 52 … … 56 61 @Override 57 62 public void actionPerformed(ActionEvent e) { 58 DataSet ds = Main.getLayerManager().getEditDataSet(); 63 DataSet ds = MainApplication.getLayerManager().getEditDataSet(); 59 64 if (ds == null) { 60 65 return; … … 62 67 63 68 // get all stuff visible on screen 64 LatLon bottomLeft = Main.map.mapView.getLatLon(0,Main.map.mapView.getHeight()); 65 LatLon topRight = Main.map.mapView.getLatLon(Main.map.mapView.getWidth(), 0); 69 MapView mapView = MainApplication.getMap().mapView; 70 LatLon bottomLeft = mapView.getLatLon(0, mapView.getHeight()); 71 LatLon topRight = mapView.getLatLon(mapView.getWidth(), 0); 66 72 Bounds b = new Bounds(bottomLeft, topRight); 67 73 … … 70 76 } catch (IOException ex) { 71 77 // how handle the exception? 72 Main.error(ex);78 Logging.error(ex); 73 79 } 74 80 75 81 String firefox = Main.pref.get("osmarender.firefox", "firefox"); 82 String pluginDir = getPluginDirs().getUserDataDirectory(false).getPath(); 76 83 try (OsmWriter w = OsmWriterFactory.createOsmWriter(new PrintWriter(new OutputStreamWriter( 77 new FileOutputStream( getPluginDir()+File.separator+"data.osm"), "UTF-8")), false, "0.6")) {84 new FileOutputStream(pluginDir+File.separator+"data.osm"), "UTF-8")), false, "0.6")) { 78 85 // write to plugin dir 79 86 w.header(); … … 118 125 String argument; 119 126 if (Main.platform instanceof PlatformHookWindows) 120 argument = "file:///"+ getPluginDir().replace('\\','/').replace(" ","%20")+File.separator+"generated.xml\"";127 argument = "file:///"+pluginDir.replace('\\','/').replace(" ","%20")+File.separator+"generated.xml\""; 121 128 else 122 argument = getPluginDir()+File.separator+"generated.xml";129 argument = pluginDir+File.separator+"generated.xml"; 123 130 124 131 // launch up the viewer … … 140 147 public OsmarenderPlugin(PluginInformation info) throws IOException { 141 148 super(info); 142 osmarenderMenu = MainMenu.add(Main .main.menu.viewMenu, new Action());149 osmarenderMenu = MainMenu.add(MainApplication.getMenu().viewMenu, new Action()); 143 150 osmarenderMenu.setVisible(false); 144 151 … … 203 210 "minlon=\"" + b.getMin().lon() + "\" " + 204 211 "maxlon=\"" + b.getMax().lon() + "\" " + "/>"; 212 String pluginDir = getPluginDirs().getUserDataDirectory(false).getPath(); 205 213 206 214 try ( 207 215 BufferedReader reader = new BufferedReader( 208 new FileReader(getPluginDir()+ File.separator + "osm-map-features.xml")209 PrintWriter writer = new PrintWriter( getPluginDir()+ File.separator + "generated.xml", "UTF-8");216 new InputStreamReader(new FileInputStream(pluginDir + File.separator + "osm-map-features.xml"), StandardCharsets.UTF_8)); 217 PrintWriter writer = new PrintWriter( pluginDir + File.separator + "generated.xml", "UTF-8"); 210 218 ) { 211 219 // osm-map-features.xml contain two placemark
Note:
See TracChangeset
for help on using the changeset viewer.