Class jovial.slotCar.track.TrackPosition
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jovial.slotCar.track.TrackPosition

java.lang.Object
   |
   +----jovial.slotCar.track.TrackPosition

public class TrackPosition
extends Object
Represents a position on a Track. Understands how to move along a track, and can deliver an x,y position, and the orientation of an object moving along the track.
See Also:
Track, TrackSegment

Constructor Index

 o TrackPosition(int, TrackSegment)
Initialize a new position

Method Index

 o distance()
 o height()
 o moveBy(double)
Move our position
 o orientation()
Report the orientation of an object going down the track at the position we represent
 o position()
Report the x,y position we represent
 o setCurrSegment(TrackSegment)
Change the current track segment.
 o setDistance(double)
Change our distance along segment.
 o setOrientation(double)
Change the value of orientation.
 o setPosition(Point)
Change our position.
 o slot()

Constructors

 o TrackPosition
  public TrackPosition(int slot,
                       TrackSegment start)
Initialize a new position
Parameters:
slot - The slot we're in. Either 0 or 1.
start - The piece of track we start on

Methods

 o moveBy
  public void moveBy(double distance)
Move our position
Parameters:
dist - Distance to move (in pixels)
 o position
  public Point position()
Report the x,y position we represent
Returns:
the position
 o orientation
  public double orientation()
Report the orientation of an object going down the track at the position we represent
Returns:
The angle. 0 is 3 o'clock, increasing angles go CCW
 o height
  public int height()
Returns:
the height associated with our position
 o slot
  public int slot()
Returns:
The slot we represent, 0 or 1
 o distance
  protected double distance()
Returns:
the distance along the current segment
 o setDistance
  protected void setDistance(double dist)
Change our distance along segment. Should only be called by TrackSegment.
Parameters:
dist - The new distance along our current track segment
 o setOrientation
  protected void setOrientation(double o)
Change the value of orientation. Should only be called by TrackSegment.
Parameters:
o - The new orientation
 o setPosition
  protected void setPosition(Point p)
Change our position. Should only be called by TrackSegment.
Parameters:
p - The new position
 o setCurrSegment
  protected void setCurrSegment(TrackSegment s)
Change the current track segment. Should only be called by TrackSegment.
Parameters:
s - The new segment

All Packages  Class Hierarchy  This Package  Previous  Next  Index