Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

traffic
Class OVehicle  view OVehicle download OVehicle.java

java.lang.Object
  extended bytraffic.OVehicle
All Implemented Interfaces:
java.io.Serializable

public class OVehicle
extends java.lang.Object
implements java.io.Serializable

Cars and Trucks that travel from one OFragment to the next as they navigate through the OCity.

Since:
2003/06/07 04:25:52
Version:
1.7, 2003/08/01 17:39:53

Field Summary
private  boolean leftfrag
           
private  float location
           
private  boolean looptrip
           
private  int mapx
           
private  int mapy
           
private  float speed
           
private  boolean stalled
           
private  float stopleft
           
private  int turnpref
           
private  float vlength
           
 
Constructor Summary
OVehicle(float speed, float location, float space)
          Constructs an OVehicle object.
 
Method Summary
 OVehicle copyVeh()
          Constructs a copy OVehicle object.
 float getLocation()
          Gets the OVehicle location within the OFragment.
 int getMapX()
          Gets the OVehicle X map coordinate.
 int getMapY()
          Gets the OVehicle Y map coordinate.
 float getSpeed()
          Gets the actual OVehicle current speed.
 int getTurnPref()
          Gets the OVehicle turn preference.
 float getVLength()
          Gets the OVehicle spacing.
 boolean hasLeftFrag()
          True if the OVehicle has left an OFragment.
 void incStopTime(float time)
          Change the OVehicle stop time.
 boolean isLTripped()
          True if the OVehicle has already tripped a loop.
 boolean isStalled()
          True if the OVehicle is currently stalled.
 boolean moreStopTime()
          True if the OVehicle needs to sit at the stop sign a while longer.
 float moveVeh(float MPH, boolean green)
          Move the OVehicle.
 void setLeftFrag(boolean state)
          Specify that the OVehicle has left an OFragment.
 void setLocation(float loc)
          Sets the OVehicle location within the OFragment.
 void setLTripped(boolean state)
          Specify that the OVehicle has already tripped a loop.
 void setmapcoords(int xx1, int yy1)
          Sets the OVehicle X and Y map coordinate.
 void setSpeed(float spd)
          Sets the actual OVehicle current speed.
 void setStalled(boolean state)
          Specify that the OVehicle is currently stalled.
 void setTurnPref(int tpf)
          Sets the OVehicle turn preference.
 void setVLength(float spc)
          Sets the OVehicle spacing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

speed

private float speed

mapx

private int mapx

mapy

private int mapy

turnpref

private int turnpref

location

private float location

vlength

private float vlength

stopleft

private float stopleft

leftfrag

private boolean leftfrag

stalled

private boolean stalled

looptrip

private boolean looptrip
Constructor Detail

OVehicle

public OVehicle(float speed,
                float location,
                float space)
Constructs an OVehicle object.

Method Detail

copyVeh

public OVehicle copyVeh()
Constructs a copy OVehicle object. This is the simpelest way to move from one OFragment to another


getTurnPref

public int getTurnPref()
Gets the OVehicle turn preference. The turn preference is the direction that the vehicle will turn at the next OIntersection. The values are:
  • R - Vehicle will turn right
  • L - Vehicle will turn left
  • S - Vehicle will go straight
  • N - Vehicle is not approaching an intersection and therefore has no preference.


setTurnPref

public void setTurnPref(int tpf)
Sets the OVehicle turn preference. The turn preference is the direction that the vehicle will turn at the next OIntersection. The values are:
  • R - Vehicle will turn right
  • L - Vehicle will turn left
  • S - Vehicle will go straight
  • N - Vehicle is not approaching an intersection and therefore has no preference.


getSpeed

public float getSpeed()
Gets the actual OVehicle current speed.


setSpeed

public void setSpeed(float spd)
Sets the actual OVehicle current speed.


moveVeh

public float moveVeh(float MPH,
                     boolean green)
Move the OVehicle. This method changes the current speed according to the need for de/acceleration. The maximum speed is always 0.1F

The Acceleration is:
speed = (1+(0.1F - speed)*50/MPH)*speed;

The Deceleration is:
speed = speed/1.3F;


getLocation

public float getLocation()
Gets the OVehicle location within the OFragment. The starting location is the length of the OFragment. The ending location is zero.


setLocation

public void setLocation(float loc)
Sets the OVehicle location within the OFragment. The starting location is the length of the OFragment. The ending location is zero.


getVLength

public float getVLength()
Gets the OVehicle spacing. (front bumper to front bumper) This combines the vehicle length and separation values from OCity.


setVLength

public void setVLength(float spc)
Sets the OVehicle spacing. (front bumper to front bumper) This combines the vehicle length and separation values from OCity.


getMapX

public int getMapX()
Gets the OVehicle X map coordinate.


getMapY

public int getMapY()
Gets the OVehicle Y map coordinate.


setmapcoords

public void setmapcoords(int xx1,
                         int yy1)
Sets the OVehicle X and Y map coordinate.


hasLeftFrag

public boolean hasLeftFrag()
True if the OVehicle has left an OFragment. Once a copy of the vehicle is placed on a new fragment or the vehicle reaches the edge of the map the old vehicle is marked as having left and it is deleted.


setLeftFrag

public void setLeftFrag(boolean state)
Specify that the OVehicle has left an OFragment. Once a copy of the vehicle is placed on a new fragment or the vehicle reaches the edge of the map the old vehicle is marked as having left and it is deleted.


isLTripped

public boolean isLTripped()
True if the OVehicle has already tripped a loop. This switch is used to avoid double counting vehicles when applying density actuation. Vehicles that are past the loop when the light first turns green are marked as such.


setLTripped

public void setLTripped(boolean state)
Specify that the OVehicle has already tripped a loop. This switch is used to avoid double counting vehicles when applying density actuation. Vehicles that are past the loop when the light first turns green are marked as such.


isStalled

public boolean isStalled()
True if the OVehicle is currently stalled. A stalled vehicle shows red on the map and decelerates if it isn't already completely stopped. Vehicles stall when they hit a red light, a stop sign or the car ahead of them.


setStalled

public void setStalled(boolean state)
Specify that the OVehicle is currently stalled. A stalled vehicle shows red on the map and decelerates if it isn't already completely stopped. Vehicles stall when they hit a red light, a stop sign or the car ahead of them.


moreStopTime

public boolean moreStopTime()
True if the OVehicle needs to sit at the stop sign a while longer. There is a minimum time that a vehicle will stop at a stop sign even if no traffic is present. Half that time is added to the stop time for every vehicle that crosses the intersection while a vehicle is waiting (to allow time for the other vehicle to clear the intersection).

This method also initializes and decrements the stop time.


incStopTime

public void incStopTime(float time)
Change the OVehicle stop time. There is a minimum time that a vehicle will stop at a stop sign even if no traffic is present. Half that time is added to the stop time for every vehicle that crosses the intersection while a vehicle is waiting (to allow time for the other vehicle to clear the intersection).