Ignore:
Timestamp:
2008-08-11T00:23:12+02:00 (16 years ago)
Author:
stoecker
Message:

fix exception - closes #1327

Location:
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java

    r627 r762  
    302302                AudioMarker newAudioMarker = AudioMarker.create(Main.proj.eastNorth2latlon(en),
    303303                        AudioMarker.inventName(offset), AudioPlayer.url().toString(), this, time, offset);
    304                
     304
    305305                // insert it at the right place in a copy the collection
    306306                Collection<Marker> newData = new ArrayList<Marker>();
    307                 am = null;
     307                am = null;
     308                AudioMarker ret = newAudioMarker; // save to have return value
    308309                for (Marker m : data) {
    309310                        if (m.getClass() == AudioMarker.class) {
     
    317318                        newData.add(m);
    318319                }
     320
    319321                if (newAudioMarker != null) {
    320322                        if (am != null)
    321                                 newAudioMarker.adjustOffset(am.syncOffset()); // i.e. same as predecessor                               
     323                                newAudioMarker.adjustOffset(am.syncOffset()); // i.e. same as predecessor
    322324                        newData.add(newAudioMarker); // insert at end
    323325                }
    324                
     326
    325327                // replace the collection
    326328                data.clear();
    327329                data.addAll(newData);
    328                 return newAudioMarker;
     330                return ret;
    329331        }
    330332       
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java

    r627 r762  
    220220         */
    221221        public void synchronize(EastNorth en) {
     222                AudioMarker recent = AudioMarker.recentlyPlayedMarker();
     223                if(recent == null)
     224                        return;
    222225                /* First, see if we dropped onto an existing audio marker in the layer being played */
    223226                Point startPoint = Main.map.mapView.getPoint(en);
    224                 AudioMarker ca = null;
    225                 AudioMarker recent = AudioMarker.recentlyPlayedMarker();               
    226                 if (recent != null || recent.parentLayer != null) {
     227                AudioMarker ca = null;
     228                if (recent.parentLayer != null) {
    227229                        double closestAudioMarkerDistanceSquared = 1.0E100;
    228                         for (Marker m : AudioMarker.recentlyPlayedMarker().parentLayer.data) {
     230                        for (Marker m : recent.parentLayer.data) {
    229231                                if (m instanceof AudioMarker) {
    230232                                        double distanceSquared = m.eastNorth.distanceSq(en);
     
    239241                /* We found the closest marker: did we actually hit it? */
    240242                if (ca != null && ! ca.containsPoint(startPoint)) ca = null;
    241                
     243
    242244                /* If we didn't hit an audio marker, we need to create one at the nearest point on the track */
    243                 if (ca == null && recent != null) {
    244                         /* work out EastNorth equivalent of 50 (default) pixels tolerance */ 
     245                if (ca == null) {
     246                        /* work out EastNorth equivalent of 50 (default) pixels tolerance */
    245247                        Point p = Main.map.mapView.getPoint(en);
    246248                        EastNorth enPlus25px = Main.map.mapView.getEastNorth(p.x+dropTolerance, p.y);
     
    255257
    256258                /* Actually do the synchronization */
    257                 if (recent.parentLayer.synchronizeAudioMarkers(ca)) {
    258                         JOptionPane.showMessageDialog(Main.parent, tr("Audio synchronized at point ") + ca.text);
     259                if(ca == null)
     260                {
     261                        JOptionPane.showMessageDialog(Main.parent,tr("Unable to create new Audio marker."));
     262                        endDrag(true);
     263                }
     264                else if (recent.parentLayer.synchronizeAudioMarkers(ca)) {
     265                        JOptionPane.showMessageDialog(Main.parent, tr("Audio synchronized at point {0}.", ca.text));
    259266                        eastNorth = ca.eastNorth;
    260267                        endDrag(false);
Note: See TracChangeset for help on using the changeset viewer.