genegui
Class ModelState

java.lang.Object
  extended bygenegui.ModelState

public class ModelState
extends java.lang.Object

ModelState.java Maintains a ModelState to be used for specifying intial states and stoppers.


Constructor Summary
ModelState()
          Simple constructor does little to be proud of.
ModelState(Model model)
          Constructor initializes the ModelState based upon a passed Model.
 
Method Summary
 void addModelStateChangeListener(ModelStateChangeListener listener)
          Called to add a new ModelStateChangeListener.
 void addModelStateView(ModelStateView view)
          Called to add a new ModelStateView to the local list.
 void addStateChangeListener(NodeStateChangeListener listener, int index)
          Adds a NodeStateChangeListener to the ModelState.
 ModelState cloneState()
          Makes a duplicate of this model state.
 void copyCellValues(int toCell, int fromCell)
          Copies all the values for one cell to another
 ModelStateView getActiveModelStateView()
          Gets the currently active (selected) ModelStateView.
 CellState getCellState(int cellIndex)
          Returns the CellState for the cell with the given index.
 CellState[] getCellStateArray()
          Returns the CellStateArray - Used by serialization
 Model getModel()
          Returns the Model that this is a ModelState for.
 java.awt.Color getNodeColor(int index)
          Returns the color for this type of node.
 NodeTemplate[] getNodeTemplates()
          Returns the array of NodeTemplates.
 int getNumberOfCells()
          Returns the number of cells in the model.
 int getNumberOfNodes()
          Returns the number of different types of nodes in the model.
 float getTime()
          Returns the ModelState time
 ModelStateToolBox getToolBox()
          Returns the one and only ModelStateToolBox attached to this ModelState
 void removeAllModelStateViews()
          Removes all ModelStateViews, disposing of them and clearing the local list.
 void removeModelStateChangeListener(ModelStateChangeListener listener)
          Called to remove a ModelStateChangeListener.
 void removeModelStateView(ModelStateView view)
          Called to remove a ModelStateView from the local list.
 void removeStateChangeListener(NodeStateChangeListener listener, int index)
          Removes a NodeStateChangeListener from the ModelState.
 void reset()
          Resets the values of all nodes for all cells to 0.
 void setActiveModelStateNodePalette(ModelStateNodePalette palette)
          Sets the one and only ModelStateNodePalette attached to thsi ModelState.
 void setActiveModelStateView(ModelStateView modelStateView)
          Sets the ModelStateView that is currently active (selected).
 void setCellState(int cellIndex, CellState state)
          Sets the CellState for the given cell to that of a new CellState.
 void setCellStateArray(CellState[] cellStateArray)
          Replaces the entire CellStateArray with a new one.
 void setModel(Model theModel)
          Sets the model.
 void setModelStateEditor(ModelStateEditor modelStateEditor)
          Sets a ModelStateEditor to be used with this ModelState if there is one
 void setNodeTemplates(NodeTemplate[] templates)
          Sets the node template array.
 void setSelectedCells(boolean[] selectedCells)
          Accepts a list of cells that are selected in a ModelStateView and updates the ActiveModelStateNodePalette.
 void setTime(float time)
          Sets the time.
 void setToolBox(ModelStateToolBox toolBox)
          Sets the one and only ModelStateToolBox attached to this ModelState.
 void updateCell(int cellIndex)
          Udates the values for a cell and notifies all node listeners that a change has occurred so the cell may be repainted were needed.
 void updateModel(Model model, float time)
          Called to completely update the values of the ModelState based upon a passed Model.
 void updateNodeValue(int index, float value)
          Updates all the value for a node for all the selected cells in the currently active ModelStateView.
 void updateNodeValue(int cellIndex, int nodeIndex, float value, ModelStateChangeListener source)
          Updates the value in a node for a state
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelState

public ModelState()
Simple constructor does little to be proud of. Used primarily by the cloneState operation.


ModelState

public ModelState(Model model)
Constructor initializes the ModelState based upon a passed Model.

Method Detail

addModelStateChangeListener

public void addModelStateChangeListener(ModelStateChangeListener listener)
Called to add a new ModelStateChangeListener.


addModelStateView

public void addModelStateView(ModelStateView view)
Called to add a new ModelStateView to the local list.


addStateChangeListener

public void addStateChangeListener(NodeStateChangeListener listener,
                                   int index)
Adds a NodeStateChangeListener to the ModelState.


cloneState

public ModelState cloneState()
Makes a duplicate of this model state. Note: this does not copy all the values. It just copies those that are important for representing the model state itself. Things like listeners are note copied.


copyCellValues

public void copyCellValues(int toCell,
                           int fromCell)
Copies all the values for one cell to another


getActiveModelStateView

public ModelStateView getActiveModelStateView()
Gets the currently active (selected) ModelStateView.

Returns:
ModelStateView - The currently selected ModelStateView.

getCellState

public CellState getCellState(int cellIndex)
Returns the CellState for the cell with the given index.

Returns:
CellState - The CellState for the cell.

getCellStateArray

public CellState[] getCellStateArray()
Returns the CellStateArray - Used by serialization

Returns:
CellState[] - The CellStateArray.

getModel

public Model getModel()
Returns the Model that this is a ModelState for.

Returns:
Model - The Model that this is a ModelState for.

getNodeColor

public java.awt.Color getNodeColor(int index)
Returns the color for this type of node. The node color is the color a cell will have if the node is the only node being viewed and it's maximum value (100%).

Returns:
Color - The color of the node when at its maximum value.

getNodeTemplates

public NodeTemplate[] getNodeTemplates()
Returns the array of NodeTemplates.

Returns:
NodeTemplate[]

getNumberOfCells

public int getNumberOfCells()
Returns the number of cells in the model.

Returns:
int - The number of cells in the model.

getNumberOfNodes

public int getNumberOfNodes()
Returns the number of different types of nodes in the model.

Returns:
int - The number of different types of nodes in the model.

getTime

public float getTime()
Returns the ModelState time

Returns:
float - The ModelState time

getToolBox

public ModelStateToolBox getToolBox()
Returns the one and only ModelStateToolBox attached to this ModelState

Returns:
ModelStateToolBox - The one and only ModelStateToolBox.

removeAllModelStateViews

public void removeAllModelStateViews()
Removes all ModelStateViews, disposing of them and clearing the local list. Usually used for close operations.


removeModelStateChangeListener

public void removeModelStateChangeListener(ModelStateChangeListener listener)
Called to remove a ModelStateChangeListener.


removeModelStateView

public void removeModelStateView(ModelStateView view)
Called to remove a ModelStateView from the local list.


removeStateChangeListener

public void removeStateChangeListener(NodeStateChangeListener listener,
                                      int index)
Removes a NodeStateChangeListener from the ModelState.


reset

public void reset()
Resets the values of all nodes for all cells to 0.


setActiveModelStateNodePalette

public void setActiveModelStateNodePalette(ModelStateNodePalette palette)
Sets the one and only ModelStateNodePalette attached to thsi ModelState.


setActiveModelStateView

public void setActiveModelStateView(ModelStateView modelStateView)
Sets the ModelStateView that is currently active (selected). Releases the old ModelViewState and updates the ModelStateNodePalette.


setCellState

public void setCellState(int cellIndex,
                         CellState state)
Sets the CellState for the given cell to that of a new CellState. The new CellStates values are copied into the CellState of the selecetd cell.


setCellStateArray

public void setCellStateArray(CellState[] cellStateArray)
Replaces the entire CellStateArray with a new one.


setModel

public void setModel(Model theModel)
Sets the model.


setModelStateEditor

public void setModelStateEditor(ModelStateEditor modelStateEditor)
Sets a ModelStateEditor to be used with this ModelState if there is one


setNodeTemplates

public void setNodeTemplates(NodeTemplate[] templates)
Sets the node template array.


setSelectedCells

public void setSelectedCells(boolean[] selectedCells)
Accepts a list of cells that are selected in a ModelStateView and updates the ActiveModelStateNodePalette. This presents a small problem when more than one cell is selected and the selected cells have different values for one or more nodes. In this case the ModelStateNodePalette will display a blank.


setTime

public void setTime(float time)
Sets the time.


setToolBox

public void setToolBox(ModelStateToolBox toolBox)
Sets the one and only ModelStateToolBox attached to this ModelState.


updateCell

public void updateCell(int cellIndex)
Udates the values for a cell and notifies all node listeners that a change has occurred so the cell may be repainted were needed.


updateModel

public void updateModel(Model model,
                        float time)
Called to completely update the values of the ModelState based upon a passed Model. This may be used for initializing the values when a new ModelStateEditor is invoked. It is also used after every integration step when a CellViewer is attached.


updateNodeValue

public void updateNodeValue(int index,
                            float value)
Updates all the value for a node for all the selected cells in the currently active ModelStateView.


updateNodeValue

public void updateNodeValue(int cellIndex,
                            int nodeIndex,
                            float value,
                            ModelStateChangeListener source)
Updates the value in a node for a state