Changeset 1863 in josm
- Timestamp:
- 2009-07-27T22:04:34+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/GeoImageLayer.java
r1811 r1863 68 68 import org.openstreetmap.josm.data.gpx.WayPoint; 69 69 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 70 import org.openstreetmap.josm.gui.MapFrame; 70 71 import org.openstreetmap.josm.gui.MapView; 71 72 import org.openstreetmap.josm.gui.PleaseWaitRunnable; … … 73 74 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 74 75 import org.openstreetmap.josm.gui.layer.GeoImageLayer.ImageLoader.ImageLoadedListener; 76 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 75 77 import org.openstreetmap.josm.tools.DateParser; 76 78 import org.openstreetmap.josm.tools.ExifReader; … … 265 267 266 268 public void imageLoaded() { 267 Main.map.mapView.repaint(); 269 MapFrame frame = Main.map; 270 if (frame != null) { 271 frame.mapView.repaint(); 272 } 268 273 } 269 274 } … … 280 285 @Override protected void realRun() throws IOException { 281 286 progressMonitor.subTask(tr("Read GPX...")); 287 progressMonitor.setTicksCount(10 + files.size()); 282 288 LinkedList<TimedPoint> gps = new LinkedList<TimedPoint>(); 283 289 284 290 // Extract dates and locations from GPX input 285 291 286 for (GpxTrack trk : gpxLayer.data.tracks) { 292 ProgressMonitor gpxSubTask = progressMonitor.createSubTaskMonitor(10, true); 293 int size = 0; 294 for (GpxTrack trk:gpxLayer.data.tracks) { 287 295 for (Collection<WayPoint> segment : trk.trackSegs) { 288 for (WayPoint p : segment) { 289 LatLon c = p.getCoor(); 290 if (!p.attr.containsKey("time")) 291 throw new IOException(tr("No time for point {0} x {1}",c.lat(),c.lon())); 292 Date d = null; 293 try { 294 d = DateParser.parse((String) p.attr.get("time")); 295 } catch (ParseException e) { 296 throw new IOException(tr("Cannot read time \"{0}\" from point {1} x {2}",p.attr.get("time"),c.lat(),c.lon())); 296 size += segment.size(); 297 } 298 } 299 gpxSubTask.beginTask(null, size); 300 301 try { 302 for (GpxTrack trk : gpxLayer.data.tracks) { 303 for (Collection<WayPoint> segment : trk.trackSegs) { 304 for (WayPoint p : segment) { 305 LatLon c = p.getCoor(); 306 if (!p.attr.containsKey("time")) 307 throw new IOException(tr("No time for point {0} x {1}",c.lat(),c.lon())); 308 Date d = null; 309 try { 310 d = DateParser.parse((String) p.attr.get("time")); 311 } catch (ParseException e) { 312 throw new IOException(tr("Cannot read time \"{0}\" from point {1} x {2}",p.attr.get("time"),c.lat(),c.lon())); 313 } 314 gps.add(new TimedPoint(d, c)); 315 gpxSubTask.worked(1); 297 316 } 298 gps.add(new TimedPoint(d, c));299 317 } 300 318 } 301 } 319 } finally { 320 gpxSubTask.finishTask(); 321 } 322 302 323 303 324 if (gps.isEmpty()) { … … 308 329 // read the image files 309 330 ArrayList<ImageEntry> data = new ArrayList<ImageEntry>(files.size()); 310 progressMonitor.setTicksCount(files.size());311 331 for (File f : files) { 312 332 if (progressMonitor.isCancelled()) … … 317 337 try { 318 338 e.time = ExifReader.readTime(f); 339 progressMonitor.worked(1); 319 340 } catch (ParseException e1) { 320 341 continue; … … 324 345 325 346 data.add(e); 326 progressMonitor.worked(1);327 347 } 328 348 layer = new GeoImageLayer(data, gps); -
trunk/src/org/openstreetmap/josm/gui/progress/PleaseWaitProgressMonitor.java
r1811 r1863 23 23 private static final int PROGRESS_BAR_MAX = 100; 24 24 private final Window dialogParent; 25 private int currentProgressValue = 0; 25 26 26 27 private PleaseWaitDialog dialog; … … 110 111 } 111 112 112 public void worked(int ticks) { 113 this.ticks += ticks; 114 updateProgress(0); 115 } 116 117 protected void updateProgress(final double progressValue) { 118 doInEDT(new Runnable() { 119 public void run() { 120 dialog.progress.setValue((int)(progressValue * PROGRESS_BAR_MAX)); 121 } 122 }); 113 protected void updateProgress(double progressValue) { 114 final int newValue = (int)(progressValue * PROGRESS_BAR_MAX); 115 if (newValue != currentProgressValue) { 116 currentProgressValue = newValue; 117 doInEDT(new Runnable() { 118 public void run() { 119 dialog.progress.setValue(currentProgressValue); 120 } 121 }); 122 } 123 123 } 124 124
Note:
See TracChangeset
for help on using the changeset viewer.