de.monarchy.guideme.view
Class FlatArrow

java.lang.Object
  extended by View
      extended by de.monarchy.guideme.view.FlatArrow

public class FlatArrow
extends View

This view represents an arrow indicating the direction the user has to turn to. The arrow is only displayed when a route has been set. It has two color indicators, one for the distance to the destination, one for the distance to the next route point. The first is the fill color of the arrow, the latter is the border color. The arrow reacts to both orientation and position changes and calculates the next route point autonomously.

Author:
dstuerze

Method Summary
static FlatArrow getInstance(Context context)
          Returns an instance of the FlatArrow.
 GeoCoordinate getLocation()
          Returns the current location of the arrow.
 void onDraw(Canvas c)
           
 void removeRoute()
          Removes the route.
 void setLocation(GeoCoordinate location)
          Sets the location and redraws.
 void setOrientation(float angle)
          Sets a new oritentation.
 void setRoute(RoutePoint[] way)
          Sets a new route to the arrow.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static FlatArrow getInstance(Context context)
Returns an instance of the FlatArrow. FlatArrow is a singleton, so it only creates one instance.

Parameters:
context - application context
Returns:
the one and only instance

onDraw

public void onDraw(Canvas c)

getLocation

public GeoCoordinate getLocation()
Returns the current location of the arrow.

Returns:
location

setLocation

public void setLocation(GeoCoordinate location)
Sets the location and redraws. Repainting is only done if target is set.

Parameters:
location - new location

setRoute

public void setRoute(RoutePoint[] way)
Sets a new route to the arrow. If null is passed, the route will be deleted and the arrow will not be drawn anymore.

Parameters:
way - new route

removeRoute

public void removeRoute()
Removes the route. Convenience method for setRoute(null).


setOrientation

public void setOrientation(float angle)
Sets a new oritentation. The orientation has to be in degrees, with 0 being north, incrementing clockwise (east 90 degrees, south 180, west 270). The orientation has to be delivered in device coordinates, the rotation of 90 degrees is measured inside the method.

Parameters:
angle - new orientation