net.kolls.railworld.tuic
Class TrainDirectionFinder

java.lang.Object
  extended by net.kolls.railworld.TrainUIController
      extended by net.kolls.railworld.tuic.TrainDirectionFinder

public class TrainDirectionFinder
extends TrainUIController

Determine the direction of a train in both radians and words. Only the lead car is considered; to indicate that a new train is being tested, call the reset() method between trains.

Author:
Steve Kollmansberger

Field Summary
 java.lang.String adesc
          When the direction is found, this will describe the direction of the lead car.
 double angle
          When the direction is found, this will contain the angle of the lead car in radians.
 
Constructor Summary
TrainDirectionFinder()
          Create a train direction finder
 
Method Summary
 void car(Car c, CLoc begin, CLoc end)
          For each Car, including a beginning and ending position.
 void reset()
          Prepare for a new train.
 void segment(Car c, java.awt.geom.Line2D l)
          For each visible segment (there may be multiple segments per car, or even 0 if the car is hidden).
 
Methods inherited from class net.kolls.railworld.TrainUIController
act
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

angle

public double angle
When the direction is found, this will contain the angle of the lead car in radians.


adesc

public java.lang.String adesc
When the direction is found, this will describe the direction of the lead car. For example, "south" or "northwest"

Constructor Detail

TrainDirectionFinder

public TrainDirectionFinder()
Create a train direction finder

Method Detail

reset

public void reset()
Prepare for a new train.


car

public void car(Car c,
                CLoc begin,
                CLoc end)
Description copied from class: TrainUIController
For each Car, including a beginning and ending position. These are given regardless of whether or not the Car is all or partially hidden.

Specified by:
car in class TrainUIController
Parameters:
c - The Car involved.
begin - Starting position.
end - Final position.

segment

public void segment(Car c,
                    java.awt.geom.Line2D l)
Description copied from class: TrainUIController
For each visible segment (there may be multiple segments per car, or even 0 if the car is hidden).

Specified by:
segment in class TrainUIController
Parameters:
c - The Car involved.
l - The current segment. There may be multiple calls to segment per Car.