public class SimulationAnimation extends Simulation
Modifier and Type | Field and Description |
---|---|
private javax.swing.JFrame |
gui
Frame for updating after each iteration
|
private int |
iteration
For counting the number of iterations
|
private MeasurementEvolution |
measurement
For recording the evolution of some measurement values of certain
metrics.
|
private int |
numIterations
For nummber of iterations limit
|
private ObserverAnimation |
observer
Observer for being notified when the simulation finishes.
|
private int |
time_interval
Waiting time for each iteration in milliseconds
|
private javax.swing.Timer |
timer
Timer for the animation
|
Constructor and Description |
---|
SimulationAnimation(javax.swing.JFrame paramGui)
Constructor with a GUI
|
Modifier and Type | Method and Description |
---|---|
int |
getIteration()
Returns the number of iteration
|
void |
run()
Runs after each time the timer runs out of time
|
void |
run(int paramNumIterations)
Runs the whole simulation with the number of iterations indicated
in the parameter in a animated simulation repainting the GUI.
|
void |
setMeasurementEvolution(MeasurementEvolution measurement)
Sets a reference to the measurement value given in the parameter
|
void |
setObserver(ObserverAnimation observer)
Sets the observer for notififying the end of the simulation
|
void |
setSpeed(double speed)
Set the speed (iterations/second) translating it to miliseconds of the
interval of each iteration.
|
getSize, live, register
private javax.swing.Timer timer
private int time_interval
private javax.swing.JFrame gui
private int iteration
private int numIterations
private MeasurementEvolution measurement
private ObserverAnimation observer
public SimulationAnimation(javax.swing.JFrame paramGui)
public void run(int paramNumIterations)
run
in class Simulation
public void run()
public int getIteration()
public void setSpeed(double speed)
public void setMeasurementEvolution(MeasurementEvolution measurement)
measurement
- Object in which the records will be recorded.public void setObserver(ObserverAnimation observer)