public abstract class AbstrModelVehicle extends java.lang.Object implements IModelVehicle
Modifier and Type | Field and Description |
---|---|
static java.lang.Double |
STANDARD_SPEED
Usual speed of the vehicle.
|
NUM_FRAMES, TIME_SLICE
Constructor and Description |
---|
AbstrModelVehicle(java.lang.String name)
Base constructor, need only a unique name, the other
parameters are set as default.
|
Modifier and Type | Method and Description |
---|---|
static Direction |
degreesToDirection(java.lang.Double degrees)
Conversion method from rotational degrees to Direction
|
static java.lang.Double |
directionToDegrees(Direction d)
Conversion method from Direction to rotational degrees.
|
Coordinates[] |
getAnglesPosition()
Return an array of 4 elements containing vehicle's angles.
|
Coordinates |
getCenterPoint()
Return center point of the vehicle, calculating it on image dimensions.
|
double |
getCurvatureAngleActual()
Return curvature radius, in radians.
|
double |
getCurvatureAngleActualInDegrees() |
double |
getCurvatureAngleToReach()
Return curvature radius, in radians.
|
java.lang.String |
getName()
Returns the name, it is unique between all vehicles.
|
java.lang.Double |
getPixelsToGo()
Return pixels that vehicle can still move.
|
Coordinates |
getPosition()
GETTERS AND SETTERS
|
java.lang.Double |
getSpeed()
Return vehicle speed, in Km/h.
|
java.lang.Double |
getSpeedToReach()
Return speed that vehicle will reach at the end its actual a movement.
|
java.awt.Image |
getSprite()
Returns sprite image of vehicle.
|
IThreadVehicle |
getThread()
Return thread of this vehicle.
|
Direction |
getWay()
Return the direction in which the vehicle is going.
|
abstract boolean |
isRunning()
Check if the vehicle is running or not.
|
static java.lang.Double |
kmPerHoursToPixelPerTimeSlice(java.lang.Double kmPerHour)
Conversion from km/h to pixel/timeSlice.
|
static java.lang.Double |
kmPerHourToMetersPerSec(java.lang.Double kmPerHour)
Conversion from km/h to m/s.
|
static java.lang.Double |
metersPerSecToKmPerHour(java.lang.Double metersPerSecond)
Conversion from m/s to km/h.
|
void |
setCurvatureAngleActual(double curvatureAngle)
Set curvature radius, in radians.
|
void |
setCurvatureAngleActualInDegrees(double curvatureAngle) |
void |
setCurvatureAngleToReach(double curvatureAngle)
Set curvature radius to be reach from the vehicle, in radians.
|
void |
setName(java.lang.String name)
Set vehicle name.
|
void |
setPixelsToGo(java.lang.Double pixels)
Set pixels that car can move in that fraction of time.
|
void |
setPosition(Coordinates position)
Set vehicle coordinates.
|
void |
setPosition(java.lang.Integer x,
java.lang.Integer y)
Set vehicle coordinates.
|
void |
setSpeed(java.lang.Double kmh)
Set vehicle speed, in Km/h, it could be negative, if doing reverse.
|
void |
setSpeedToReach(java.lang.Double kmh)
Set speed to be reached at the end of its actual movement.
|
void |
setSprite(java.awt.Image image)
Set sprite image of vehicle.
|
void |
setThread(IThreadVehicle thread)
Set reference to thread updating this vehicle.
|
abstract void |
start()
This method must be used to start the thread.
|
java.lang.String |
toString() |
public static final java.lang.Double STANDARD_SPEED
public AbstrModelVehicle(java.lang.String name)
name
- unique name of the vehiclepublic abstract void start()
start
in interface IModelVehicle
public abstract boolean isRunning()
isRunning
in interface IModelVehicle
public static java.lang.Double kmPerHourToMetersPerSec(java.lang.Double kmPerHour)
kmPerHour
- value to be convertedpublic static java.lang.Double metersPerSecToKmPerHour(java.lang.Double metersPerSecond)
metersPerSecond
- value to be convertedpublic static java.lang.Double kmPerHoursToPixelPerTimeSlice(java.lang.Double kmPerHour)
kmPerHour
- value to be convertedpublic Coordinates getPosition()
getPosition
in interface IModelVehicle
public void setPosition(Coordinates position)
IModelVehicle
setPosition
in interface IModelVehicle
position
- coordinates of the vehiclepublic void setPosition(java.lang.Integer x, java.lang.Integer y)
IModelVehicle
setPosition
in interface IModelVehicle
x
- value of coordinate xy
- value of coordinate ypublic Coordinates getCenterPoint()
public Coordinates[] getAnglesPosition()
getAnglesPosition
in interface IModelVehicle
public Direction getWay()
getWay
in interface IModelVehicle
public static java.lang.Double directionToDegrees(Direction d)
d
- Direction to be convertedpublic static Direction degreesToDirection(java.lang.Double degrees)
degrees
- Value to be convertedpublic java.lang.Double getSpeed()
IModelVehicle
getSpeed
in interface IModelVehicle
public void setSpeed(java.lang.Double kmh)
IModelVehicle
setSpeed
in interface IModelVehicle
public java.lang.Double getSpeedToReach()
IModelVehicle
getSpeedToReach
in interface IModelVehicle
public void setSpeedToReach(java.lang.Double kmh)
IModelVehicle
setSpeedToReach
in interface IModelVehicle
kmh
- speed value to be reachedpublic java.awt.Image getSprite()
IModelVehicle
getSprite
in interface IModelVehicle
public void setSprite(java.awt.Image image)
IModelVehicle
setSprite
in interface IModelVehicle
image
- image to be setted as sprite of the vehiclepublic void setCurvatureAngleActual(double curvatureAngle)
IModelVehicle
setCurvatureAngleActual
in interface IModelVehicle
curvatureAngle
- rotation radians of vehiclepublic void setCurvatureAngleActualInDegrees(double curvatureAngle)
public double getCurvatureAngleActual()
IModelVehicle
getCurvatureAngleActual
in interface IModelVehicle
public double getCurvatureAngleActualInDegrees()
public void setCurvatureAngleToReach(double curvatureAngle)
IModelVehicle
setCurvatureAngleToReach
in interface IModelVehicle
curvatureAngle
- rotation radians to be reachpublic double getCurvatureAngleToReach()
IModelVehicle
getCurvatureAngleToReach
in interface IModelVehicle
public java.lang.String getName()
IModelVehicle
getName
in interface IModelVehicle
public void setName(java.lang.String name)
setName
in interface IModelVehicle
name
- unique name of the vehiclepublic IThreadVehicle getThread()
IModelVehicle
getThread
in interface IModelVehicle
public void setThread(IThreadVehicle thread)
IModelVehicle
setThread
in interface IModelVehicle
thread
- thread referencepublic java.lang.Double getPixelsToGo()
IModelVehicle
getPixelsToGo
in interface IModelVehicle
public void setPixelsToGo(java.lang.Double pixels)
IModelVehicle
setPixelsToGo
in interface IModelVehicle
pixels
- pixels this car can move in this fraction of timepublic java.lang.String toString()
toString
in class java.lang.Object