Changeset 33916 in osm


Ignore:
Timestamp:
2017-11-26T15:38:01+01:00 (7 years ago)
Author:
donvip
Message:

update to JOSM 13007

Location:
applications/editors/josm/plugins/osmarender
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/osmarender/build.xml

    r32680 r33916  
    55    <property name="commit.message" value="Fixed #4360 - osmarender plugin does not load"/>
    66    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    7     <property name="plugin.main.version" value="10580"/>
     7    <property name="plugin.main.version" value="13007"/>
    88
    99    <property name="stylesheets" location="./stylesheets"/>
  • applications/editors/josm/plugins/osmarender/src/org/openstreetmap/josm/plugins/osmarender/OsmarenderPlugin.java

    r32501 r33916  
    88import java.io.BufferedReader;
    99import java.io.File;
     10import java.io.FileInputStream;
    1011import java.io.FileOutputStream;
    11 import java.io.FileReader;
    1212import java.io.IOException;
     13import java.io.InputStreamReader;
    1314import java.io.OutputStreamWriter;
    1415import java.io.PrintWriter;
     16import java.nio.charset.StandardCharsets;
    1517import java.util.HashSet;
    1618import java.util.Set;
     
    3335import org.openstreetmap.josm.data.osm.Relation;
    3436import org.openstreetmap.josm.data.osm.Way;
     37import org.openstreetmap.josm.gui.MainApplication;
    3538import org.openstreetmap.josm.gui.MainMenu;
    3639import org.openstreetmap.josm.gui.MapFrame;
     40import org.openstreetmap.josm.gui.MapView;
    3741import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    3842import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
     
    4448import org.openstreetmap.josm.plugins.PluginInformation;
    4549import org.openstreetmap.josm.tools.GBC;
     50import org.openstreetmap.josm.tools.Logging;
    4651import org.openstreetmap.josm.tools.PlatformHookWindows;
    4752
     
    5661        @Override
    5762        public void actionPerformed(ActionEvent e) {
    58             DataSet ds = Main.getLayerManager().getEditDataSet();
     63            DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    5964            if (ds == null) {
    6065                return;
     
    6267
    6368            // 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);
    6672            Bounds b = new Bounds(bottomLeft, topRight);
    6773
     
    7076            } catch (IOException ex) {
    7177                // how handle the exception?
    72                 Main.error(ex);
     78                Logging.error(ex);
    7379            }
    7480
    7581            String firefox = Main.pref.get("osmarender.firefox", "firefox");
     82            String pluginDir = getPluginDirs().getUserDataDirectory(false).getPath();
    7683            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")) {
    7885                // write to plugin dir
    7986                w.header();
     
    118125                String argument;
    119126                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\"";
    121128                else
    122                     argument = getPluginDir()+File.separator+"generated.xml";
     129                    argument = pluginDir+File.separator+"generated.xml";
    123130
    124131                // launch up the viewer
     
    140147    public OsmarenderPlugin(PluginInformation info) throws IOException {
    141148        super(info);
    142         osmarenderMenu = MainMenu.add(Main.main.menu.viewMenu, new Action());
     149        osmarenderMenu = MainMenu.add(MainApplication.getMenu().viewMenu, new Action());
    143150        osmarenderMenu.setVisible(false);
    144151
     
    203210            "minlon=\"" + b.getMin().lon() + "\" " +
    204211            "maxlon=\"" + b.getMax().lon() + "\" " + "/>";
     212        String pluginDir = getPluginDirs().getUserDataDirectory(false).getPath();
    205213
    206214        try (
    207215            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");
    210218        ) {
    211219            // osm-map-features.xml contain two placemark
Note: See TracChangeset for help on using the changeset viewer.