se.liu.ida.critiquer.simulation
Class DefaultAgentSimulationState

java.lang.Object
  extended by se.liu.ida.critiquer.simulation.DefaultAgentSimulationState
All Implemented Interfaces:
Serializable, AgentSimulationState, SimulationElement

public class DefaultAgentSimulationState
extends Object
implements AgentSimulationState

Author:
olale
See Also:
Serialized Form

Field Summary
static String FUEL_LEVEL
           
 
Constructor Summary
DefaultAgentSimulationState(Agent agent)
           
 
Method Summary
 void consumeActivity(Activity activity)
          When activity has finished, calculate how properties of the agent are modified
 Agent getAgent()
           
 Object getProperty(String name)
          There may be a number of properties associated with a state of an agent during a simulation.
 void initSimulation(SimulationEngine engine)
          Called every time the simulation engine starts a simulation.
 void renderState(GeoView view, Graphics2D g2)
          Render a visual representation of this agent state in the simulation view.
protected  void setProperties()
          Set the properties that define this state.
 void setProperty(String key, Object value)
          Enter property values to be used during the simulation
 void stepBackward(int step)
          Called by the simulation engine when the time is decreased in the simulation.
 void stepForward(int step)
          Move forward in the simulation with the agent
 void stepTo(Calendar time)
          Step forward or backwards in time to the absolute time time
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FUEL_LEVEL

public static final String FUEL_LEVEL
See Also:
Constant Field Values
Constructor Detail

DefaultAgentSimulationState

public DefaultAgentSimulationState(Agent agent)
Method Detail

setProperty

public void setProperty(String key,
                        Object value)
Description copied from interface: AgentSimulationState
Enter property values to be used during the simulation

Specified by:
setProperty in interface AgentSimulationState
Parameters:
key - identifying this property
value - the value

getProperty

public Object getProperty(String name)
Description copied from interface: AgentSimulationState
There may be a number of properties associated with a state of an agent during a simulation. This method returns one based on the name and type of the property. Properties may be fuel level, current radar coverage or other information.

Specified by:
getProperty in interface AgentSimulationState
Parameters:
name - of the property
Returns:
the value of property name, null if not available.

renderState

public void renderState(GeoView view,
                        Graphics2D g2)
Description copied from interface: AgentSimulationState
Render a visual representation of this agent state in the simulation view. This is one of the main purposes of a simulation: To see what the allocated resources will do over time during the simulation.

Specified by:
renderState in interface AgentSimulationState

getAgent

public Agent getAgent()
Specified by:
getAgent in interface AgentSimulationState
See Also:
AgentSimulationState.getAgent()

initSimulation

public void initSimulation(SimulationEngine engine)
Called every time the simulation engine starts a simulation. TODO: What is the semantics when simulating activities that have parents and children? Should we simply assume that there is some sensible implementation of this provided by the agents?

Specified by:
initSimulation in interface SimulationElement
See Also:
se.liu.ida.critiquer.simulation.SimulationElement#initSimulation()

stepTo

public void stepTo(Calendar time)
Step forward or backwards in time to the absolute time time

Specified by:
stepTo in interface SimulationElement
Parameters:
time - the destination time

stepForward

public void stepForward(int step)
Move forward in the simulation with the agent

Specified by:
stepForward in interface SimulationElement
Parameters:
step - in minutes forward
See Also:
SimulationElement.stepForward(int)

setProperties

protected void setProperties()
Set the properties that define this state.


consumeActivity

public void consumeActivity(Activity activity)
When activity has finished, calculate how properties of the agent are modified

Specified by:
consumeActivity in interface AgentSimulationState
Parameters:
activity -

stepBackward

public void stepBackward(int step)
Description copied from interface: SimulationElement
Called by the simulation engine when the time is decreased in the simulation. The time amount must be negative and is measured in minutes.

Specified by:
stepBackward in interface SimulationElement
Parameters:
step - in minutes backwards
See Also:
SimulationElement.stepBackward(int)