MATES 3.0-rc2

org.mates.sim
Class Experiment

java.lang.Object
  extended byorg.mates.sim.Experiment
Direct Known Subclasses:
StatisticsPlugin, TopologyMoviePlugin

public abstract class Experiment
extends java.lang.Object

A class for automating an experiment within MATES. Experiments can have "sub-experiments," creating an experiment tree. This allows for a sort of "plugin" interface for MATES. In other words, say one implements a routing algorithm. This algorithm could be encapsulated by one experiment. Afterward, this experiment could be added as a sub-experiment to all other experiments that require routing. All experiments within the same tree use the same Simulator object. Any operation performed to an experiment that is not at the root will first be propagated to the root. For example, say iterate() is called on a sub-experiment. The call to iterate() will be propagated up through the tree until it reaches the root. When it reaches the root, the root will first iterate itself (and thereby the Simulator), and then iterate each of its children.

Author:
Evan Sultanik

Field Summary
protected  Experiment parent
          Reference to this experiment's parent.
protected  Simulator simulator
          Reference to the simulator associated with this experiment tree.
 
Constructor Summary
protected Experiment()
          Creates a new Experiment, with a new Simulator.
  Experiment(Experiment parent)
          Creates a new experiment as a sub-experiment of parent.
protected Experiment(Simulator simulator)
          Creates a new Experiment from an existing Simulator.
 
Method Summary
 boolean complete()
          Returns true if the experiment is complete.
 java.awt.Component getGUI()
          Returns the GUI component associated with this experiment.
 java.awt.Component[] getMenuItems()
          Returns an array of menu items (usually in the form of JMenuItems) to be added to the GUI for this experiment.
 Experiment getParentExperiment()
          Returns the parent experiment of this experiment.
 Simulator getSimulator()
          Returns the simulator associated with this experiment tree.
 java.util.ArrayList getSubExperiments()
          Returns an ArrayList containing all of this experiment's sub-experiments.
protected  void handleInitialize()
          Callback function for initializing the experiment.
protected  void handleIterate()
          Callback function for iterating the experiment.
 void handleMenuAction(java.awt.event.ActionEvent e, java.awt.Component frame)
          Callback function for when one of this experiment's menu items is acted upon.
protected  void handleReset()
          Callback function for resetting the experiment.
 void initialize()
          Causes handleInitialize() to be called on all experiments in this experiment tree.
 void iterate()
          Causes the simulator to iterate itself, followed by calling handleIterate() on all experiments in this experiment tree.
 void reset()
          Causes the simulator to reset itself, followed by calling handleReset() on all experiments in this experiment tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

simulator

protected Simulator simulator
Reference to the simulator associated with this experiment tree.


parent

protected Experiment parent
Reference to this experiment's parent. If null, this experiment is at the root of the experiment tree.

Constructor Detail

Experiment

protected Experiment()
Creates a new Experiment, with a new Simulator. This experiment will have no parent; it will be the root of the experiment tree.


Experiment

protected Experiment(Simulator simulator)
Creates a new Experiment from an existing Simulator.


Experiment

public Experiment(Experiment parent)
Creates a new experiment as a sub-experiment of parent. The new experiment will inherit the Simulator object of its parent.

Method Detail

getParentExperiment

public Experiment getParentExperiment()
Returns the parent experiment of this experiment.

Returns:
the parent of this experiment, or null if this experiment is at the root of the experiment tree.

getSubExperiments

public java.util.ArrayList getSubExperiments()
Returns an ArrayList containing all of this experiment's sub-experiments. This is guaranteed not to be null.


getSimulator

public Simulator getSimulator()
Returns the simulator associated with this experiment tree.


initialize

public final void initialize()
Causes handleInitialize() to be called on all experiments in this experiment tree.


handleInitialize

protected void handleInitialize()
Callback function for initializing the experiment. Sub-classes of Experiment need not re-implement this function. This function is empty by default; therefore, super.handleInitialize() need not be called from re-implementations of this function.


iterate

public final void iterate()
Causes the simulator to iterate itself, followed by calling handleIterate() on all experiments in this experiment tree.


handleIterate

protected void handleIterate()
Callback function for iterating the experiment. This function will be called after the simulator has been iterated. Sub-classes of Experiment need not re-implement this function. This function is empty by default; therefore, super.handleIterate() need not be called from re-implementations of this function.


reset

public final void reset()
Causes the simulator to reset itself, followed by calling handleReset() on all experiments in this experiment tree.


handleReset

protected void handleReset()
Callback function for resetting the experiment. This function will be called after the simulator has been reset. Sub-classes of Experiment need not re-implement this function. This function is empty by default; therefore, super.handleReset() need not be called from re-implementations of this function.


complete

public boolean complete()
Returns true if the experiment is complete. By default, this function always returns false. Classes extending Experiment should re-implement this function to return true when the experiment is complete. Also, if this class is not the root of the experiment tree, complete() will instead return parent.complete().


getMenuItems

public java.awt.Component[] getMenuItems()
Returns an array of menu items (usually in the form of JMenuItems) to be added to the GUI for this experiment. By default, this function returns null.


getGUI

public java.awt.Component getGUI()
Returns the GUI component associated with this experiment. This component will then be displayed if GraphicalUserInterface is used. This function defaults to return null. getGUI() is intended for child classes that extend Experiment to re-implement this function and return a GUI object.


handleMenuAction

public void handleMenuAction(java.awt.event.ActionEvent e,
                             java.awt.Component frame)
Callback function for when one of this experiment's menu items is acted upon.


MATES 3.0-rc2

Submit a bug or request a feature
http://mates.sourceforge.net/

Copyright 2004 Evan Sultanik