Changeset 547 in josm for trunk/src


Ignore:
Timestamp:
2008-02-18T18:27:12+01:00 (16 years ago)
Author:
david
Message:

much improved audio handling: threaded audio, controls, sync with waypoints

Location:
trunk/src/org/openstreetmap/josm
Files:
7 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MainMenu.java

    r529 r547  
    4141import org.openstreetmap.josm.actions.UnselectAllAction;
    4242import org.openstreetmap.josm.actions.UploadAction;
     43import org.openstreetmap.josm.actions.audio.AudioBackAction;
     44import org.openstreetmap.josm.actions.audio.AudioFwdAction;
     45import org.openstreetmap.josm.actions.audio.AudioNextAction;
     46import org.openstreetmap.josm.actions.audio.AudioPlayPauseAction;
     47import org.openstreetmap.josm.actions.audio.AudioPrevAction;
    4348import org.openstreetmap.josm.actions.search.SearchAction;
    4449import org.openstreetmap.josm.data.DataSetChecker;
     
    8792        public final JosmAction joinNodeWay = new JoinNodeWayAction();
    8893
     94        /* Audio menu */
     95        public final JosmAction audioPlayPause = new AudioPlayPauseAction();
     96        public final JosmAction audioNext = new AudioNextAction();
     97        public final JosmAction audioPrev = new AudioPrevAction();
     98        public final JosmAction audioFwd = new AudioFwdAction();
     99        public final JosmAction audioBack = new AudioBackAction();
     100
    89101        /* Help menu */
    90102        public final HelpAction help = new HelpAction();
     
    95107        public final JMenu viewMenu = new JMenu(tr("View"));
    96108        public final JMenu toolsMenu = new JMenu(tr("Tools"));
     109        public final JMenu audioMenu = new JMenu(tr("Audio"));
    97110        public final JMenu presetsMenu = new JMenu(tr("Presets"));
    98111        public final JMenu helpMenu = new JMenu(tr("Help"));
     
    193206                add(toolsMenu);
    194207
     208                if (! Main.pref.getBoolean("audio.menuinvisible")) {
     209                        audioMenu.setMnemonic('A');
     210                        current = audioMenu.add(audioPlayPause);
     211                        current.setAccelerator(audioPlayPause.shortCut);
     212                        current = audioMenu.add(audioNext);
     213                        current.setAccelerator(audioNext.shortCut);
     214                        current = audioMenu.add(audioPrev);
     215                        current.setAccelerator(audioPrev.shortCut);
     216                        current = audioMenu.add(audioFwd);
     217                        current.setAccelerator(audioFwd.shortCut);
     218                        current = audioMenu.add(audioBack);
     219                        current.setAccelerator(audioBack.shortCut);
     220                        add(audioMenu);
     221                }
     222
    195223                add(presetsMenu);
    196224                presetsMenu.setMnemonic('P');
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r512 r547  
    5757import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
    5858import org.openstreetmap.josm.gui.dialogs.LayerListPopup;
     59import org.openstreetmap.josm.gui.layer.markerlayer.Marker;
     60import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
    5961import org.openstreetmap.josm.tools.ColorHelper;
    6062import org.openstreetmap.josm.tools.DontShowAgainInfo;
     
    135137                });
    136138
     139                JMenuItem markersFromNamedTrackpoints = new JMenuItem(tr("Markers From Named Points"), ImageProvider.get("addmarkers"));
     140                markersFromNamedTrackpoints.addActionListener(new ActionListener() {
     141                        public void actionPerformed(ActionEvent e) {
     142/*
     143                                public Collection<GpxTrack> tracks = new LinkedList<GpxTrack>();
     144                                public Collection<Collection<WayPoint>> trackSegs
     145                                = new LinkedList<Collection<WayPoint>>();
     146                                */
     147                                GpxData namedTrackPoints = new GpxData();
     148                                for (GpxTrack track : data.tracks)
     149                                        for (Collection<WayPoint> seg : track.trackSegs)
     150                                                for (WayPoint point : seg)
     151                                                        if (point.attr.containsKey("name") || point.attr.containsKey("desc"))
     152                                                                namedTrackPoints.waypoints.add(point);
     153
     154                    MarkerLayer ml = new MarkerLayer(namedTrackPoints, tr("Named Trackpoints from {0}", name), associatedFile);
     155                    if (ml.data.size() > 0) {
     156                        Main.main.addLayer(ml);
     157                    }
     158                        }
     159                });
     160
    137161                JMenuItem tagimage = new JMenuItem(tr("Import images"), ImageProvider.get("tagimages"));
    138162                tagimage.addActionListener(new ActionListener() {
     
    192216                                line,
    193217                                tagimage,
     218                                markersFromNamedTrackpoints,
    194219                                new JMenuItem(new ConvertToDataLayerAction()),
    195220                                new JSeparator(),
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/AudioMarker.java

    r298 r547  
    1717import org.openstreetmap.josm.Main;
    1818import org.openstreetmap.josm.data.coor.LatLon;
     19import org.openstreetmap.josm.tools.AudioPlayer;
    1920
    2021/**
     
    2728
    2829        private URL audioUrl;
     30        private double syncOffset;
     31        private static AudioMarker recentlyPlayedMarker = null;
    2932
    3033        /**
     
    3235         * one or return <code>null</code>.
    3336         */
    34         public static AudioMarker create(LatLon ll, String url) {
     37        public static AudioMarker create(LatLon ll, String text, String url, double offset) {
    3538                try {
    36                         return new AudioMarker(ll, new URL(url));
     39                        return new AudioMarker(ll, text, new URL(url), offset);
    3740                } catch (Exception ex) {
    3841                        return null;
     
    4043        }
    4144
    42         private AudioMarker(LatLon ll, URL audioUrl) {
    43                 super(ll, "speech.png");
     45        private AudioMarker(LatLon ll, String text, URL audioUrl, double offset) {
     46                super(ll, text, "speech.png", offset);
    4447                this.audioUrl = audioUrl;
     48                this.syncOffset = 0.0;
    4549        }
    4650
    4751        @Override public void actionPerformed(ActionEvent ev) {
    48                 AudioInputStream audioInputStream = null;
    49                 try {
    50                         audioInputStream = AudioSystem.getAudioInputStream(audioUrl);
    51                 } catch (Exception e) {
    52                         audioMalfunction(e);
    53                         return;
    54                 }
    55                 AudioFormat     audioFormat = audioInputStream.getFormat();
    56                 SourceDataLine line = null;
    57                 DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);
    58                 try {
    59                         line = (SourceDataLine) AudioSystem.getLine(info);
    60                         line.open(audioFormat);
    61                 } catch (Exception e)   {
    62                         audioMalfunction(e);
    63                         return;
    64                 }
    65                 line.start();
    66 
    67                 int     nBytesRead = 0;
    68                 byte[]  abData = new byte[16384];
    69                 while (nBytesRead != -1) {
    70                         try {
    71                                 nBytesRead = audioInputStream.read(abData, 0, abData.length);
    72                         } catch (IOException e) {
    73                                 audioMalfunction(e);
    74                                 return;
    75                         }
    76                         if (nBytesRead >= 0) {
    77                                 /* int  nBytesWritten = */ line.write(abData, 0, nBytesRead);
    78                         }
    79                 }
    80                 line.drain();
    81                 line.close();
     52                play();
    8253        }
    8354
    84         void audioMalfunction(Exception ex) {
    85                 JOptionPane.showMessageDialog(Main.parent,
    86                                 "<html><b>" +
    87                                 tr("There was an error while trying to play the sound file for this marker.") +
    88                                 "</b><br>" + ex.getClass().getName() + ":<br><i>" + ex.getMessage() + "</i></html>",
    89                                 tr("Error playing sound"), JOptionPane.ERROR_MESSAGE);
     55        public static AudioMarker recentlyPlayedMarker() {
     56                return recentlyPlayedMarker;
     57        }
     58       
     59        public URL url() {
     60                return audioUrl;
     61        }
     62       
     63        /**
     64         * Starts playing the audio associated with the marker: used in response to pressing
     65         * the marker as well as indirectly
     66         *
     67         */
     68        public void play() {
     69                try {
     70                        AudioPlayer.play(audioUrl, offset + syncOffset);
     71                        recentlyPlayedMarker = this;
     72                } catch (Exception e) {
     73                        AudioPlayer.audioMalfunction(e);
     74                }
     75        }
     76       
     77        public void adjustOffset(double adjustment) {
     78                syncOffset = adjustment; // added to offset may turn out negative, but that's ok
    9079        }
    9180}
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ButtonMarker.java

    r298 r547  
    1414import org.openstreetmap.josm.data.coor.LatLon;
    1515import org.openstreetmap.josm.gui.MapView;
     16import org.openstreetmap.josm.gui.layer.Layer;
    1617
    1718/**
     
    2526        private Rectangle buttonRectangle;
    2627       
    27         public ButtonMarker(LatLon ll, String buttonImage) {
    28                 super(ll, null, buttonImage);
     28        public ButtonMarker(LatLon ll, String buttonImage, double offset) {
     29                super(ll, null, buttonImage, offset);
     30                buttonRectangle = new Rectangle(0, 0, symbol.getIconWidth(), symbol.getIconHeight());
     31        }
     32       
     33        public ButtonMarker(LatLon ll, String text, String buttonImage, double offset) {
     34                super(ll, text, buttonImage, offset);
    2935                buttonRectangle = new Rectangle(0, 0, symbol.getIconWidth(), symbol.getIconHeight());
    3036        }
     
    4248                Border b;
    4349                Point mousePosition = mv.getMousePosition();
    44                 if (mousePosition == null)
    45                         return; // mouse outside the whole window
    4650               
    47                 if (mousePressed) {
    48                         b = BorderFactory.createBevelBorder(BevelBorder.LOWERED);
    49                 } else {
    50                         b = BorderFactory.createBevelBorder(BevelBorder.RAISED);
     51                if (mousePosition != null) {
     52                        // mouse is inside the window
     53                        if (mousePressed) {
     54                                b = BorderFactory.createBevelBorder(BevelBorder.LOWERED);
     55                        } else {
     56                                b = BorderFactory.createBevelBorder(BevelBorder.RAISED);
     57                        }
     58                        Insets inset = b.getBorderInsets(mv);
     59                        Rectangle r = new Rectangle(buttonRectangle);
     60                        r.grow((inset.top+inset.bottom)/2, (inset.left+inset.right)/2);
     61                        b.paintBorder(mv, g, r.x, r.y, r.width, r.height);
    5162                }
    52                 Insets inset = b.getBorderInsets(mv);
    53                 Rectangle r = new Rectangle(buttonRectangle);
    54                 r.grow((inset.top+inset.bottom)/2, (inset.left+inset.right)/2);
    55                 b.paintBorder(mv, g, r.x, r.y, r.width, r.height);
     63                if ((text != null) && (show.equalsIgnoreCase("show")) && Main.pref.getBoolean("marker.buttonlabels"))
     64                        g.drawString(text, screen.x+4, screen.y+2);
    5665        }
    5766}
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ImageMarker.java

    r298 r547  
    3434        public URL imageUrl;
    3535
    36         public static ImageMarker create(LatLon ll, String url) {
     36        public static ImageMarker create(LatLon ll, String url, double offset) {
    3737                try {
    38                         return new ImageMarker(ll, new URL(url));
     38                        return new ImageMarker(ll, new URL(url), offset);
    3939                } catch (Exception ex) {
    4040                        return null;
     
    4242        }
    4343
    44         private ImageMarker(LatLon ll, URL imageUrl) {
    45                 super(ll, "photo.png");
     44        private ImageMarker(LatLon ll, URL imageUrl, double offset) {
     45                super(ll, "photo.png", offset);
    4646                this.imageUrl = imageUrl;
    4747        }
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java

    r541 r547  
    6464        public final String text;
    6565        public final Icon symbol;
     66        public double offset; /* time offset in seconds from the gpx point from which it was derived,
     67                                                         may be adjusted later to sync with other data, so not final */
    6668
    6769        /**
     
    7678                Marker.markerProducers.add(new MarkerProducers() {
    7779                        public Marker createMarker(WayPoint wpt, File relativePath) {
     80                                return createMarker(wpt, relativePath, 0.0);
     81                        }
     82                       
     83                        public Marker createMarker(WayPoint wpt, File relativePath, double offset) {
    7884                                String uri = null;
    7985                                // cheapest way to check whether "link" object exists and is a non-empty
     
    9096                    uri = new File(relativePath, uri).toURI().toString();
    9197
    92                 if (uri == null) {
    93                     String name_desc = "";
    94                     if (wpt.attr.containsKey("name")) {
    95                         name_desc = wpt.getString("name");
    96                     } else if (wpt.attr.containsKey("desc")) {
    97                         name_desc = wpt.getString("desc");
    98                     }
    99                     return new Marker(wpt.latlon, name_desc, wpt.getString("symbol"));
     98                String name_desc = "";
     99                if (wpt.attr.containsKey("name")) {
     100                        name_desc = wpt.getString("name");
     101                } else if (wpt.attr.containsKey("desc")) {
     102                    name_desc = wpt.getString("desc");
    100103                }
    101 
    102                 if (uri.endsWith(".wav"))
    103                     return AudioMarker.create(wpt.latlon, uri);
     104               
     105                if (uri == null)
     106                    return new Marker(wpt.latlon, name_desc, wpt.getString("symbol"), offset);
     107                else if (uri.endsWith(".wav"))
     108                    return AudioMarker.create(wpt.latlon, name_desc, uri, offset);
    104109                else if (uri.endsWith(".png") || uri.endsWith(".jpg") || uri.endsWith(".jpeg") || uri.endsWith(".gif"))
    105                                         return ImageMarker.create(wpt.latlon, uri);
     110                                        return ImageMarker.create(wpt.latlon, uri, offset);
    106111                                else
    107                                         return WebMarker.create(wpt.latlon, uri);
     112                                        return WebMarker.create(wpt.latlon, uri, offset);
    108113                        }
    109114
     
    119124        }
    120125
    121         public Marker(LatLon ll, String text, String iconName) {
     126        public Marker(LatLon ll, String text, String iconName, double offset) {
    122127                eastNorth = Main.proj.latlon2eastNorth(ll);
    123128                this.text = text;
     129                this.offset = offset;
    124130                Icon symbol = ImageProvider.getIfAvailable("markers",iconName);
    125131                if (symbol == null)
     
    177183         * @param relativePath An path to use for constructing relative URLs or
    178184         *        <code>null</code> for no relative URLs
     185         * @param offset double in seconds as the time offset of this marker from
     186         *                the GPX file from which it was derived (if any). 
    179187         * @return a new Marker object
    180188         */
    181         public static Marker createMarker(WayPoint wpt, File relativePath) {
     189        public static Marker createMarker(WayPoint wpt, File relativePath, double offset) {
    182190                for (MarkerProducers maker : Marker.markerProducers) {
    183                         Marker marker = maker.createMarker(wpt, relativePath);
     191                        Marker marker = maker.createMarker(wpt, relativePath, offset);
    184192                        if (marker != null)
    185193                                return marker;
     
    187195                return null;
    188196        }
     197       
     198        /**
     199         * Returns an AudioMarker derived from this Marker and the provided uri
     200         * Subclasses of specific marker types override this to return null as they can't
     201         * be turned into AudioMarkers. This includes AudioMarkers themselves, as they
     202         * already have audio. 
     203         *
     204         * @param uri uri of wave file
     205         * @return AudioMarker
     206         */
     207       
     208        public AudioMarker audioMarkerFromMarker(String uri) {
     209                AudioMarker audioMarker = AudioMarker.create(Main.proj.eastNorth2latlon(this.eastNorth), this.text, uri, this.offset);
     210                return audioMarker;
     211        }
    189212}
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java

    r444 r547  
    1616import java.util.ArrayList;
    1717import java.util.Collection;
     18import java.util.Iterator;
     19import java.util.Date;
     20import java.text.SimpleDateFormat;
     21import java.text.ParsePosition;
     22import java.text.ParseException;
     23import java.net.URL;
    1824
    1925import javax.swing.Icon;
    2026import javax.swing.JColorChooser;
     27import javax.swing.JFileChooser;
    2128import javax.swing.JMenuItem;
    2229import javax.swing.JOptionPane;
    2330import javax.swing.JSeparator;
    2431import javax.swing.SwingUtilities;
     32import javax.swing.filechooser.FileFilter;
    2533
    2634import org.openstreetmap.josm.Main;
     
    3341import org.openstreetmap.josm.gui.dialogs.LayerListPopup;
    3442import org.openstreetmap.josm.gui.layer.Layer;
     43import org.openstreetmap.josm.gui.layer.markerlayer.AudioMarker;
    3544import org.openstreetmap.josm.tools.ColorHelper;
    3645import org.openstreetmap.josm.tools.ImageProvider;
     46import org.openstreetmap.josm.tools.AudioPlayer;
    3747
    3848/**
     
    6070                this.associatedFile = associatedFile;
    6171                this.data = new ArrayList<Marker>();
    62                
     72                double offset = 0.0;
     73                Date firstDate = null;
     74
    6375                for (WayPoint wpt : indata.waypoints) {
    64             Marker m = Marker.createMarker(wpt, indata.storageFile);
     76                        /* calculate time differences in waypoints */
     77                        if (wpt.attr.containsKey("time")) {
     78                                SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); // ignore timezone, as it is all relative
     79                                Date d = f.parse(wpt.attr.get("time").toString(), new ParsePosition(0));
     80                                if (d == null /* failed to parse */) {
     81                                        offset = 0.0;
     82                                } else if (firstDate == null) {
     83                                        firstDate = d;
     84                                        offset = 0.0;
     85                                } else {
     86                                        offset = (d.getTime() - firstDate.getTime()) / 1000.0; /* ms => seconds */
     87                                }
     88                        }
     89                       
     90            Marker m = Marker.createMarker(wpt, indata.storageFile, offset);
    6591            if (m != null)
    6692                data.add(m);
     
    7399                                                if (e.getButton() != MouseEvent.BUTTON1)
    74100                                                        return;
     101                                                boolean mousePressedInButton = false;
     102                                                if (e.getPoint() != null) {
     103                                                        for (Marker mkr : data) {
     104                                                                if (mkr.containsPoint(e.getPoint())) {
     105                                                                        mousePressedInButton = true;
     106                                                                        break;
     107                                                                }
     108                                                        }
     109                                                }
     110                                                if (! mousePressedInButton)
     111                                                        return;
    75112                                                mousePressed  = true;
    76113                                                if (visible)
     
    78115                                        }
    79116                                        @Override public void mouseReleased(MouseEvent ev) {
    80                                                 if (ev.getButton() != MouseEvent.BUTTON1)
     117                                                if (ev.getButton() != MouseEvent.BUTTON1 || ! mousePressed)
    81118                                                        return;
    82119                                                mousePressed = false;
     
    116153                else
    117154                        g.setColor(Color.GRAY);
    118 
     155               
    119156                for (Marker mkr : data) {
    120157                        if (mousePos != null && mkr.containsPoint(mousePos)) {
     
    143180                for (Marker mkr : data)
    144181                        v.visit(mkr.eastNorth);
     182        }
     183
     184        public void applyAudio(File wavFile) {
     185                String uri = "file:".concat(wavFile.getAbsolutePath());
     186                Collection<Marker> markers = new ArrayList<Marker>();
     187            for (Marker mkr : data) {
     188                AudioMarker audioMarker = mkr.audioMarkerFromMarker(uri);
     189                if (audioMarker == null) {
     190                        markers.add(mkr);
     191                } else {
     192                    markers.add(audioMarker);
     193                }
     194            }
     195            data.clear();
     196            data.addAll(markers);
    145197        }
    146198
     
    171223                });
    172224
     225                JMenuItem applyaudio = new JMenuItem(tr("Apply Audio"), ImageProvider.get("applyaudio"));
     226                applyaudio.addActionListener(new ActionListener(){
     227                        public void actionPerformed(ActionEvent e) {
     228                                JFileChooser fc = new JFileChooser(Main.pref.get("tagimages.lastdirectory"));
     229                                fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
     230                                fc.setAcceptAllFileFilterUsed(false);
     231                                fc.setFileFilter(new FileFilter(){
     232                                        @Override public boolean accept(File f) {
     233                                                return f.isDirectory() || f.getName().toLowerCase().endsWith(".wav");
     234                                        }
     235                                        @Override public String getDescription() {
     236                                                return tr("Wave Audio files (*.wav)");
     237                                        }
     238                                });
     239                                fc.showOpenDialog(Main.parent);
     240                                File sel = fc.getSelectedFile();
     241                                if (sel == null)
     242                                        return;
     243                                applyAudio(sel);
     244                                Main.map.repaint();
     245                        }
     246                });
     247
     248                JMenuItem syncaudio = new JMenuItem(tr("Synchronize Audio"), ImageProvider.get("audio-sync"));
     249                syncaudio.addActionListener(new ActionListener(){
     250                        public void actionPerformed(ActionEvent e) {
     251                                adjustOffsetsOnAudioMarkers();
     252                        }
     253                });
     254
    173255                return new Component[] {
    174256                        new JMenuItem(new LayerListDialog.ShowHideLayerAction(this)),
     
    177259                        new JSeparator(),
    178260                        color,
     261                        new JSeparator(),
     262                        syncaudio,
     263                        applyaudio,
    179264                        new JMenuItem(new RenameLayerAction(associatedFile, this)),
    180265                        new JSeparator(),
     
    182267                };
    183268        }
     269
     270        private void adjustOffsetsOnAudioMarkers() {
     271                Marker startMarker = AudioMarker.recentlyPlayedMarker();
     272                if (startMarker != null && ! data.contains(startMarker)) {
     273                        // message?
     274                        startMarker = null;
     275                }
     276                if (startMarker == null) {
     277                        // find the first audioMarker in this layer
     278                        for (Marker m : data) {
     279                                if (m.getClass() == AudioMarker.class) {
     280                                        startMarker = m;
     281                                        break;
     282                                }
     283                        }
     284                }
     285                if (startMarker == null) {
     286                        // still no marker to work from - message?
     287                        return;
     288                }
     289                // apply adjustment to all subsequent audio markers in the layer
     290                double adjustment = AudioPlayer.position(); // in seconds
     291                boolean seenStart = false;
     292                URL url = ((AudioMarker)startMarker).url();
     293                for (Marker m : data) {
     294                        if (m == startMarker)
     295                                seenStart = true;
     296                        if (seenStart) {
     297                                AudioMarker ma = (AudioMarker) m; // it must be an AudioMarker
     298                                if (! ma.url().equals(url))
     299                                        break;
     300                                ma.adjustOffset(adjustment);
     301                        }
     302                }
     303        }
     304       
     305        public static void playAudio() {
     306                if (Main.map == null || Main.map.mapView == null)
     307                        return;
     308                for (Layer layer : Main.map.mapView.getAllLayers()) {
     309                        if (layer.getClass() == MarkerLayer.class) {
     310                                MarkerLayer markerLayer = (MarkerLayer) layer;
     311                                for (Marker marker : markerLayer.data) {
     312                                        if (marker.getClass() == AudioMarker.class) {
     313                                                ((AudioMarker)marker).play();
     314                                                break;
     315                                        }
     316                                }
     317                        }
     318                }
     319        }
     320
     321        public static void playNextMarker() {
     322                playAdjacentMarker(true);
     323        }
     324       
     325        public static void playPreviousMarker() {
     326                playAdjacentMarker(false);
     327        }
     328       
     329        private static void playAdjacentMarker(boolean next) {
     330                Marker startMarker = AudioMarker.recentlyPlayedMarker();
     331                if (startMarker == null) {
     332                        // message?
     333                        return;
     334                }
     335                Marker previousMarker = null;
     336                Marker targetMarker = null;
     337                boolean nextTime = false;
     338                if (Main.map == null || Main.map.mapView == null)
     339                        return;
     340                for (Layer layer : Main.map.mapView.getAllLayers()) {
     341                        if (layer.getClass() == MarkerLayer.class) {
     342                                MarkerLayer markerLayer = (MarkerLayer) layer;
     343                                for (Marker marker : markerLayer.data) {
     344                                        if (marker == startMarker) {
     345                                                if (next) {
     346                                                        nextTime = true;
     347                                                } else {
     348                                                        ((AudioMarker)previousMarker).play();
     349                                                        break;
     350                                                }
     351                                        } else if (nextTime) {
     352                                                ((AudioMarker)marker).play();
     353                                                return;
     354                                        }
     355                                        previousMarker = marker;
     356                                }
     357                        }
     358                }
     359        }
     360       
    184361}
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerProducers.java

    r444 r547  
    2727         * @return A Marker object, or <code>null</code>.
    2828         */
    29         public Marker createMarker(WayPoint wp, File relativePath);
     29        public Marker createMarker(WayPoint wp, File relativePath, double offset);
    3030}
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/WebMarker.java

    r298 r547  
    2323        public URL webUrl;
    2424
    25         public static WebMarker create (LatLon ll, String url) {
     25        public static WebMarker create (LatLon ll, String url, double offset) {
    2626                try {
    27                         return new WebMarker(ll, new URL(url));
     27                        return new WebMarker(ll, new URL(url), offset);
    2828                } catch (Exception ex) {
    2929                        return null;
     
    3131        }
    3232
    33         private WebMarker(LatLon ll, URL webUrl) {
    34                 super(ll, "web.png");
     33        private WebMarker(LatLon ll, URL webUrl, double offset) {
     34                super(ll, "web.png", offset);
    3535                this.webUrl = webUrl;
    3636        }
  • trunk/src/org/openstreetmap/josm/io/GpxReader.java

    r542 r547  
    238238                                        currentState = states.pop();
    239239                                        currentTrackSeg.add(currentWayPoint);
    240                                         String option = "marker.namedtrackpoints";
    241                                         if (Main.pref.hasKey(option) &&
    242                                                 Main.pref.getBoolean(option) &&
     240                                        if (Main.pref.getBoolean("marker.namedtrackpoints") &&
    243241                                                (currentWayPoint.attr.containsKey("name") ||
    244242                                                        currentWayPoint.attr.containsKey("desc")))
Note: See TracChangeset for help on using the changeset viewer.