fdda.core.impl
Class DemonstratorImpl

java.lang.Object
  |
  +--fdda.core.impl.DemonstratorImpl
All Implemented Interfaces:
Demonstrator, EventListener, PropertyListener, Runnable

class DemonstratorImpl
extends Object
implements Runnable, Demonstrator, PropertyListener

Manages the demonstration of a project. Therefore, it runs an extra thread that moves the messages and calls the methods of active nodes in an 'endless' loop. Registers itself as a PropertyListener with each node and connection to be able to react to changes of the 'working' property.

Author:
Jörg Rüdenauer

Constructor Summary
DemonstratorImpl(Project project, GraphicsControl graphicsControl)
          Constructor
 
Method Summary
 void addActiveMessage(Message message)
          Adds a message to the active messages.
 void addActiveNode(Node node)
          Adds a node to the active nodes.
 Message createMessage(Node sender, Node receiver, Object payload)
          Creates a new message.
 void endPause()
          Continues the demonstration.
 Statistics getCurrentStatistics()
          Returns up-to-date statistics about the demo.
 boolean isPaused()
          Returns whether the demo is paused.
 boolean isRunning()
          Returns whether the demo is running (and not paused).
 boolean isStopped()
          Returns whether the demo is stopped.
 void pause()
          Pauses the demonstration.
 void pauseActiveNode(Node node, long timeInMillis)
          Removes a node from the active nodes for a certain time.
 void propertyAdded(PropertyEvent pe)
          Called whenever a property is added to the PropertyHolder.
 void propertyChanged(PropertyEvent pe)
          Called whenever a property of the PropertyHolder is changed.
 void propertyRemoved(PropertyEvent pe)
          Called whenever a property is removed from the PropertyHolder.
 void removeActiveNode(Node node)
          Removes a node from the active nodes.
 void reset()
          Resets the demonstrator for a new run.
 void run()
          Runs the demonstration.
 void start()
          Starts the demonstration thread.
 void stop()
          Stops the demonstration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DemonstratorImpl

public DemonstratorImpl(Project project,
                        GraphicsControl graphicsControl)
Constructor

Parameters:
project - the project that is demonstrated
graphicsControl - the graphics controlling object
Method Detail

reset

public void reset()
Resets the demonstrator for a new run. Also resets the statistics.


start

public void start()
Starts the demonstration thread.


pause

public void pause()
Pauses the demonstration. Pause will not be in effect immediately after the return of the method.


endPause

public void endPause()
Continues the demonstration. Continuation will not be in effect immediately after the return of the method.


stop

public void stop()
Stops the demonstration. Demonstration will not be stopped immediately after the return of the method.


isStopped

public boolean isStopped()
Description copied from interface: Demonstrator
Returns whether the demo is stopped.

Specified by:
isStopped in interface Demonstrator
Returns:
whether the demo is stopped

isPaused

public boolean isPaused()
Description copied from interface: Demonstrator
Returns whether the demo is paused.

Specified by:
isPaused in interface Demonstrator
Returns:
whether the demo is paused

isRunning

public boolean isRunning()
Description copied from interface: Demonstrator
Returns whether the demo is running (and not paused).

Specified by:
isRunning in interface Demonstrator
Returns:
whether the demo is paused

run

public void run()
Runs the demonstration. First registers itself as listener; than demonstrates (the actual work is done by the method doLoop); than cleans up, changes the state of the project back and informs the user. Only than, the demo counts as stopped.

Specified by:
run in interface Runnable
See Also:
Runnable.run()

addActiveNode

public void addActiveNode(Node node)
Description copied from interface: Demonstrator
Adds a node to the active nodes. That means that the run()-method of this node will be called once each cycle.

Specified by:
addActiveNode in interface Demonstrator
Parameters:
node - the node

removeActiveNode

public void removeActiveNode(Node node)
Description copied from interface: Demonstrator
Removes a node from the active nodes. That means that its run()-method won't be called anymore.

Specified by:
removeActiveNode in interface Demonstrator
Parameters:
node - the node

addActiveMessage

public void addActiveMessage(Message message)
Description copied from interface: Demonstrator
Adds a message to the active messages. That means that this message is on its way to a receiving node. Once it reaches its destination, it is automatically removed.

Specified by:
addActiveMessage in interface Demonstrator
Parameters:
message - the message

pauseActiveNode

public void pauseActiveNode(Node node,
                            long timeInMillis)
Description copied from interface: Demonstrator
Removes a node from the active nodes for a certain time. After that time, the node becomes active again. The algorithm isn't terminated while there are still nodes waiting for activation at a fixed point of time.

Specified by:
pauseActiveNode in interface Demonstrator
Parameters:
node - the node
timeInMillis - time in milliseconds after which the node will be activated

createMessage

public Message createMessage(Node sender,
                             Node receiver,
                             Object payload)
Description copied from interface: Demonstrator
Creates a new message.

Specified by:
createMessage in interface Demonstrator
Parameters:
sender - the node that sends the message
receiver - the node that shall receive the message
payload - possible payload that the message carries
Returns:
the newly created message

getCurrentStatistics

public Statistics getCurrentStatistics()
Description copied from interface: Demonstrator
Returns up-to-date statistics about the demo. These statistics even continue to get updated.

Specified by:
getCurrentStatistics in interface Demonstrator
Returns:
statistics for the demo

propertyChanged

public void propertyChanged(PropertyEvent pe)
Description copied from interface: PropertyListener
Called whenever a property of the PropertyHolder is changed.

Specified by:
propertyChanged in interface PropertyListener
Parameters:
pe - the PropertyEvent

propertyAdded

public void propertyAdded(PropertyEvent pe)
Description copied from interface: PropertyListener
Called whenever a property is added to the PropertyHolder.

Specified by:
propertyAdded in interface PropertyListener
Parameters:
pe - the PropertyEvent

propertyRemoved

public void propertyRemoved(PropertyEvent pe)
Description copied from interface: PropertyListener
Called whenever a property is removed from the PropertyHolder.

Specified by:
propertyRemoved in interface PropertyListener
Parameters:
pe - the PropertyEvent


API documentation for FDDA version 0.9. Generated on 17/02/2004 14:12.