Changeset 762 in josm
- Timestamp:
- 2008-08-11T00:23:12+02:00 (16 years ago)
- 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 302 302 AudioMarker newAudioMarker = AudioMarker.create(Main.proj.eastNorth2latlon(en), 303 303 AudioMarker.inventName(offset), AudioPlayer.url().toString(), this, time, offset); 304 304 305 305 // insert it at the right place in a copy the collection 306 306 Collection<Marker> newData = new ArrayList<Marker>(); 307 am = null; 307 am = null; 308 AudioMarker ret = newAudioMarker; // save to have return value 308 309 for (Marker m : data) { 309 310 if (m.getClass() == AudioMarker.class) { … … 317 318 newData.add(m); 318 319 } 320 319 321 if (newAudioMarker != null) { 320 322 if (am != null) 321 newAudioMarker.adjustOffset(am.syncOffset()); // i.e. same as predecessor 323 newAudioMarker.adjustOffset(am.syncOffset()); // i.e. same as predecessor 322 324 newData.add(newAudioMarker); // insert at end 323 325 } 324 326 325 327 // replace the collection 326 328 data.clear(); 327 329 data.addAll(newData); 328 return newAudioMarker;330 return ret; 329 331 } 330 332 -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java
r627 r762 220 220 */ 221 221 public void synchronize(EastNorth en) { 222 AudioMarker recent = AudioMarker.recentlyPlayedMarker(); 223 if(recent == null) 224 return; 222 225 /* First, see if we dropped onto an existing audio marker in the layer being played */ 223 226 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) { 227 229 double closestAudioMarkerDistanceSquared = 1.0E100; 228 for (Marker m : AudioMarker.recentlyPlayedMarker().parentLayer.data) {230 for (Marker m : recent.parentLayer.data) { 229 231 if (m instanceof AudioMarker) { 230 232 double distanceSquared = m.eastNorth.distanceSq(en); … … 239 241 /* We found the closest marker: did we actually hit it? */ 240 242 if (ca != null && ! ca.containsPoint(startPoint)) ca = null; 241 243 242 244 /* 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 */ 245 247 Point p = Main.map.mapView.getPoint(en); 246 248 EastNorth enPlus25px = Main.map.mapView.getEastNorth(p.x+dropTolerance, p.y); … … 255 257 256 258 /* 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)); 259 266 eastNorth = ca.eastNorth; 260 267 endDrag(false);
Note:
See TracChangeset
for help on using the changeset viewer.