Changeset 18044 in josm
- Timestamp:
- 2021-07-16T22:35:07+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/layer/geoimage
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/AdjustTimezoneAndOffsetDialog.java
r18043 r18044 27 27 /** 28 28 * Dialog used to manually adjust timezone and offset for GPX correlation. 29 * @since 18043 (extracted from CorrelateGpxWithImages) 29 * @since 18043 (extracted from {@link CorrelateGpxWithImages}) 30 30 */ 31 31 public class AdjustTimezoneAndOffsetDialog extends ExtendedDialog { -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
r18043 r18044 6 6 7 7 import java.awt.BorderLayout; 8 import java.awt.Component;9 8 import java.awt.Cursor; 10 9 import java.awt.Dimension; … … 34 33 import java.util.Date; 35 34 import java.util.List; 36 import java.util.Objects;37 35 import java.util.TimeZone; 38 36 import java.util.concurrent.TimeUnit; … … 46 44 import javax.swing.JButton; 47 45 import javax.swing.JCheckBox; 48 import javax.swing.JComponent;49 46 import javax.swing.JFileChooser; 50 47 import javax.swing.JLabel; … … 54 51 import javax.swing.JScrollPane; 55 52 import javax.swing.JSeparator; 56 import javax.swing.JSpinner;57 53 import javax.swing.ListSelectionModel; 58 54 import javax.swing.MutableComboBoxModel; 59 import javax.swing.SpinnerNumberModel;60 55 import javax.swing.SwingConstants; 61 import javax.swing.border.Border;62 56 import javax.swing.event.DocumentEvent; 63 57 import javax.swing.event.DocumentListener; … … 86 80 import org.openstreetmap.josm.gui.widgets.JosmTextField; 87 81 import org.openstreetmap.josm.spi.preferences.Config; 88 import org.openstreetmap.josm.spi.preferences.IPreferences;89 82 import org.openstreetmap.josm.tools.Destroyable; 90 83 import org.openstreetmap.josm.tools.GBC; … … 292 285 private class AdvancedSettingsActionListener implements ActionListener { 293 286 294 private class CheckBoxActionListener implements ActionListener {295 private final JComponent[] comps;296 297 CheckBoxActionListener(JComponent... c) {298 comps = Objects.requireNonNull(c);299 }300 301 @Override302 public void actionPerformed(ActionEvent e) {303 setEnabled((JCheckBox) e.getSource());304 }305 306 public void setEnabled(JCheckBox cb) {307 for (JComponent comp : comps) {308 if (comp instanceof JSpinner) {309 comp.setEnabled(cb.isSelected());310 } else if (comp instanceof JPanel) {311 boolean en = cb.isSelected();312 for (Component c : comp.getComponents()) {313 if (c instanceof JSpinner) {314 c.setEnabled(en);315 } else {316 c.setEnabled(cb.isSelected());317 if (en && c instanceof JCheckBox) {318 en = ((JCheckBox) c).isSelected();319 }320 }321 }322 }323 }324 }325 }326 327 private void addCheckBoxActionListener(JCheckBox cb, JComponent... c) {328 CheckBoxActionListener listener = new CheckBoxActionListener(c);329 cb.addActionListener(listener);330 listener.setEnabled(cb);331 }332 333 287 @Override 334 288 public void actionPerformed(ActionEvent e) { 335 336 IPreferences s = Config.getPref(); 337 JPanel p = new JPanel(new GridBagLayout()); 338 339 Border border1 = BorderFactory.createEmptyBorder(0, 20, 0, 0); 340 Border border2 = BorderFactory.createEmptyBorder(10, 0, 5, 0); 341 Border border = BorderFactory.createEmptyBorder(0, 40, 0, 0); 342 FlowLayout layout = new FlowLayout(); 343 344 JLabel l = new JLabel(tr("Segment settings")); 345 l.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); 346 p.add(l, GBC.eol()); 347 JCheckBox cInterpolSeg = new JCheckBox(tr("Interpolate between segments"), s.getBoolean("geoimage.seg.int", true)); 348 cInterpolSeg.setBorder(border1); 349 p.add(cInterpolSeg, GBC.eol()); 350 351 JCheckBox cInterpolSegTime = new JCheckBox(tr("only when the segments are less than # minutes apart:"), 352 s.getBoolean("geoimage.seg.int.time", true)); 353 JSpinner sInterpolSegTime = new JSpinner( 354 new SpinnerNumberModel(s.getInt("geoimage.seg.int.time.val", 60), 0, Integer.MAX_VALUE, 1)); 355 ((JSpinner.DefaultEditor) sInterpolSegTime.getEditor()).getTextField().setColumns(3); 356 JPanel pInterpolSegTime = new JPanel(layout); 357 pInterpolSegTime.add(cInterpolSegTime); 358 pInterpolSegTime.add(sInterpolSegTime); 359 pInterpolSegTime.setBorder(border); 360 p.add(pInterpolSegTime, GBC.eol()); 361 362 JCheckBox cInterpolSegDist = new JCheckBox(tr("only when the segments are less than # meters apart:"), 363 s.getBoolean("geoimage.seg.int.dist", true)); 364 JSpinner sInterpolSegDist = new JSpinner( 365 new SpinnerNumberModel(s.getInt("geoimage.seg.int.dist.val", 50), 0, Integer.MAX_VALUE, 1)); 366 ((JSpinner.DefaultEditor) sInterpolSegDist.getEditor()).getTextField().setColumns(3); 367 JPanel pInterpolSegDist = new JPanel(layout); 368 pInterpolSegDist.add(cInterpolSegDist); 369 pInterpolSegDist.add(sInterpolSegDist); 370 pInterpolSegDist.setBorder(border); 371 p.add(pInterpolSegDist, GBC.eol()); 372 373 JCheckBox cTagSeg = new JCheckBox(tr("Tag images at the closest end of a segment, when not interpolated"), 374 s.getBoolean("geoimage.seg.tag", true)); 375 cTagSeg.setBorder(border1); 376 p.add(cTagSeg, GBC.eol()); 377 378 JCheckBox cTagSegTime = new JCheckBox(tr("only within # minutes of the closest trackpoint:"), 379 s.getBoolean("geoimage.seg.tag.time", true)); 380 JSpinner sTagSegTime = new JSpinner( 381 new SpinnerNumberModel(s.getInt("geoimage.seg.tag.time.val", 2), 0, Integer.MAX_VALUE, 1)); 382 ((JSpinner.DefaultEditor) sTagSegTime.getEditor()).getTextField().setColumns(3); 383 JPanel pTagSegTime = new JPanel(layout); 384 pTagSegTime.add(cTagSegTime); 385 pTagSegTime.add(sTagSegTime); 386 pTagSegTime.setBorder(border); 387 p.add(pTagSegTime, GBC.eol()); 388 389 l = new JLabel(tr("Track settings (note that multiple tracks can be in one GPX file)")); 390 l.setBorder(border2); 391 p.add(l, GBC.eol()); 392 JCheckBox cInterpolTrack = new JCheckBox(tr("Interpolate between tracks"), s.getBoolean("geoimage.trk.int", false)); 393 cInterpolTrack.setBorder(border1); 394 p.add(cInterpolTrack, GBC.eol()); 395 396 JCheckBox cInterpolTrackTime = new JCheckBox(tr("only when the tracks are less than # minutes apart:"), 397 s.getBoolean("geoimage.trk.int.time", false)); 398 JSpinner sInterpolTrackTime = new JSpinner( 399 new SpinnerNumberModel(s.getInt("geoimage.trk.int.time.val", 60), 0, Integer.MAX_VALUE, 1)); 400 ((JSpinner.DefaultEditor) sInterpolTrackTime.getEditor()).getTextField().setColumns(3); 401 JPanel pInterpolTrackTime = new JPanel(layout); 402 pInterpolTrackTime.add(cInterpolTrackTime); 403 pInterpolTrackTime.add(sInterpolTrackTime); 404 pInterpolTrackTime.setBorder(border); 405 p.add(pInterpolTrackTime, GBC.eol()); 406 407 JCheckBox cInterpolTrackDist = new JCheckBox(tr("only when the tracks are less than # meters apart:"), 408 s.getBoolean("geoimage.trk.int.dist", false)); 409 JSpinner sInterpolTrackDist = new JSpinner( 410 new SpinnerNumberModel(s.getInt("geoimage.trk.int.dist.val", 50), 0, Integer.MAX_VALUE, 1)); 411 ((JSpinner.DefaultEditor) sInterpolTrackDist.getEditor()).getTextField().setColumns(3); 412 JPanel pInterpolTrackDist = new JPanel(layout); 413 pInterpolTrackDist.add(cInterpolTrackDist); 414 pInterpolTrackDist.add(sInterpolTrackDist); 415 pInterpolTrackDist.setBorder(border); 416 p.add(pInterpolTrackDist, GBC.eol()); 417 418 JCheckBox cTagTrack = new JCheckBox("<html>" + 419 tr("Tag images at the closest end of a track, when not interpolated<br>" + 420 "(also applies before the first and after the last track)") + "</html>", 421 s.getBoolean("geoimage.trk.tag", true)); 422 cTagTrack.setBorder(border1); 423 p.add(cTagTrack, GBC.eol()); 424 425 JCheckBox cTagTrackTime = new JCheckBox(tr("only within # minutes of the closest trackpoint:"), 426 s.getBoolean("geoimage.trk.tag.time", true)); 427 JSpinner sTagTrackTime = new JSpinner( 428 new SpinnerNumberModel(s.getInt("geoimage.trk.tag.time.val", 2), 0, Integer.MAX_VALUE, 1)); 429 ((JSpinner.DefaultEditor) sTagTrackTime.getEditor()).getTextField().setColumns(3); 430 JPanel pTagTrackTime = new JPanel(layout); 431 pTagTrackTime.add(cTagTrackTime); 432 pTagTrackTime.add(sTagTrackTime); 433 pTagTrackTime.setBorder(border); 434 p.add(pTagTrackTime, GBC.eol()); 435 436 l = new JLabel(tr("Advanced")); 437 l.setBorder(border2); 438 p.add(l, GBC.eol()); 439 JCheckBox cForce = new JCheckBox("<html>" + 440 tr("Force tagging of all pictures (temporarily overrides the settings above).") + "<br>" + 441 tr("This option will not be saved permanently.") + "</html>", forceTags); 442 cForce.setBorder(BorderFactory.createEmptyBorder(0, 20, 10, 0)); 443 p.add(cForce, GBC.eol()); 444 445 addCheckBoxActionListener(cInterpolSegTime, sInterpolSegTime); 446 addCheckBoxActionListener(cInterpolSegDist, sInterpolSegDist); 447 addCheckBoxActionListener(cInterpolSeg, pInterpolSegTime, pInterpolSegDist); 448 449 addCheckBoxActionListener(cTagSegTime, sTagSegTime); 450 addCheckBoxActionListener(cTagSeg, pTagSegTime); 451 452 addCheckBoxActionListener(cInterpolTrackTime, sInterpolTrackTime); 453 addCheckBoxActionListener(cInterpolTrackDist, sInterpolTrackDist); 454 addCheckBoxActionListener(cInterpolTrack, pInterpolTrackTime, pInterpolTrackDist); 455 456 addCheckBoxActionListener(cTagTrackTime, sTagTrackTime); 457 addCheckBoxActionListener(cTagTrack, pTagTrackTime); 458 459 460 ExtendedDialog ed = new ExtendedDialog(MainApplication.getMainFrame(), tr("Advanced settings"), tr("OK"), tr("Cancel")) 461 .setButtonIcons("ok", "cancel").setContent(p); 289 AdvancedCorrelationSettingsDialog ed = new AdvancedCorrelationSettingsDialog(MainApplication.getMainFrame(), forceTags); 462 290 if (ed.showDialog().getValue() == 1) { 463 464 s.putBoolean("geoimage.seg.int", cInterpolSeg.isSelected()); 465 s.putBoolean("geoimage.seg.int.dist", cInterpolSegDist.isSelected()); 466 s.putInt("geoimage.seg.int.dist.val", (int) sInterpolSegDist.getValue()); 467 s.putBoolean("geoimage.seg.int.time", cInterpolSegTime.isSelected()); 468 s.putInt("geoimage.seg.int.time.val", (int) sInterpolSegTime.getValue()); 469 s.putBoolean("geoimage.seg.tag", cTagSeg.isSelected()); 470 s.putBoolean("geoimage.seg.tag.time", cTagSegTime.isSelected()); 471 s.putInt("geoimage.seg.tag.time.val", (int) sTagSegTime.getValue()); 472 473 s.putBoolean("geoimage.trk.int", cInterpolTrack.isSelected()); 474 s.putBoolean("geoimage.trk.int.dist", cInterpolTrackDist.isSelected()); 475 s.putInt("geoimage.trk.int.dist.val", (int) sInterpolTrackDist.getValue()); 476 s.putBoolean("geoimage.trk.int.time", cInterpolTrackTime.isSelected()); 477 s.putInt("geoimage.trk.int.time.val", (int) sInterpolTrackTime.getValue()); 478 s.putBoolean("geoimage.trk.tag", cTagTrack.isSelected()); 479 s.putBoolean("geoimage.trk.tag.time", cTagTrackTime.isSelected()); 480 s.putInt("geoimage.trk.tag.time.val", (int) sTagTrackTime.getValue()); 481 482 forceTags = cForce.isSelected(); // This setting is not supposed to be saved permanently 291 forceTags = ed.isForceTaggingSelected(); // This setting is not supposed to be saved permanently 483 292 484 293 statusBarUpdater.matchAndUpdateStatusBar(); … … 494 303 * Then values of timezone and delta are set. 495 304 * @author chris 496 *497 305 */ 498 306 private class SetOffsetActionListener implements ActionListener { 499 JCheckBox ckDst; 500 ImageDisplay imgDisp; 501 JLabel lbExifTime; 502 JosmTextField tfGpsTime; 307 private JCheckBox ckDst; 308 private ImageDisplay imgDisp; 309 private JLabel lbExifTime; 310 private JosmTextField tfGpsTime; 503 311 504 312 class TimeZoneItem implements Comparable<TimeZoneItem> {
Note:
See TracChangeset
for help on using the changeset viewer.