generator2
Class MovingObject

java.lang.Object
  |
  +--generator2.MovingObject

public class MovingObject
extends java.lang.Object

Class representing a moving object.


Constructor Summary
MovingObject(int id, int objClass, Node start, Node dest, int time)
          Constructor.
 
Method Summary
 void addToContainer(MovingObjects container)
          Adds the moving object to the container.
static double computeDistance(double x1, double y1, double x2, double y2)
          Computes the distance between two points.
 boolean computeRoute()
          Computes a new route from the current position of the object to its destination.
protected  void decreaseUsage(PathEdge actPathEdge)
          Decreases the usage in the path until one path edge is reached.
protected  PathEdge getActPathEdge()
          Return the current path edge where the object is.
protected  Node getDestinationNode()
          Return the destination node.
 int getId()
          Returns the identifier of the object.
 int getObjectClass()
          Returns the object class.
 int getRepNum()
          Returns the report number of the object.
protected  Node getStartingNode()
          Return the starting node.
 boolean move(int newTime, Reporter reporter)
          Moves the object to the position at the new time.
 void reportEnd(Reporter reporter)
          Reports that the moving object has reached its destination.
 void reportNewObject(Reporter reporter)
          Reports a new moving object.
 void setDestination(Node dest)
          Sets the destination node.
 void setRepNum(int num)
          Sets the report number of the object.
 void setStart(Node start)
          Sets the starting node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MovingObject

public MovingObject(int id,
                    int objClass,
                    Node start,
                    Node dest,
                    int time)
Constructor.

Parameters:
id - object identifier
objClass - object class
start - starting node
dest - destination node
time - starting time
Method Detail

addToContainer

public void addToContainer(MovingObjects container)
Adds the moving object to the container.

Parameters:
container - container

computeDistance

public static double computeDistance(double x1,
                                     double y1,
                                     double x2,
                                     double y2)
Computes the distance between two points.

Parameters:
x1 - x-coordinate of the 1st point
y1 - y-coordinate of the 1st point
x2 - x-coordinate of the 2nd point
y2 - y-coordinate of the 2nd point
Returns:
distance

computeRoute

public boolean computeRoute()
Computes a new route from the current position of the object to its destination.

Returns:
computation successful?

decreaseUsage

protected void decreaseUsage(PathEdge actPathEdge)
Decreases the usage in the path until one path edge is reached.

Parameters:
actPathEdge - the path edge which stops the operation

getActPathEdge

protected PathEdge getActPathEdge()
Return the current path edge where the object is.

Returns:
current path edge

getDestinationNode

protected Node getDestinationNode()
Return the destination node.

Returns:
destination

getId

public int getId()
Returns the identifier of the object.

Returns:
the id

getObjectClass

public int getObjectClass()
Returns the object class.

Returns:
the class

getRepNum

public int getRepNum()
Returns the report number of the object.

Returns:
report number

getStartingNode

protected Node getStartingNode()
Return the starting node.

Returns:
start

move

public boolean move(int newTime,
                    Reporter reporter)
Moves the object to the position at the new time. The position(s) are reported.

Parameters:
newTime - new time
reporter - reporter
Returns:
has the object reached its destination?

reportEnd

public void reportEnd(Reporter reporter)
Reports that the moving object has reached its destination.

Parameters:
reporter - reporter

reportNewObject

public void reportNewObject(Reporter reporter)
Reports a new moving object.

Parameters:
reporter - the reporter object

setDestination

public void setDestination(Node dest)
Sets the destination node.


setRepNum

public void setRepNum(int num)
Sets the report number of the object.

Parameters:
num - the new report number

setStart

public void setStart(Node start)
Sets the starting node.