public abstract class Observer extends Object
Some observers take repeats into account. If you repeat the simulations, they will yield average data.
Each observer should override the toString
method which should return a string
representation of its data.
You can register a PrintWriter
to the Observer
. If you have, the return
value of toString
is printed if a simulation has finished.
Constructor and Description |
---|
Observer(Simulator sim)
Creates an observer dedicated to one simulator.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
activateReaction(int mu,
double tau,
Simulator.FireType fireType,
int times)
Gets called before a reaction fires.
|
abstract void |
finished()
Gets called when a simulation has finished, directly after the termination check.
|
String |
getLabelFormat()
Gets the label format of
getLabel(String) . |
int |
getNumSimulations()
Gets the number of finished repeats of the simulation.
|
PrintWriter |
getPrintWriter()
Gets the registered
PrintWriter |
Simulator |
getSimulator()
Gets the simulator
|
double |
getTheta()
Gets the moment in time, where the simulator has to invoke
theta(double) . |
void |
print()
Gets called after the
finish call and prints the results of this observer if a
PrintWriter is registered. |
void |
setLabelFormat(String labelFormat)
Sets the label format for
getLabel(String) . |
void |
setPrintWriter(PrintWriter printWriter)
Registers a
PrintWriter |
void |
setTheta(double theta)
Sets the moment in time, where the simulator has to invoke
theta(double) . |
abstract void |
started()
Gets called when the simulation has started after the initialization and before the termination
condition is checked the first time.
|
abstract void |
step()
Gets called after each termination check and before
Simulator.performStep(fern.simulation.controller.SimulationController)
is called. |
abstract void |
theta(double theta)
Gets called by simulators when a certain moment in time is reached.
|
public Observer(Simulator sim)
Simulator.addObserver(Observer)
in order to do this.sim
- the simulatorpublic abstract void started()
public abstract void step()
Simulator.performStep(fern.simulation.controller.SimulationController)
is called.public abstract void finished()
public abstract void theta(double theta)
getTheta()
theta
- moment in timepublic abstract void activateReaction(int mu, double tau, Simulator.FireType fireType, int times)
mu
- the reaction which is supposed to firetau
- the time the reaction fires (at this time Simulator.getTime()
does not
necessarily yield the firing time)fireType
- the type of the firingtimes
- TODOpublic void print()
finish
call and prints the results of this observer if a
PrintWriter
is registered.public double getTheta()
theta(double)
.public void setTheta(double theta)
theta(double)
.theta
- the thetapublic PrintWriter getPrintWriter()
PrintWriter
PrintWriter
public void setPrintWriter(PrintWriter printWriter)
PrintWriter
printWriter
- the PrintWriter
public void setLabelFormat(String labelFormat)
getLabel(String)
.labelFormat
- the label formatgetLabel(String)
public String getLabelFormat()
getLabel(String)
.getLabel(String)
public Simulator getSimulator()
public int getNumSimulations()
finished
call, so within finish
of an extending class it is the
number of repeats without the actual simulation.Copyright © 2007–2021. All rights reserved.