|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opensourcephysics.ejs.Simulation
public abstract class Simulation
A base interface for a simulation
Field Summary | |
---|---|
static int |
MAXIMUM_FPS
|
static int |
MINIMUM_FPS
|
Constructor Summary | |
---|---|
Simulation()
|
Method Summary | |
---|---|
void |
apply()
apply user interface changes |
void |
apply(java.lang.String _variable)
apply a single change in the user interface |
void |
applyAll()
apply user interface changes. |
java.net.URL |
getCodebase()
Returns the codebase |
Model |
getModel()
|
java.lang.String |
getVariable(java.lang.String _name)
This method returns a String with the value of a public variable of the model. |
java.lang.String |
getVariable(java.lang.String _name,
java.lang.String _sep)
This method returns a String with the value of a public variable of the model. |
View |
getView()
|
void |
initialize()
Initialize model using user interface changes |
boolean |
isPaused()
Returns whether the simulation is running or not |
boolean |
isPlaying()
Returns whether the simulation is running or not |
void |
pause()
Stops the simulation |
void |
play()
Sets the simulation in play mode |
boolean |
readState(java.lang.String _filename)
|
boolean |
readState(java.lang.String _filename,
java.net.URL _codebase)
Reads the state of the model either from a file on the disk, from memory or from a url location. |
void |
reset()
Resets the simulation to a complete initial state |
void |
run()
Implementation of the Runnable interface |
boolean |
saveState(java.lang.String _filename)
Saves the state of the model either to a file on the disk or to memory. |
void |
setAutoplay(boolean _play)
Sets whether the simulation should be set to play mode when it is reset. |
void |
setCodebase(java.net.URL _codebase)
Sets the codebase |
void |
setDelay(int _aDelay)
Sets the delay between two steps of the simulation |
void |
setFPS(int _fps)
Sets the (approximate) number of frames per second for the simulation |
void |
setModel(Model _aModel)
|
boolean |
setVariable(java.lang.String _name,
java.lang.String _value)
This method sets the value of a public variable of the model. |
boolean |
setVariable(java.lang.String _variable,
java.lang.String _value,
java.lang.String _sep)
This method sets the value of a public variable of the model. |
boolean |
setVariables(java.lang.String _valueList)
This method is used to set more than one variables of the model at once. |
boolean |
setVariables(java.lang.String _valueList,
java.lang.String _sep,
java.lang.String _arraySep)
This method is used to set more than one variables of the model at once. |
void |
setView(View _aView)
|
void |
step()
step |
void |
update()
update |
void |
updateAfterModelAction()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MAXIMUM_FPS
public static final int MINIMUM_FPS
Constructor Detail |
---|
public Simulation()
Method Detail |
---|
public Model getModel()
public void setModel(Model _aModel)
public View getView()
public void setView(View _aView)
public void setCodebase(java.net.URL _codebase)
public java.net.URL getCodebase()
public void play()
public void pause()
public void run()
run
in interface java.lang.Runnable
public void setFPS(int _fps)
_fps
- the number of frames per secondpublic void setDelay(int _aDelay)
_aDelay
- the number of milliseconds for the delaypublic void setAutoplay(boolean _play)
_play
- Whether it should playpublic boolean isPlaying()
public boolean isPaused()
public void reset()
public void initialize()
public void apply()
public void applyAll()
public void apply(java.lang.String _variable)
public void update()
public void step()
public void updateAfterModelAction()
public java.lang.String getVariable(java.lang.String _name)
_name
- The name of a public variable of the model
public java.lang.String getVariable(java.lang.String _name, java.lang.String _sep)
_name
- The name of a public variable of the model_sep
- A separator string to use for array variables
public boolean setVariable(java.lang.String _name, java.lang.String _value)
_name
- the name of a public variable of the model_value
- the value to be given to the variable
public boolean setVariable(java.lang.String _variable, java.lang.String _value, java.lang.String _sep)
_variable
- the name of a public variable of the model_value
- the value to be given to the variable_sep
- the separator string for arrays
public boolean setVariables(java.lang.String _valueList)
_valueList
- the string containing the pairs 'variable=value'
setVariable(String,String)
public boolean setVariables(java.lang.String _valueList, java.lang.String _sep, java.lang.String _arraySep)
_valueList
- the string containing the pairs 'variable=value'_sep
- the separator string between pairs_arraySep
- the separator string for values of array variables
setVariable(String,String)
public boolean saveState(java.lang.String _filename)
The state of the model is saved by writing to disk all its public fields which implement the java.io.Serializable interface. This includes primitives and arrays.
_filename
- the name of a file (either in disk or in memory)
public boolean readState(java.lang.String _filename)
public boolean readState(java.lang.String _filename, java.net.URL _codebase)
The state of the model is read by reading from disk all its public fields which implement the java.io.Serializable interface. This includes primitives and arrays.
_filename
- the name of a file (either in disk , in memory or a url)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |