public class Renderer
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected int |
height
height of the surface to draw to
|
protected
android.view.SurfaceHolder |
holder
holder of the surface the renderer draws to
|
protected android.graphics.Paint
|
paint
Paint instance of the renderer
|
protected int |
pixelPerLine
height of a rectangle representing one
vehicle
|
protected int |
pixelPerVehicle
width of a rectangle representing one
vehicle
|
protected float |
tooShortPerHeight
amount of pixels per height which are lost by
rounding
|
protected float |
tooShortPerTrackLength
amount of pixels per track position which are
lost by rounding
|
protected Track |
track
the track to render
|
protected int |
width
width of the surface to draw to
|
Constructor and Description |
---|
Renderer(Track track,
android.view.SurfaceHolder holder)
Constuctor for a Renderer.
|
Modifier and Type | Method and Description |
---|---|
protected void |
draw()
Draws the current state of the track history
to the Surface.
|
protected int |
getColor(float curVelocity,
float maxVelocity)
Utility function which calculates a color
from the relation between the current speed of a
vehicle and it's maximum speed (from red over yellow to
green).
|
void |
setSize(int width,
int height)
Updates the dimension information of the
renderer.
|
void |
setTrack(Track track)
Updates the track of the Surface.
|
protected Track track
protected int pixelPerVehicle
protected int pixelPerLine
protected float tooShortPerTrackLength
protected float tooShortPerHeight
protected android.graphics.Paint paint
protected android.view.SurfaceHolder holder
protected int width
protected int height
public Renderer(Track track, android.view.SurfaceHolder holder)
track
- the track to renderholder
- the holder of the surface to draw to
public void setSize(int width, int height)
width
- the width of the SurfaceViewheight
- the height of the SurfaceViewpublic void setTrack(Track track)
track
- the new track to renderprotected int getColor(float curVelocity, float maxVelocity)
curVelocity
- current velocity of the vehicle
maxVelocity
- maximum velocity of the vehilce
protected void draw()