package genegui; import java.awt.Color; import java.util.ArrayList; import java.util.Enumeration; import java.util.Vector; import main.Model; import main.NodeTemplate; /** ModelState.java Maintains a ModelState to be used for specifying intial states and stoppers.

@author WJS */ public class ModelState { /** The unique ModelStateNodePalette attached to this ModelState */ private ModelStateNodePalette ActiveModelStateNodePalette; /** The active ModelStateView window */ private ModelStateView ActiveModelStateView; /** An array of CellState for each cell in the ModelState */ private CellState[] CellStateArray; /** A vector of ModelStateChangeListeners */ private Vector ModelStateChangeListeners = new Vector(); /** Each element in the array is an ArrayList of NodeStateChangeListeners */ private ArrayList[] NodeListeners; /** An array of of NodeTemplates */ private NodeTemplate[] NodeTemplates; /** A pointer to the Model that this ModelState is for */ private Model TheModel; /** Pointer to the ModelStateEditor that is bound to this ModelState */ private ModelStateEditor TheModelStateEditor; /** A time value for the ModelState */ private float Time = 0.0f; /** The unique ModelStateToolBox attached to this ModelState */ private ModelStateToolBox ToolBox; /** A list of all known ModelStateViews attached to this palette */ private Vector ViewList = new Vector(); /** Simple constructor does little to be proud of. Used primarily by the cloneState operation. @author WJS */ public ModelState() { } /** Constructor initializes the ModelState based upon a passed Model. @param Model model - Model object that the ModelState is to be built for. @author WJS */ public ModelState(Model model) { TheModel = model; // Build CellStateArray and NodeListenerArray based upon Model values CellStateArray = new CellState[TheModel.numCells]; for (int i=0;i0) setActiveModelStateView((ModelStateView)ViewList.get(i-1)); else setActiveModelStateView(null); } ViewList.remove(view); TheModelStateEditor.closeModelStateView(view); } /** Removes a NodeStateChangeListener from the ModelState. @param NodeStateChangeListener listener - The NodeStateChangeListener. @param int index - The index of the node the listener is to be attachted to. @author WJS */ public void removeStateChangeListener(NodeStateChangeListener listener, int index) { NodeListeners[index].remove(listener); } /** Resets the values of all nodes for all cells to 0. @author WJS */ public void reset() { // Reset all the cells to 0 for (int i=0;i