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

Quick Search    Search Deep

traffic
Class OFragment  view OFragment download OFragment.java

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

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

a street Fragment is an unbroken piece of street that has a constant speed, number of lanes and direction. Fragments also begin and end at intersections or other entrances and exits. Fragments are created by the GStreet panel, held by OStreet and contain OVehicles.

Since:
2003/06/17 01:28:43
Version:
1.5, 2003/08/01 17:39:53

Field Summary
private  float edensity
           
private  boolean eintr
           
private  int einum
           
private  float flength
           
private  int lanecount
           
private  boolean mapped
           
private  int mapx1
           
private  int mapx2
           
private  int mapy1
           
private  int mapy2
           
private  int MPH
           
private  double orientation
           
private  java.util.Vector platoon
           
private  float prevloc
           
private  int sdensity
           
private  boolean sintr
           
private  int sinum
           
private  float slength
           
private  int timeleft
           
private  float xlength
           
private  float ylength
           
 
Constructor Summary
OFragment(double ornt, int speed, float slength, float flength, int lanecount)
          Constructs the OFragment.
 
Method Summary
 void addVehicle(OVehicle car)
          Adds OVehicle to the end of the queue.
 void changeFrag(OVehicle veh, OVehicle vehx, OFragment fragx)
          Moves an OVehicle from one OFragment to the next.
 void exitVehicle(int index)
          Removes OVehicle from the queue.
 float getEDensity()
          Gets the OFragment exit density.
 int getEInum()
          Gets the OFragment ending OIntersection number
 float getFLth()
          Gets the OFragment length in yards or meters
 int getLanes()
          Gets the OFragment number of lanes
 int getMapX1()
          Gets the OFragment starting X map coordinate.
 int getMapX2()
          Gets the OFragment ending X map coordinate.
 int getMapY1()
          Gets the OFragment starting Y map coordinate.
 int getMapY2()
          Gets the OFragment ending Y map coordinate.
 float getPrevLoc()
          Gets the location of the previous OVehicle within the OFragment.
 int getSDensity()
          Gets the time till next car enters the OFragment.
 int getSInum()
          Gets the OFragment starting OIntersection number
 float getSLth()
          Gets the OFragment length in seconds
 double getSSOrnt()
          Gets the OFragment orientation, or direction in degrees.
 int getVehCount()
          Gets the number of OVehicles contained in this OFragment.
 int getVehMPH()
          Gets the OFragment speed limit (works for KPH too).
 float getXLth()
          Gets the OFragment length in seconds in the X direction.
 float getYLth()
          Gets the OFragment length in seconds in the Y direction.
 boolean isEIntr()
          True if OFragment ends at an OIntersection
 boolean isMapped()
          True if OFragment has been mapped.
 boolean isSIntr()
          True if OFragment starts at an OIntersection
 void runTraffic(OStreet sss)
          Create, distroy, move and make turning decisions for OVehicles.
 void setEDensity(float edens)
          Sets the OFragment exit density.
 void setEIntr(boolean state)
          Set OFragment OIntersection endiness.
 void setEInum(int inum)
          Sets the OFragment ending OIntersection number.
 void setFLth(float length)
          Sets the OFragment length in yards or meters.
 void setLanes(int lanes)
          Sets the OFragment number of lanes
 void setMapCoords(int xx1, int xx2, int yy1, int yy2)
          Sets the OFragment starting and ending X and Y map coordinates.
 void setMapped(boolean state)
          Sets the OFragment mapped state.
 void setSDensity(int sdens)
          Sets the time till next car enters the OFragment.
 void setSIntr(boolean state)
          Set OFragment OIntersection startiness.
 void setSInum(int inum)
          Sets the OFragment starting OIntersection number.
 void setSLth(float slength)
          Gets the OFragment length in seconds.
 void setSSOrnt(double ornt)
          Gets the OFragment orientation, or direction in degrees.
 void setVehMPH(int speed)
          Sets the OFragment speed limit (works for KPH too).
 OVehicle useVeh(int index)
          Gets an OVehicle object from this OFragment.
 void zeroTimeLeft()
          Sets the time till next car enters the OFragment to zero.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

orientation

private double orientation

MPH

private int MPH

slength

private float slength

flength

private float flength

xlength

private float xlength

ylength

private float ylength

prevloc

private float prevloc

lanecount

private int lanecount

sdensity

private int sdensity

edensity

private float edensity

timeleft

private int timeleft

sintr

private boolean sintr

sinum

private int sinum

eintr

private boolean eintr

einum

private int einum

mapx1

private int mapx1

mapx2

private int mapx2

mapy1

private int mapy1

mapy2

private int mapy2

mapped

private boolean mapped

platoon

private java.util.Vector platoon
Constructor Detail

OFragment

public OFragment(double ornt,
                 int speed,
                 float slength,
                 float flength,
                 int lanecount)
Constructs the OFragment. OFragments are created on the GStreet panel. Once created, it will be added to an OStreet.

Method Detail

addVehicle

public void addVehicle(OVehicle car)
Adds OVehicle to the end of the queue. This method is not directly user accessable. Cars are added by the OFragment runTraffic method. The number of cars to be added is detailed in the GDensity panel.


exitVehicle

public void exitVehicle(int index)
Removes OVehicle from the queue. This method is not directly user accessable. Cars are removed by the OFragment runTraffic method. The number of cars to be removed is detailed in the GDensity panel.


getVehMPH

public int getVehMPH()
Gets the OFragment speed limit (works for KPH too).


setVehMPH

public void setVehMPH(int speed)
Sets the OFragment speed limit (works for KPH too).


getLanes

public int getLanes()
Gets the OFragment number of lanes


setLanes

public void setLanes(int lanes)
Sets the OFragment number of lanes


getSLth

public float getSLth()
Gets the OFragment length in seconds


setSLth

public final void setSLth(float slength)
Gets the OFragment length in seconds.


getFLth

public float getFLth()
Gets the OFragment length in yards or meters


setFLth

public final void setFLth(float length)
Sets the OFragment length in yards or meters.


getXLth

public float getXLth()
Gets the OFragment length in seconds in the X direction. This is needed for mapping the OFragment.


getYLth

public float getYLth()
Gets the OFragment length in seconds in the Y direction. This is needed for mapping the OFragment.


getPrevLoc

public float getPrevLoc()
Gets the location of the previous OVehicle within the OFragment. This method is used to tell if a car is too close to the car ahead of it.


setSSOrnt

public void setSSOrnt(double ornt)
Gets the OFragment orientation, or direction in degrees.


getSSOrnt

public double getSSOrnt()
Gets the OFragment orientation, or direction in degrees.


isSIntr

public boolean isSIntr()
True if OFragment starts at an OIntersection


setSIntr

public void setSIntr(boolean state)
Set OFragment OIntersection startiness.


isEIntr

public boolean isEIntr()
True if OFragment ends at an OIntersection


setEIntr

public void setEIntr(boolean state)
Set OFragment OIntersection endiness.


getSInum

public int getSInum()
Gets the OFragment starting OIntersection number


setSInum

public void setSInum(int inum)
Sets the OFragment starting OIntersection number.


getEInum

public int getEInum()
Gets the OFragment ending OIntersection number


setEInum

public void setEInum(int inum)
Sets the OFragment ending OIntersection number.


zeroTimeLeft

public void zeroTimeLeft()
Sets the time till next car enters the OFragment to zero. This is the counter for the tenth seconds entered on the GDensity panel. It is zeroed when traffic is eXpunged.


getSDensity

public int getSDensity()
Gets the time till next car enters the OFragment. These are the number of tenth seconds (sec/10) that pass between vehicle entry events. These tenth seconds are entered on the GDensity panel.


setSDensity

public void setSDensity(int sdens)
Sets the time till next car enters the OFragment. These are the number of tenth seconds (sec/10) that pass between vehicle entry events. These tenth seconds are entered on the GDensity panel.


getEDensity

public float getEDensity()
Gets the OFragment exit density. Exits are entered as a % chance that a vehicle will leave.


setEDensity

public void setEDensity(float edens)
Sets the OFragment exit density. Exits are entered as a % chance that a vehicle will leave.


isMapped

public boolean isMapped()
True if OFragment has been mapped. Once a fragment has been mapped it contains it's map coordinates and can be drawn on the map without further calculation.


setMapped

public void setMapped(boolean state)
Sets the OFragment mapped state. Once a fragment has been mapped it contains it's map coordinates and can be drawn on the map without further calculation.


getMapX1

public int getMapX1()
Gets the OFragment starting X map coordinate.


getMapX2

public int getMapX2()
Gets the OFragment ending X map coordinate.


getMapY1

public int getMapY1()
Gets the OFragment starting Y map coordinate.


getMapY2

public int getMapY2()
Gets the OFragment ending Y map coordinate.


setMapCoords

public void setMapCoords(int xx1,
                         int xx2,
                         int yy1,
                         int yy2)
Sets the OFragment starting and ending X and Y map coordinates. Due to the complexities of mapping, the words starting and ending may be somewhat relative.


getVehCount

public int getVehCount()
Gets the number of OVehicles contained in this OFragment.


useVeh

public OVehicle useVeh(int index)
Gets an OVehicle object from this OFragment.


runTraffic

public void runTraffic(OStreet sss)
Create, distroy, move and make turning decisions for OVehicles. Fragments at an intersection are numbered counter-clockwise. This method is called by the JavaDriver runTraffic method.


changeFrag

public void changeFrag(OVehicle veh,
                       OVehicle vehx,
                       OFragment fragx)
Moves an OVehicle from one OFragment to the next. The 'next' is determined before this method is called.