"Create Video" dialog - "Estimated remaining time" text
Code: Select all
this.progressBar = new JProgressBar();
this.progressBar.setIndeterminate(true);
this.progressBar.getModel().addChangeListener(new ChangeListener() {
private long timeAfterFirstImage;
public void stateChanged(ChangeEvent ev) {
int progressValue = progressBar.getValue();
progressBar.setIndeterminate(progressValue <= progressBar.getMinimum() + 1);
if (progressValue == progressBar.getMinimum()
|| progressValue == progressBar.getMaximum()) {
progressLabel.setText("");
if (progressValue == progressBar.getMinimum()) {
int framesCount = progressBar.getMaximum() - progressBar.getMinimum();
String progressLabelFormat = preferences.getLocalizedString(VideoPanel.class, "progressStartLabel.format");
progressLabel.setText(String.format(progressLabelFormat, framesCount,
formatDuration(framesCount * 1000 / controller.getFrameRate())));
}
} else if (progressValue == progressBar.getMinimum() + 1) {
this.timeAfterFirstImage = System.currentTimeMillis();
} else {
// Update progress label once the second image is generated
// (the first one can take more time because of initialization process)
String progressLabelFormat = preferences.getLocalizedString(VideoPanel.class, "progressLabel.format");
long estimatedRemainingTime = (System.currentTimeMillis() - this.timeAfterFirstImage)
/ (progressValue - 1 - progressBar.getMinimum())
* (progressBar.getMaximum() - progressValue - 1);
String estimatedRemainingTimeText = formatDuration(estimatedRemainingTime);
progressLabel.setText(String.format(progressLabelFormat,
progressValue, progressBar.getMaximum(), estimatedRemainingTimeText));
}
}
Code: Select all
this.progressBar = new JProgressBar();
this.progressBar.setIndeterminate(true);
this.progressBar.getModel().addChangeListener(new ChangeListener() {
private long timeAfterFirstImage;
// MeekMark Begin
private long timeAfter10Images;
private long timeAfter11Images;
private long timeEstimate;
// MeekMark End
public void stateChanged(ChangeEvent ev) {
int progressValue = progressBar.getValue();
progressBar.setIndeterminate(progressValue <= progressBar.getMinimum() + 1);
if (progressValue == progressBar.getMinimum()
|| progressValue == progressBar.getMaximum()) {
progressLabel.setText("");
if (progressValue == progressBar.getMinimum()) {
int framesCount = progressBar.getMaximum() - progressBar.getMinimum();
String progressLabelFormat = preferences.getLocalizedString(VideoPanel.class, "progressStartLabel.format");
progressLabel.setText(String.format(progressLabelFormat, framesCount,
formatDuration(framesCount * 1000 / controller.getFrameRate())));
}
// MeekMark Begin
} else if (progressValue == progressBar.getMinimum() + 11) {
this.timeAfter11Images = System.currentTimeMillis();
this.timeEstimate = timeAfter11Images - timeAfter10Images;
} else if (progressValue == progressBar.getMinimum() + 10) {
this.timeAfter10Images = System.currentTimeMillis();
} else if (progressValue == progressBar.getMinimum() + 1) {
this.timeAfterFirstImage = System.currentTimeMillis();
this.timeEstimate = this.timeAfterFirstImage;
} else {
// Update progress label once the second image is generated
// (the first FEW?? can take more time because of initialization process)
String progressLabelFormat = preferences.getLocalizedString(VideoPanel.class, "progressLabel.format");
long estimatedRemainingTime = (System.currentTimeMillis() - this.timeEstimate)
/ (progressValue - 1 - progressBar.getMinimum())
* (progressBar.getMaximum() - progressValue - 1);
// MeekMark End
String estimatedRemainingTimeText = formatDuration(estimatedRemainingTime);
progressLabel.setText(String.format(progressLabelFormat,
progressValue, progressBar.getMaximum(), estimatedRemainingTimeText));
}
}