1 |
/**
|
2 |
* ZANavi, Zoff Android Navigation system.
|
3 |
* Copyright (C) 2013 - 2015 Zoff <zoff@zoff.cc>
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* version 2 as published by the Free Software Foundation.
|
8 |
*
|
9 |
* This program is distributed in the hope that it will be useful,
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
* GNU General Public License for more details.
|
13 |
*
|
14 |
* You should have received a copy of the GNU General Public License
|
15 |
* along with this program; if not, write to the
|
16 |
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
17 |
* Boston, MA 02110-1301, USA.
|
18 |
*/
|
19 |
|
20 |
package com.zoffcc.applications.zanavi;
|
21 |
|
22 |
import android.content.Context;
|
23 |
import android.content.res.Resources;
|
24 |
import android.graphics.Bitmap;
|
25 |
import android.graphics.BitmapFactory;
|
26 |
import android.graphics.Canvas;
|
27 |
import android.graphics.Paint;
|
28 |
import android.util.AttributeSet;
|
29 |
import android.widget.ImageView;
|
30 |
|
31 |
public class ZANaviOSDCompass extends ImageView
|
32 |
{
|
33 |
int w = 10;
|
34 |
int h = 10;
|
35 |
float w2 = w / 2;
|
36 |
float h2 = h / 2;
|
37 |
Bitmap bitmap_measure = null;
|
38 |
Paint paint_2 = new Paint();
|
39 |
Paint paint_3 = new Paint();
|
40 |
int cx = 0;
|
41 |
int cy = 0;
|
42 |
|
43 |
public ZANaviOSDCompass(Context context)
|
44 |
{
|
45 |
super(context);
|
46 |
|
47 |
Resources res = getResources();
|
48 |
bitmap_measure = BitmapFactory.decodeResource(res, R.drawable.zanavi_measure);
|
49 |
paint_2.setDither(true);
|
50 |
paint_2.setAntiAlias(true);
|
51 |
|
52 |
paint_3.setColor(0xffcc0000);
|
53 |
paint_3.setStyle(Paint.Style.FILL);
|
54 |
// paint_3.setStrokeWidth(4);
|
55 |
}
|
56 |
|
57 |
public ZANaviOSDCompass(Context context, AttributeSet attrs)
|
58 |
{
|
59 |
super(context, attrs);
|
60 |
|
61 |
Resources res = getResources();
|
62 |
bitmap_measure = BitmapFactory.decodeResource(res, R.drawable.zanavi_measure);
|
63 |
paint_2.setDither(true);
|
64 |
paint_2.setAntiAlias(true);
|
65 |
|
66 |
paint_3.setColor(0xffcc0000);
|
67 |
paint_3.setStyle(Paint.Style.FILL);
|
68 |
// paint_3.setStrokeWidth(4);
|
69 |
}
|
70 |
|
71 |
@Override
|
72 |
public void onSizeChanged(int w1, int h1, int oldw, int oldh)
|
73 |
{
|
74 |
super.onSizeChanged(w1, h1, oldw, oldh);
|
75 |
this.w = w1;
|
76 |
this.h = h1;
|
77 |
this.w2 = w / 2;
|
78 |
this.h2 = h / 2;
|
79 |
|
80 |
cx = (w - bitmap_measure.getWidth()) / 2;
|
81 |
cy = (h - bitmap_measure.getHeight()) / 2;
|
82 |
}
|
83 |
|
84 |
public void onDraw(Canvas c)
|
85 |
{
|
86 |
if (NavitAndroidOverlay.measure_mode)
|
87 |
{
|
88 |
super.onDraw(c);
|
89 |
// c.drawColor(0xFFAAAAAA, PorterDuff.Mode.CLEAR);
|
90 |
c.drawCircle(w2, h2, w2, paint_3);
|
91 |
c.drawBitmap(bitmap_measure, cx, cy, paint_2);
|
92 |
}
|
93 |
else
|
94 |
{
|
95 |
c.rotate(Navit.OSD_compass.angle_north, w2, h2);
|
96 |
super.onDraw(c);
|
97 |
}
|
98 |
|
99 |
// System.out.println("onDraw:OSDCompass");
|
100 |
}
|
101 |
}
|