Changeset 17 in josm for src/org/openstreetmap/josm/actions/OpenGpxAction.java
- Timestamp:
- 2005-10-09T04:14:40+02:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/actions/OpenGpxAction.java
r16 r17 1 1 package org.openstreetmap.josm.actions; 2 2 3 import java.awt.GridBagLayout; 3 4 import java.awt.event.ActionEvent; 4 5 import java.awt.event.KeyEvent; … … 8 9 9 10 import javax.swing.AbstractAction; 10 import javax.swing.ImageIcon; 11 import javax.swing.Box; 12 import javax.swing.JCheckBox; 11 13 import javax.swing.JFileChooser; 14 import javax.swing.JLabel; 12 15 import javax.swing.JOptionPane; 16 import javax.swing.JPanel; 13 17 import javax.swing.filechooser.FileFilter; 14 18 15 19 import org.openstreetmap.josm.data.osm.DataSet; 20 import org.openstreetmap.josm.gui.GBC; 21 import org.openstreetmap.josm.gui.ImageProvider; 16 22 import org.openstreetmap.josm.gui.Main; 17 23 import org.openstreetmap.josm.gui.MapFrame; 24 import org.openstreetmap.josm.gui.layer.Layer; 25 import org.openstreetmap.josm.gui.layer.LayerFactory; 18 26 import org.openstreetmap.josm.io.GpxReader; 19 27 import org.openstreetmap.josm.io.DataReader.ConnectionException; … … 32 40 */ 33 41 public OpenGpxAction() { 34 super("Open GPX", new ImageIcon(Main.class.getResource("/images/opengpx.png")));42 super("Open GPX", ImageProvider.get("opengpx")); 35 43 putValue(MNEMONIC_KEY, KeyEvent.VK_O); 44 putValue(SHORT_DESCRIPTION, "Open a file in GPX format."); 36 45 } 37 46 … … 48 57 return "GPX or XML Files"; 49 58 }}); 50 fc.showOpenDialog(Main.main); 59 60 // additional options 61 JCheckBox rawGps = new JCheckBox("Raw GPS data", true); 62 rawGps.setToolTipText("Check this, if the data are obtained from a gps device."); 63 JCheckBox newLayer = new JCheckBox("As Layer", true); 64 newLayer.setToolTipText("Open as a new layer or replace all current layers."); 65 if (Main.main.getMapFrame() == null) { 66 newLayer.setEnabled(false); 67 newLayer.setSelected(false); 68 } 69 70 JPanel p = new JPanel(new GridBagLayout()); 71 p.add(new JLabel("Options"), GBC.eop()); 72 p.add(rawGps, GBC.eol()); 73 p.add(newLayer, GBC.eol()); 74 p.add(Box.createVerticalGlue(), GBC.eol().fill()); 75 fc.setAccessory(p); 76 77 if (fc.showOpenDialog(Main.main) != JFileChooser.APPROVE_OPTION) 78 return; 79 51 80 File gpxFile = fc.getSelectedFile(); 52 81 if (gpxFile == null) … … 54 83 55 84 try { 56 DataSet dataSet = new GpxReader(new FileReader(gpxFile)).parse(); 57 MapFrame map = new MapFrame(dataSet); 58 Main.main.setMapFrame(gpxFile.getName(), map); 85 DataSet dataSet = new GpxReader(new FileReader(gpxFile), rawGps.isSelected()).parse(); 86 87 Layer layer = LayerFactory.create(dataSet, gpxFile.getName(), rawGps.isSelected()); 88 89 if (Main.main.getMapFrame() == null || !newLayer.isSelected()) 90 Main.main.setMapFrame(gpxFile.getName(), new MapFrame(layer)); 91 else 92 Main.main.getMapFrame().mapView.addLayer(layer); 93 59 94 } catch (ParseException x) { 60 95 x.printStackTrace();
Note:
See TracChangeset
for help on using the changeset viewer.