Changeset 200 in josm for src/org/openstreetmap


Ignore:
Timestamp:
2007-02-14T16:21:14+01:00 (17 years ago)
Author:
imi
Message:
  • new MarkerLayer code from Frederik. Supports Audio, Image and WebMarker (links)
Location:
src/org/openstreetmap/josm
Files:
8 added
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/actions/OpenAction.java

    r189 r200  
    1818import org.openstreetmap.josm.Main;
    1919import org.openstreetmap.josm.data.osm.DataSet;
    20 import org.openstreetmap.josm.gui.layer.MarkerLayer;
    2120import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2221import org.openstreetmap.josm.gui.layer.RawGpsLayer;
    23 import org.openstreetmap.josm.gui.layer.MarkerLayer.Marker;
    2422import org.openstreetmap.josm.gui.layer.RawGpsLayer.GpsPoint;
     23import org.openstreetmap.josm.gui.layer.markerlayer.Marker;
     24import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
    2525import org.openstreetmap.josm.io.OsmReader;
    2626import org.openstreetmap.josm.io.RawCsvReader;
  • src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java

    r181 r200  
    5353        static JList instance;
    5454        private JScrollPane listScrollPane;
    55        
     55
    5656        public final static class DeleteLayerAction extends AbstractAction {
    5757
     
    9191                        Layer l = layer == null ? (Layer)instance.getSelectedValue() : layer;
    9292                        l.visible = !l.visible;
     93                        Main.map.mapView.repaint();
     94                        instance.repaint();
     95                }
     96        }
     97
     98        public final static class ShowHideMarkerText extends AbstractAction {
     99                private final Layer layer;
     100
     101                public ShowHideMarkerText(Layer layer) {
     102                        super(tr("Show/Hide Text"), ImageProvider.get("dialogs", "showhide"));
     103                        putValue(SHORT_DESCRIPTION, tr("Toggle visible state of the marker text."));
     104                        putValue("help", "Dialog/LayerList/ShowHideText");
     105                        this.layer = layer;
     106                }
     107
     108                public void actionPerformed(ActionEvent e) {
     109                        Layer l = layer == null ? (Layer)instance.getSelectedValue() : layer;
     110                        String current = Main.pref.get("marker.show "+l.name,"show");
     111                        Main.pref.put("marker.show "+l.name, current.equalsIgnoreCase("show") ? "hide" : "show");
    93112                        Main.map.mapView.repaint();
    94113                        instance.repaint();
  • src/org/openstreetmap/josm/io/RawGpsReader.java

    r189 r200  
    88import java.util.ArrayList;
    99import java.util.Collection;
     10import java.util.HashMap;
    1011import java.util.LinkedList;
    1112import java.util.Stack;
    1213
    1314import org.openstreetmap.josm.data.coor.LatLon;
    14 import org.openstreetmap.josm.gui.layer.MarkerLayer.Marker;
    1515import org.openstreetmap.josm.gui.layer.RawGpsLayer.GpsPoint;
     16import org.openstreetmap.josm.gui.layer.markerlayer.Marker;
    1617import org.xml.sax.Attributes;
    1718import org.xml.sax.SAXException;
     
    4344                private Collection<GpsPoint> current = new LinkedList<GpsPoint>();
    4445                private LatLon currentLatLon;
    45                 private String currentTime = "";
    46                 private String currentName = "";
     46                private HashMap<String, String> currentTagValues = new HashMap<String, String>();
    4747                private Stack<String> tags = new Stack<String>();
    4848
     
    5050                        if (qName.equals("wpt") || qName.equals("trkpt")) {
    5151                                try {
    52                         double lat = Double.parseDouble(atts.getValue("lat"));
    53                         double lon = Double.parseDouble(atts.getValue("lon"));
    54                                 if (Math.abs(lat) > 90)
    55                                         throw new SAXException(tr("Data error: lat value \"{0}\" is out of bound.", lat));
    56                                 if (Math.abs(lon) > 180)
    57                                         throw new SAXException(tr("Data error: lon value \"{0}\" is out of bound.", lon));
    58                         currentLatLon = new LatLon(lat, lon);
    59                 } catch (NumberFormatException e) {
    60                         e.printStackTrace();
    61                         throw new SAXException(e);
    62                 }
    63                 currentTime = "";
    64                 currentName = "";
     52                                        double lat = Double.parseDouble(atts.getValue("lat"));
     53                                        double lon = Double.parseDouble(atts.getValue("lon"));
     54                                        if (Math.abs(lat) > 90)
     55                                                throw new SAXException(tr("Data error: lat value \"{0}\" is out of bound.", lat));
     56                                        if (Math.abs(lon) > 180)
     57                                                throw new SAXException(tr("Data error: lon value \"{0}\" is out of bound.", lon));
     58                                        currentLatLon = new LatLon(lat, lon);
     59                                } catch (NumberFormatException e) {
     60                                        e.printStackTrace();
     61                                        throw new SAXException(e);
     62                                }
     63                                currentTagValues.clear();
    6564                        }
    6665                        tags.push(qName);
     
    6968                @Override public void characters(char[] ch, int start, int length) {
    7069                        String peek = tags.peek();
    71                         if (peek.equals("time") || peek.equals("name")) {
     70                        if (peek.equals("time") || peek.equals("name") || peek.equals("link") || peek.equals("symbol")) {
    7271                                String tag = tags.pop();
    7372                                if (tags.empty() || (!tags.peek().equals("wpt") && !tags.peek().equals("trkpt"))) {
     
    7675                                }
    7776                                String contents = new String(ch, start, length);
    78                                 if (peek.equals("time")) currentTime += contents; else currentName += contents;
     77                                String oldContents = currentTagValues.get(peek);
     78                                if (oldContents == null) {
     79                                        currentTagValues.put(peek, contents);
     80                                } else {
     81                                        currentTagValues.put(peek, oldContents + contents);     
     82                                }
    7983                                tags.push(tag);
    8084                        }
     
    8387                @Override public void endElement(String namespaceURI, String localName, String qName) {
    8488                        if (qName.equals("trkpt")) {
    85                                 current.add(new GpsPoint(currentLatLon, currentTime));
    86                                 currentTime = "";
    87                                 currentName = "";
     89                                current.add(new GpsPoint(currentLatLon, currentTagValues.get("time")));
     90                                currentTagValues.clear();
    8891                        } else if (qName.equals("wpt")) {
    89                                 markerData.add(new Marker(currentLatLon, currentName, null));
    90                                 currentTime = "";
    91                                 currentName = "";
     92                                markerData.add(Marker.createMarker(currentLatLon, currentTagValues));
     93                                currentTagValues.clear();
    9294                        } else if (qName.equals("trkseg") || qName.equals("trk") || qName.equals("gpx")) {
    9395                                newTrack();
    94                                 currentTime = "";
    95                                 currentName = "";
     96                                currentTagValues.clear();
    9697                        }
    9798                        tags.pop();
    98         }
     99                }
    99100
    100101                private void newTrack() {
  • src/org/openstreetmap/josm/tools/ImageProvider.java

    r159 r200  
    5252         */
    5353        public static ImageIcon get(String subdir, String name) {
    54                 if (subdir != "")
     54                ImageIcon icon = getIfAvailable(subdir, name);
     55                if (icon == null) {
     56                        String ext = name.indexOf('.') != -1 ? "" : ".png";
     57                        throw new NullPointerException("/images/"+subdir+name+ext+" not found");
     58                }
     59                return icon;
     60        }
     61
     62        /**
     63         * Like {@link #get(String)}, but does not throw and return <code>null</code>
     64         * in case of nothing is found. Use this, if the image to retrieve is optional.
     65         */
     66        public static ImageIcon getIfAvailable(String subdir, String name) {
     67                if (name == null)
     68                        return null;
     69                if (subdir == null || subdir != "")
    5570                        subdir += "/";
    5671                String ext = name.indexOf('.') != -1 ? "" : ".png";
  • src/org/openstreetmap/josm/tools/OpenBrowser.java

    r149 r200  
    22
    33import java.io.IOException;
     4import java.net.MalformedURLException;
     5import java.net.URL;
     6
     7import javax.swing.JApplet;
     8
     9import org.openstreetmap.josm.Main;
    410
    511/**
     
    1319         */
    1420        public static String displayUrl(String url) {
     21                if (Main.applet) {
     22                        try {
     23                                JApplet applet = (JApplet) Main.parent;
     24                                applet.getAppletContext().showDocument(new URL(url));
     25                                return null;
     26                        } catch (MalformedURLException mue) {
     27                                return mue.getMessage();
     28                        }
     29                }
     30
    1531                String os = System.getProperty("os.name");
    1632                if (os == null)
     
    3753        private static void linux(String url) throws IOException {
    3854                try {
    39                 Runtime.getRuntime().exec("gnome-open " + url);
    40         } catch (IOException e) {
    41                 Runtime.getRuntime().exec("kfmclient openURL " + url);
    42         }
     55                        Runtime.getRuntime().exec("gnome-open " + url);
     56                } catch (IOException e) {
     57                        Runtime.getRuntime().exec("kfmclient openURL " + url);
     58                }
    4359        }
    4460
Note: See TracChangeset for help on using the changeset viewer.