Changeset 1865 in josm for trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
- Timestamp:
- 2009-07-28T19:48:39+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
r1724 r1865 34 34 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 35 35 import org.openstreetmap.josm.gui.MapView; 36 import org.openstreetmap.josm.gui.OptionPaneUtil; 36 37 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 37 38 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; … … 90 91 if (wpt_has_link) { 91 92 for (GpxLink oneLink : (Collection<GpxLink>) wpt.attr.get(GpxData.META_LINKS)) { 92 if (!oneLink.uri.equals(lastLinkedFile))firstTime = time; 93 if (!oneLink.uri.equals(lastLinkedFile)) { 94 firstTime = time; 95 } 93 96 lastLinkedFile = oneLink.uri; 94 97 break; … … 96 99 } 97 100 Marker m = Marker.createMarker(wpt, indata.storageFile, this, time, time - firstTime); 98 if (m != null) 101 if (m != null) { 99 102 data.add(m); 103 } 100 104 } 101 105 … … 118 122 return; 119 123 mousePressed = true; 120 if (visible) 124 if (visible) { 121 125 Main.map.mapView.repaint(); 126 } 122 127 } 123 128 @Override public void mouseReleased(MouseEvent ev) { … … 129 134 if (ev.getPoint() != null) { 130 135 for (Marker mkr : data) { 131 if (mkr.containsPoint(ev.getPoint())) 136 if (mkr.containsPoint(ev.getPoint())) { 132 137 mkr.actionPerformed(new ActionEvent(this, 0, null)); 138 } 133 139 } 134 140 } … … 183 189 184 190 @Override public void visitBoundingBox(BoundingXYVisitor v) { 185 for (Marker mkr : data) 191 for (Marker mkr : data) { 186 192 v.visit(mkr.getEastNorth()); 193 } 187 194 } 188 195 … … 198 205 JColorChooser c = new JColorChooser(getColor(name)); 199 206 Object[] options = new Object[]{tr("OK"), tr("Cancel"), tr("Default")}; 200 int answer = JOptionPane.showOptionDialog(Main.parent, c, tr("Choose a color"), JOptionPane.OK_CANCEL_OPTION, 201 JOptionPane.PLAIN_MESSAGE, null, options, options[0]); 207 int answer = OptionPaneUtil.showOptionDialog( 208 Main.parent, 209 c, 210 tr("Choose a color"), 211 JOptionPane.OK_CANCEL_OPTION, 212 JOptionPane.PLAIN_MESSAGE, 213 options, 214 options[0] 215 ); 202 216 switch (answer) { 203 217 case 0: … … 219 233 public void actionPerformed(ActionEvent e) { 220 234 if (! AudioPlayer.paused()) { 221 JOptionPane.showMessageDialog(Main.parent,tr("You need to pause audio at the moment when you hear your synchronization cue.")); 235 OptionPaneUtil.showMessageDialog( 236 Main.parent, 237 tr("You need to pause audio at the moment when you hear your synchronization cue."), 238 tr("Warning"), 239 JOptionPane.WARNING_MESSAGE 240 ); 222 241 return; 223 242 } 224 243 AudioMarker recent = AudioMarker.recentlyPlayedMarker(); 225 244 if (synchronizeAudioMarkers(recent)) { 226 JOptionPane.showMessageDialog(Main.parent, tr("Audio synchronized at point {0}.", recent.text)); 245 OptionPaneUtil.showMessageDialog( 246 Main.parent, 247 tr("Audio synchronized at point {0}.", recent.text), 248 tr("Information"), 249 JOptionPane.INFORMATION_MESSAGE 250 ); 227 251 } else { 228 JOptionPane.showMessageDialog(Main.parent,tr("Unable to synchronize in layer being played.")); 252 OptionPaneUtil.showMessageDialog( 253 Main.parent, 254 tr("Unable to synchronize in layer being played."), 255 tr("Error"), 256 JOptionPane.ERROR_MESSAGE 257 ); 229 258 } 230 259 } … … 236 265 public void actionPerformed(ActionEvent e) { 237 266 if (! AudioPlayer.paused()) { 238 JOptionPane.showMessageDialog(Main.parent,tr("You need to have paused audio at the point on the track where you want the marker.")); 267 OptionPaneUtil.showMessageDialog( 268 Main.parent, 269 tr("You need to have paused audio at the point on the track where you want the marker."), 270 tr("Warning"), 271 JOptionPane.WARNING_MESSAGE 272 ); 239 273 return; 240 274 } … … 285 319 URL url = startMarker.url(); 286 320 for (Marker m : data) { 287 if (m == startMarker) 321 if (m == startMarker) { 288 322 seenStart = true; 323 } 289 324 if (seenStart) { 290 325 AudioMarker ma = (AudioMarker) m; // it must be an AudioMarker 291 if (ma.url().equals(url)) 326 if (ma.url().equals(url)) { 292 327 ma.adjustOffset(adjustment); 328 } 293 329 } 294 330 } … … 308 344 } 309 345 if (am == null) { 310 JOptionPane.showMessageDialog(Main.parent,tr("No existing audio markers in this layer to offset from.")); 346 OptionPaneUtil.showMessageDialog( 347 Main.parent, 348 tr("No existing audio markers in this layer to offset from."), 349 tr("Error"), 350 JOptionPane.ERROR_MESSAGE 351 ); 311 352 return null; 312 353 } … … 314 355 // make our new marker 315 356 AudioMarker newAudioMarker = AudioMarker.create(coor, 316 AudioMarker.inventName(offset), AudioPlayer.url().toString(), this, time, offset);357 AudioMarker.inventName(offset), AudioPlayer.url().toString(), this, time, offset); 317 358 318 359 // insert it at the right place in a copy the collection … … 333 374 334 375 if (newAudioMarker != null) { 335 if (am != null) 376 if (am != null) { 336 377 newAudioMarker.adjustOffset(am.syncOffset()); // i.e. same as predecessor 378 } 337 379 newData.add(newAudioMarker); // insert at end 338 380 } … … 363 405 for (Marker marker : markerLayer.data) { 364 406 if (marker == startMarker) { 365 if (next) 407 if (next) { 366 408 nextTime = true; 367 else {368 if (previousMarker == null) 409 } else { 410 if (previousMarker == null) { 369 411 previousMarker = startMarker; // if no previous one, play the first one again 412 } 370 413 return previousMarker; 371 414 } … … 389 432 return; 390 433 Layer l = Main.map.mapView.getActiveLayer(); 391 if(l != null) 434 if(l != null) { 392 435 m = getAdjacentMarker(startMarker, next, l); 436 } 393 437 if(m == null) 394 438 { … … 396 440 { 397 441 m = getAdjacentMarker(startMarker, next, layer); 398 if(m != null) 399 break; 400 } 401 } 402 if(m != null) 442 if(m != null) { 443 break; 444 } 445 } 446 } 447 if(m != null) { 403 448 ((AudioMarker)m).play(); 449 } 404 450 } 405 451
Note:
See TracChangeset
for help on using the changeset viewer.