/*
* File name: ProgressBarsPlugin.java (package eas.plugins.standard.timeEstimation)
* Author(s): lko
* Java version: 7.0
* Generation date: 27.03.2013 (10:02:47)
*
* (c) This file and the EAS (Easy Agent Simulation) framework containing it
* is protected by Creative Commons by-nc-sa license. Any altered or
* further developed versions of this file have to meet the agreements
* stated by the license conditions.
*
* In a nutshell
* -------------
* You are free:
* - to Share -- to copy, distribute and transmit the work
* - to Remix -- to adapt the work
*
* Under the following conditions:
* - Attribution -- You must attribute the work in the manner specified by the
* author or licensor (but not in any way that suggests that they endorse
* you or your use of the work).
* - Noncommercial -- You may not use this work for commercial purposes.
* - Share Alike -- If you alter, transform, or build upon this work, you may
* distribute the resulting work only under the same or a similar license to
* this one.
*
* + Detailed license conditions (Germany):
* http://creativecommons.org/licenses/by-nc-sa/3.0/de/
* + Detailed license conditions (unported):
* http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en
*
* This header must be placed in the beginning of any version of this file.
*/
package eas.plugins.standard.progressEstimation;
import java.util.LinkedList;
import java.util.List;
import eas.miscellaneous.useful.progress.LProgressBar;
import eas.plugins.AbstractDefaultPlugin;
import eas.simulation.EASRunnable;
import eas.simulation.Wink;
import eas.simulation.event.EASEvent;
import eas.startSetup.ParCollection;
import eas.startSetup.SingleParameter;
/**
* @author lko
*/
public class AllroundProgressBarsPlugin extends AbstractDefaultPlugin<EASRunnable> {
/**
*
*/
private static final long serialVersionUID = -1608958885538554795L;
@Override
public List<String> getRequiredPlugins() {
return null;
}
@Override
public List<String> getSupportedPlugins() {
return null;
}
@Override
public List<SingleParameter> getParameters() {
return null;
}
@Override
public String id() {
return AbstractDefaultPlugin.ALLROUND_PLUGIN_PREFIX + "-progressBars";
}
private LProgressBar bar;
@Override
public void runBeforeSimulation(EASRunnable env, ParCollection params) {
LinkedList<Double> barValues = new LinkedList<>();
barValues.add(7.0);
barValues.add(7.0);
barValues.add(7.0);
// barValues.add(7.0);
bar = new LProgressBar(barValues);
bar.getFrame().setTitle("Progress");
bar.getFrame().setVisible(true);
bar.setShowEstimatedTimeLeft(true);
bar.setSmooth(true);
}
@Override
public void runAfterSimulation(EASRunnable env, ParCollection params) {
}
@Override
public void runDuringSimulation(EASRunnable env, Wink currentSimTime,
ParCollection params) {
double percent = 100 / params.getParValueDouble("TimeToTermination") * currentSimTime.getCurrentTime();
bar.setValue(percent);
bar.refreshBars();
}
@Override
public void handleEvent(EASEvent event, EASRunnable env, Wink lastSimTime,
ParCollection params) {
}
@Override
public void onSimulationResumed(EASRunnable env, Wink resumeTime,
ParCollection params) {
this.bar.getFrame().setVisible(true);
}
}