source: josm/trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/WebMarker.java@ 5684

Last change on this file since 5684 was 5684, checked in by bastiK, 11 years ago

add session support for marker layers (see #4029)

The data is exported to a separate GPX file that contains one waypoint for each marker.
This is not very elegant, because most of the time, all the info is already contained in the original GPX File.
However, when dealing with audio markers, they can be synchronized, or additional markers are added
at certain playback positions. This info must be retained.
Another complication is, that two or more MarkerLayers can be merged to one.

All these problems are avoided by explicitly exporting the markers to a separate file (as done in this commit).

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.gui.layer.markerlayer;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.event.ActionEvent;
7import java.net.URL;
8import java.util.Collections;
9
10import javax.swing.JOptionPane;
11
12import org.openstreetmap.josm.Main;
13import org.openstreetmap.josm.data.coor.LatLon;
14import org.openstreetmap.josm.data.gpx.GpxConstants;
15import org.openstreetmap.josm.data.gpx.GpxLink;
16import org.openstreetmap.josm.data.gpx.WayPoint;
17import org.openstreetmap.josm.tools.OpenBrowser;
18
19/**
20 * Marker class with Web URL activation.
21 *
22 * @author Frederik Ramm <frederik@remote.org>
23 *
24 */
25public class WebMarker extends ButtonMarker {
26
27 public final URL webUrl;
28
29 public WebMarker(LatLon ll, URL webUrl, MarkerLayer parentLayer, double time, double offset) {
30 super(ll, "web.png", parentLayer, time, offset);
31 this.webUrl = webUrl;
32 }
33
34 @Override public void actionPerformed(ActionEvent ev) {
35 String error = OpenBrowser.displayUrl(webUrl.toString());
36 if (error != null) {
37 JOptionPane.showMessageDialog(Main.parent,
38 "<html><b>" +
39 tr("There was an error while trying to display the URL for this marker") +
40 "</b><br>" + tr("(URL was: ") + webUrl.toString() + ")" + "<br>" + error,
41 tr("Error displaying URL"), JOptionPane.ERROR_MESSAGE);
42 }
43 }
44
45 @Override
46 public WayPoint convertToWayPoint() {
47 WayPoint wpt = super.convertToWayPoint();
48 GpxLink link = new GpxLink(webUrl.toString());
49 link.type = "web";
50 wpt.attr.put(GpxConstants.META_LINKS, Collections.singleton(link));
51 return wpt;
52 }
53}
Note: See TracBrowser for help on using the repository browser.