edu.colorado.cs.ns2.animation
Class Animate

java.lang.Object
  extended by edu.colorado.cs.ns2.animation.Animate
All Implemented Interfaces:
java.lang.Runnable

public class Animate
extends java.lang.Object
implements java.lang.Runnable

This class implements the animation thread. It is responsible for populating the simulatio nevent TimeLine and animating the Packet Flow.

Author:
Kevin Bauer, Pushkar Sambhoos.
See Also:
Runnable

Field Summary
private  java.awt.Container contentPane
          A Reference to the JFrame's contentPane.
private  DrawableMover mover
          A Reference to the DrawableMover object.
private  java.util.Vector<TimeLine> timeLine
          A time line of simulation events.
 
Constructor Summary
Animate(java.awt.Container contentPane, DrawableMover mover)
          Constructor.
 
Method Summary
 void drawPacket(int X, int Y, int packetSize)
          Draw a Rectangle to represent the packet.
 void erasePacket(int X, int Y, int packetSize)
          Erase the Rectangle at the given Location.
 java.util.Vector<java.awt.Point> getPacketFlow(int fromNode, int toNode, int noOfPoints)
          Calculates the set of Co-ordinates at which the packet component should be drawn in the Animation.
 void run()
          This is the animation thread's main entry point.
 void setupTimeLine()
          Sets up the TimeLine of events that need to be animated and stores it as a Vector of TimeLine Objects.
 void sortTimeLine()
          Sort the TimeLine Vector using Quicksort.
 void startAnimation(int increment)
          Reads the TimeLine Vector and animates pakcets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

contentPane

private java.awt.Container contentPane
A Reference to the JFrame's contentPane.


mover

private DrawableMover mover
A Reference to the DrawableMover object.


timeLine

private java.util.Vector<TimeLine> timeLine
A time line of simulation events.

Constructor Detail

Animate

public Animate(java.awt.Container contentPane,
               DrawableMover mover)
Constructor.

Parameters:
contentPane -
mover -
Method Detail

run

public void run()
This is the animation thread's main entry point. The animation thread must setup the simulation event time line, sort the time line, and start the animation.

Specified by:
run in interface java.lang.Runnable

getPacketFlow

public java.util.Vector<java.awt.Point> getPacketFlow(int fromNode,
                                                      int toNode,
                                                      int noOfPoints)
Calculates the set of Co-ordinates at which the packet component should be drawn in the Animation.

Parameters:
fromNode - - Read from the out.nam File
toNode - - Read from the out.nam File
noOfPoints - - The number of Points between two nodes where packet needs to be drawn.
Returns:
- An Vector of Points containing the co-ordinates of the locations of packet to be drawn.

setupTimeLine

public void setupTimeLine()
Sets up the TimeLine of events that need to be animated and stores it as a Vector of TimeLine Objects.


startAnimation

public void startAnimation(int increment)
Reads the TimeLine Vector and animates pakcets.

Parameters:
increment - - Time Interval in ms for incrementing the simulation time period.

sortTimeLine

public void sortTimeLine()
Sort the TimeLine Vector using Quicksort.


drawPacket

public void drawPacket(int X,
                       int Y,
                       int packetSize)
Draw a Rectangle to represent the packet.

Parameters:
X - x co-ordinate for the Rectangle
Y - y co-ordinate for the Rectangle
packetSize - - the size of the rectangle - currently ignored

erasePacket

public void erasePacket(int X,
                        int Y,
                        int packetSize)
Erase the Rectangle at the given Location.

Parameters:
X - x co-ordinate for the Rectangle
Y - y co-ordinate for the Rectangle
packetSize - - the size of the rectangle - currently ignored