Changeset 1519 in josm
- Timestamp:
- 2009-03-30T16:42:12+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java
r1275 r1519 117 117 r = new GpxReader(is,file.getAbsoluteFile().getParentFile()); 118 118 r.data.storageFile = file; 119 GpxLayer gpxLayer = new GpxLayer(r.data, fn );119 GpxLayer gpxLayer = new GpxLayer(r.data, fn, true); 120 120 Main.main.addLayer(gpxLayer); 121 121 if (Main.pref.getBoolean("marker.makeautomarkers", true)) { … … 155 155 if(r.getNumberOfCoordinates()>0) { 156 156 r.data.storageFile = file; 157 GpxLayer gpxLayer = new GpxLayer(r.data, fn );157 GpxLayer gpxLayer = new GpxLayer(r.data, fn, true); 158 158 Main.main.addLayer(gpxLayer); 159 159 if (Main.pref.getBoolean("marker.makeautomarkers", true)) { -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r1508 r1519 84 84 private colorModes computeCacheColored; 85 85 private int computeCacheColorTracksTune; 86 private boolean isLocalFile; 86 87 87 88 public GpxLayer(GpxData d) { … … 95 96 this(d); 96 97 this.name = name; 98 } 99 100 public GpxLayer(GpxData d, String name, boolean isLocal) { 101 this(d); 102 this.name = name; 103 this.isLocalFile = isLocal; 97 104 } 98 105 … … 204 211 File sel[] = fc.getSelectedFiles(); 205 212 if(sel != null) { 206 207 208 209 210 211 212 213 213 // sort files in increasing order of timestamp (this is the end time, but so long as they don't overlap, that's fine) 214 if (sel.length > 1) { 215 Arrays.sort(sel, new Comparator<File>() { 216 public int compare(File a, File b) { 217 return a.lastModified() <= b.lastModified() ? -1 : 1; 218 } 219 }); 220 } 214 221 double firstStartTime = sel[0].lastModified()/1000.0 /* ms -> seconds */ - AudioUtil.getCalibratedDuration(sel[0]); 215 222 for (int i = 0; i < sel.length; i++) { … … 391 398 int maxLineLength = Main.pref.getInteger("draw.rawgps.max-line-length", -1); 392 399 // draw line between points, global setting 393 boolean lines = Main.pref.getBoolean("draw.rawgps.lines");400 boolean lines = (Main.pref.getBoolean("draw.rawgps.lines") || (Main.pref.getBoolean("draw.rawgps.lines.localfiles") && this.isLocalFile)); 394 401 String linesKey = "draw.rawgps.lines.layer "+name; 395 402 // draw lines, per-layer setting … … 923 930 double startTime = lastModified - duration; 924 931 startTime = firstStartTime + (startTime - firstStartTime) / 925 932 Main.pref.getDouble("audio.calibration", "1.0" /* default, ratio */); 926 933 WayPoint w1 = null; 927 934 WayPoint w2 = null; 928 935 929 930 931 932 936 for (GpxTrack track : data.tracks) { 937 if (track.trackSegs == null) continue; 938 for (Collection<WayPoint> seg : track.trackSegs) { 939 for (WayPoint w : seg) { 933 940 if (startTime < w.time) { 934 941 w2 = w; … … 939 946 if (w2 != null) break; 940 947 } 941 } 948 } 942 949 943 950 if (w1 == null || w2 == null) { 944 951 timedMarkersOmitted = true; 945 952 } else { 946 947 948 953 EastNorth eastNorth = w1.eastNorth.interpolate( 954 w2.eastNorth, 955 (startTime - w1.time)/(w2.time - w1.time)); 949 956 wayPointFromTimeStamp = new WayPoint(Main.proj.eastNorth2latlon(eastNorth)); 950 957 wayPointFromTimeStamp.time = startTime; … … 954 961 wayPointFromTimeStamp.attr.put("name", name); 955 962 waypoints.add(wayPointFromTimeStamp); 956 } 963 } 957 964 } 958 965 … … 1004 1011 /* timeFromAudio intended for future use to shift markers of this type on synchronization */ 1005 1012 if (w == wayPointFromTimeStamp) { 1006 1013 am.timeFromAudio = true; 1007 1014 } 1008 1015 ml.data.add(am); -
trunk/src/org/openstreetmap/josm/gui/preferences/DrawingPreference.java
r1425 r1519 27 27 public class DrawingPreference implements PreferenceSetting { 28 28 29 private JCheckBox drawRawGpsLines = new JCheckBox(tr("Draw lines between raw gps points.")); 29 private ButtonGroup gpsLinesGroup; 30 private JRadioButton drawRawGpsLinesAll = new JRadioButton(tr("All")); 31 private JRadioButton drawRawGpsLinesLocal = new JRadioButton(tr("Local files")); 32 private JRadioButton drawRawGpsLinesNone = new JRadioButton(tr("None")); 33 private ActionListener drawRawGpsLinesActionListener; 30 34 private JTextField drawRawGpsMaxLineLength = new JTextField(8); 31 35 private JCheckBox forceRawGpsLines = new JCheckBox(tr("Force lines if no segments imported.")); … … 54 58 55 59 // drawRawGpsLines 56 drawRawGpsLines.addActionListener(new ActionListener(){ 60 gpsLinesGroup = new ButtonGroup(); 61 gpsLinesGroup.add(drawRawGpsLinesNone); 62 gpsLinesGroup.add(drawRawGpsLinesLocal); 63 gpsLinesGroup.add(drawRawGpsLinesAll); 64 65 if(Main.pref.getBoolean("draw.rawgps.lines")) { 66 drawRawGpsLinesAll.setSelected(true); 67 } else if (Main.pref.getBoolean("draw.rawgps.lines.localfiles")) { 68 drawRawGpsLinesLocal.setSelected(true); 69 } else { 70 drawRawGpsLinesNone.setSelected(true); 71 } 72 73 panel.add(new JLabel(tr("Draw lines between raw GPS points")), GBC.eol().insets(20,0,0,0)); 74 panel.add(drawRawGpsLinesNone, GBC.eol().insets(40,0,0,0)); 75 panel.add(drawRawGpsLinesLocal, GBC.eol().insets(40,0,0,0)); 76 panel.add(drawRawGpsLinesAll, GBC.eol().insets(40,0,0,0)); 77 78 drawRawGpsLinesActionListener = new ActionListener(){ 57 79 public void actionPerformed(ActionEvent e) { 58 forceRawGpsLines.setEnabled( drawRawGpsLines.isSelected());59 drawRawGpsMaxLineLength.setEnabled( drawRawGpsLines.isSelected());60 drawGpsArrows.setEnabled( drawRawGpsLines.isSelected());80 forceRawGpsLines.setEnabled(!drawRawGpsLinesNone.isSelected()); 81 drawRawGpsMaxLineLength.setEnabled(!drawRawGpsLinesNone.isSelected()); 82 drawGpsArrows.setEnabled(!drawRawGpsLinesNone.isSelected() ); 61 83 drawGpsArrowsFast.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 62 84 drawGpsArrowsMinDist.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 63 85 } 64 }); 65 drawRawGpsLines.setSelected(Main.pref.getBoolean("draw.rawgps.lines")); 66 drawRawGpsLines.setToolTipText(tr("If your gps device draws too few lines, select this to draw lines along your way.")); 67 panel.add(drawRawGpsLines, GBC.eol().insets(20,0,0,0)); 86 }; 87 88 drawRawGpsLinesNone.addActionListener(drawRawGpsLinesActionListener); 89 drawRawGpsLinesLocal.addActionListener(drawRawGpsLinesActionListener); 90 drawRawGpsLinesAll.addActionListener(drawRawGpsLinesActionListener); 68 91 69 92 // drawRawGpsMaxLineLength 70 93 drawRawGpsMaxLineLength.setText(Integer.toString(Main.pref.getInteger("draw.rawgps.max-line-length", -1))); 71 94 drawRawGpsMaxLineLength.setToolTipText(tr("Maximum length (in meters) to draw lines. Set to '-1' to draw all lines.")); 72 drawRawGpsMaxLineLength.setEnabled( drawRawGpsLines.isSelected());95 drawRawGpsMaxLineLength.setEnabled(!drawRawGpsLinesNone.isSelected()); 73 96 panel.add(new JLabel(tr("Maximum length (meters)")), GBC.std().insets(40,0,0,0)); 74 97 panel.add(drawRawGpsMaxLineLength, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5)); … … 77 100 forceRawGpsLines.setToolTipText(tr("Force drawing of lines if the imported data contain no line information.")); 78 101 forceRawGpsLines.setSelected(Main.pref.getBoolean("draw.rawgps.lines.force")); 79 forceRawGpsLines.setEnabled( drawRawGpsLines.isSelected());102 forceRawGpsLines.setEnabled(!drawRawGpsLinesNone.isSelected()); 80 103 panel.add(forceRawGpsLines, GBC.eop().insets(40,0,0,0)); 81 104 … … 89 112 drawGpsArrows.setToolTipText(tr("Draw direction arrows for lines, connecting GPS points.")); 90 113 drawGpsArrows.setSelected(Main.pref.getBoolean("draw.rawgps.direction")); 91 drawGpsArrows.setEnabled( drawRawGpsLines.isSelected());114 drawGpsArrows.setEnabled(!drawRawGpsLinesNone.isSelected()); 92 115 panel.add(drawGpsArrows, GBC.eop().insets(40,0,0,0)); 93 116 … … 221 244 222 245 public boolean ok() { 223 Main.pref.put("draw.rawgps.lines", drawRawGpsLines.isSelected()); 246 Main.pref.put("draw.rawgps.lines", drawRawGpsLinesAll.isSelected()); 247 Main.pref.put("draw.rawgps.lines.localfiles", drawRawGpsLinesLocal.isSelected()); 224 248 Main.pref.put("draw.rawgps.max-line-length", drawRawGpsMaxLineLength.getText()); 225 249 Main.pref.put("draw.rawgps.lines.force", forceRawGpsLines.isSelected());
Note:
See TracChangeset
for help on using the changeset viewer.