1 |
/**
|
2 |
* ZANavi, Zoff Android Navigation system.
|
3 |
* Copyright (C) 2011-2012 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.graphics.Bitmap;
|
24 |
import android.graphics.Canvas;
|
25 |
import android.graphics.Color;
|
26 |
import android.graphics.Paint;
|
27 |
import android.graphics.PorterDuff;
|
28 |
import android.graphics.Rect;
|
29 |
import android.graphics.RectF;
|
30 |
import android.os.Handler;
|
31 |
import android.os.Message;
|
32 |
import android.widget.ImageView;
|
33 |
|
34 |
public class NavitOSDJava extends ImageView
|
35 |
{
|
36 |
public int mCanvasWidth = 1;
|
37 |
public int mCanvasHeight = 1;
|
38 |
public static float draw_factor = 1.0f;
|
39 |
|
40 |
public static Handler progress_handler_ = new Handler();
|
41 |
|
42 |
private static Boolean show_scale = false;
|
43 |
|
44 |
private static Boolean one_shot = false;
|
45 |
private static long last_paint_me = 0L;
|
46 |
|
47 |
static Bitmap compass_b = null;
|
48 |
static Canvas compass_c = null;
|
49 |
static int compass_radius = 0;
|
50 |
static int compass_center_x = 0;
|
51 |
static int compass_center_y = 0;
|
52 |
static int compass_lt_x = 0;
|
53 |
static int compass_lt_y = 0;
|
54 |
static int compass_w = 0;
|
55 |
static int compass_h = 0;
|
56 |
static Boolean did_draw_circle = false;
|
57 |
|
58 |
static Bitmap ddtt_b = null;
|
59 |
static Canvas ddtt_c = null;
|
60 |
static int ddtt_lt_x = 0;
|
61 |
static int ddtt_lt_y = 0;
|
62 |
static int ddtt_text_start_x = 0;
|
63 |
static int ddtt_text_start_y = 0;
|
64 |
static int ddtt_w = 0;
|
65 |
static int ddtt_h = 0;
|
66 |
static int ddtt_font_size = 0;
|
67 |
|
68 |
static Bitmap eta_b = null;
|
69 |
static Canvas eta_c = null;
|
70 |
static int eta_lt_x = 0;
|
71 |
static int eta_lt_y = 0;
|
72 |
static int eta_text_start_x = 0;
|
73 |
static int eta_text_start_y = 0;
|
74 |
static int eta_w = 0;
|
75 |
static int eta_h = 0;
|
76 |
static int eta_font_size = 0;
|
77 |
|
78 |
static Bitmap nt_b = null;
|
79 |
static Canvas nt_c = null;
|
80 |
static int nt_lt_x = 0;
|
81 |
static int nt_lt_y = 0;
|
82 |
static int nt_lt_xB = 0;
|
83 |
static int nt_lt_yB = 0;
|
84 |
static int nt_text_start_x = 0;
|
85 |
static int nt_text_start_y = 0;
|
86 |
static int nt_w = 0;
|
87 |
static int nt_h = 0;
|
88 |
static int nt_font_size = 0;
|
89 |
|
90 |
static Bitmap dttarget_b = null;
|
91 |
static Canvas dttarget_c = null;
|
92 |
static int dttarget_lt_x = 0;
|
93 |
static int dttarget_lt_y = 0;
|
94 |
static int dttarget_text_start_x = 0;
|
95 |
static int dttarget_text_start_y = 0;
|
96 |
static int dttarget_w = 0;
|
97 |
static int dttarget_h = 0;
|
98 |
static int dttarget_font_size = 0;
|
99 |
|
100 |
static Bitmap scale_b = null;
|
101 |
static Canvas scale_c = null;
|
102 |
static int scale_lt_x = 0;
|
103 |
static int scale_lt_y = 0;
|
104 |
static int scale_text_start_x = 0;
|
105 |
static int scale_text_start_y = 0;
|
106 |
static int scale_line_start_x = 0;
|
107 |
static int scale_line_end_x = 0;
|
108 |
static int scale_line_start_y = 0;
|
109 |
static int scale_line_middle_y = 0;
|
110 |
static int scale_line_end_y = 0;
|
111 |
static int scale_w = 0;
|
112 |
static int scale_h = 0;
|
113 |
static int scale_font_size = 0;
|
114 |
|
115 |
static int nextt_lt_x = 0;
|
116 |
static int nextt_lt_y = 0;
|
117 |
static int nextt_w = 0;
|
118 |
static int nextt_h = 0;
|
119 |
static int nextt_lt_xB = 0;
|
120 |
static int nextt_lt_yB = 0;
|
121 |
static int nextt_wB = 0;
|
122 |
static int nextt_hB = 0;
|
123 |
|
124 |
static int nextt_str_ltx = 0;
|
125 |
static int nextt_str_lty = 0;
|
126 |
static int nextt_str_ltxB = 0;
|
127 |
static int nextt_str_ltyB = 0;
|
128 |
static int nextt_str_w = 0;
|
129 |
static int nextt_str_h = 0;
|
130 |
static int nextt_str_wB = 0;
|
131 |
static int nextt_str_hB = 0;
|
132 |
static int nextt_str_font_size = 0;
|
133 |
static int nextt_str_start_x = 0;
|
134 |
static int nextt_str_start_y = 0;
|
135 |
|
136 |
static int sat_status_lt_x = 0;
|
137 |
static int sat_status_lt_y = 0;
|
138 |
static int sat_status_lt_w = 0;
|
139 |
static int sat_status_lt_h = 0;
|
140 |
static int sat_status_max_sats = 13;
|
141 |
|
142 |
static Paint paint = new Paint();
|
143 |
|
144 |
// private long last_timestamp = 0L;
|
145 |
// public static final int UPDATE_INTERVAL = 400; // in ms
|
146 |
|
147 |
public NavitOSDJava(Context context)
|
148 |
{
|
149 |
super(context);
|
150 |
|
151 |
progress_handler_ = this.progress_handler;
|
152 |
|
153 |
// b_ = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_4444);
|
154 |
// compass_b = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
|
155 |
compass_b = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_4444);
|
156 |
compass_c = new Canvas(compass_b);
|
157 |
ddtt_b = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_4444);
|
158 |
ddtt_c = new Canvas(ddtt_b);
|
159 |
scale_b = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_4444);
|
160 |
scale_c = new Canvas(ddtt_b);
|
161 |
dttarget_b = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_4444);
|
162 |
dttarget_c = new Canvas(dttarget_b);
|
163 |
eta_b = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_4444);
|
164 |
eta_c = new Canvas(eta_b);
|
165 |
nt_b = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_4444);
|
166 |
nt_c = new Canvas(nt_b);
|
167 |
|
168 |
// this.setOnLongClickListener(new OnLongClickListener()
|
169 |
// {
|
170 |
// @Override
|
171 |
// public boolean onLongClick(View v)
|
172 |
// {
|
173 |
// return true;
|
174 |
// }
|
175 |
// });
|
176 |
}
|
177 |
|
178 |
@Override
|
179 |
public void onSizeChanged(int w, int h, int oldw, int oldh)
|
180 |
{
|
181 |
super.onSizeChanged(w, h, oldw, oldh);
|
182 |
this.mCanvasWidth = w;
|
183 |
this.mCanvasHeight = h;
|
184 |
|
185 |
sat_status_lt_x = 2;
|
186 |
sat_status_lt_y = (int) (this.mCanvasHeight * 0.15);
|
187 |
sat_status_lt_w = 6;
|
188 |
sat_status_lt_h = this.mCanvasHeight - (int) (this.mCanvasHeight * (0.35 + 0.15));
|
189 |
sat_status_max_sats = 13;
|
190 |
|
191 |
draw_factor = 1.0f;
|
192 |
if (Navit.my_display_density.compareTo("mdpi") == 0)
|
193 |
{
|
194 |
draw_factor = 1.0f;
|
195 |
}
|
196 |
else if (Navit.my_display_density.compareTo("ldpi") == 0)
|
197 |
{
|
198 |
draw_factor = 0.7f;
|
199 |
}
|
200 |
else if (Navit.my_display_density.compareTo("hdpi") == 0)
|
201 |
{
|
202 |
draw_factor = 1.5f;
|
203 |
}
|
204 |
|
205 |
float real_factor = draw_factor / 1.5f;
|
206 |
|
207 |
// abs
|
208 |
compass_radius = (int) (50 * real_factor);
|
209 |
compass_lt_x = (int) (mCanvasWidth - (2 * compass_radius) - (16 * real_factor));
|
210 |
compass_lt_y = (int) (mCanvasHeight - (2 * compass_radius) - ((16 + 50) * real_factor));
|
211 |
// rel
|
212 |
compass_w = (int) (2 * compass_radius + 16 * real_factor);
|
213 |
compass_h = (int) (2 * compass_radius + 16 * real_factor);
|
214 |
compass_center_x = (int) (compass_w - compass_radius - 8 * real_factor);
|
215 |
compass_center_y = (int) (compass_h - compass_radius - 8 * real_factor);
|
216 |
|
217 |
ddtt_w = (int) (compass_w);
|
218 |
ddtt_h = (int) (40 * real_factor);
|
219 |
ddtt_lt_x = (int) (mCanvasWidth - (2 * compass_radius) - (16 * real_factor));
|
220 |
ddtt_lt_y = (int) (mCanvasHeight - 50 * real_factor);
|
221 |
ddtt_text_start_x = (int) (20 * real_factor);
|
222 |
ddtt_text_start_y = (int) (30 * real_factor);
|
223 |
ddtt_font_size = (int) (24 * real_factor);
|
224 |
|
225 |
dttarget_w = (int) (2 * (int) (50 * real_factor) + 16 * real_factor);
|
226 |
dttarget_h = (int) (40 * real_factor);
|
227 |
dttarget_lt_x = (int) ((mCanvasWidth / 2) - (dttarget_w / 2));
|
228 |
dttarget_lt_y = (int) (mCanvasHeight - 50 * real_factor);
|
229 |
dttarget_text_start_x = (int) (20 * real_factor);
|
230 |
dttarget_text_start_y = (int) (30 * real_factor);
|
231 |
dttarget_font_size = (int) (24 * real_factor);
|
232 |
|
233 |
eta_w = (int) (2 * (int) (50 * real_factor) + 16 * real_factor);
|
234 |
eta_h = (int) (40 * real_factor);
|
235 |
eta_lt_x = (int) (int) ((mCanvasWidth / 2) - (eta_w / 2));
|
236 |
eta_lt_y = (int) (mCanvasHeight - 50 * real_factor) - dttarget_h - 5;
|
237 |
eta_text_start_x = (int) (20 * real_factor);
|
238 |
eta_text_start_y = (int) (30 * real_factor);
|
239 |
eta_font_size = (int) (24 * real_factor);
|
240 |
|
241 |
scale_w = (int) (202 * real_factor);
|
242 |
scale_h = (int) (40 * real_factor);
|
243 |
scale_line_start_x = (int) (1 * real_factor);
|
244 |
scale_line_end_x = (int) (201 * real_factor);
|
245 |
scale_line_start_y = (int) (1 * real_factor);
|
246 |
scale_line_middle_y = (int) (1 * real_factor);
|
247 |
scale_line_end_y = (int) (8 * real_factor);
|
248 |
scale_lt_x = (int) (mCanvasWidth - scale_w - 4);
|
249 |
scale_lt_y = (int) (65);
|
250 |
scale_text_start_x = (int) (10 * real_factor);
|
251 |
scale_text_start_y = (int) (30 * real_factor);
|
252 |
scale_font_size = (int) (24 * real_factor);
|
253 |
|
254 |
// next turn icons
|
255 |
nextt_w = (int) (100 * real_factor);
|
256 |
nextt_h = (int) (100 * real_factor);
|
257 |
nextt_lt_x = (int) (10 * real_factor);
|
258 |
nextt_lt_y = (int) (mCanvasHeight - 50 * real_factor) - nextt_h - 5;
|
259 |
// next turn icons
|
260 |
|
261 |
// next turn icons -- BIG --
|
262 |
int smaller_size = mCanvasWidth;
|
263 |
float shrink_factor = 0.65f;
|
264 |
if (mCanvasWidth > mCanvasHeight)
|
265 |
{
|
266 |
// phone is turned in landscape-mode
|
267 |
smaller_size = mCanvasHeight;
|
268 |
shrink_factor = 0.43f;
|
269 |
}
|
270 |
|
271 |
nextt_wB = (int) (smaller_size * shrink_factor);
|
272 |
nextt_hB = (int) (smaller_size * shrink_factor);
|
273 |
nextt_lt_xB = (int) ((mCanvasWidth - nextt_wB) / 2);
|
274 |
nextt_lt_yB = (int) (60 * real_factor);
|
275 |
// next turn icons -- BIG --
|
276 |
|
277 |
// next turn streetname --
|
278 |
nextt_str_w = mCanvasWidth;
|
279 |
nextt_str_h = (int) (65 * real_factor);
|
280 |
nextt_str_ltx = 0;
|
281 |
nextt_str_lty = 20;
|
282 |
nextt_str_font_size = (int) (41 * real_factor);
|
283 |
nextt_str_start_x = 8;
|
284 |
nextt_str_start_y = (int) (46 * real_factor);
|
285 |
// next turn streetname --
|
286 |
|
287 |
// next turn streetname -- BIG --
|
288 |
nextt_str_wB = mCanvasWidth;
|
289 |
nextt_str_hB = (int) (65 * real_factor);
|
290 |
nextt_str_ltxB = 0;
|
291 |
nextt_str_ltyB = nextt_lt_yB + nextt_hB + 4;
|
292 |
// next turn streetname -- BIG --
|
293 |
|
294 |
// next turn in XX m --
|
295 |
nt_w = (int) (100 * real_factor);
|
296 |
nt_h = (int) (40 * real_factor);
|
297 |
nt_lt_x = (int) (10 * real_factor);
|
298 |
nt_lt_y = (int) (mCanvasHeight - 50 * real_factor);
|
299 |
nt_text_start_x = (int) (20 * real_factor);
|
300 |
nt_text_start_y = (int) (30 * real_factor);
|
301 |
nt_font_size = (int) (24 * real_factor);
|
302 |
// next turn in XX m --
|
303 |
|
304 |
// next turn in XX m -- BIG --
|
305 |
nt_lt_xB = nextt_lt_xB;
|
306 |
nt_lt_yB = nextt_lt_yB - nt_h - 4;
|
307 |
// next turn in XX m -- BIG --
|
308 |
|
309 |
if (compass_b != null)
|
310 |
{
|
311 |
compass_b.recycle();
|
312 |
}
|
313 |
compass_b = Bitmap.createBitmap(compass_w, compass_h, Bitmap.Config.ARGB_4444);
|
314 |
compass_c = new Canvas(compass_b);
|
315 |
|
316 |
if (ddtt_b != null)
|
317 |
{
|
318 |
ddtt_b.recycle();
|
319 |
}
|
320 |
ddtt_b = Bitmap.createBitmap(ddtt_w, ddtt_h, Bitmap.Config.ARGB_4444);
|
321 |
ddtt_c = new Canvas(ddtt_b);
|
322 |
|
323 |
if (scale_b != null)
|
324 |
{
|
325 |
scale_b.recycle();
|
326 |
}
|
327 |
scale_b = Bitmap.createBitmap(scale_w, scale_h, Bitmap.Config.ARGB_4444);
|
328 |
scale_c = new Canvas(scale_b);
|
329 |
|
330 |
if (dttarget_b != null)
|
331 |
{
|
332 |
dttarget_b.recycle();
|
333 |
}
|
334 |
dttarget_b = Bitmap.createBitmap(dttarget_w, dttarget_h, Bitmap.Config.ARGB_4444);
|
335 |
dttarget_c = new Canvas(dttarget_b);
|
336 |
|
337 |
if (eta_b != null)
|
338 |
{
|
339 |
eta_b.recycle();
|
340 |
}
|
341 |
eta_b = Bitmap.createBitmap(eta_w, eta_h, Bitmap.Config.ARGB_4444);
|
342 |
eta_c = new Canvas(eta_b);
|
343 |
|
344 |
if (nt_b != null)
|
345 |
{
|
346 |
nt_b.recycle();
|
347 |
}
|
348 |
nt_b = Bitmap.createBitmap(nt_w, nt_h, Bitmap.Config.ARGB_4444);
|
349 |
nt_c = new Canvas(nt_b);
|
350 |
|
351 |
}
|
352 |
|
353 |
public static void draw_real()
|
354 |
{
|
355 |
//if (!NavitGraphics.MAP_DISPLAY_OFF)
|
356 |
//{
|
357 |
/*
|
358 |
* if ((last_paint_me + 100) < System.currentTimeMillis())
|
359 |
* {
|
360 |
* try
|
361 |
* {
|
362 |
* last_paint_me = System.currentTimeMillis();
|
363 |
* }
|
364 |
* catch (Exception r)
|
365 |
* {
|
366 |
* //r.printStackTrace();
|
367 |
* }
|
368 |
* }
|
369 |
* else
|
370 |
* {
|
371 |
* return;
|
372 |
* }
|
373 |
*/
|
374 |
//}
|
375 |
//System.out.println("draw real 1");
|
376 |
|
377 |
try
|
378 |
{
|
379 |
compass_c.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
|
380 |
ddtt_c.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
|
381 |
scale_c.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
|
382 |
dttarget_c.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
|
383 |
eta_c.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
|
384 |
nt_c.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
|
385 |
|
386 |
// compass_c.drawColor(Color.LTGRAY);
|
387 |
// ddtt_c.drawColor(Color.CYAN);
|
388 |
|
389 |
int dest_valid = NavitGraphics.CallbackDestinationValid2();
|
390 |
|
391 |
did_draw_circle = false;
|
392 |
if (!NavitGraphics.MAP_DISPLAY_OFF)
|
393 |
{
|
394 |
|
395 |
if (Navit.OSD_compass.angle_north_valid)
|
396 |
{
|
397 |
paint.setColor(Color.BLACK);
|
398 |
paint.setStyle(Paint.Style.STROKE);
|
399 |
paint.setStrokeWidth(2);
|
400 |
paint.setAntiAlias(true);
|
401 |
compass_c.drawCircle(compass_center_x, compass_center_y, compass_radius, paint);
|
402 |
did_draw_circle = true;
|
403 |
int end_x = (int) ((float) Math.sin((float) Math.toRadians(Navit.OSD_compass.angle_north)) * compass_radius);
|
404 |
int end_y = (int) ((float) Math.cos((float) Math.toRadians(Navit.OSD_compass.angle_north)) * compass_radius);
|
405 |
// System.out.println("x " + end_x + " y " + end_y);
|
406 |
compass_c.drawLine(compass_center_x - end_x, compass_center_y + end_y, compass_center_x, compass_center_y, paint);
|
407 |
paint.setColor(Color.RED);
|
408 |
paint.setStrokeWidth(4);
|
409 |
compass_c.drawLine(compass_center_x + end_x, compass_center_y - end_y, compass_center_x, compass_center_y, paint);
|
410 |
}
|
411 |
if ((Navit.OSD_compass.angle_target_valid) && (dest_valid > 0))
|
412 |
{
|
413 |
paint.setColor(Color.BLACK);
|
414 |
paint.setStyle(Paint.Style.STROKE);
|
415 |
paint.setStrokeWidth(2);
|
416 |
paint.setAntiAlias(true);
|
417 |
if (!did_draw_circle)
|
418 |
{
|
419 |
compass_c.drawCircle(compass_center_x, compass_center_y, compass_radius, paint);
|
420 |
did_draw_circle = true;
|
421 |
}
|
422 |
int end_x = (int) ((float) Math.sin((float) Math.toRadians(Navit.OSD_compass.angle_target)) * compass_radius);
|
423 |
int end_y = (int) ((float) Math.cos((float) Math.toRadians(Navit.OSD_compass.angle_target)) * compass_radius);
|
424 |
// System.out.println("x " + end_x + " y " + end_y);
|
425 |
paint.setColor(Color.GREEN);
|
426 |
compass_c.drawLine(compass_center_x, compass_center_y, compass_center_x + end_x, compass_center_y - end_y, paint);
|
427 |
}
|
428 |
}
|
429 |
|
430 |
if ((Navit.OSD_compass.direct_distance_to_target_valid) && (dest_valid > 0))
|
431 |
{
|
432 |
paint.setColor(Color.argb(140, 136, 136, 136));
|
433 |
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
434 |
paint.setStrokeWidth(2);
|
435 |
paint.setAntiAlias(true);
|
436 |
ddtt_c.drawRoundRect(new RectF(0, 0, ddtt_w, ddtt_h), 10, 10, paint);
|
437 |
|
438 |
paint.setColor(Color.BLACK);
|
439 |
paint.setStrokeWidth(3);
|
440 |
paint.setStyle(Paint.Style.FILL);
|
441 |
paint.setTextSize(ddtt_font_size);
|
442 |
paint.setAntiAlias(true);
|
443 |
ddtt_c.drawText(Navit.OSD_compass.direct_distance_to_target, ddtt_text_start_x, ddtt_text_start_y, paint);
|
444 |
}
|
445 |
if ((Navit.OSD_route_001.arriving_time_valid) && (dest_valid > 0))
|
446 |
{
|
447 |
paint.setColor(Color.argb(140, 136, 136, 136));
|
448 |
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
449 |
paint.setStrokeWidth(2);
|
450 |
paint.setAntiAlias(true);
|
451 |
eta_c.drawRoundRect(new RectF(0, 0, eta_w, eta_h), 10, 10, paint);
|
452 |
|
453 |
paint.setColor(Color.BLACK);
|
454 |
paint.setStrokeWidth(3);
|
455 |
paint.setStyle(Paint.Style.FILL);
|
456 |
paint.setTextSize(eta_font_size);
|
457 |
paint.setAntiAlias(true);
|
458 |
eta_c.drawText(Navit.OSD_route_001.arriving_time, eta_text_start_x, eta_text_start_y, paint);
|
459 |
}
|
460 |
if ((Navit.OSD_route_001.driving_distance_to_target_valid) && (dest_valid > 0))
|
461 |
{
|
462 |
paint.setColor(Color.argb(140, 136, 136, 136));
|
463 |
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
464 |
paint.setStrokeWidth(2);
|
465 |
paint.setAntiAlias(true);
|
466 |
dttarget_c.drawRoundRect(new RectF(0, 0, dttarget_w, dttarget_h), 10, 10, paint);
|
467 |
|
468 |
paint.setColor(Color.BLACK);
|
469 |
paint.setStrokeWidth(3);
|
470 |
paint.setStyle(Paint.Style.FILL);
|
471 |
paint.setTextSize(dttarget_font_size);
|
472 |
paint.setAntiAlias(true);
|
473 |
dttarget_c.drawText(Navit.OSD_route_001.driving_distance_to_target, dttarget_text_start_x, dttarget_text_start_y, paint);
|
474 |
}
|
475 |
if ((Navit.OSD_nextturn.nextturn_distance_valid) && (dest_valid > 0))
|
476 |
{
|
477 |
if (NavitGraphics.MAP_DISPLAY_OFF)
|
478 |
{
|
479 |
paint.setColor(Color.argb(255, 20, 20, 230));
|
480 |
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
481 |
paint.setStrokeWidth(2);
|
482 |
paint.setAntiAlias(true);
|
483 |
nt_c.drawRoundRect(new RectF(0, 0, nt_w, nt_h), 10, 10, paint);
|
484 |
|
485 |
paint.setColor(Color.WHITE);
|
486 |
paint.setStrokeWidth(3);
|
487 |
paint.setStyle(Paint.Style.FILL);
|
488 |
paint.setTextSize(nt_font_size);
|
489 |
paint.setAntiAlias(true);
|
490 |
nt_c.drawText(Navit.OSD_nextturn.nextturn_distance, nt_text_start_x, nt_text_start_y, paint);
|
491 |
}
|
492 |
else
|
493 |
{
|
494 |
paint.setColor(Color.argb(140, 136, 136, 136));
|
495 |
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
496 |
paint.setStrokeWidth(2);
|
497 |
paint.setAntiAlias(true);
|
498 |
nt_c.drawRoundRect(new RectF(0, 0, nt_w, nt_h), 10, 10, paint);
|
499 |
|
500 |
paint.setColor(Color.BLACK);
|
501 |
paint.setStrokeWidth(3);
|
502 |
paint.setStyle(Paint.Style.FILL);
|
503 |
paint.setTextSize(nt_font_size);
|
504 |
paint.setAntiAlias(true);
|
505 |
nt_c.drawText(Navit.OSD_nextturn.nextturn_distance, nt_text_start_x, nt_text_start_y, paint);
|
506 |
}
|
507 |
}
|
508 |
|
509 |
if (show_scale)
|
510 |
{
|
511 |
if (Navit.OSD_scale.scale_valid)
|
512 |
{
|
513 |
paint.setColor(Color.BLACK);
|
514 |
paint.setStrokeWidth(3);
|
515 |
paint.setAntiAlias(true);
|
516 |
paint.setStyle(Paint.Style.STROKE);
|
517 |
// mothod a
|
518 |
scale_c.drawLine(scale_line_start_x, scale_line_middle_y, scale_line_start_x + Navit.OSD_scale.var, scale_line_middle_y, paint);
|
519 |
// method b
|
520 |
// scale_c.drawLine(scale_line_start_x, scale_line_middle_y, scale_line_end_x, scale_line_middle_y, paint);
|
521 |
scale_c.drawLine(scale_line_start_x, scale_line_start_y, scale_line_start_x, scale_line_end_y, paint);
|
522 |
scale_c.drawLine(scale_line_start_x + Navit.OSD_scale.var, scale_line_start_y, scale_line_start_x + Navit.OSD_scale.var, scale_line_end_y, paint);
|
523 |
paint.setStyle(Paint.Style.FILL);
|
524 |
paint.setTextSize(scale_font_size);
|
525 |
scale_c.drawText(Navit.OSD_scale.scale_text, scale_text_start_x, scale_text_start_y, paint);
|
526 |
}
|
527 |
}
|
528 |
}
|
529 |
catch (Exception e)
|
530 |
{
|
531 |
e.printStackTrace();
|
532 |
}
|
533 |
|
534 |
if (NavitGraphics.MAP_DISPLAY_OFF)
|
535 |
{
|
536 |
one_shot = true;
|
537 |
}
|
538 |
}
|
539 |
|
540 |
public void onDraw(Canvas c)
|
541 |
{
|
542 |
//System.out.println("draw real 2");
|
543 |
|
544 |
try
|
545 |
{
|
546 |
c.drawBitmap(compass_b, compass_lt_x, compass_lt_y, null);
|
547 |
}
|
548 |
catch (Exception e)
|
549 |
{
|
550 |
e.printStackTrace();
|
551 |
}
|
552 |
try
|
553 |
{
|
554 |
c.drawBitmap(ddtt_b, ddtt_lt_x, ddtt_lt_y, null);
|
555 |
}
|
556 |
catch (Exception e)
|
557 |
{
|
558 |
e.printStackTrace();
|
559 |
}
|
560 |
try
|
561 |
{
|
562 |
c.drawBitmap(dttarget_b, dttarget_lt_x, dttarget_lt_y, null);
|
563 |
}
|
564 |
catch (Exception e)
|
565 |
{
|
566 |
e.printStackTrace();
|
567 |
}
|
568 |
try
|
569 |
{
|
570 |
c.drawBitmap(eta_b, eta_lt_x, eta_lt_y, null);
|
571 |
}
|
572 |
catch (Exception e)
|
573 |
{
|
574 |
e.printStackTrace();
|
575 |
}
|
576 |
|
577 |
if (show_scale)
|
578 |
{
|
579 |
try
|
580 |
{
|
581 |
c.drawBitmap(scale_b, scale_lt_x, scale_lt_y, null);
|
582 |
}
|
583 |
catch (Exception e)
|
584 |
{
|
585 |
e.printStackTrace();
|
586 |
}
|
587 |
}
|
588 |
|
589 |
try
|
590 |
{
|
591 |
if (NavitGraphics.MAP_DISPLAY_OFF)
|
592 |
{
|
593 |
c.drawBitmap(nt_b, nt_lt_xB, nt_lt_yB, null);
|
594 |
}
|
595 |
else
|
596 |
{
|
597 |
c.drawBitmap(nt_b, nt_lt_x, nt_lt_y, null);
|
598 |
}
|
599 |
}
|
600 |
catch (Exception e)
|
601 |
{
|
602 |
e.printStackTrace();
|
603 |
}
|
604 |
|
605 |
try
|
606 |
{
|
607 |
if ((Navit.OSD_nextturn.nextturn_streetname != null) || (Navit.PREF_follow_gps))
|
608 |
{
|
609 |
if (NavitGraphics.MAP_DISPLAY_OFF)
|
610 |
{
|
611 |
paint.setColor(Color.argb(255, 20, 20, 230));
|
612 |
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
613 |
paint.setStrokeWidth(2);
|
614 |
paint.setAntiAlias(true);
|
615 |
c.drawRoundRect(new RectF(nextt_str_ltxB, nextt_str_ltyB, nextt_str_ltxB + nextt_str_wB, nextt_str_ltyB + nextt_str_hB), 10, 10, paint);
|
616 |
paint.setColor(Color.WHITE);
|
617 |
paint.setStrokeWidth(3);
|
618 |
paint.setStyle(Paint.Style.FILL);
|
619 |
if (Navit.OSD_nextturn.nextturn_streetname.length() > (nextt_str_ltxB + nextt_str_wB) / 25)
|
620 |
{
|
621 |
paint.setTextSize((int) (nextt_str_font_size * 0.70));
|
622 |
}
|
623 |
else
|
624 |
{
|
625 |
paint.setTextSize(nextt_str_font_size);
|
626 |
}
|
627 |
paint.setAntiAlias(true);
|
628 |
c.drawText(Navit.OSD_nextturn.nextturn_streetname_systematic + " " + Navit.OSD_nextturn.nextturn_streetname, nextt_str_ltxB + nextt_str_start_x, nextt_str_ltyB + nextt_str_start_y, paint);
|
629 |
}
|
630 |
else
|
631 |
{
|
632 |
paint.setColor(Color.argb(140, 136, 136, 136));
|
633 |
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
634 |
paint.setStrokeWidth(2);
|
635 |
paint.setAntiAlias(true);
|
636 |
c.drawRoundRect(new RectF(nextt_str_ltxB, nextt_str_lty, nextt_str_ltx + nextt_str_w, nextt_str_lty + nextt_str_h), 10, 10, paint);
|
637 |
paint.setColor(Color.BLACK);
|
638 |
paint.setStrokeWidth(3);
|
639 |
paint.setStyle(Paint.Style.FILL);
|
640 |
if (Navit.OSD_nextturn.nextturn_streetname.length() > (nextt_str_ltxB + nextt_str_wB) / 25)
|
641 |
{
|
642 |
paint.setTextSize((int) (nextt_str_font_size * 0.70));
|
643 |
}
|
644 |
else
|
645 |
{
|
646 |
paint.setTextSize(nextt_str_font_size);
|
647 |
}
|
648 |
paint.setAntiAlias(true);
|
649 |
c.drawText(Navit.OSD_nextturn.nextturn_streetname_systematic + " " + Navit.OSD_nextturn.nextturn_streetname, nextt_str_ltx + nextt_str_start_x, nextt_str_lty + nextt_str_start_y, paint);
|
650 |
}
|
651 |
}
|
652 |
else
|
653 |
{
|
654 |
paint.setColor(Color.argb(0, 0, 0, 0));
|
655 |
paint.setStyle(Paint.Style.FILL);
|
656 |
paint.setStrokeWidth(3);
|
657 |
paint.setAntiAlias(false);
|
658 |
if (NavitGraphics.MAP_DISPLAY_OFF)
|
659 |
{
|
660 |
c.drawRect(new RectF(nextt_str_ltxB, nextt_str_ltyB, nextt_str_ltxB + nextt_str_wB, nextt_str_ltyB + nextt_str_hB), paint);
|
661 |
}
|
662 |
else
|
663 |
{
|
664 |
c.drawRect(new RectF(nextt_str_ltx, nextt_str_lty, nextt_str_ltx + nextt_str_w, nextt_str_lty + nextt_str_h), paint);
|
665 |
}
|
666 |
}
|
667 |
}
|
668 |
catch (Exception e)
|
669 |
{
|
670 |
|
671 |
}
|
672 |
|
673 |
try
|
674 |
{
|
675 |
if ((Navit.OSD_nextturn.nextturn_image_valid) && (NavitGraphics.CallbackDestinationValid2() > 0))
|
676 |
{
|
677 |
if (NavitGraphics.MAP_DISPLAY_OFF)
|
678 |
{
|
679 |
paint.setColor(Color.argb(255, 20, 20, 230));
|
680 |
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
681 |
paint.setStrokeWidth(2);
|
682 |
paint.setAntiAlias(true);
|
683 |
c.drawRoundRect(new RectF(nextt_lt_xB, nextt_lt_yB, nextt_lt_xB + nextt_wB, nextt_lt_yB + nextt_hB), 10, 10, paint);
|
684 |
Rect dst = new Rect(nextt_lt_xB, nextt_lt_yB, nextt_lt_xB + nextt_wB, nextt_lt_yB + nextt_hB);
|
685 |
c.drawBitmap(Navit.OSD_nextturn.nextturn_image, null, dst, null);
|
686 |
}
|
687 |
else
|
688 |
{
|
689 |
paint.setColor(Color.argb(140, 136, 136, 136));
|
690 |
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
691 |
paint.setStrokeWidth(2);
|
692 |
paint.setAntiAlias(true);
|
693 |
c.drawRoundRect(new RectF(nextt_lt_x, nextt_lt_y, nextt_lt_x + nextt_w, nextt_lt_y + nextt_h), 10, 10, paint);
|
694 |
Rect dst = new Rect(nextt_lt_x, nextt_lt_y, nextt_lt_x + nextt_w, nextt_lt_y + nextt_h);
|
695 |
c.drawBitmap(Navit.OSD_nextturn.nextturn_image, null, dst, null);
|
696 |
}
|
697 |
// c.drawBitmap(Navit.OSD_nextturn.nextturn_image, nextt_lt_x, nextt_lt_y, null);
|
698 |
}
|
699 |
else
|
700 |
{
|
701 |
paint.setColor(Color.argb(0, 0, 0, 0));
|
702 |
paint.setStyle(Paint.Style.FILL);
|
703 |
paint.setStrokeWidth(3);
|
704 |
paint.setAntiAlias(false);
|
705 |
if (NavitGraphics.MAP_DISPLAY_OFF)
|
706 |
{
|
707 |
c.drawRect(new RectF(nextt_lt_xB, nextt_lt_yB, nextt_lt_xB + nextt_wB, nextt_lt_yB + nextt_hB), paint);
|
708 |
}
|
709 |
else
|
710 |
{
|
711 |
c.drawRect(new RectF(nextt_lt_x, nextt_lt_y, nextt_lt_x + nextt_w, nextt_lt_y + nextt_h), paint);
|
712 |
}
|
713 |
//c.clipRect(nextt_lt_x, nextt_lt_y, nextt_lt_x + nextt_w, nextt_lt_y + nextt_h);
|
714 |
//c.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
|
715 |
}
|
716 |
}
|
717 |
catch (Exception e)
|
718 |
{
|
719 |
e.printStackTrace();
|
720 |
}
|
721 |
|
722 |
try
|
723 |
{
|
724 |
if (Navit.PREF_show_sat_status)
|
725 |
{
|
726 |
// fill rect
|
727 |
paint.setColor(Color.GRAY);
|
728 |
paint.setStyle(Paint.Style.FILL);
|
729 |
paint.setStrokeWidth(0);
|
730 |
paint.setAntiAlias(true);
|
731 |
c.drawRect(new Rect(sat_status_lt_x, sat_status_lt_y, sat_status_lt_x + sat_status_lt_w, sat_status_lt_y + sat_status_lt_h), paint);
|
732 |
|
733 |
// fill inactive sats
|
734 |
paint.setColor(Color.YELLOW);
|
735 |
paint.setStyle(Paint.Style.FILL);
|
736 |
paint.setStrokeWidth(0);
|
737 |
paint.setAntiAlias(true);
|
738 |
c.drawRect(new Rect(sat_status_lt_x, sat_status_lt_y + sat_status_lt_h - (sat_status_lt_h / sat_status_max_sats * Navit.sats), sat_status_lt_x + sat_status_lt_w, sat_status_lt_y + sat_status_lt_h), paint);
|
739 |
|
740 |
// fill active sats
|
741 |
paint.setColor(Color.GREEN);
|
742 |
paint.setStyle(Paint.Style.FILL);
|
743 |
paint.setStrokeWidth(0);
|
744 |
paint.setAntiAlias(true);
|
745 |
c.drawRect(new Rect(sat_status_lt_x, sat_status_lt_y + sat_status_lt_h - (sat_status_lt_h / sat_status_max_sats * Navit.satsInFix), sat_status_lt_x + sat_status_lt_w, sat_status_lt_y + sat_status_lt_h), paint);
|
746 |
|
747 |
// black rect around it all
|
748 |
paint.setColor(Color.BLACK);
|
749 |
paint.setStyle(Paint.Style.STROKE);
|
750 |
paint.setStrokeWidth(1);
|
751 |
paint.setAntiAlias(true);
|
752 |
c.drawRect(new Rect(sat_status_lt_x, sat_status_lt_y, sat_status_lt_x + sat_status_lt_w, sat_status_lt_y + sat_status_lt_h), paint);
|
753 |
}
|
754 |
}
|
755 |
catch (Exception e)
|
756 |
{
|
757 |
e.printStackTrace();
|
758 |
}
|
759 |
|
760 |
if (!Navit.PREF_follow_gps)
|
761 |
{
|
762 |
if (!NavitGraphics.MAP_DISPLAY_OFF)
|
763 |
{
|
764 |
// show cross hair
|
765 |
paint.setColor(Color.DKGRAY);
|
766 |
paint.setStyle(Paint.Style.STROKE);
|
767 |
paint.setStrokeWidth(1);
|
768 |
paint.setAntiAlias(true);
|
769 |
int wm = mCanvasWidth / 2;
|
770 |
int hm = mCanvasHeight / 2;
|
771 |
c.drawLine(wm - 8, hm, wm - 35, hm, paint);
|
772 |
c.drawLine(wm + 8, hm, wm + 35, hm, paint);
|
773 |
c.drawLine(wm, hm - 8, wm, hm - 35, paint);
|
774 |
c.drawLine(wm, hm + 8, wm, hm + 35, paint);
|
775 |
}
|
776 |
}
|
777 |
|
778 |
if (NavitGraphics.MAP_DISPLAY_OFF)
|
779 |
{
|
780 |
if (one_shot)
|
781 |
{
|
782 |
//System.out.println("one shot");
|
783 |
one_shot = false;
|
784 |
this.postInvalidate();
|
785 |
}
|
786 |
}
|
787 |
}
|
788 |
|
789 |
// @Override
|
790 |
// public boolean onTouchEvent(MotionEvent event)
|
791 |
// {
|
792 |
// Boolean x = super.onTouchEvent(event);
|
793 |
// return false;
|
794 |
// }
|
795 |
|
796 |
public Handler progress_handler = new Handler()
|
797 |
{
|
798 |
public void handleMessage(Message msg)
|
799 |
{
|
800 |
switch (msg.what)
|
801 |
{
|
802 |
case 1:
|
803 |
postInvalidate();
|
804 |
break;
|
805 |
}
|
806 |
}
|
807 |
};
|
808 |
}
|