Ticket #11844: time_estimate.patch

File time_estimate.patch, 1.7 KB (added by skorbut, 6 years ago)
  • photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/GeotaggingAction.java

     
    236236            progressMonitor.subTask(tr("Writing position information to image files..."));
    237237            progressMonitor.setTicksCount(images.size());
    238238
     239            final long startTime = System.currentTimeMillis();
     240
    239241            currentIndex = 0;
    240242            while (currentIndex < images.size()) {
    241243                if (canceled) return;
     
    275277                    }
    276278                }
    277279                progressMonitor.worked(1);
     280
     281                float millisecsPerFile = ((float)(System.currentTimeMillis()-startTime))/((currentIndex+1)); // currentIndex starts at 0
     282                int filesLeft = images.size()-currentIndex-1;
     283                int secsLeft = (int)Math.ceil((millisecsPerFile*filesLeft/1000));
     284                String timeLeft;
     285                if (secsLeft < 60) {
     286                        timeLeft = secsLeft + "s";
     287                } else if (secsLeft < 3600) {
     288                        timeLeft = secsLeft/60 + "min " + secsLeft%60 + "s";
     289                } else {
     290                        timeLeft = secsLeft/3600 + "h " + ((secsLeft)/60)%60 + "min " + secsLeft%60 + "s";
     291                }
     292                                progressMonitor.subTask(tr("Writing position information to image files... Estimated time left: {0}", timeLeft));
     293
    278294                if (debug) {
    279295                    System.err.println("finished " + e.getFile());
    280296                }