source: other-projects/tipple-android/tipple-ar/tipple-standalone-hpg/src/org/greenstone/android/tipple/base/MapViewTipple.java@ 26528

Last change on this file since 26528 was 26528, checked in by davidb, 11 years ago

Code developed by the Tipple-AR Smoke and Mirrors team, based on the main tipple trunk

File size: 1.7 KB
Line 
1package org.greenstone.android.tipple.base;
2
3import org.greenstone.android.tipple.R;
4import org.mapsforge.android.maps.MapView;
5
6import android.content.Context;
7import android.graphics.Bitmap;
8import android.graphics.BitmapFactory;
9import android.graphics.Canvas;
10import android.graphics.Matrix;
11import android.graphics.Paint;
12import android.graphics.Point;
13import android.view.Display;
14import android.view.WindowManager;
15
16public class MapViewTipple extends MapView
17{
18 protected float currentRotation = 0;
19 Context context;
20 SensorFusion sensor_;
21
22 public MapViewTipple(Context context, SensorFusion sensorFusion) {
23 super(context);
24 this.context = context;
25 sensor_ = sensorFusion;
26 }
27
28 @Override
29 public void onDraw(Canvas canvas) {
30 WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
31 Display display = wm.getDefaultDisplay();
32 int width = display.getWidth();
33 int height = display.getHeight();
34 Bitmap rotatedArrow;
35
36 currentRotation = sensor_.getBearingDegrees();
37
38 canvas.save();
39 super.onDraw(canvas);
40
41 Bitmap headingArrow = BitmapFactory.decodeResource(getResources(), R.drawable.arrows);
42 Matrix matrix = new Matrix();
43 matrix.postRotate(currentRotation, headingArrow.getWidth()-20, headingArrow.getHeight()-5);
44 rotatedArrow = Bitmap.createBitmap(headingArrow , 0, 0, headingArrow.getWidth(), headingArrow.getHeight(), matrix, true);
45 matrix.setTranslate(20, 20);
46 rotatedArrow = Bitmap.createBitmap(rotatedArrow , 0, 0, rotatedArrow.getWidth(), rotatedArrow.getHeight(), matrix, true);
47 canvas.drawBitmap(rotatedArrow, matrix, new Paint());
48
49 //canvas.rotate(currentRotation);
50
51 canvas.restore();
52 }
53}
Note: See TracBrowser for help on using the repository browser.