Changeset 554 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2008-02-22T18:31:49+01:00 (17 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r553 r554 515 515 point.eastNorth.distance(prevPoint.eastNorth) > audioGapRadiansSquared)) 516 516 { 517 String markerName; 518 int wholeSeconds = (int)(offset + 0.5); 519 if (wholeSeconds < 60) 520 markerName = Integer.toString(wholeSeconds); 521 else if (wholeSeconds < 3600) 522 markerName = String.format("%d:%02d", wholeSeconds / 60, wholeSeconds % 60); 523 else 524 markerName = String.format("%d:%02d:%02d", wholeSeconds / 3600, (wholeSeconds % 3600)/60, wholeSeconds % 60); 525 AudioMarker am = AudioMarker.create(point.latlon, markerName, uri, ml, time, offset); 517 518 AudioMarker am = AudioMarker.create(point.latlon, 519 AudioMarker.inventName(offset), uri, ml, time, offset); 526 520 ml.data.add(am); 527 521 prevPoint = point; -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/AudioMarker.java
r553 r554 75 75 try { 76 76 // first enable tracing the audio along the track 77 if (Main.pref.getBoolean("marker.traceaudio" ) && parentLayer != null) {77 if (Main.pref.getBoolean("marker.traceaudio", true) && parentLayer != null) { 78 78 parentLayer.traceAudio(); 79 79 } … … 89 89 syncOffset = adjustment; // added to offset may turn out negative, but that's ok 90 90 } 91 92 public double syncOffset() { 93 return syncOffset; 94 } 95 96 public static String inventName (double offset) { 97 int wholeSeconds = (int)(offset + 0.5); 98 if (wholeSeconds < 60) 99 return Integer.toString(wholeSeconds); 100 else if (wholeSeconds < 3600) 101 return String.format("%d:%02d", wholeSeconds / 60, wholeSeconds % 60); 102 else 103 return String.format("%d:%02d:%02d", wholeSeconds / 3600, (wholeSeconds % 3600)/60, wholeSeconds % 60); 104 } 91 105 } -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
r553 r554 69 69 private Rectangle audioTracer = null; 70 70 private Icon audioTracerIcon = null; 71 private EastNorth audioTracerPosition = null;71 private EastNorth playheadPosition = null; 72 72 private static Timer timer = null; 73 73 private static double audioAnimationInterval = 0.0; // seconds 74 private static double p reviousTime = -1.0;74 private static double playheadTime = -1.0; 75 75 76 76 public MarkerLayer(GpxData indata, String name, File associatedFile, GpxLayer fromLayer) { … … 163 163 164 164 if (audioTracer != null) { 165 Point screen = Main.map.mapView.getPoint( audioTracerPosition);165 Point screen = Main.map.mapView.getPoint(playheadPosition); 166 166 audioTracer.setLocation(screen.x, screen.y); 167 167 audioTracerIcon.paintIcon(Main.map.mapView, g, screen.x, screen.y); … … 193 193 recentlyPlayedMarker.offset - 194 194 recentlyPlayedMarker.syncOffset; 195 if (Math.abs(audioTime- p reviousTime) < audioAnimationInterval)195 if (Math.abs(audioTime- playheadTime) < audioAnimationInterval) 196 196 return; 197 197 if (fromLayer == null) … … 220 220 if (w1 == null) 221 221 return; 222 audioTracerPosition = w2 == null ?222 playheadPosition = w2 == null ? 223 223 w1.eastNorth : 224 224 w1.eastNorth.interpolate(w2.eastNorth, … … 229 229 audioTracer = new Rectangle(0, 0, audioTracerIcon.getIconWidth(), audioTracerIcon.getIconHeight()); 230 230 } 231 p reviousTime = audioTime;231 playheadTime = audioTime; 232 232 Main.map.mapView.repaint(); 233 233 } … … 322 322 }); 323 323 324 return new Component[] { 325 new JMenuItem(new LayerListDialog.ShowHideLayerAction(this)), 326 new JMenuItem(new LayerListDialog.ShowHideMarkerText(this)), 327 new JMenuItem(new LayerListDialog.DeleteLayerAction(this)), 328 new JSeparator(), 329 color, 330 new JSeparator(), 331 syncaudio, 332 applyaudio, 333 new JMenuItem(new RenameLayerAction(associatedFile, this)), 334 new JSeparator(), 335 new JMenuItem(new LayerListPopup.InfoAction(this)) 336 }; 324 JMenuItem moveaudio = new JMenuItem(tr("Make Audio Marker At Play Head"), ImageProvider.get("addmarkers")); 325 moveaudio.addActionListener(new ActionListener(){ 326 public void actionPerformed(ActionEvent e) { 327 makeAudioMarkerAtPlayHead(); 328 } 329 }); 330 331 Collection<Component> components = new ArrayList<Component>(); 332 components.add(new JMenuItem(new LayerListDialog.ShowHideLayerAction(this))); 333 components.add(new JMenuItem(new LayerListDialog.ShowHideMarkerText(this))); 334 components.add(new JMenuItem(new LayerListDialog.DeleteLayerAction(this))); 335 components.add(new JSeparator()); 336 components.add(color); 337 components.add(new JSeparator()); 338 components.add(syncaudio); 339 components.add(applyaudio); 340 if (Main.pref.getBoolean("marker.traceaudio", true)) { 341 components.add (moveaudio); 342 } 343 components.add(new JMenuItem(new RenameLayerAction(associatedFile, this))); 344 components.add(new JSeparator()); 345 components.add(new JMenuItem(new LayerListPopup.InfoAction(this))); 346 return components.toArray(new Component[0]); 337 347 } 338 348 339 349 private void adjustOffsetsOnAudioMarkers() { 350 if (! AudioPlayer.paused()) { 351 JOptionPane.showMessageDialog(Main.parent,tr("You need to pause audio at the moment when you hear your synchronization cue.")); 352 return; 353 } 340 354 Marker startMarker = AudioMarker.recentlyPlayedMarker(); 355 boolean explicitMarker = true; 341 356 if (startMarker != null && ! data.contains(startMarker)) { 342 // message?357 explicitMarker = false; 343 358 startMarker = null; 344 359 } … … 354 369 if (startMarker == null) { 355 370 // still no marker to work from - message? 371 JOptionPane.showMessageDialog(Main.parent,tr("No audio marker found in the layer to synchronize with.")); 356 372 return; 357 373 } … … 365 381 if (seenStart) { 366 382 AudioMarker ma = (AudioMarker) m; // it must be an AudioMarker 367 if (! ma.url().equals(url)) 368 break; 369 ma.adjustOffset(adjustment); 370 } 371 } 383 if (ma.url().equals(url)) 384 ma.adjustOffset(adjustment); 385 } 386 } 387 388 JOptionPane.showMessageDialog(Main.parent, explicitMarker ? 389 tr("Audio synchronized with most recently played marker and subsequent ones (that have the same sound track).") : 390 tr("Audio synchronized with audio markers in the layer (that have the same sound track as the first one).")); 391 } 392 393 private void makeAudioMarkerAtPlayHead() { 394 if (! AudioPlayer.paused()) { 395 JOptionPane.showMessageDialog(Main.parent,tr("You need to pause audio at the point on the track where you want the marker.")); 396 return; 397 } 398 // find first audio marker to get absolute start time 399 double offset = 0.0; 400 AudioMarker am = null; 401 for (Marker m : data) { 402 if (m.getClass() == AudioMarker.class) { 403 am = (AudioMarker)m; 404 offset = playheadTime - am.time; 405 break; 406 } 407 } 408 if (am == null) { 409 JOptionPane.showMessageDialog(Main.parent,tr("No existing audio markers in this layer to offset from.")); 410 return; 411 } 412 413 // make our new marker 414 AudioMarker newAudioMarker = AudioMarker.create(Main.proj.eastNorth2latlon(playheadPosition), 415 AudioMarker.inventName(offset), AudioPlayer.url().toString(), this, playheadTime, offset); 416 417 // insert it at the right place in a copy the collection 418 Collection<Marker> newData = new ArrayList<Marker>(); 419 am = null; 420 for (Marker m : data) { 421 if (m.getClass() == AudioMarker.class) { 422 am = (AudioMarker) m; 423 if (newAudioMarker != null && offset < am.offset) { 424 newAudioMarker.adjustOffset(am.syncOffset()); // i.e. same as predecessor 425 newData.add(newAudioMarker); 426 newAudioMarker = null; 427 } 428 } 429 newData.add(m); 430 } 431 if (newAudioMarker != null) { 432 if (am != null) 433 newAudioMarker.adjustOffset(am.syncOffset()); // i.e. same as predecessor 434 newData.add(newAudioMarker); // insert at end 435 newAudioMarker = null; 436 } 437 438 // replace the collection 439 data.clear(); 440 data.addAll(newData); 441 Main.map.mapView.repaint(); 372 442 } 373 443 -
trunk/src/org/openstreetmap/josm/gui/preferences/AudioPreference.java
r553 r554 7 7 import java.awt.event.ActionListener; 8 8 9 import javax.swing.Box; 9 10 import javax.swing.JCheckBox; 10 11 import javax.swing.JLabel; … … 61 62 } 62 63 }); 63 markerAudioTraceVisible.setSelected(Main.pref.getBoolean("marker.traceaudio" ));64 markerAudioTraceVisible.setSelected(Main.pref.getBoolean("marker.traceaudio", true)); 64 65 markerAudioTraceVisible.setToolTipText(tr("Display a moving icon representing the point on the synchronized track where the audio currently playing was recorded.")); 65 66 gui.audio.add(markerAudioTraceVisible, GBC.eol().insets(0,0,0,0)); … … 85 86 } 86 87 }); 87 markersNamedTrackpoints.setSelected(Main.pref.getBoolean("marker s.namedtrackpoints"));88 markersNamedTrackpoints.setSelected(Main.pref.getBoolean("marker.namedtrackpoints")); 88 89 markersNamedTrackpoints.setToolTipText(tr("Automatically create audio markers from trackpoints (rather than explicit waypoints) with names or descriptions.")); 89 90 gui.audio.add(markersNamedTrackpoints, GBC.eol().insets(0,0,0,0)); … … 108 109 gui.audio.add(new JLabel(tr("Lead-in time (seconds)")), GBC.std()); 109 110 gui.audio.add(audioLeadIn, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5)); 111 112 gui.audio.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL)); 110 113 } 111 114 … … 114 117 Main.pref.put("marker.traceaudio", markerAudioTraceVisible.isSelected()); 115 118 Main.pref.put("marker.buttonlabels", markerButtonLabels.isSelected()); 116 Main.pref.put("marker s.namedtrackpoints", markersNamedTrackpoints.isSelected());119 Main.pref.put("marker.namedtrackpoints", markersNamedTrackpoints.isSelected()); 117 120 Main.pref.put("marker.audiosampleminsecs", audioSampleMinSecs.getText()); 118 121 Main.pref.put("marker.audiosampleminmetres", audioSampleMinMetres.getText()); -
trunk/src/org/openstreetmap/josm/io/GpxReader.java
r553 r554 227 227 break; 228 228 case wpt: 229 if (qName.equals("ele") || qName.equals(" time") || qName.equals("desc")229 if (qName.equals("ele") || qName.equals("desc") 230 230 || qName.equals("magvar") || qName.equals("geoidheight") 231 || qName.equals("name") || qName.equals("time")232 || qName.equals(" sym") || qName.equals("cmt") || qName.equals("type")) {231 || qName.equals("name") || qName.equals("sym") 232 || qName.equals("cmt") || qName.equals("type")) { 233 233 currentWayPoint.attr.put(qName, accumulator.toString()); 234 } else if (qName.equals("time")) { 235 currentWayPoint.attr.put(qName, accumulator.toString()); 236 currentWayPoint.setTime(); 234 237 } else if (qName.equals("rtept")) { 235 238 currentState = states.pop(); 236 currentWayPoint.setTime();237 239 currentRoute.routePoints.add(currentWayPoint); 238 240 } else if (qName.equals("trkpt")) { 239 241 currentState = states.pop(); 240 currentWayPoint.setTime();241 242 currentTrackSeg.add(currentWayPoint); 242 243 if (Main.pref.getBoolean("marker.namedtrackpoints") && … … 248 249 } else if (qName.equals("wpt")) { 249 250 currentState = states.pop(); 250 currentWayPoint.setTime();251 251 currentData.waypoints.add(currentWayPoint); 252 252 }
Note:
See TracChangeset
for help on using the changeset viewer.