/[zanavi_public1]/navit/navit/android/src/com/zoffcc/applications/zanavi/NavitOSDJava.java
ZANavi

Diff of /navit/navit/android/src/com/zoffcc/applications/zanavi/NavitOSDJava.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 40 Revision 41
20package com.zoffcc.applications.zanavi; 20package com.zoffcc.applications.zanavi;
21 21
22import android.content.Context; 22import android.content.Context;
23import android.graphics.Bitmap; 23import android.graphics.Bitmap;
24import android.graphics.Canvas; 24import android.graphics.Canvas;
25import android.graphics.Color;
26import android.graphics.Paint; 25import android.graphics.Paint;
27import android.graphics.Rect;
28import android.graphics.RectF; 26import android.graphics.RectF;
29import android.os.Debug;
30import android.os.Handler; 27import android.os.Handler;
31import android.os.Message; 28import android.os.Message;
32 29
33public class NavitOSDJava // extends View 30public class NavitOSDJava // extends View
34{ 31{
54 private static Object sync_dummy_001 = new Object(); 51 private static Object sync_dummy_001 = new Object();
55 private static Boolean allow_drawing = true; 52 private static Boolean allow_drawing = true;
56 public static Integer synchro_obj = 0; 53 public static Integer synchro_obj = 0;
57 // private static Boolean in_draw_real = false; 54 // private static Boolean in_draw_real = false;
58 55
59 public static Handler progress_handler_ = new Handler(); 56 // public static Handler progress_handler_ = new Handler();
60 57
61 private static Boolean show_scale = false; 58 private static Boolean show_scale = false;
62 59
63 //private static Boolean one_shot = false; 60 //private static Boolean one_shot = false;
64 private static long last_paint_me = 0L; 61 private static long last_paint_me = 0L;
155 152
156 static int nextt_str_ltx = 0; 153 static int nextt_str_ltx = 0;
157 static int nextt_str_lty = 0; 154 static int nextt_str_lty = 0;
158 static int nextt_str_ltxB = 0; 155 static int nextt_str_ltxB = 0;
159 static int nextt_str_ltyB = 0; 156 static int nextt_str_ltyB = 0;
160 static int nextt_str_w = 0; 157 //static int nextt_str_w = 0;
161 static int nextt_str_h = 0; 158 static int nextt_str_h = 0;
162 static int nextt_str_wB = 0; 159 static int nextt_str_wB = 0;
163 static int nextt_str_hB = 0; 160 static int nextt_str_hB = 0;
164 static int nextt_str_font_size = 0; 161 // static int nextt_str_font_size = 0;
165 static int nextt_str_start_x = 0; 162 // static int nextt_str_start_x = 0;
166 static int nextt_str_start_y = 0; 163 // static int nextt_str_start_y = 0;
167 164
168 static int sat_status_lt_x = 0; 165 static int sat_status_lt_x = 0;
169 static int sat_status_lt_y = 0; 166 static int sat_status_lt_y = 0;
170 static int sat_status_lt_w = 0; 167 static int sat_status_lt_w = 0;
171 static int sat_status_lt_h = 0; 168 static int sat_status_lt_h = 0;
175 static Paint paint_crosshair = new Paint(); 172 static Paint paint_crosshair = new Paint();
176 173
177 // private long last_timestamp = 0L; 174 // private long last_timestamp = 0L;
178 // public static final int UPDATE_INTERVAL = 400; // in ms 175 // public static final int UPDATE_INTERVAL = 400; // in ms
179 176
180
181 // ------ UNUSED !!!!!!!! -------- 177 // ------ UNUSED !!!!!!!! --------
182 // ------ UNUSED !!!!!!!! -------- 178 // ------ UNUSED !!!!!!!! --------
183 // ------ UNUSED !!!!!!!! -------- 179 // ------ UNUSED !!!!!!!! --------
184 // ------ UNUSED !!!!!!!! -------- 180 // ------ UNUSED !!!!!!!! --------
185 public NavitOSDJava(Context context) 181 public NavitOSDJava(Context context)
186 { 182 {
187 // // super(context); 183 // // super(context);
188 // 184 //
189 // progress_handler_ = this.progress_handler; 185 // progress_handler_ = this.progress_handler;
190 // 186 //
191 // OSD_element_bg_001 = Color.argb(255, 80, 80, 150); // Color.argb(255, 190, 190, 190); // Color.argb(140, 136, 136, 136);
192 // OSD_element_bg_001_compass = Color.argb(255, 236, 229, 182); // 236, 229, 182 187 // OSD_element_bg_001_compass = Color.argb(255, 236, 229, 182); // 236, 229, 182
193 // OSD_element_text_001 = Color.argb(255, 255, 255, 255); // text color 188 // OSD_element_text_001 = Color.argb(255, 255, 255, 255); // text color
194 // OSD_element_text_shadow_001 = Color.rgb(0, 0, 0); // text shadow 189 // OSD_element_text_shadow_001 = Color.rgb(0, 0, 0); // text shadow
195 // OSD_element_text_shadow_width = 5; // 3 + 2; 190 // OSD_element_text_shadow_width = 5; // 3 + 2;
196 // 191 //
223 // public void onSizeChanged(int w, int h, int oldw, int oldh) 218 // public void onSizeChanged(int w, int h, int oldw, int oldh)
224 // { 219 // {
225 // super.onSizeChanged(w, h, oldw, oldh); 220 // super.onSizeChanged(w, h, oldw, oldh);
226 // } 221 // }
227 222
228 //@Override
229 public void onSizeChangedXX(int w, int h, int oldw, int oldh)
230 {
231 // super.onSizeChanged(w, h, oldw, oldh);
232 this.mCanvasWidth = w;
233 this.mCanvasHeight = h;
234
235 wm = w / 2;
236 hm = h / 2;
237
238 sat_status_lt_x = 2;
239 sat_status_lt_y = (int) (this.mCanvasHeight * 0.15);
240 sat_status_lt_w = 6;
241 sat_status_lt_h = this.mCanvasHeight - (int) (this.mCanvasHeight * (0.35 + 0.15));
242 sat_status_max_sats = 13;
243
244 draw_factor = 1.0f;
245 if (Navit.my_display_density.compareTo("mdpi") == 0)
246 {
247 draw_factor = 1.0f;
248 }
249 else if (Navit.my_display_density.compareTo("ldpi") == 0)
250 {
251 draw_factor = 0.7f;
252 }
253 else if (Navit.my_display_density.compareTo("hdpi") == 0)
254 {
255 draw_factor = 1.5f;
256 }
257
258 // correct for ultra high DPI
259 if (Navit.metrics.densityDpi >= 320) //&& (Navit.PREF_shrink_on_high_dpi))
260 {
261 draw_factor = 1.8f * Navit.metrics.densityDpi / NavitGraphics.Global_want_dpi_other;
262 NavitStreetFontLetterWidth = (int) ((float) NavitStreetFontLetterWidth_base * Navit.metrics.densityDpi / NavitGraphics.Global_want_dpi_other);
263 }
264
265 float real_factor = draw_factor / 1.5f;
266
267 // abs
268 compass_radius = (int) (50 * real_factor);
269 compass_lt_x = (int) (mCanvasWidth - (2 * compass_radius) - (16 * real_factor));
270 compass_lt_y = (int) (mCanvasHeight - (2 * compass_radius) - ((16 + 50) * real_factor));
271 // rel
272 compass_w = (int) (2 * compass_radius + 16 * real_factor);
273 compass_h = (int) (2 * compass_radius + 16 * real_factor);
274 compass_center_x = (int) (compass_w - compass_radius - 8 * real_factor);
275 compass_center_y = (int) (compass_h - compass_radius - 8 * real_factor);
276
277 ddtt_w = (int) (compass_w);
278 ddtt_h = (int) (40 * real_factor);
279 ddtt_lt_x = (int) (mCanvasWidth - (2 * compass_radius) - (16 * real_factor));
280 ddtt_lt_y = (int) (mCanvasHeight - 50 * real_factor);
281 ddtt_text_start_x = (int) (20 * real_factor);
282 ddtt_text_start_y = (int) (30 * real_factor);
283 ddtt_font_size = (int) (24 * real_factor);
284
285 dttarget_w = (int) (2 * (int) (50 * real_factor) + 16 * real_factor);
286 dttarget_h = (int) (40 * real_factor);
287 dttarget_lt_x = (int) ((mCanvasWidth / 2) - (dttarget_w / 2));
288 dttarget_lt_y = (int) (mCanvasHeight - 50 * real_factor);
289 dttarget_text_start_x = (int) (20 * real_factor);
290 dttarget_text_start_y = (int) (30 * real_factor);
291 dttarget_font_size = (int) (24 * real_factor);
292
293 eta_w = (int) (2 * (int) (50 * real_factor) + 16 * real_factor);
294 eta_h = (int) (40 * real_factor);
295 eta_lt_x = (int) (int) ((mCanvasWidth / 2) - (eta_w / 2));
296 eta_lt_y = (int) (mCanvasHeight - 50 * real_factor) - dttarget_h - 5;
297 eta_text_start_x = (int) (20 * real_factor);
298 eta_text_start_y = (int) (30 * real_factor);
299 eta_font_size = (int) (24 * real_factor);
300
301 scale_w = (int) (202 * real_factor);
302 scale_h = (int) (40 * real_factor);
303 scale_line_start_x = (int) (1 * real_factor);
304 scale_line_end_x = (int) (201 * real_factor);
305 scale_line_start_y = (int) (1 * real_factor);
306 scale_line_middle_y = (int) (1 * real_factor);
307 scale_line_end_y = (int) (8 * real_factor);
308 scale_lt_x = (int) (mCanvasWidth - scale_w - 4);
309 scale_lt_y = (int) (65);
310 scale_text_start_x = (int) (10 * real_factor);
311 scale_text_start_y = (int) (30 * real_factor);
312 scale_font_size = (int) (24 * real_factor);
313
314 // next turn icons
315 nextt_w = (int) (100 * real_factor);
316 nextt_h = (int) (100 * real_factor);
317 nextt_lt_x = (int) (10 * real_factor);
318 nextt_lt_y = (int) (mCanvasHeight - 50 * real_factor) - nextt_h - 5;
319 // next turn icons
320
321 // next turn icons -- BIG --
322 int smaller_size = mCanvasWidth;
323 float shrink_factor = 0.65f;
324 if (mCanvasWidth > mCanvasHeight)
325 {
326 // phone is turned in landscape-mode
327 smaller_size = mCanvasHeight;
328 shrink_factor = 0.43f;
329 }
330
331 nextt_wB = (int) (smaller_size * shrink_factor);
332 nextt_hB = (int) (smaller_size * shrink_factor);
333 nextt_lt_xB = (int) ((mCanvasWidth - nextt_wB) / 2);
334 nextt_lt_yB = (int) (60 * real_factor);
335 // next turn icons -- BIG --
336
337 // next turn streetname --
338 nextt_str_w = mCanvasWidth;
339 nextt_str_h = (int) (65 * real_factor);
340 nextt_str_ltx = 0;
341 nextt_str_lty = 20;
342 nextt_str_font_size = (int) (41 * real_factor);
343 nextt_str_start_x = 8;
344 nextt_str_start_y = (int) (46 * real_factor);
345 // next turn streetname --
346
347 // next turn streetname -- BIG --
348 nextt_str_wB = mCanvasWidth;
349 nextt_str_hB = (int) (65 * real_factor);
350 nextt_str_ltxB = 0;
351 nextt_str_ltyB = nextt_lt_yB + nextt_hB + 4;
352 // next turn streetname -- BIG --
353
354 // next turn in XX m --
355 nt_w = (int) (100 * real_factor);
356 nt_h = (int) (40 * real_factor);
357 nt_lt_x = (int) (10 * real_factor);
358 nt_lt_y = (int) (mCanvasHeight - 50 * real_factor);
359 nt_text_start_x = (int) (20 * real_factor);
360 nt_text_start_y = (int) (30 * real_factor);
361 nt_font_size = (int) (24 * real_factor);
362 // next turn in XX m --
363
364 // next turn in XX m -- BIG --
365 nt_lt_xB = nextt_lt_xB;
366 nt_lt_yB = nextt_lt_yB - nt_h - 4;
367 // next turn in XX m -- BIG --
368
369 if (compass_b != null)
370 {
371 compass_b.recycle();
372 compass_b = null;
373 }
374 compass_b = Bitmap.createBitmap(compass_w, compass_h, Bitmap.Config.ARGB_8888);
375 compass_c = new Canvas(compass_b);
376
377 if (ddtt_b != null)
378 {
379 ddtt_b.recycle();
380 ddtt_b = null;
381 }
382 ddtt_b = Bitmap.createBitmap(ddtt_w, ddtt_h, Bitmap.Config.ARGB_8888);
383 ddtt_c = new Canvas(ddtt_b);
384
385 if (scale_b != null)
386 {
387 scale_b.recycle();
388 scale_b = null;
389 }
390 scale_b = Bitmap.createBitmap(scale_w, scale_h, Bitmap.Config.ARGB_8888);
391 scale_c = new Canvas(scale_b);
392
393 if (dttarget_b != null)
394 {
395 dttarget_b.recycle();
396 dttarget_b = null;
397 }
398 dttarget_b = Bitmap.createBitmap(dttarget_w, dttarget_h, Bitmap.Config.ARGB_8888);
399 dttarget_c = new Canvas(dttarget_b);
400
401 if (eta_b != null)
402 {
403 eta_b.recycle();
404 eta_b = null;
405 }
406 eta_b = Bitmap.createBitmap(eta_w, eta_h, Bitmap.Config.ARGB_8888);
407 eta_c = new Canvas(eta_b);
408
409 if (nt_b != null)
410 {
411 nt_b.recycle();
412 nt_b = null;
413 }
414 nt_b = Bitmap.createBitmap(nt_w, nt_h, Bitmap.Config.ARGB_8888);
415 nt_c = new Canvas(nt_b);
416
417 boolean need_create_bitmap = true;
418 if (rest_osd_b != null)
419 {
420 System.out.println("OSD:have bitmap 001 new:" + w + " x " + h + " old:" + rest_osd_b.getWidth() + " x " + rest_osd_b.getHeight());
421
422 if (rest_osd_b.getHeight() >= h)
423 {
424 if (rest_osd_b.getWidth() >= w)
425 {
426 need_create_bitmap = false;
427 }
428 }
429 }
430
431 if (need_create_bitmap)
432 {
433 System.out.println("OSD:Creating bitmap 001");
434
435 if (rest_osd_b != null)
436 {
437 rest_osd_b.recycle();
438 rest_osd_b = null;
439 rest_osd_c = null;
440 System.gc();
441 }
442
443 try
444 {
445 rest_osd_b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
446 rest_osd_c = new Canvas(rest_osd_b);
447 }
448 catch (OutOfMemoryError e)
449 {
450 int usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L);
451 System.out.println("OOM:OSD:001");
452 String usedMegsString = String.format(" - Memory Used: %d MB", usedMegs);
453 System.out.println("" + usedMegsString);
454 System.out.println("@@@@@@@@ out of VM Memory @@@@@@@@");
455 System.gc();
456 System.gc();
457 usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L);
458 usedMegsString = String.format(" - Memory Used: %d MB", usedMegs);
459 System.out.println("" + usedMegsString);
460 // try again
461 rest_osd_b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
462 rest_osd_c = new Canvas(rest_osd_b);
463 }
464 }
465 else
466 {
467 System.out.println("OSD:Reusing bitmap 001");
468 }
469
470 need_create_bitmap = true;
471 if (buffer_osd_b != null)
472 {
473 System.out.println("OSD:have bitmap 002 new:" + w + " x " + h + " old:" + buffer_osd_b.getWidth() + " x " + buffer_osd_b.getHeight());
474
475 if (buffer_osd_b.getHeight() >= h)
476 {
477 if (buffer_osd_b.getWidth() >= w)
478 {
479 need_create_bitmap = false;
480 }
481 }
482 }
483
484 if (need_create_bitmap)
485 {
486 System.out.println("OSD:Creating bitmap 002");
487
488 if (buffer_osd_b != null)
489 {
490 buffer_osd_b.recycle();
491 buffer_osd_b = null;
492 buffer_osd_c = null;
493 System.gc();
494 }
495
496 try
497 {
498 buffer_osd_b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
499 buffer_osd_c = new Canvas(buffer_osd_b);
500 }
501 catch (OutOfMemoryError e)
502 {
503 int usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L);
504 System.out.println("OOM:OSD:002");
505 String usedMegsString = String.format(" - Memory Used: %d MB", usedMegs);
506 System.out.println("" + usedMegsString);
507 System.out.println("@@@@@@@@ out of VM Memory @@@@@@@@");
508 System.gc();
509 System.gc();
510 usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L);
511 usedMegsString = String.format(" - Memory Used: %d MB", usedMegs);
512 System.out.println("" + usedMegsString);
513 // try again
514 buffer_osd_b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
515 buffer_osd_c = new Canvas(buffer_osd_b);
516 }
517 }
518 else
519 {
520 System.out.println("OSD:Reusing bitmap 002");
521 }
522
523 // if (buffer2_osd_b != null)
524 // {
525 // buffer2_osd_b.recycle();
526 // buffer2_osd_b = null;
527 // }
528 //
529 // try
530 // {
531 // buffer2_osd_b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
532 // buffer2_osd_c = new Canvas(buffer2_osd_b);
533 // }
534 // catch (OutOfMemoryError e)
535 // {
536 // int usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L);
537 // System.out.println("OOM:OSD:003");
538 // String usedMegsString = String.format(" - Memory Used: %d MB", usedMegs);
539 // System.out.println("" + usedMegsString);
540 // System.out.println("@@@@@@@@ out of VM Memory @@@@@@@@");
541 // System.gc();
542 // usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L);
543 // usedMegsString = String.format(" - Memory Used: %d MB", usedMegs);
544 // System.out.println("" + usedMegsString);
545 // // try again
546 // buffer2_osd_b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
547 // buffer2_osd_c = new Canvas(buffer2_osd_b);
548 // }
549
550 // ----------------- make all bitmaps seethru ---------------------
551 // rest_osd_c.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
552 NavitGraphics.NavitAOSDJava_.rest_osd_b.eraseColor(Color.TRANSPARENT);
553
554 compass_b.eraseColor(Color.TRANSPARENT);
555 ddtt_b.eraseColor(Color.TRANSPARENT);
556 NavitGraphics.NavitAOSDJava_.scale_b.eraseColor(Color.TRANSPARENT);
557 dttarget_b.eraseColor(Color.TRANSPARENT);
558 eta_b.eraseColor(Color.TRANSPARENT);
559 nt_b.eraseColor(Color.TRANSPARENT);
560 }
561
562 public static class drawOSDThread extends Thread 223 public static class drawOSDThread extends Thread
563 { 224 {
564 private Boolean running = true; 225 private Boolean running = true;
565 private boolean start_work = false; 226 private boolean start_work = false;
566 private boolean need_redraw_osd = false; 227 private boolean need_redraw_osd = false;
620 } 281 }
621 } 282 }
622 283
623 public static void draw_real_wrapper(boolean redraw_osd, boolean redraw_overlay) 284 public static void draw_real_wrapper(boolean redraw_osd, boolean redraw_overlay)
624 { 285 {
625 //System.out.println("OSD:draw_real_wrapper:begin"); 286 // System.out.println("OSD:draw_real_wrapper:begin");
626 Navit.draw_osd_thread.buzz(redraw_osd, redraw_overlay); 287 Navit.draw_osd_thread.buzz(redraw_osd, redraw_overlay);
627 //++ draw_real(); 288 //++ draw_real();
628 //System.out.println("OSD:draw_real_wrapper:end"); 289 // System.out.println("OSD:draw_real_wrapper:end");
629 } 290 }
630 291
631 synchronized public static void draw_real() 292 synchronized public static void draw_real()
632 { 293 {
633 294
634 }
635
636 synchronized public static void draw_realXX()
637 {
638 //System.out.println("OSD:004:begin");
639
640 // if (in_draw_real == true)
641 // {
642 // System.out.println("OSD:parallel001");
643 // return;
644 // }
645
646 //in_draw_real = true;
647
648 try
649 {
650 // compass_c.drawColor(Color.LTGRAY);
651 // ddtt_c.drawColor(Color.CYAN);
652
653 dest_valid = NavitGraphics.CallbackDestinationValid2();
654
655 did_draw_circle = false;
656 if (!NavitGraphics.MAP_DISPLAY_OFF)
657 {
658 if ((Navit.OSD_compass.angle_north_valid) || ((Navit.OSD_compass.angle_target_valid) && (dest_valid > 0)))
659 {
660 // compass_c.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
661 paint.setStyle(Paint.Style.FILL_AND_STROKE);
662 paint.setStrokeWidth(2);
663 paint.setAntiAlias(true);
664 paint.setColor(OSD_element_bg_001_compass);
665 compass_c.drawRoundRect(new RectF(0 + 3, 0 + 3, compass_w - 3, compass_h - 3), 18, 18, paint);
666 }
667
668 if (Navit.OSD_compass.angle_north_valid)
669 {
670 paint.setColor(Color.BLACK);
671 paint.setStyle(Paint.Style.STROKE);
672 paint.setStrokeWidth(2);
673 paint.setAntiAlias(true);
674 compass_c.drawCircle(compass_center_x, compass_center_y, compass_radius, paint);
675 did_draw_circle = true;
676 end_x = (int) ((float) Math.sin((float) Math.toRadians(Navit.OSD_compass.angle_north)) * compass_radius);
677 end_y = (int) ((float) Math.cos((float) Math.toRadians(Navit.OSD_compass.angle_north)) * compass_radius);
678 // System.out.println("x " + end_x + " y " + end_y);
679 paint.setStrokeWidth(2);
680 if (Navit.metrics.densityDpi >= 320)
681 {
682 paint.setStrokeWidth(4);
683 }
684 compass_c.drawLine(compass_center_x - end_x, compass_center_y + end_y, compass_center_x, compass_center_y, paint);
685 paint.setColor(Color.RED);
686 paint.setStrokeWidth(4);
687 if (Navit.metrics.densityDpi >= 320)
688 {
689 paint.setStrokeWidth(8);
690 }
691 compass_c.drawLine(compass_center_x + end_x, compass_center_y - end_y, compass_center_x, compass_center_y, paint);
692 }
693 if ((Navit.OSD_compass.angle_target_valid) && (dest_valid > 0))
694 {
695 paint.setColor(Color.BLACK);
696 paint.setStyle(Paint.Style.STROKE);
697 paint.setStrokeWidth(2);
698 paint.setAntiAlias(true);
699 if (!did_draw_circle)
700 {
701 compass_c.drawCircle(compass_center_x, compass_center_y, compass_radius, paint);
702 did_draw_circle = true;
703 }
704 end_x = (int) ((float) Math.sin((float) Math.toRadians(Navit.OSD_compass.angle_target)) * compass_radius);
705 end_y = (int) ((float) Math.cos((float) Math.toRadians(Navit.OSD_compass.angle_target)) * compass_radius);
706 // System.out.println("x " + end_x + " y " + end_y);
707 paint.setStrokeWidth(2);
708 if (Navit.metrics.densityDpi >= 320)
709 {
710 paint.setStrokeWidth(4);
711 }
712 paint.setColor(Color.GREEN);
713 compass_c.drawLine(compass_center_x, compass_center_y, compass_center_x + end_x, compass_center_y - end_y, paint);
714 }
715 }
716
717 if ((Navit.OSD_compass.direct_distance_to_target_valid) && (dest_valid > 0))
718 {
719 paint.setColor(OSD_element_bg_001);
720 paint.setStyle(Paint.Style.FILL_AND_STROKE);
721 paint.setStrokeWidth(2);
722 paint.setAntiAlias(true);
723 ddtt_c.drawRoundRect(new RectF(0 + 2, 0 + 2, ddtt_w - 2, ddtt_h - 2), 10, 10, paint);
724
725 paint.setColor(OSD_element_text_shadow_001);
726 paint.setStrokeWidth(OSD_element_text_shadow_width);
727 paint.setStyle(Paint.Style.STROKE);
728 paint.setTextSize(ddtt_font_size);
729 paint.setAntiAlias(true);
730 ddtt_c.drawText(Navit.OSD_compass.direct_distance_to_target, ddtt_text_start_x, ddtt_text_start_y, paint);
731
732 paint.setColor(OSD_element_text_001);
733 paint.setStrokeWidth(3);
734 paint.setStyle(Paint.Style.FILL);
735 paint.setTextSize(ddtt_font_size);
736 paint.setAntiAlias(true);
737 ddtt_c.drawText(Navit.OSD_compass.direct_distance_to_target, ddtt_text_start_x, ddtt_text_start_y, paint);
738 }
739 if ((Navit.OSD_route_001.arriving_time_valid) && (dest_valid > 0))
740 {
741 paint.setColor(OSD_element_bg_001);
742 paint.setStyle(Paint.Style.FILL_AND_STROKE);
743 paint.setStrokeWidth(2);
744 paint.setAntiAlias(true);
745 eta_c.drawRoundRect(new RectF(0 + 2, 0 + 2, eta_w - 2, eta_h - 2), 10, 10, paint);
746
747 paint.setColor(OSD_element_text_shadow_001);
748 paint.setStrokeWidth(OSD_element_text_shadow_width);
749 paint.setStyle(Paint.Style.STROKE);
750 paint.setTextSize(eta_font_size);
751 paint.setAntiAlias(true);
752 eta_c.drawText(Navit.OSD_route_001.arriving_time, eta_text_start_x, eta_text_start_y, paint);
753
754 paint.setColor(OSD_element_text_001);
755 paint.setStrokeWidth(3);
756 paint.setStyle(Paint.Style.FILL);
757 paint.setTextSize(eta_font_size);
758 paint.setAntiAlias(true);
759 eta_c.drawText(Navit.OSD_route_001.arriving_time, eta_text_start_x, eta_text_start_y, paint);
760 }
761 if ((Navit.OSD_route_001.driving_distance_to_target_valid) && (dest_valid > 0))
762 {
763 paint.setColor(OSD_element_bg_001);
764 paint.setStyle(Paint.Style.FILL_AND_STROKE);
765 paint.setStrokeWidth(2);
766 paint.setAntiAlias(true);
767 dttarget_c.drawRoundRect(new RectF(0 + 2, 0 + 2, dttarget_w - 2, dttarget_h - 2), 10, 10, paint);
768
769 paint.setColor(OSD_element_text_shadow_001);
770 paint.setStrokeWidth(OSD_element_text_shadow_width);
771 paint.setStyle(Paint.Style.STROKE);
772 paint.setTextSize(dttarget_font_size);
773 paint.setAntiAlias(true);
774 dttarget_c.drawText(Navit.OSD_route_001.driving_distance_to_target, dttarget_text_start_x, dttarget_text_start_y, paint);
775
776 paint.setColor(OSD_element_text_001);
777 paint.setStrokeWidth(3);
778 paint.setStyle(Paint.Style.FILL);
779 paint.setTextSize(dttarget_font_size);
780 paint.setAntiAlias(true);
781 dttarget_c.drawText(Navit.OSD_route_001.driving_distance_to_target, dttarget_text_start_x, dttarget_text_start_y, paint);
782 }
783 if ((Navit.OSD_nextturn.nextturn_distance_valid) && (dest_valid > 0))
784 {
785 if (NavitGraphics.MAP_DISPLAY_OFF)
786 {
787 paint.setColor(Color.argb(255, 20, 20, 230));
788 paint.setStyle(Paint.Style.FILL_AND_STROKE);
789 paint.setStrokeWidth(2);
790 paint.setAntiAlias(true);
791 nt_c.drawRoundRect(new RectF(0 + 2, 0 + 2, nt_w - 2, nt_h - 2), 10, 10, paint);
792
793 paint.setColor(Color.WHITE);
794 paint.setStrokeWidth(3);
795 paint.setStyle(Paint.Style.FILL);
796 paint.setTextSize(nt_font_size);
797 paint.setAntiAlias(true);
798 nt_c.drawText(Navit.OSD_nextturn.nextturn_distance, nt_text_start_x, nt_text_start_y, paint);
799 }
800 else
801 {
802 paint.setColor(OSD_element_bg_001);
803 paint.setStyle(Paint.Style.FILL_AND_STROKE);
804 paint.setStrokeWidth(2);
805 paint.setAntiAlias(true);
806 nt_c.drawRoundRect(new RectF(0 + 2, 0 + 2, nt_w - 2, nt_h - 2), 10, 10, paint);
807
808 paint.setColor(OSD_element_text_shadow_001);
809 paint.setStrokeWidth(OSD_element_text_shadow_width);
810 paint.setStyle(Paint.Style.STROKE);
811 paint.setTextSize(nt_font_size);
812 paint.setAntiAlias(true);
813 nt_c.drawText(Navit.OSD_nextturn.nextturn_distance, nt_text_start_x, nt_text_start_y, paint);
814
815 paint.setColor(OSD_element_text_001);
816 paint.setStrokeWidth(3);
817 paint.setStyle(Paint.Style.FILL);
818 paint.setTextSize(nt_font_size);
819 paint.setAntiAlias(true);
820 nt_c.drawText(Navit.OSD_nextturn.nextturn_distance, nt_text_start_x, nt_text_start_y, paint);
821 }
822 }
823
824 if (show_scale)
825 {
826 if (Navit.OSD_scale.scale_valid)
827 {
828 paint.setColor(Color.BLACK);
829 paint.setStrokeWidth(3);
830 paint.setAntiAlias(true);
831 paint.setStyle(Paint.Style.STROKE);
832 // mothod a
833 NavitGraphics.NavitAOSDJava_.scale_c.drawLine(scale_line_start_x, scale_line_middle_y, scale_line_start_x + Navit.OSD_scale.var, scale_line_middle_y, paint);
834 // method b
835 // scale_c.drawLine(scale_line_start_x, scale_line_middle_y, scale_line_end_x, scale_line_middle_y, paint);
836 NavitGraphics.NavitAOSDJava_.scale_c.drawLine(scale_line_start_x, scale_line_start_y, scale_line_start_x, scale_line_end_y, paint);
837 NavitGraphics.NavitAOSDJava_.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);
838
839 paint.setColor(OSD_element_text_shadow_001);
840 paint.setStrokeWidth(OSD_element_text_shadow_width);
841 paint.setStyle(Paint.Style.STROKE);
842 paint.setTextSize(scale_font_size);
843 NavitGraphics.NavitAOSDJava_.scale_c.drawText(Navit.OSD_scale.scale_text, scale_text_start_x, scale_text_start_y, paint);
844
845 paint.setStyle(Paint.Style.FILL);
846 paint.setColor(OSD_element_text_001);
847 paint.setStrokeWidth(3);
848 paint.setTextSize(scale_font_size);
849 NavitGraphics.NavitAOSDJava_.scale_c.drawText(Navit.OSD_scale.scale_text, scale_text_start_x, scale_text_start_y, paint);
850 }
851 }
852 }
853 catch (Exception e)
854 {
855 //e.printStackTrace();
856 }
857
858 try
859 {
860 if ((Navit.OSD_nextturn.nextturn_streetname != null) || (Navit.PREF_follow_gps))
861 {
862 if (NavitGraphics.MAP_DISPLAY_OFF)
863 {
864 paint.setColor(Color.argb(255, 20, 20, 230));
865 paint.setStyle(Paint.Style.FILL_AND_STROKE);
866 paint.setStrokeWidth(2);
867 paint.setAntiAlias(true);
868 NavitGraphics.NavitAOSDJava_.rest_osd_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);
869 paint.setColor(Color.WHITE);
870 paint.setStrokeWidth(3);
871 paint.setStyle(Paint.Style.FILL);
872 if ((Navit.OSD_nextturn.nextturn_streetname.length() + 1 + Navit.OSD_nextturn.nextturn_streetname_systematic.length()) > (nextt_str_wB / NavitStreetFontLetterWidth))
873 {
874 if ((Navit.OSD_nextturn.nextturn_streetname.length() + 1 + Navit.OSD_nextturn.nextturn_streetname_systematic.length()) > (2 * (nextt_str_wB / NavitStreetFontLetterWidth)))
875 {
876 paint.setTextSize((int) (nextt_str_font_size * 0.40));
877 }
878 else
879 {
880 paint.setTextSize((int) (nextt_str_font_size * 0.70));
881 }
882 }
883 else
884 {
885 paint.setTextSize(nextt_str_font_size);
886 }
887 paint.setAntiAlias(true);
888 NavitGraphics.NavitAOSDJava_.rest_osd_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);
889 }
890 else
891 {
892 paint.setColor(OSD_element_bg_001);
893 paint.setStyle(Paint.Style.FILL_AND_STROKE);
894 paint.setStrokeWidth(2);
895 paint.setAntiAlias(true);
896 NavitGraphics.NavitAOSDJava_.rest_osd_c.drawRoundRect(new RectF(nextt_str_ltx, nextt_str_lty, nextt_str_ltx + nextt_str_w, nextt_str_lty + nextt_str_h), 10, 10, paint);
897 paint.setColor(Color.BLACK);
898 paint.setStrokeWidth(3);
899 paint.setStyle(Paint.Style.FILL);
900 if ((Navit.OSD_nextturn.nextturn_streetname.length() + 1 + Navit.OSD_nextturn.nextturn_streetname_systematic.length()) > (nextt_str_wB / NavitStreetFontLetterWidth))
901 {
902 if ((Navit.OSD_nextturn.nextturn_streetname.length() + 1 + Navit.OSD_nextturn.nextturn_streetname_systematic.length()) > (2 * (nextt_str_wB / NavitStreetFontLetterWidth)))
903 {
904 paint.setTextSize((int) (nextt_str_font_size * 0.40));
905 }
906 else
907 {
908 paint.setTextSize((int) (nextt_str_font_size * 0.70));
909 }
910 }
911 else
912 {
913 paint.setTextSize(nextt_str_font_size);
914 }
915
916 paint.setColor(OSD_element_text_shadow_001);
917 paint.setStrokeWidth(OSD_element_text_shadow_width);
918 paint.setStyle(Paint.Style.STROKE);
919 paint.setAntiAlias(true);
920 NavitGraphics.NavitAOSDJava_.rest_osd_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);
921
922 paint.setColor(OSD_element_text_001);
923 paint.setStrokeWidth(3);
924 paint.setStyle(Paint.Style.FILL);
925 paint.setAntiAlias(true);
926 NavitGraphics.NavitAOSDJava_.rest_osd_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);
927 }
928 }
929 else
930 {
931 paint.setColor(Color.argb(0, 0, 0, 0));
932 paint.setStyle(Paint.Style.FILL);
933 paint.setStrokeWidth(3);
934 paint.setAntiAlias(false);
935 if (NavitGraphics.MAP_DISPLAY_OFF)
936 {
937 NavitGraphics.NavitAOSDJava_.rest_osd_c.drawRect(new RectF(nextt_str_ltxB, nextt_str_ltyB, nextt_str_ltxB + nextt_str_wB, nextt_str_ltyB + nextt_str_hB), paint);
938 }
939 else
940 {
941 NavitGraphics.NavitAOSDJava_.rest_osd_c.drawRect(new RectF(nextt_str_ltx, nextt_str_lty, nextt_str_ltx + nextt_str_w, nextt_str_lty + nextt_str_h), paint);
942 }
943 }
944 }
945 catch (Exception e)
946 {
947
948 }
949
950 try
951 {
952 if ((Navit.OSD_nextturn.nextturn_image_valid) && (NavitGraphics.CallbackDestinationValid2() > 0))
953 {
954 if (NavitGraphics.MAP_DISPLAY_OFF)
955 {
956 paint.setColor(Color.argb(255, 20, 20, 230));
957 paint.setStyle(Paint.Style.FILL_AND_STROKE);
958 paint.setStrokeWidth(2);
959 paint.setAntiAlias(true);
960 dst = new RectF(nextt_lt_xB, nextt_lt_yB, nextt_lt_xB + nextt_wB, nextt_lt_yB + nextt_hB);
961 NavitGraphics.NavitAOSDJava_.rest_osd_c.drawRoundRect(new RectF(nextt_lt_xB, nextt_lt_yB, nextt_lt_xB + nextt_wB, nextt_lt_yB + nextt_hB), 10, 10, paint);
962 NavitGraphics.NavitAOSDJava_.rest_osd_c.drawBitmap(Navit.OSD_nextturn.nextturn_image, null, dst, null);
963 }
964 else
965 {
966 paint.setColor(OSD_element_bg_001);
967 paint.setStyle(Paint.Style.FILL_AND_STROKE);
968 paint.setStrokeWidth(2);
969 paint.setAntiAlias(true);
970 dst = new RectF(nextt_lt_x, nextt_lt_y, nextt_lt_x + nextt_w, nextt_lt_y + nextt_h);
971 NavitGraphics.NavitAOSDJava_.rest_osd_c.drawRoundRect(new RectF(nextt_lt_x, nextt_lt_y, nextt_lt_x + nextt_w, nextt_lt_y + nextt_h), 10, 10, paint);
972 NavitGraphics.NavitAOSDJava_.rest_osd_c.drawBitmap(Navit.OSD_nextturn.nextturn_image, null, dst, null);
973 }
974 }
975 else
976 {
977 paint.setColor(Color.argb(0, 0, 0, 0));
978 paint.setStyle(Paint.Style.FILL);
979 paint.setStrokeWidth(3);
980 paint.setAntiAlias(false);
981 if (NavitGraphics.MAP_DISPLAY_OFF)
982 {
983 NavitGraphics.NavitAOSDJava_.rest_osd_c.drawRect(new RectF(nextt_lt_xB, nextt_lt_yB, nextt_lt_xB + nextt_wB, nextt_lt_yB + nextt_hB), paint);
984 }
985 else
986 {
987 NavitGraphics.NavitAOSDJava_.rest_osd_c.drawRect(new RectF(nextt_lt_x, nextt_lt_y, nextt_lt_x + nextt_w, nextt_lt_y + nextt_h), paint);
988 }
989 }
990 }
991 catch (Exception e)
992 {
993 //e.printStackTrace();
994 }
995
996 try
997 {
998 if (Navit.PREF_show_sat_status)
999 {
1000 // fill rect
1001 paint.setColor(Color.GRAY);
1002 paint.setStyle(Paint.Style.FILL);
1003 paint.setStrokeWidth(0);
1004 paint.setAntiAlias(true);
1005 NavitGraphics.NavitAOSDJava_.rest_osd_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);
1006
1007 if (Navit.sats > sat_status_max_sats)
1008 {
1009 sat_status_max_sats = Navit.sats;
1010 }
1011
1012 // fill inactive sats
1013 paint.setColor(Color.YELLOW);
1014 paint.setStyle(Paint.Style.FILL);
1015 paint.setStrokeWidth(0);
1016 paint.setAntiAlias(true);
1017 NavitGraphics.NavitAOSDJava_.rest_osd_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);
1018
1019 // fill active sats
1020 paint.setColor(Color.GREEN);
1021 paint.setStyle(Paint.Style.FILL);
1022 paint.setStrokeWidth(0);
1023 paint.setAntiAlias(true);
1024 NavitGraphics.NavitAOSDJava_.rest_osd_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);
1025
1026 // black rect around it all
1027 paint.setColor(Color.BLACK);
1028 paint.setStyle(Paint.Style.STROKE);
1029 paint.setStrokeWidth(1);
1030 paint.setAntiAlias(true);
1031 NavitGraphics.NavitAOSDJava_.rest_osd_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);
1032 }
1033 }
1034 catch (Exception e)
1035 {
1036 //e.printStackTrace();
1037 }
1038
1039 //if (NavitGraphics.MAP_DISPLAY_OFF)
1040 //{
1041 // one_shot = true;
1042 //}
1043 // allow_drawing = true;
1044
1045 onDraw_part2();
1046
1047 //in_draw_real = false;
1048
1049 //System.out.println("OSD:004:end");
1050 } 295 }
1051 296
1052 public void onDraw(Canvas c) 297 public void onDraw(Canvas c)
1053 { 298 {
1054 // System.out.println("XYZ:NavitOSDJava -> onDraw"); 299 // System.out.println("XYZ:NavitOSDJava -> onDraw");
1055 // NOTHING HERE anymore !!!!!! 300 // NOTHING HERE anymore !!!!!!
1056 }
1057
1058 public void onDrawXX(Canvas c)
1059 {
1060
1061 //System.out.println("draw:isHardwareAccelerated=" + c.isHardwareAccelerated());
1062
1063 try
1064 {
1065 // synchronized (sync_dummy_001)
1066 // {
1067 allow_drawing = false;
1068 c.drawBitmap(buffer_osd_b, 0, 0, null);
1069 allow_drawing = true;
1070 // }
1071
1072 //++boolean got_it = take_synchro();
1073 //System.out.println("OO:002:synchro_obj=" + synchro_obj);
1074 //++while (got_it == false)
1075 //++{
1076 //++ //System.out.println("do_draw:blocking wait ...");
1077 //++ Thread.sleep(5);
1078 //++ got_it = take_synchro();
1079 //++}
1080 //System.out.println("OO:002:start");
1081 // c.drawBitmap(NavitGraphics.NavitAOSDJava_.buffer_osd_b, 0, 0, null);
1082 //c.drawBitmap(rest_osd_b, 0, 0, null);
1083 //System.out.println("OO:002:end");
1084 //++if (got_it)
1085 //++{
1086 //++ release_synchro();
1087 //++}
1088
1089 if (!Navit.PREF_follow_gps)
1090 {
1091 if (!NavitGraphics.MAP_DISPLAY_OFF)
1092 {
1093 // show cross hair
1094 paint_crosshair.setColor(Color.DKGRAY);
1095 paint_crosshair.setStyle(Paint.Style.STROKE);
1096 delta_1 = 8;
1097 delta_2 = 35;
1098 if (Navit.metrics.densityDpi >= 320) //&& (Navit.PREF_shrink_on_high_dpi))
1099 {
1100 paint_crosshair.setStrokeWidth(2);
1101 delta_1 = 8 * 2;
1102 delta_2 = 35 * 2;
1103 }
1104 else
1105 {
1106 paint_crosshair.setStrokeWidth(1);
1107 }
1108 paint_crosshair.setAntiAlias(true);
1109 c.drawLine(wm - delta_1, hm, wm - delta_2, hm, paint_crosshair);
1110 c.drawLine(wm + delta_1, hm, wm + delta_2, hm, paint_crosshair);
1111 c.drawLine(wm, hm - delta_1, wm, hm - delta_2, paint_crosshair);
1112 c.drawLine(wm, hm + delta_1, wm, hm + delta_2, paint_crosshair);
1113 }
1114 }
1115
1116 }
1117 catch (Exception e)
1118 {
1119 // e.printStackTrace();
1120 }
1121
1122 // System.out.println("OSD:002:draw:end");
1123 } 301 }
1124 302
1125 public static boolean take_synchro() 303 public static boolean take_synchro()
1126 { 304 {
1127 synchronized (synchro_obj) 305 synchronized (synchro_obj)

Legend:
Removed from v.40  
changed lines
  Added in v.41

   
Visit the ZANavi Wiki