1 | /** |
1 | /** |
2 | * ZANavi, Zoff Android Navigation system. |
2 | * ZANavi, Zoff Android Navigation system. |
3 | * Copyright (C) 2011 Zoff <zoff@zoff.cc> |
3 | * Copyright (C) 2011 - 2012 Zoff <zoff@zoff.cc> |
4 | * |
4 | * |
5 | * This program is free software; you can redistribute it and/or |
5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License |
6 | * modify it under the terms of the GNU General Public License |
7 | * version 2 as published by the Free Software Foundation. |
7 | * version 2 as published by the Free Software Foundation. |
8 | * |
8 | * |
… | |
… | |
94 | public final static DashPathEffect[] dashes__low = { null, l001, l002, l003, l004, l005, l006 }; |
94 | public final static DashPathEffect[] dashes__low = { null, l001, l002, l003, l004, l005, l006 }; |
95 | public final static DashPathEffect[] dashes__high = { null, h001, h002, h003, h004, h005, h006 }; |
95 | public final static DashPathEffect[] dashes__high = { null, h001, h002, h003, h004, h005, h006 }; |
96 | |
96 | |
97 | public static int navit_route_status = 0; |
97 | public static int navit_route_status = 0; |
98 | |
98 | |
99 | // public static NavitOSDJava NavitAOSDJava_ = null; |
99 | public final float BIGMAP_FACTOR = (10465f / 2f) * 0.8f; |
|
|
100 | |
100 | public static long last_paint_OSD = 0; |
101 | public static long last_paint_OSD = 0; |
101 | |
102 | |
102 | public static Boolean wait_for_redraw_map = false; |
103 | public static Boolean wait_for_redraw_map = false; |
103 | |
104 | |
|
|
105 | public static Boolean MAP_DISPLAY_OFF = false; |
|
|
106 | |
|
|
107 | public static int mCanvasWidth = 1; |
|
|
108 | public static int mCanvasHeight = 1; |
|
|
109 | |
104 | public static final Boolean DEBUG_TOUCH = false; |
110 | public static final Boolean DEBUG_TOUCH = false; |
|
|
111 | public static Boolean ZOOM_MODE_ACTIVE = false; |
|
|
112 | public static float ZOOM_MODE_SCALE = 0; |
105 | |
113 | |
106 | public static float draw_factor = 1.0f; |
114 | public static float draw_factor = 1.0f; |
107 | |
115 | |
108 | public static String debug_line_1 = ""; |
116 | public static String debug_line_1 = ""; |
109 | public static String debug_line_2 = ""; |
117 | public static String debug_line_2 = ""; |
110 | public static String debug_line_3 = ""; |
118 | public static String debug_line_3 = ""; |
|
|
119 | public static String debug_line_4 = ""; |
111 | |
120 | |
112 | public static final int DRAW_ONEWAY_ARROWS_AT_ORDER = 13; |
121 | public static final int DRAW_ONEWAY_ARROWS_AT_ORDER = 13; |
|
|
122 | public static final int DRAW_DETAIL_DASHES_AT_ORDER = 13; |
|
|
123 | public static final int DRAW_MORE_DETAILS_AT_ORDER = 9; |
|
|
124 | public static final int DRAW_MORE_DETAILS_TUNNEL_BRIDGES_AT_ORDER = 8; |
113 | |
125 | |
114 | public static long[] OverlayDrawThread_cancel_drawing_timeout__options = { 300L, 900L, 2100L, 20000L }; // 900L normal, 300L short, 2100L long |
126 | public static long[] OverlayDrawThread_cancel_drawing_timeout__options = { 300L, 900L, 2100L, 20000L }; // 900L normal, 300L short, 2100L long |
115 | public static int[] OverlayDrawThread_cancel_thread_sleep_time__options = { 100, 200, 400, 400 }; |
127 | public static int[] OverlayDrawThread_cancel_thread_sleep_time__options = { 100, 200, 400, 400 }; |
116 | public static long[] OverlayDrawThread_cancel_thread_timeout__options = { 3000L, 3000L, 3000L, 22000L }; |
128 | public static long[] OverlayDrawThread_cancel_thread_timeout__options = { 3000L, 3000L, 3000L, 22000L }; |
117 | |
129 | |
… | |
… | |
141 | int pos_wraparound; |
153 | int pos_wraparound; |
142 | int overlay_disabled; |
154 | int overlay_disabled; |
143 | float trackball_x, trackball_y; |
155 | float trackball_x, trackball_y; |
144 | View view; |
156 | View view; |
145 | RelativeLayout relativelayout; |
157 | RelativeLayout relativelayout; |
146 | NavitCamera camera; |
158 | // --obsolote --- // NavitCamera camera; |
147 | Activity activity; |
159 | Activity activity; |
148 | |
160 | |
149 | private Bitmap bigmap_bitmap_temp = null; |
161 | private Bitmap bigmap_bitmap_temp = null; |
|
|
162 | private Matrix matrix_oneway_arrows = null; |
|
|
163 | private float wsave_003 = 0f; |
|
|
164 | private float wsave_004 = 0f; |
|
|
165 | private Boolean b_paint_antialias = true; |
|
|
166 | private Path b_paint_path = new Path(); |
150 | |
167 | |
151 | public static Boolean in_map = true; // always in map mode, now |
168 | public static Boolean in_map = true; // always in map mode, now |
152 | |
169 | |
153 | // for menu key |
170 | // for menu key |
154 | private static long time_for_long_press = 300L; |
171 | private static long time_for_long_press = 300L; |
… | |
… | |
164 | // here you can draw all the nice things you want |
181 | // here you can draw all the nice things you want |
165 | // and get touch events for it (without touching C-code) |
182 | // and get touch events for it (without touching C-code) |
166 | public NavitAndroidOverlay NavitAOverlay = null; |
183 | public NavitAndroidOverlay NavitAOverlay = null; |
167 | public static NavitAndroidOverlay NavitAOverlay_s = null; |
184 | public static NavitAndroidOverlay NavitAOverlay_s = null; |
168 | private NavitOSDJava NavitAOSDJava = null; |
185 | private NavitOSDJava NavitAOSDJava = null; |
|
|
186 | public static NavitOSDJava NavitAOSDJava_ = null; |
169 | private TextView NavitMsgTv = null; |
187 | private TextView NavitMsgTv = null; |
170 | public static TextView NavitMsgTv_ = null; |
188 | public static TextView NavitMsgTv_ = null; |
|
|
189 | public ZANaviBusySpinner busyspinner = null; |
|
|
190 | public static ZANaviBusySpinner busyspinner_ = null; |
|
|
191 | public ZANaviBusyText busyspinnertext = null; |
|
|
192 | public static ZANaviBusyText busyspinnertext_ = null; |
171 | |
193 | |
172 | private TextView NavitMsgTv2 = null; |
194 | private TextView NavitMsgTv2 = null; |
173 | public static TextView NavitMsgTv2_ = null; |
195 | public static TextView NavitMsgTv2_ = null; |
174 | |
196 | |
175 | public static NavitGlobalMap NavitGlobalMap_ = null; |
197 | public static NavitGlobalMap NavitGlobalMap_ = null; |
176 | |
198 | |
177 | public void SetCamera(int use_camera) |
199 | public void SetCamera(int use_camera) |
178 | { |
200 | { |
|
|
201 | // ------ obsolete |
|
|
202 | |
|
|
203 | /* |
179 | if (use_camera != 0 && camera == null) |
204 | * if (use_camera != 0 && camera == null) |
180 | { |
205 | * { |
181 | // activity.requestWindowFeature(Window.FEATURE_NO_TITLE); |
206 | * // activity.requestWindowFeature(Window.FEATURE_NO_TITLE); |
182 | camera = new NavitCamera(activity); |
207 | * camera = new NavitCamera(activity); |
183 | relativelayout.addView(camera); |
208 | * relativelayout.addView(camera); |
184 | relativelayout.bringChildToFront(view); |
209 | * relativelayout.bringChildToFront(view); |
185 | } |
210 | * } |
|
|
211 | */ |
186 | } |
212 | } |
187 | |
213 | |
188 | public static SensorThread touch_sensor_thread = null; |
214 | public static SensorThread touch_sensor_thread = null; |
189 | |
215 | |
190 | private class SensorThread extends Thread |
216 | private class SensorThread extends Thread |
… | |
… | |
390 | } |
416 | } |
391 | } |
417 | } |
392 | |
418 | |
393 | public NavitGraphics(Activity activity, NavitGraphics parent, int x, int y, int w, int h, int alpha, int wraparound, int use_camera) |
419 | public NavitGraphics(Activity activity, NavitGraphics parent, int x, int y, int w, int h, int alpha, int wraparound, int use_camera) |
394 | { |
420 | { |
|
|
421 | |
|
|
422 | System.out.println("GC001--"); |
|
|
423 | |
395 | if (parent == null) |
424 | if (parent == null) |
396 | { |
425 | { |
|
|
426 | System.out.println("GC002--"); |
|
|
427 | |
397 | this.activity = activity; |
428 | this.activity = activity; |
398 | view = new View(activity) |
429 | view = new View(activity) |
399 | { |
430 | { |
400 | int touch_mode = NONE; |
431 | int touch_mode = NONE; |
401 | float oldDist = 0; |
432 | float oldDist = 0; |
402 | PointF touch_now = new PointF(0, 0); |
433 | PointF touch_now = new PointF(0, 0); |
|
|
434 | PointF touch_now_center = new PointF(0, 0); |
403 | PointF touch_start = new PointF(0, 0); |
435 | PointF touch_start = new PointF(0, 0); |
404 | PointF touch_prev = new PointF(0, 0); |
436 | PointF touch_prev = new PointF(0, 0); |
405 | static final int NONE = 0; |
437 | static final int NONE = 0; |
406 | static final int DRAG = 1; |
438 | static final int DRAG = 1; |
407 | static final int ZOOM = 2; |
439 | static final int ZOOM = 2; |
… | |
… | |
409 | |
441 | |
410 | @Override |
442 | @Override |
411 | protected void onDraw(Canvas canvas) |
443 | protected void onDraw(Canvas canvas) |
412 | { |
444 | { |
413 | super.onDraw(canvas); |
445 | super.onDraw(canvas); |
|
|
446 | |
|
|
447 | if (!MAP_DISPLAY_OFF) |
|
|
448 | { |
|
|
449 | if (ZOOM_MODE_ACTIVE) |
|
|
450 | { |
|
|
451 | canvas.save(); |
|
|
452 | canvas.scale(ZOOM_MODE_SCALE, ZOOM_MODE_SCALE, this.touch_now_center.x, this.touch_now_center.y); |
|
|
453 | } |
414 | canvas.drawBitmap(draw_bitmap, pos_x, pos_y, null); |
454 | canvas.drawBitmap(draw_bitmap, pos_x, pos_y, null); |
|
|
455 | if (ZOOM_MODE_ACTIVE) |
|
|
456 | { |
|
|
457 | canvas.restore(); |
|
|
458 | } |
|
|
459 | } |
415 | if (overlay_disabled == 0) |
460 | if (overlay_disabled == 0) |
416 | { |
461 | { |
417 | //Log.e("NavitGraphics", "view -> onDraw 1"); |
462 | //Log.e("NavitGraphics", "view -> onDraw 1"); |
418 | // assume we ARE in map view mode! |
463 | // assume we ARE in map view mode! |
419 | in_map = true; |
464 | in_map = true; |
420 | |
465 | |
|
|
466 | if (!MAP_DISPLAY_OFF) |
|
|
467 | { |
421 | Object overlays_array[]; |
468 | Object overlays_array[]; |
422 | overlays_array = overlays.toArray(); |
469 | overlays_array = overlays.toArray(); |
423 | //int ov_count = 0; |
470 | //int ov_count = 0; |
424 | for (Object overlay : overlays_array) |
471 | for (Object overlay : overlays_array) |
425 | { |
|
|
426 | //ov_count++; |
|
|
427 | //Log.e("NavitGraphics", "view -> onDraw 2:" + ov_count); |
|
|
428 | |
|
|
429 | NavitGraphics overlay_graphics = (NavitGraphics) overlay; |
|
|
430 | if (overlay_graphics.overlay_disabled == 0) |
|
|
431 | { |
472 | { |
|
|
473 | //ov_count++; |
|
|
474 | //Log.e("NavitGraphics", "view -> onDraw 2:" + ov_count); |
|
|
475 | |
|
|
476 | NavitGraphics overlay_graphics = (NavitGraphics) overlay; |
|
|
477 | if (overlay_graphics.overlay_disabled == 0) |
|
|
478 | { |
432 | //Log.e("NavitGraphics", "view -> onDraw 3:" + ov_count); |
479 | //Log.e("NavitGraphics", "view -> onDraw 3:" + ov_count); |
433 | |
480 | |
434 | int x = overlay_graphics.pos_x; |
481 | int x = overlay_graphics.pos_x; |
435 | int y = overlay_graphics.pos_y; |
482 | int y = overlay_graphics.pos_y; |
436 | if (overlay_graphics.pos_wraparound != 0 && x < 0) x += bitmap_w; |
483 | if (overlay_graphics.pos_wraparound != 0 && x < 0) x += bitmap_w; |
437 | if (overlay_graphics.pos_wraparound != 0 && y < 0) y += bitmap_h; |
484 | if (overlay_graphics.pos_wraparound != 0 && y < 0) y += bitmap_h; |
438 | canvas.drawBitmap(overlay_graphics.draw_bitmap, x, y, null); |
485 | canvas.drawBitmap(overlay_graphics.draw_bitmap, x, y, null); |
|
|
486 | } |
439 | } |
487 | } |
440 | } |
488 | } |
441 | } |
489 | } |
442 | } |
490 | } |
443 | |
491 | |
444 | @Override |
492 | @Override |
445 | protected void onSizeChanged(int w, int h, int oldw, int oldh) |
493 | protected void onSizeChanged(int w, int h, int oldw, int oldh) |
446 | { |
494 | { |
|
|
495 | mCanvasWidth = w; |
|
|
496 | mCanvasHeight = h; |
|
|
497 | |
447 | Log.e("Navit", "NavitGraphics -> onSizeChanged pixels x=" + w + " pixels y=" + h); |
498 | Log.e("Navit", "NavitGraphics -> onSizeChanged pixels x=" + w + " pixels y=" + h); |
448 | Log.e("Navit", "NavitGraphics -> onSizeChanged dpi=" + Navit.metrics.densityDpi); |
499 | Log.e("Navit", "NavitGraphics -> onSizeChanged dpi=" + Navit.metrics.densityDpi); |
449 | Log.e("Navit", "NavitGraphics -> onSizeChanged density=" + Navit.metrics.density); |
500 | Log.e("Navit", "NavitGraphics -> onSizeChanged density=" + Navit.metrics.density); |
450 | Log.e("Navit", "NavitGraphics -> onSizeChanged scaledDensity=" + Navit.metrics.scaledDensity); |
501 | Log.e("Navit", "NavitGraphics -> onSizeChanged scaledDensity=" + Navit.metrics.scaledDensity); |
451 | super.onSizeChanged(w, h, oldw, oldh); |
502 | super.onSizeChanged(w, h, oldw, oldh); |
… | |
… | |
474 | } |
525 | } |
475 | |
526 | |
476 | draw_canvas = new Canvas(draw_bitmap); |
527 | draw_canvas = new Canvas(draw_bitmap); |
477 | bitmap_w = w; |
528 | bitmap_w = w; |
478 | bitmap_h = h; |
529 | bitmap_h = h; |
479 | SizeChangedCallback(SizeChangedCallbackID, w, h); |
530 | SizeChangedCallback(w, h); |
480 | |
531 | |
481 | draw_factor = 1.0f; |
532 | draw_factor = 1.0f; |
482 | if (Navit.my_display_density.compareTo("mdpi") == 0) |
533 | if (Navit.my_display_density.compareTo("mdpi") == 0) |
483 | { |
534 | { |
484 | draw_factor = 1.0f; |
535 | draw_factor = 1.0f; |
… | |
… | |
506 | } |
557 | } |
507 | } |
558 | } |
508 | |
559 | |
509 | public void do_longpress_action(float x, float y) |
560 | public void do_longpress_action(float x, float y) |
510 | { |
561 | { |
|
|
562 | // this is called!!! yes really!! via REFLECT (make it better later) |
511 | if (!NavitAndroidOverlay.confirmed_bubble) |
563 | if (!NavitAndroidOverlay.confirmed_bubble) |
512 | { |
564 | { |
513 | Log.e("NavitGraphics", "do_longpress_action enter"); |
565 | Log.e("NavitGraphics", "do_longpress_action enter"); |
514 | NavitAndroidOverlayBubble b = new NavitAndroidOverlayBubble(); |
566 | NavitAndroidOverlayBubble b = new NavitAndroidOverlayBubble(); |
515 | b.x = (int) x; |
567 | b.x = (int) x; |
… | |
… | |
557 | this.touch_prev.set(event.getX(), event.getY()); |
609 | this.touch_prev.set(event.getX(), event.getY()); |
558 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_DOWN start"); |
610 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_DOWN start"); |
559 | |
611 | |
560 | d_pos_x_old = pos_x; |
612 | d_pos_x_old = pos_x; |
561 | d_pos_y_old = pos_y; |
613 | d_pos_y_old = pos_y; |
|
|
614 | //Log.e("NavitGraphics", "pos_x=" + pos_x); |
|
|
615 | //Log.e("NavitGraphics", "pos_y=" + pos_y); |
562 | |
616 | |
563 | if (in_map) |
617 | if (in_map) |
564 | { |
618 | { |
565 | if (!NavitAOverlay.get_show_bubble()) |
619 | if (!NavitAOverlay.get_show_bubble()) |
566 | { |
620 | { |
… | |
… | |
589 | // wait_for_redraw_map = false; |
643 | // wait_for_redraw_map = false; |
590 | |
644 | |
591 | touch_mode = DRAG; |
645 | touch_mode = DRAG; |
592 | |
646 | |
593 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_DOWN end"); |
647 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_DOWN end"); |
|
|
648 | |
|
|
649 | // hold all map drawing ----------- |
|
|
650 | Message msg = new Message(); |
|
|
651 | Bundle b = new Bundle(); |
|
|
652 | b.putInt("Callback", 69); |
|
|
653 | msg.setData(b); |
|
|
654 | try |
|
|
655 | { |
|
|
656 | callback_handler.sendMessage(msg); |
|
|
657 | } |
|
|
658 | catch (Exception e) |
|
|
659 | { |
|
|
660 | } |
|
|
661 | // hold all map drawing ----------- |
594 | } |
662 | } |
595 | else if ((switch_value == MotionEvent.ACTION_UP) || (switch_value == _ACTION_POINTER_UP_)) |
663 | else if ((switch_value == MotionEvent.ACTION_UP) || (switch_value == _ACTION_POINTER_UP_)) |
596 | { |
664 | { |
597 | this.touch_now.set(event.getX(), event.getY()); |
665 | this.touch_now.set(event.getX(), event.getY()); |
598 | touch_now2 = touch_now; |
666 | touch_now2 = touch_now; |
599 | touch_start2 = touch_start; |
667 | touch_start2 = touch_start; |
600 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_UP start"); |
668 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_UP start"); |
601 | |
|
|
602 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "xxxxxxxxxx"); |
669 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "xxxxxxxxxx"); |
603 | try |
670 | try |
604 | { |
671 | { |
605 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "sensor thread stop X1"); |
672 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "sensor thread stop X1"); |
606 | //touch_sensor_thread.down(); |
673 | //touch_sensor_thread.down(); |
… | |
… | |
722 | // this.touch_now |
789 | // this.touch_now |
723 | //pos_x = (int) (this.touch_now.x - this.touch_start.x); |
790 | //pos_x = (int) (this.touch_now.x - this.touch_start.x); |
724 | //pos_y = (int) (this.touch_now.y - this.touch_start.y); |
791 | //pos_y = (int) (this.touch_now.y - this.touch_start.y); |
725 | pos_x = d_pos_x_old; |
792 | pos_x = d_pos_x_old; |
726 | pos_y = d_pos_y_old; |
793 | pos_y = d_pos_y_old; |
727 | ButtonCallback(ButtonCallbackID, 1, 1, (int) this.touch_start.x, (int) this.touch_start.y); // down |
794 | // ??? // ButtonCallback(1, 1, (int) this.touch_start.x, (int) this.touch_start.y); // down |
728 | //this.invalidate(); |
795 | //this.invalidate(); |
729 | //this.postInvalidate(); |
796 | //this.postInvalidate(); |
730 | // DRAG ----------- new END -------------- |
797 | // DRAG ----------- new END -------------- |
731 | // DRAG ----------- new END -------------- |
798 | // DRAG ----------- new END -------------- |
732 | // DRAG ----------- new END -------------- |
799 | // DRAG ----------- new END -------------- |
733 | |
800 | |
734 | MotionCallback(MotionCallbackID, x, y); |
801 | // allow all map drawing ----------- |
735 | ButtonCallback(ButtonCallbackID, 0, 1, x, y); // up |
802 | Message msg2 = new Message(); |
|
|
803 | Bundle b2 = new Bundle(); |
|
|
804 | b2.putInt("Callback", 70); |
|
|
805 | msg2.setData(b2); |
|
|
806 | try |
|
|
807 | { |
|
|
808 | callback_handler.sendMessage(msg2); |
|
|
809 | } |
|
|
810 | catch (Exception e) |
|
|
811 | { |
|
|
812 | } |
|
|
813 | |
|
|
814 | // MotionCallback(x, y); |
|
|
815 | MotionCallback((int) this.touch_start.x, (int) this.touch_start.y, (int) this.touch_now.x, (int) this.touch_now.y); |
|
|
816 | // ??? // ButtonCallback(0, 1, x, y); // up |
|
|
817 | |
|
|
818 | try |
|
|
819 | { |
|
|
820 | // try to show current location/streetname |
|
|
821 | Message msg1 = new Message(); |
|
|
822 | Bundle b1 = new Bundle(); |
|
|
823 | b1.putInt("Callback", 9901); |
|
|
824 | msg1.setData(b1); |
|
|
825 | NavitGraphics.callback_handler_s.sendMessage(msg1); |
|
|
826 | } |
|
|
827 | catch (Exception e) |
|
|
828 | { |
|
|
829 | |
|
|
830 | } |
736 | |
831 | |
737 | touch_mode = NONE; |
832 | touch_mode = NONE; |
738 | } |
833 | } |
739 | else |
834 | else |
740 | { |
835 | { |
741 | if (touch_mode == ZOOM) |
836 | if (touch_mode == ZOOM) |
742 | { |
837 | { |
743 | // end of "pinch zoom" move |
838 | // end of "pinch zoom" move |
|
|
839 | ZOOM_MODE_ACTIVE = false; |
|
|
840 | ZOOM_MODE_SCALE = 0; |
744 | |
841 | |
745 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "onTouch zoom"); |
842 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "onTouch zoom"); |
746 | |
843 | |
747 | float newDist = spacing(event); |
844 | float newDist = spacing(event); |
748 | float scale = 0; |
845 | float scale = 0; |
749 | if (newDist > 10f) |
846 | if (newDist > 10f) |
750 | { |
847 | { |
751 | scale = newDist / oldDist; |
848 | scale = newDist / oldDist; |
752 | } |
849 | } |
753 | |
850 | |
754 | if (scale > 1.3) |
851 | if (scale > 1.05) |
755 | { |
852 | { |
756 | wait_for_redraw_map = true; |
853 | wait_for_redraw_map = true; |
757 | if (DEBUG_TOUCH) System.out.println("wait_for_redraw_map=true 4"); |
854 | if (DEBUG_TOUCH) System.out.println("wait_for_redraw_map=true 4"); |
758 | |
855 | |
759 | try |
856 | try |
… | |
… | |
770 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "hide bubble 2"); |
867 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "hide bubble 2"); |
771 | // if we drag, hide the bubble |
868 | // if we drag, hide the bubble |
772 | NavitAOverlay.hide_bubble(); |
869 | NavitAOverlay.hide_bubble(); |
773 | |
870 | |
774 | // zoom in |
871 | // zoom in |
775 | // CallbackMessageChannel(1, ""); |
872 | if (scale < 0.2f) |
|
|
873 | { |
|
|
874 | scale = 0.2f; |
|
|
875 | } |
|
|
876 | else if (scale > 5) |
|
|
877 | { |
|
|
878 | scale = 5; |
|
|
879 | } |
|
|
880 | |
|
|
881 | pos_x = d_pos_x_old; |
|
|
882 | pos_y = d_pos_y_old; |
|
|
883 | |
776 | Message msg = new Message(); |
884 | Message msg = new Message(); |
777 | Bundle b = new Bundle(); |
885 | Bundle b = new Bundle(); |
778 | b.putInt("Callback", 1); |
886 | b.putInt("Callback", 61); |
|
|
887 | //System.out.println("sc1:" + Navit.GlobalScaleLevel); |
|
|
888 | Navit.GlobalScaleLevel = (int) (Navit.GlobalScaleLevel / scale); |
|
|
889 | //System.out.println("sc1.1:" + Navit.GlobalScaleLevel); |
|
|
890 | |
|
|
891 | this.touch_now_center = calc_center(event); |
|
|
892 | b.putString("s", (int) this.touch_now_center.x + "#" + (int) this.touch_now_center.y + "#" + Integer.toString(Navit.GlobalScaleLevel)); |
779 | msg.setData(b); |
893 | msg.setData(b); |
|
|
894 | try |
|
|
895 | { |
780 | callback_handler.sendMessage(msg); |
896 | callback_handler.sendMessage(msg); |
|
|
897 | //System.out.println("touch: set zoom(in) level: " + Navit.GlobalScaleLevel); |
|
|
898 | } |
|
|
899 | catch (Exception e) |
|
|
900 | { |
|
|
901 | } |
781 | |
902 | |
782 | // next lines are a hack, without it screen will not get updated anymore! |
903 | // next lines are a hack, without it screen will not get updated anymore! |
783 | //*ButtonCallback(ButtonCallbackID, 1, 1, x, y); // down |
904 | //*ButtonCallback(ButtonCallbackID, 1, 1, x, y); // down |
784 | //*MotionCallback(MotionCallbackID, x + 15, y); |
905 | //*MotionCallback(MotionCallbackID, x + 15, y); |
785 | //*MotionCallback(MotionCallbackID, x - 15, y); |
906 | //*MotionCallback(MotionCallbackID, x - 15, y); |
… | |
… | |
801 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "hide bubble X3"); |
922 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "hide bubble X3"); |
802 | NavitAOverlay.hide_bubble(); |
923 | NavitAOverlay.hide_bubble(); |
803 | |
924 | |
804 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "onTouch zoom in"); |
925 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "onTouch zoom in"); |
805 | } |
926 | } |
806 | else if (scale < 0.8) |
927 | else if (scale < 0.95) |
807 | { |
928 | { |
808 | wait_for_redraw_map = true; |
929 | wait_for_redraw_map = true; |
809 | if (DEBUG_TOUCH) System.out.println("wait_for_redraw_map=true 5"); |
930 | if (DEBUG_TOUCH) System.out.println("wait_for_redraw_map=true 5"); |
810 | |
931 | |
811 | try |
932 | try |
… | |
… | |
822 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "hide bubble 3"); |
943 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "hide bubble 3"); |
823 | // if we drag, hide the bubble |
944 | // if we drag, hide the bubble |
824 | NavitAOverlay.hide_bubble(); |
945 | NavitAOverlay.hide_bubble(); |
825 | |
946 | |
826 | // zoom out |
947 | // zoom out |
827 | // CallbackMessageChannel(2, ""); |
948 | |
|
|
949 | if (scale < 0.2f) |
|
|
950 | { |
|
|
951 | scale = 0.2f; |
|
|
952 | } |
|
|
953 | else if (scale > 6) |
|
|
954 | { |
|
|
955 | scale = 6; |
|
|
956 | } |
|
|
957 | |
|
|
958 | pos_x = d_pos_x_old; |
|
|
959 | pos_y = d_pos_y_old; |
|
|
960 | |
828 | Message msg = new Message(); |
961 | Message msg = new Message(); |
829 | Bundle b = new Bundle(); |
962 | Bundle b = new Bundle(); |
830 | b.putInt("Callback", 2); |
963 | b.putInt("Callback", 61); |
|
|
964 | //System.out.println("sc2:" + Navit.GlobalScaleLevel); |
|
|
965 | Navit.GlobalScaleLevel = (int) (Navit.GlobalScaleLevel / scale); |
|
|
966 | if (Navit.GlobalScaleLevel < 2) |
|
|
967 | { |
|
|
968 | Navit.GlobalScaleLevel = 2; |
|
|
969 | } |
|
|
970 | //System.out.println("sc2.1:" + Navit.GlobalScaleLevel); |
|
|
971 | this.touch_now_center = calc_center(event); |
|
|
972 | b.putString("s", (int) this.touch_now_center.x + "#" + (int) this.touch_now_center.y + "#" + Integer.toString(Navit.GlobalScaleLevel)); |
831 | msg.setData(b); |
973 | msg.setData(b); |
|
|
974 | try |
|
|
975 | { |
832 | callback_handler.sendMessage(msg); |
976 | callback_handler.sendMessage(msg); |
|
|
977 | //System.out.println("touch: set zoom(out) level: " + Navit.GlobalScaleLevel); |
|
|
978 | } |
|
|
979 | catch (Exception e) |
|
|
980 | { |
|
|
981 | } |
833 | |
982 | |
834 | // next lines are a hack, without it screen will not get updated anymore! |
983 | // next lines are a hack, without it screen will not get updated anymore! |
835 | //*ButtonCallback(ButtonCallbackID, 1, 1, x, y); // down |
984 | //*ButtonCallback(ButtonCallbackID, 1, 1, x, y); // down |
836 | //*MotionCallback(MotionCallbackID, x + 15, y); |
985 | //*MotionCallback(MotionCallbackID, x + 15, y); |
837 | //*MotionCallback(MotionCallbackID, x - 15, y); |
986 | //*MotionCallback(MotionCallbackID, x - 15, y); |
… | |
… | |
855 | |
1004 | |
856 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "onTouch zoom out"); |
1005 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "onTouch zoom out"); |
857 | } |
1006 | } |
858 | else |
1007 | else |
859 | { |
1008 | { |
|
|
1009 | pos_x = d_pos_x_old; |
|
|
1010 | pos_y = d_pos_y_old; |
|
|
1011 | |
860 | // move was not zoom-out OR zoom-in |
1012 | // move was not zoom-out OR zoom-in |
861 | // so just ignore and remove any pending stuff |
1013 | // so just ignore and remove any pending stuff |
862 | if (DEBUG_TOUCH) System.out.println("wait_for_redraw_map=false 10"); |
1014 | if (DEBUG_TOUCH) System.out.println("wait_for_redraw_map=false 10"); |
863 | NavitGraphics.wait_for_redraw_map = false; |
1015 | NavitGraphics.wait_for_redraw_map = false; |
864 | try |
1016 | try |
… | |
… | |
888 | if (DEBUG_TOUCH) Log.d("NavitGraphics", "touch_mode=NONE (END of ZOOM part 2)"); |
1040 | if (DEBUG_TOUCH) Log.d("NavitGraphics", "touch_mode=NONE (END of ZOOM part 2)"); |
889 | touch_mode = NONE; |
1041 | touch_mode = NONE; |
890 | } |
1042 | } |
891 | } |
1043 | } |
892 | } |
1044 | } |
|
|
1045 | |
|
|
1046 | //Log.e("NavitGraphics", "pos_x=" + pos_x); |
|
|
1047 | //Log.e("NavitGraphics", "pos_y=" + pos_y); |
|
|
1048 | //Log.e("NavitGraphics", "d_pos_x_old=" + d_pos_x_old); |
|
|
1049 | //Log.e("NavitGraphics", "d_pos_y_old=" + d_pos_y_old); |
|
|
1050 | |
|
|
1051 | // on final "UP" action, always reset the display center |
|
|
1052 | if (switch_value == MotionEvent.ACTION_UP) |
|
|
1053 | { |
|
|
1054 | pos_x = d_pos_x_old; |
|
|
1055 | pos_y = d_pos_y_old; |
|
|
1056 | |
|
|
1057 | try |
|
|
1058 | { |
|
|
1059 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "sensor thread stop final88"); |
|
|
1060 | touch_sensor_thread.stop_me(); |
|
|
1061 | } |
|
|
1062 | catch (Exception e) |
|
|
1063 | { |
|
|
1064 | |
|
|
1065 | } |
|
|
1066 | |
|
|
1067 | // allow all map drawing ----------- |
|
|
1068 | Message msg2 = new Message(); |
|
|
1069 | Bundle b2 = new Bundle(); |
|
|
1070 | b2.putInt("Callback", 70); |
|
|
1071 | msg2.setData(b2); |
|
|
1072 | try |
|
|
1073 | { |
|
|
1074 | callback_handler.sendMessage(msg2); |
|
|
1075 | } |
|
|
1076 | catch (Exception e) |
|
|
1077 | { |
|
|
1078 | } |
|
|
1079 | // allow all map drawing ----------- |
|
|
1080 | } |
893 | } |
1081 | } |
894 | else if (switch_value == MotionEvent.ACTION_MOVE) |
1082 | else if (switch_value == MotionEvent.ACTION_MOVE) |
895 | { |
1083 | { |
896 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_MOVE"); |
1084 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_MOVE"); |
897 | |
1085 | |
… | |
… | |
927 | |
1115 | |
928 | if ((in_map) && (spacing(touch_start2, touch_now2) < long_press_on_screen_max_distance)) |
1116 | if ((in_map) && (spacing(touch_start2, touch_now2) < long_press_on_screen_max_distance)) |
929 | { |
1117 | { |
930 | // now its still a PRESS, because we have not moved around too much! |
1118 | // now its still a PRESS, because we have not moved around too much! |
931 | |
1119 | |
932 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "in move: still a RESS action"); |
1120 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "in move: still a PRESS action"); |
933 | |
1121 | |
934 | // is it a still ongoing long press? |
1122 | // is it a still ongoing long press? |
935 | if ((System.currentTimeMillis() - last_touch_on_screen) > long_press_on_screen_interval) |
1123 | if ((System.currentTimeMillis() - last_touch_on_screen) > long_press_on_screen_interval) |
936 | { |
1124 | { |
937 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "onTouch up (LONG PRESS 2) ***** 22 *****"); |
1125 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "onTouch up (LONG PRESS 2) ***** 22 *****"); |
… | |
… | |
972 | { |
1160 | { |
973 | this.touch_now.set(event.getX(), event.getY()); |
1161 | this.touch_now.set(event.getX(), event.getY()); |
974 | this.touch_prev.set(event.getX(), event.getY()); |
1162 | this.touch_prev.set(event.getX(), event.getY()); |
975 | |
1163 | |
976 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "zoom 2"); |
1164 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "zoom 2"); |
|
|
1165 | |
|
|
1166 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "hide bubble 73"); |
|
|
1167 | NavitAOverlay.hide_bubble(); |
|
|
1168 | try |
|
|
1169 | { |
|
|
1170 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "touch_sensor_thread.stop 73"); |
|
|
1171 | touch_sensor_thread.stop_me(); |
|
|
1172 | } |
|
|
1173 | catch (Exception e) |
|
|
1174 | { |
|
|
1175 | } |
|
|
1176 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "hide bubble 74"); |
|
|
1177 | NavitAOverlay.hide_bubble(); |
|
|
1178 | |
|
|
1179 | // were are in the middle of a zooming action here ---------- |
|
|
1180 | // were are in the middle of a zooming action here ---------- |
|
|
1181 | |
|
|
1182 | this.touch_now_center = calc_center(event); |
|
|
1183 | float newDist = spacing(event); |
|
|
1184 | float scale = 0; |
|
|
1185 | try |
|
|
1186 | { |
|
|
1187 | scale = newDist / oldDist; |
|
|
1188 | } |
|
|
1189 | catch (Exception ee) |
|
|
1190 | { |
|
|
1191 | |
|
|
1192 | } |
|
|
1193 | ZOOM_MODE_SCALE = scale; |
|
|
1194 | ZOOM_MODE_ACTIVE = true; |
|
|
1195 | this.invalidate(); |
|
|
1196 | // Log.e("NavitGraphics", "x:" + this.touch_now.x + " y:" + this.touch_now.y); |
|
|
1197 | // were are in the middle of a zooming action here ---------- |
|
|
1198 | // were are in the middle of a zooming action here ---------- |
977 | } |
1199 | } |
978 | } |
1200 | } |
979 | else if (switch_value == _ACTION_POINTER_DOWN_) |
1201 | else if (switch_value == _ACTION_POINTER_DOWN_) |
980 | { |
1202 | { |
981 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_POINTER_DOWN"); |
1203 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_POINTER_DOWN"); |
… | |
… | |
983 | oldDist = spacing(event); |
1205 | oldDist = spacing(event); |
984 | if (oldDist > 10f) |
1206 | if (oldDist > 10f) |
985 | { |
1207 | { |
986 | touch_mode = ZOOM; |
1208 | touch_mode = ZOOM; |
987 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "--> zoom"); |
1209 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "--> zoom"); |
|
|
1210 | // zoom action starts here -------- |
|
|
1211 | // zoom action starts here -------- |
|
|
1212 | // zoom action starts here -------- |
|
|
1213 | // zoom action starts here -------- |
988 | } |
1214 | } |
989 | } |
1215 | } |
990 | return true; |
1216 | return true; |
991 | } |
1217 | } |
992 | |
1218 | |
993 | private float spacing(PointF a, PointF b) |
1219 | private float spacing(PointF a, PointF b) |
994 | { |
1220 | { |
995 | float x = a.x - b.x; |
1221 | float x = a.x - b.x; |
996 | float y = a.y - b.y; |
1222 | float y = a.y - b.y; |
997 | return FloatMath.sqrt(x * x + y * y); |
1223 | return FloatMath.sqrt(x * x + y * y); |
|
|
1224 | } |
|
|
1225 | |
|
|
1226 | public PointF calc_center(MotionEvent event) |
|
|
1227 | { |
|
|
1228 | //float x; |
|
|
1229 | //float y; |
|
|
1230 | PointF ret = new PointF(0, 0); |
|
|
1231 | try |
|
|
1232 | { |
|
|
1233 | float y0 = 0; |
|
|
1234 | float y1 = 0; |
|
|
1235 | float x0 = 0; |
|
|
1236 | float x1 = 0; |
|
|
1237 | |
|
|
1238 | x0 = event.getX(0); |
|
|
1239 | y0 = event.getY(0); |
|
|
1240 | try |
|
|
1241 | { |
|
|
1242 | x1 = event.getX(1); |
|
|
1243 | y1 = event.getY(1); |
|
|
1244 | } |
|
|
1245 | catch (Exception ex) |
|
|
1246 | { |
|
|
1247 | ex.printStackTrace(); |
|
|
1248 | } |
|
|
1249 | ret.x = x0 - ((x0 - x1) / 2); |
|
|
1250 | ret.y = y0 - ((y0 - y1) / 2); |
|
|
1251 | } |
|
|
1252 | catch (Exception ex) |
|
|
1253 | { |
|
|
1254 | ex.printStackTrace(); |
|
|
1255 | ret.x = event.getX(0); |
|
|
1256 | ret.y = event.getY(0); |
|
|
1257 | } |
|
|
1258 | return ret; |
998 | } |
1259 | } |
999 | |
1260 | |
1000 | public float spacing(MotionEvent event) |
1261 | public float spacing(MotionEvent event) |
1001 | { |
1262 | { |
1002 | float x; |
1263 | float x; |
… | |
… | |
1071 | // android overlay |
1332 | // android overlay |
1072 | |
1333 | |
1073 | // android OSDJava |
1334 | // android OSDJava |
1074 | Log.e("Navit", "create android OSDJava"); |
1335 | Log.e("Navit", "create android OSDJava"); |
1075 | NavitAOSDJava = new NavitOSDJava(relativelayout.getContext()); |
1336 | NavitAOSDJava = new NavitOSDJava(relativelayout.getContext()); |
1076 | // NavitAOSDJava_ = NavitAOSDJava; |
1337 | NavitAOSDJava_ = NavitAOSDJava; |
1077 | RelativeLayout.LayoutParams NavitAOSDJava_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); |
1338 | RelativeLayout.LayoutParams NavitAOSDJava_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); |
1078 | relativelayout.addView(NavitAOSDJava, NavitAOSDJava_lp); |
1339 | relativelayout.addView(NavitAOSDJava, NavitAOSDJava_lp); |
1079 | NavitAOSDJava.bringToFront(); |
1340 | NavitAOSDJava.bringToFront(); |
1080 | NavitAOSDJava.invalidate(); |
1341 | NavitAOSDJava.invalidate(); |
1081 | // android OSDJava |
1342 | // android OSDJava |
… | |
… | |
1088 | // NavitMsgTv_lp.height = 50; |
1349 | // NavitMsgTv_lp.height = 50; |
1089 | NavitMsgTv_lp.leftMargin = 120; |
1350 | NavitMsgTv_lp.leftMargin = 120; |
1090 | // NavitMsgTv.setHeight(10); |
1351 | // NavitMsgTv.setHeight(10); |
1091 | int tc = Color.argb(125, 0, 0, 0); // half transparent black |
1352 | int tc = Color.argb(125, 0, 0, 0); // half transparent black |
1092 | NavitMsgTv.setBackgroundColor(tc); |
1353 | NavitMsgTv.setBackgroundColor(tc); |
1093 | NavitMsgTv.setLines(3); |
1354 | NavitMsgTv.setLines(4); |
1094 | NavitMsgTv.setTextSize(12); |
1355 | NavitMsgTv.setTextSize(12); |
1095 | NavitMsgTv.setTextColor(Color.argb(255, 200, 200, 200)); // almost white |
1356 | NavitMsgTv.setTextColor(Color.argb(255, 200, 200, 200)); // almost white |
1096 | relativelayout.addView(NavitMsgTv, NavitMsgTv_lp); |
1357 | relativelayout.addView(NavitMsgTv, NavitMsgTv_lp); |
1097 | NavitMsgTv.bringToFront(); |
1358 | NavitMsgTv.bringToFront(); |
1098 | NavitMsgTv.invalidate(); |
1359 | NavitMsgTv.invalidate(); |
… | |
… | |
1124 | NavitMsgTv2.invalidate(); |
1385 | NavitMsgTv2.invalidate(); |
1125 | NavitMsgTv2.setEnabled(false); |
1386 | NavitMsgTv2.setEnabled(false); |
1126 | NavitMsgTv2.setVisibility(View.GONE); |
1387 | NavitMsgTv2.setVisibility(View.GONE); |
1127 | // android Speech Messages TextView |
1388 | // android Speech Messages TextView |
1128 | |
1389 | |
|
|
1390 | // busy spinner view on top of everything |
|
|
1391 | ZANaviBusySpinner busyspinner = new ZANaviBusySpinner(relativelayout.getContext()); |
|
|
1392 | busyspinner_ = busyspinner; |
|
|
1393 | RelativeLayout.LayoutParams ZANaviBusySpinner_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); |
|
|
1394 | relativelayout.addView(busyspinner, ZANaviBusySpinner_lp); |
|
|
1395 | busyspinner.bringToFront(); |
|
|
1396 | busyspinner.invalidate(); |
|
|
1397 | busyspinner.setVisibility(View.INVISIBLE); |
|
|
1398 | |
|
|
1399 | ZANaviBusyText busyspinnertext = new ZANaviBusyText(relativelayout.getContext()); |
|
|
1400 | busyspinnertext_ = busyspinnertext; |
|
|
1401 | RelativeLayout.LayoutParams ZANaviBusyText_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); |
|
|
1402 | relativelayout.addView(busyspinnertext, ZANaviBusyText_lp); |
|
|
1403 | busyspinnertext.bringToFront(); |
|
|
1404 | busyspinnertext.invalidate(); |
|
|
1405 | busyspinnertext.setVisibility(View.INVISIBLE); |
|
|
1406 | // busy spinner view on top of everything |
|
|
1407 | |
1129 | // big map overlay |
1408 | // big map overlay |
1130 | // NavitGlobalMap_ = new NavitGlobalMap(relativelayout.getContext()); |
1409 | // NavitGlobalMap_ = new NavitGlobalMap(relativelayout.getContext()); |
1131 | // RelativeLayout.LayoutParams NavitGlobalMap_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); |
1410 | // RelativeLayout.LayoutParams NavitGlobalMap_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); |
1132 | // relativelayout.addView(NavitGlobalMap_, NavitGlobalMap_lp); |
1411 | // relativelayout.addView(NavitGlobalMap_, NavitGlobalMap_lp); |
1133 | // NavitGlobalMap_.bringToFront(); |
1412 | // NavitGlobalMap_.bringToFront(); |
… | |
… | |
1253 | } |
1532 | } |
1254 | else if (msg.getData().getInt("Callback") == 21) |
1533 | else if (msg.getData().getInt("Callback") == 21) |
1255 | { |
1534 | { |
1256 | int x = msg.getData().getInt("x"); |
1535 | int x = msg.getData().getInt("x"); |
1257 | int y = msg.getData().getInt("y"); |
1536 | int y = msg.getData().getInt("y"); |
1258 | ButtonCallback(ButtonCallbackID, 1, 1, x, y); // down |
1537 | // ??? // ButtonCallback(1, 1, x, y); // down |
1259 | } |
1538 | } |
1260 | else if (msg.getData().getInt("Callback") == 22) |
1539 | else if (msg.getData().getInt("Callback") == 22) |
1261 | { |
1540 | { |
1262 | int x = msg.getData().getInt("x"); |
1541 | int x = msg.getData().getInt("x"); |
1263 | int y = msg.getData().getInt("y"); |
1542 | int y = msg.getData().getInt("y"); |
1264 | ButtonCallback(ButtonCallbackID, 0, 1, x, y); // up |
1543 | // ??? // ButtonCallback(0, 1, x, y); // up |
1265 | } |
1544 | } |
1266 | else if (msg.getData().getInt("Callback") == 23) |
1545 | else if (msg.getData().getInt("Callback") == 23) |
1267 | { |
1546 | { |
1268 | int x = msg.getData().getInt("x"); |
1547 | int x = msg.getData().getInt("x"); |
1269 | int y = msg.getData().getInt("y"); |
1548 | int y = msg.getData().getInt("y"); |
1270 | MotionCallback(MotionCallbackID, x, y); |
1549 | MotionCallback(x, y, 0, 0); |
1271 | } |
1550 | } |
1272 | else if (msg.getData().getInt("Callback") == 24) |
1551 | else if (msg.getData().getInt("Callback") == 24) |
1273 | { |
1552 | { |
1274 | try |
1553 | try |
1275 | { |
1554 | { |
… | |
… | |
1399 | CallbackMessageChannel(51, "" + x + "#" + y); |
1678 | CallbackMessageChannel(51, "" + x + "#" + y); |
1400 | } |
1679 | } |
1401 | else if (msg.getData().getInt("Callback") == 52) |
1680 | else if (msg.getData().getInt("Callback") == 52) |
1402 | { |
1681 | { |
1403 | // switch to demo vehicle |
1682 | // switch to demo vehicle |
|
|
1683 | String s = msg.getData().getString("s"); |
1404 | CallbackMessageChannel(52, ""); |
1684 | CallbackMessageChannel(52, s); |
1405 | } |
1685 | } |
1406 | else if (msg.getData().getInt("Callback") == 53) |
1686 | else if (msg.getData().getInt("Callback") == 53) |
1407 | { |
1687 | { |
1408 | // dont speak streetnames |
1688 | // dont speak streetnames |
1409 | CallbackMessageChannel(53, ""); |
1689 | CallbackMessageChannel(53, ""); |
… | |
… | |
1435 | { |
1715 | { |
1436 | // street search radius factor (multiplier) |
1716 | // street search radius factor (multiplier) |
1437 | String s = msg.getData().getString("s"); |
1717 | String s = msg.getData().getString("s"); |
1438 | CallbackMessageChannel(58, s); |
1718 | CallbackMessageChannel(58, s); |
1439 | } |
1719 | } |
|
|
1720 | else if (msg.getData().getInt("Callback") == 59) |
|
|
1721 | { |
|
|
1722 | // enable layer "name" |
|
|
1723 | String s = msg.getData().getString("s"); |
|
|
1724 | CallbackMessageChannel(59, s); |
|
|
1725 | } |
|
|
1726 | else if (msg.getData().getInt("Callback") == 60) |
|
|
1727 | { |
|
|
1728 | // disable layer "name" |
|
|
1729 | String s = msg.getData().getString("s"); |
|
|
1730 | CallbackMessageChannel(60, s); |
|
|
1731 | } |
|
|
1732 | else if (msg.getData().getInt("Callback") == 61) |
|
|
1733 | { |
|
|
1734 | // zoom to specific zoomlevel at given point as center |
|
|
1735 | // pixel-x#pixel-y#zoom-level |
|
|
1736 | String s = msg.getData().getString("s"); |
|
|
1737 | CallbackMessageChannel(61, s); |
|
|
1738 | } |
|
|
1739 | else if (msg.getData().getInt("Callback") == 62) |
|
|
1740 | { |
|
|
1741 | // disable map drawing |
|
|
1742 | CallbackMessageChannel(62, ""); |
|
|
1743 | } |
|
|
1744 | else if (msg.getData().getInt("Callback") == 63) |
|
|
1745 | { |
|
|
1746 | // enable map drawing |
|
|
1747 | CallbackMessageChannel(63, ""); |
|
|
1748 | } |
|
|
1749 | else if (msg.getData().getInt("Callback") == 64) |
|
|
1750 | { |
|
|
1751 | // draw map |
|
|
1752 | CallbackMessageChannel(64, ""); |
|
|
1753 | } |
|
|
1754 | else if (msg.getData().getInt("Callback") == 65) |
|
|
1755 | { |
|
|
1756 | // draw map async |
|
|
1757 | CallbackMessageChannel(65, ""); |
|
|
1758 | } |
|
|
1759 | else if (msg.getData().getInt("Callback") == 66) |
|
|
1760 | { |
|
|
1761 | // enable "water from relations" |
|
|
1762 | CallbackMessageChannel(66, ""); |
|
|
1763 | } |
|
|
1764 | else if (msg.getData().getInt("Callback") == 67) |
|
|
1765 | { |
|
|
1766 | // disable "water from relations" |
|
|
1767 | CallbackMessageChannel(67, ""); |
|
|
1768 | } |
|
|
1769 | else if (msg.getData().getInt("Callback") == 68) |
|
|
1770 | { |
|
|
1771 | // shift "order" by this value (only for drawing objects) |
|
|
1772 | String s = msg.getData().getString("s"); |
|
|
1773 | CallbackMessageChannel(68, s); |
|
|
1774 | } |
|
|
1775 | else if (msg.getData().getInt("Callback") == 69) |
|
|
1776 | { |
|
|
1777 | // stop drawing map |
|
|
1778 | CallbackMessageChannel(69, ""); |
|
|
1779 | } |
|
|
1780 | else if (msg.getData().getInt("Callback") == 70) |
|
|
1781 | { |
|
|
1782 | // allow drawing map |
|
|
1783 | CallbackMessageChannel(70, ""); |
|
|
1784 | } |
|
|
1785 | else if (msg.getData().getInt("Callback") == 71) |
|
|
1786 | { |
|
|
1787 | // activate/deactivate "route graph" display |
|
|
1788 | // 0 -> deactivate |
|
|
1789 | // 1 -> activate |
|
|
1790 | String s = msg.getData().getString("s"); |
|
|
1791 | CallbackMessageChannel(71, s); |
|
|
1792 | } |
|
|
1793 | else if (msg.getData().getInt("Callback") == 72) |
|
|
1794 | { |
|
|
1795 | // update the route path and route graph (e.g. after setting new roadblocks) |
|
|
1796 | // does not update destinations!!! |
|
|
1797 | CallbackMessageChannel(72, ""); |
|
|
1798 | } |
|
|
1799 | else if (msg.getData().getInt("Callback") == 73) |
|
|
1800 | { |
|
|
1801 | // update the route path and route graph (e.g. after setting new roadblocks) |
|
|
1802 | // this destroys the route graph and calcs everything totally new! |
|
|
1803 | CallbackMessageChannel(73, ""); |
|
|
1804 | } |
1440 | } |
1805 | } |
1441 | }; |
1806 | }; |
1442 | |
1807 | |
1443 | public native void SizeChangedCallback(int id, int x, int y); |
1808 | public native void SizeChangedCallback(int w, int h); |
1444 | |
1809 | |
1445 | public native void ButtonCallback(int id, int pressed, int button, int x, int y); |
1810 | // public native void ButtonCallback(int pressed, int button, int x, int y); |
1446 | |
1811 | |
1447 | public native void MotionCallback(int id, int x, int y); |
1812 | public native void MotionCallback(int x1, int y1, int x2, int y2); |
1448 | |
1813 | |
1449 | public native void KeypressCallback(int id, String s); |
1814 | // public native void KeypressCallback(String s); |
1450 | |
1815 | |
1451 | private Canvas draw_canvas; |
1816 | private Canvas draw_canvas; |
1452 | private Bitmap draw_bitmap; |
1817 | private Bitmap draw_bitmap; |
|
|
1818 | |
1453 | private int SizeChangedCallbackID, ButtonCallbackID, MotionCallbackID, KeypressCallbackID; |
1819 | // private int SizeChangedCallbackID, ButtonCallbackID, MotionCallbackID, KeypressCallbackID; |
1454 | |
1820 | |
1455 | // private int count; |
1821 | // private int count; |
|
|
1822 | /* |
1456 | public void setSizeChangedCallback(int id) |
1823 | * public void setSizeChangedCallback(int id) |
|
|
1824 | * { |
|
|
1825 | * SizeChangedCallbackID = id; |
|
|
1826 | * } |
|
|
1827 | */ |
|
|
1828 | |
|
|
1829 | /* |
|
|
1830 | * public void setButtonCallback(int id) |
|
|
1831 | * { |
|
|
1832 | * ButtonCallbackID = id; |
|
|
1833 | * } |
|
|
1834 | */ |
|
|
1835 | |
|
|
1836 | /* |
|
|
1837 | * public void setMotionCallback(int id) |
|
|
1838 | * { |
|
|
1839 | * MotionCallbackID = id; |
|
|
1840 | * Navit.setMotionCallback(id, this); |
|
|
1841 | * } |
|
|
1842 | */ |
|
|
1843 | |
|
|
1844 | /* |
|
|
1845 | * public void setKeypressCallback(int id) |
|
|
1846 | * { |
|
|
1847 | * KeypressCallbackID = id; |
|
|
1848 | * // set callback id also in main intent (for menus) |
|
|
1849 | * Navit.setKeypressCallback(id, this); |
|
|
1850 | * } |
|
|
1851 | */ |
|
|
1852 | |
|
|
1853 | public void NavitSetGrObj() |
1457 | { |
1854 | { |
1458 | SizeChangedCallbackID = id; |
1855 | // set the (static) graphics object (this is bad, please fix me!!) |
1459 | } |
1856 | Navit.N_NavitGraphics = this; |
1460 | |
|
|
1461 | public void setButtonCallback(int id) |
|
|
1462 | { |
|
|
1463 | ButtonCallbackID = id; |
|
|
1464 | } |
|
|
1465 | |
|
|
1466 | public void setMotionCallback(int id) |
|
|
1467 | { |
|
|
1468 | MotionCallbackID = id; |
|
|
1469 | Navit.setMotionCallback(id, this); |
|
|
1470 | } |
|
|
1471 | |
|
|
1472 | public void setKeypressCallback(int id) |
|
|
1473 | { |
|
|
1474 | KeypressCallbackID = id; |
|
|
1475 | // set callback id also in main intent (for menus) |
|
|
1476 | Navit.setKeypressCallback(id, this); |
|
|
1477 | } |
1857 | } |
1478 | |
1858 | |
1479 | protected void draw_polyline(Paint paint, int c[]) |
1859 | protected void draw_polyline(Paint paint, int c[]) |
1480 | { |
1860 | { |
1481 | // Log.e("NavitGraphics","draw_polyline"); |
1861 | // Log.e("NavitGraphics","draw_polyline"); |
1482 | paint.setStyle(Paint.Style.STROKE); |
1862 | paint.setStyle(Paint.Style.STROKE); |
1483 | Boolean b = paint.isAntiAlias(); |
1863 | b_paint_antialias = paint.isAntiAlias(); |
1484 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
1864 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
1485 | //paint.setStrokeWidth(0); |
1865 | //paint.setStrokeWidth(0); |
1486 | Path path = new Path(); |
1866 | b_paint_path.reset(); |
1487 | path.moveTo(c[0], c[1]); |
1867 | b_paint_path.moveTo(c[0], c[1]); |
1488 | for (int i = 2; i < c.length; i += 2) |
1868 | for (int i = 2; i < c.length; i += 2) |
1489 | { |
1869 | { |
1490 | path.lineTo(c[i], c[i + 1]); |
1870 | b_paint_path.lineTo(c[i], c[i + 1]); |
1491 | } |
1871 | } |
1492 | //global_path.close(); |
1872 | //global_path.close(); |
1493 | draw_canvas.drawPath(path, paint); |
1873 | draw_canvas.drawPath(b_paint_path, paint); |
1494 | paint.setAntiAlias(b); |
1874 | paint.setAntiAlias(b_paint_antialias); |
1495 | //paint.setPathEffect(dashed_map_lines__no_dash); |
1875 | //paint.setPathEffect(dashed_map_lines__no_dash); |
1496 | } |
1876 | } |
1497 | |
1877 | |
1498 | protected void draw_polyline2(Paint paint, int c[], int order, int oneway) |
1878 | protected void draw_polyline2(Paint paint, int c[], int order, int oneway) |
1499 | { |
1879 | { |
1500 | // Log.e("NavitGraphics","draw_polyline2"); |
1880 | // Log.e("NavitGraphics", "draw_polyline2 count=" + c.length); |
|
|
1881 | if (!Navit.PREF_gui_oneway_arrows) |
|
|
1882 | { |
|
|
1883 | return; |
|
|
1884 | } |
|
|
1885 | |
|
|
1886 | // Boolean normal = false; |
|
|
1887 | // Matrix matrix = null; |
|
|
1888 | |
|
|
1889 | // this gets already checked in c-source!! |
|
|
1890 | //if (order > DRAW_ONEWAY_ARROWS_AT_ORDER) |
|
|
1891 | //{ |
|
|
1892 | |
|
|
1893 | // line less than 44px -> dont draw arrow! |
|
|
1894 | int len = (c[0] - c[2]) * (c[1] - c[3]); |
|
|
1895 | if (len < 0) |
|
|
1896 | { |
|
|
1897 | len = -len; |
|
|
1898 | } |
|
|
1899 | if (len > (2000)) |
|
|
1900 | { |
1501 | paint.setStyle(Paint.Style.STROKE); |
1901 | paint.setStyle(Paint.Style.STROKE); |
1502 | Boolean b = paint.isAntiAlias(); |
1902 | b_paint_antialias = paint.isAntiAlias(); |
1503 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
1903 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
1504 | |
1904 | |
1505 | Boolean normal = false; |
|
|
1506 | |
|
|
1507 | // create matrix for the manipulation |
1905 | // create matrix for the manipulation |
1508 | Matrix matrix = new Matrix(); |
1906 | matrix_oneway_arrows = new Matrix(); |
1509 | |
1907 | |
1510 | int middle_x = c[0] + (int) ((c[2] - c[0]) / 2); |
1908 | int middle_x = c[0] + (int) ((c[2] - c[0]) / 2); |
1511 | int middle_y = c[1] + (int) ((c[3] - c[1]) / 2); |
1909 | int middle_y = c[1] + (int) ((c[3] - c[1]) / 2); |
1512 | double d_x = ((c[2] - c[0]) / 6); |
1910 | double d_x = ((c[2] - c[0]) / 6); |
1513 | double d_y = ((c[3] - c[1]) / 6); |
1911 | double d_y = ((c[3] - c[1]) / 6); |
1514 | int angle = (int) (Math.toDegrees(Math.atan2(d_y, d_x))); |
1912 | int angle = (int) (Math.toDegrees(Math.atan2(d_y, d_x))); |
1515 | // System.out.println("arrow angle=" + angle); |
1913 | // System.out.println("arrow angle=" + angle); |
1516 | matrix.postTranslate(-Navit.oneway_arrow.getWidth() / 2, -Navit.oneway_arrow.getHeight() / 2); |
1914 | matrix_oneway_arrows.postTranslate(-Navit.oneway_arrow.getWidth() / 2, -Navit.oneway_arrow.getHeight() / 2); |
1517 | |
1915 | |
1518 | if (order > DRAW_ONEWAY_ARROWS_AT_ORDER) |
|
|
1519 | { |
|
|
1520 | if (oneway == 1) |
1916 | if (oneway == 1) |
1521 | { |
1917 | { |
1522 | if (!Navit.PREF_gui_oneway_arrows) |
|
|
1523 | { |
|
|
1524 | return; |
|
|
1525 | } |
|
|
1526 | // rotate the Bitmap |
1918 | // rotate the Bitmap |
1527 | matrix.postRotate(angle); |
1919 | matrix_oneway_arrows.postRotate(angle); |
1528 | } |
1920 | } |
1529 | else if (oneway == 2) |
1921 | else if (oneway == 2) |
1530 | { |
1922 | { |
1531 | if (!Navit.PREF_gui_oneway_arrows) |
|
|
1532 | { |
|
|
1533 | return; |
|
|
1534 | } |
|
|
1535 | // rotate the Bitmap |
1923 | // rotate the Bitmap |
1536 | matrix.postRotate(angle + 180); |
1924 | matrix_oneway_arrows.postRotate(angle + 180); |
1537 | } |
1925 | } |
1538 | |
1926 | |
1539 | if (oneway > 0) |
1927 | if (oneway > 0) |
1540 | { |
1928 | { |
1541 | if (c.length == 4) |
1929 | if (c.length == 4) |
1542 | { |
1930 | { |
1543 | matrix.postTranslate(middle_x, middle_y); |
1931 | matrix_oneway_arrows.postTranslate(middle_x, middle_y); |
1544 | draw_canvas.drawBitmap(Navit.oneway_arrow, matrix, paint); |
1932 | draw_canvas.drawBitmap(Navit.oneway_arrow, matrix_oneway_arrows, paint); |
1545 | } |
1933 | } |
|
|
1934 | |
|
|
1935 | paint.setAntiAlias(b_paint_antialias); |
|
|
1936 | |
1546 | } |
1937 | } |
1547 | else |
1938 | else |
1548 | { |
1939 | { |
1549 | normal = true; |
1940 | // normal = true; |
1550 | } |
1941 | return; |
1551 | } |
1942 | } |
1552 | else |
|
|
1553 | { |
|
|
1554 | normal = true; |
|
|
1555 | } |
|
|
1556 | |
|
|
1557 | if (normal) |
|
|
1558 | { |
|
|
1559 | // normal line |
|
|
1560 | Path path = new Path(); |
|
|
1561 | path.moveTo(c[0], c[1]); |
|
|
1562 | for (int i = 2; i < c.length; i += 2) |
|
|
1563 | { |
|
|
1564 | path.lineTo(c[i], c[i + 1]); |
|
|
1565 | } |
1943 | } |
1566 | draw_canvas.drawPath(path, paint); |
|
|
1567 | } |
1944 | //} |
1568 | paint.setAntiAlias(b); |
1945 | //else |
|
|
1946 | //{ |
|
|
1947 | // // normal = true; |
|
|
1948 | // // draw nothing, just return! |
|
|
1949 | // return; |
|
|
1950 | //} |
|
|
1951 | |
1569 | //paint.setPathEffect(dashed_map_lines__no_dash); |
1952 | //paint.setPathEffect(dashed_map_lines__no_dash); |
1570 | } |
1953 | } |
1571 | |
1954 | |
|
|
1955 | // draw normal polylines -> this function gets called the most!! XX-thousand times |
|
|
1956 | // draw normal polylines -> this function gets called the most!! XX-thousand times |
|
|
1957 | // draw normal polylines -> this function gets called the most!! XX-thousand times |
1572 | protected void draw_polyline3(Paint paint, int c[], int order, int width) |
1958 | protected void draw_polyline3(Paint paint, int c[], int order, int width) |
1573 | { |
1959 | { |
1574 | // Log.e("NavitGraphics","draw_polyline3"); |
1960 | // Log.e("NavitGraphics","draw_polyline3"); |
1575 | paint.setStyle(Paint.Style.STROKE); |
1961 | paint.setStyle(Paint.Style.STROKE); |
1576 | Boolean b = paint.isAntiAlias(); |
1962 | b_paint_antialias = paint.isAntiAlias(); |
1577 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
1963 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
1578 | float wsave = paint.getStrokeWidth(); |
1964 | wsave_003 = paint.getStrokeWidth(); |
1579 | paint.setStrokeWidth(width); |
1965 | paint.setStrokeWidth(width); |
1580 | |
1966 | |
1581 | paint.setStyle(Paint.Style.FILL); |
1967 | if (order > DRAW_MORE_DETAILS_AT_ORDER) |
1582 | paint.setStrokeWidth(0); |
|
|
1583 | draw_canvas.drawCircle(c[0], c[1], (width / 2), paint); |
|
|
1584 | for (int i = 2; i < c.length; i += 2) |
|
|
1585 | { |
1968 | { |
1586 | //if (i < (c.length - 2)) |
|
|
1587 | //{ |
|
|
1588 | paint.setStyle(Paint.Style.FILL); |
1969 | paint.setStyle(Paint.Style.FILL); |
1589 | paint.setStrokeWidth(0); |
1970 | paint.setStrokeWidth(0); |
|
|
1971 | draw_canvas.drawCircle(c[0], c[1], (width / 2), paint); |
|
|
1972 | } |
|
|
1973 | for (int i = 2; i < c.length; i += 2) |
|
|
1974 | { |
|
|
1975 | if (order > DRAW_MORE_DETAILS_AT_ORDER) |
|
|
1976 | { |
|
|
1977 | //if (i < (c.length - 2)) |
|
|
1978 | //{ |
|
|
1979 | paint.setStyle(Paint.Style.FILL); |
|
|
1980 | paint.setStrokeWidth(0); |
1590 | draw_canvas.drawCircle(c[i], c[i + 1], (width / 2), paint); |
1981 | draw_canvas.drawCircle(c[i], c[i + 1], (width / 2), paint); |
1591 | //} |
1982 | //} |
1592 | paint.setStyle(Paint.Style.STROKE); |
1983 | paint.setStyle(Paint.Style.STROKE); |
1593 | paint.setStrokeWidth(width); |
1984 | paint.setStrokeWidth(width); |
|
|
1985 | } |
1594 | draw_canvas.drawLine(c[i - 2], c[i - 1], c[i], c[i + 1], paint); |
1986 | draw_canvas.drawLine(c[i - 2], c[i - 1], c[i], c[i + 1], paint); |
1595 | } |
1987 | } |
1596 | paint.setAntiAlias(b); |
1988 | paint.setAntiAlias(b_paint_antialias); |
1597 | paint.setStrokeWidth(wsave); |
1989 | paint.setStrokeWidth(wsave_003); |
1598 | //paint.setPathEffect(dashed_map_lines__no_dash); |
1990 | //paint.setPathEffect(dashed_map_lines__no_dash); |
1599 | } |
1991 | } |
1600 | |
1992 | |
|
|
1993 | // draw normal polylines -> this function gets called the most!! XX-thousand times |
|
|
1994 | // draw normal polylines -> this function gets called the most!! XX-thousand times |
|
|
1995 | // draw normal polylines -> this function gets called the most!! XX-thousand times |
|
|
1996 | |
|
|
1997 | // for bridge or tunnel this function is used |
1601 | protected void draw_polyline4(Paint paint, int c[], int order, int width, int type) |
1998 | protected void draw_polyline4(Paint paint, int c[], int order, int width, int type) |
1602 | { |
1999 | { |
|
|
2000 | // type:0 -> normal line |
1603 | // type:1 -> underground (tunnel) |
2001 | // type:1 -> underground (tunnel) |
1604 | // type:2 -> bridge |
2002 | // type:2 -> bridge |
1605 | |
2003 | |
1606 | Boolean b = paint.isAntiAlias(); |
2004 | b_paint_antialias = paint.isAntiAlias(); |
1607 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
2005 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
1608 | float wsave = paint.getStrokeWidth(); |
2006 | wsave_004 = paint.getStrokeWidth(); |
|
|
2007 | |
|
|
2008 | if (order <= DRAW_MORE_DETAILS_TUNNEL_BRIDGES_AT_ORDER) |
|
|
2009 | { |
|
|
2010 | type = 0; |
|
|
2011 | } |
1609 | |
2012 | |
1610 | if (type == 2) |
2013 | if (type == 2) |
1611 | { |
2014 | { |
1612 | // bridge |
2015 | // bridge |
1613 | // |
2016 | // |
1614 | //int csave = paint.getColor(); |
2017 | //int csave = paint.getColor(); |
1615 | paint.setAlpha(120); // 0 .. 255 // 255 -> no seethru |
2018 | paint.setAlpha(120); // 0 .. 255 // 255 -> no seethru |
1616 | paint.setStyle(Paint.Style.STROKE); |
2019 | paint.setStyle(Paint.Style.STROKE); |
1617 | paint.setStrokeWidth(width + 2); |
2020 | paint.setStrokeWidth(width + 2); |
1618 | // paint.setColor(Color.BLACK); |
2021 | // paint.setColor(Color.BLACK); |
1619 | if (order > 12) |
2022 | if (order > DRAW_DETAIL_DASHES_AT_ORDER) |
1620 | { |
2023 | { |
1621 | paint.setStrokeWidth(width + 4); |
2024 | paint.setStrokeWidth(width + 4); |
1622 | } |
2025 | } |
1623 | for (int i = 2; i < c.length; i += 2) |
2026 | for (int i = 2; i < c.length; i += 2) |
1624 | { |
2027 | { |
… | |
… | |
1648 | |
2051 | |
1649 | if (type == 1) |
2052 | if (type == 1) |
1650 | { |
2053 | { |
1651 | // tunnel |
2054 | // tunnel |
1652 | paint.setAlpha(70); // 0 .. 255 // 255 -> no seethru |
2055 | paint.setAlpha(70); // 0 .. 255 // 255 -> no seethru |
1653 | if (order > 13) |
2056 | if (order > DRAW_DETAIL_DASHES_AT_ORDER) |
1654 | { |
2057 | { |
1655 | paint.setPathEffect(dashed_map_lines__low); |
2058 | paint.setPathEffect(dashed_map_lines__low); |
1656 | } |
2059 | } |
1657 | else |
2060 | else |
1658 | { |
2061 | { |
… | |
… | |
1671 | { |
2074 | { |
1672 | draw_canvas.drawLine(c[i - 2], c[i - 1], c[i], c[i + 1], paint); |
2075 | draw_canvas.drawLine(c[i - 2], c[i - 1], c[i], c[i + 1], paint); |
1673 | } |
2076 | } |
1674 | |
2077 | |
1675 | paint.setPathEffect(dashed_map_lines__no_dash); |
2078 | paint.setPathEffect(dashed_map_lines__no_dash); |
1676 | paint.setAntiAlias(b); |
2079 | paint.setAntiAlias(b_paint_antialias); |
1677 | paint.setStrokeWidth(wsave); |
2080 | paint.setStrokeWidth(wsave_004); |
1678 | } |
2081 | } |
1679 | |
2082 | |
1680 | protected void set_dashes(Paint paint, int variant, int order) |
2083 | protected void set_dashes(Paint paint, int variant, int order) |
1681 | { |
2084 | { |
1682 | if (variant == 0) |
2085 | if (variant == 0) |
1683 | { |
2086 | { |
1684 | paint.setPathEffect(dashed_map_lines__no_dash); |
2087 | paint.setPathEffect(dashed_map_lines__no_dash); |
1685 | return; |
2088 | return; |
1686 | } |
2089 | } |
1687 | |
2090 | |
1688 | if (order > 13) |
2091 | if (order > DRAW_DETAIL_DASHES_AT_ORDER) |
1689 | { |
2092 | { |
1690 | paint.setPathEffect(dashes__low[variant]); |
2093 | paint.setPathEffect(dashes__low[variant]); |
1691 | } |
2094 | } |
1692 | else |
2095 | else |
1693 | { |
2096 | { |
… | |
… | |
1695 | } |
2098 | } |
1696 | } |
2099 | } |
1697 | |
2100 | |
1698 | protected void draw_polyline_dashed(Paint paint, int c[], int order, int oneway) |
2101 | protected void draw_polyline_dashed(Paint paint, int c[], int order, int oneway) |
1699 | { |
2102 | { |
|
|
2103 | // |
|
|
2104 | // |
|
|
2105 | // !! this function is unsed now !! |
|
|
2106 | // |
|
|
2107 | // |
|
|
2108 | |
1700 | paint.setStyle(Paint.Style.STROKE); |
2109 | paint.setStyle(Paint.Style.STROKE); |
1701 | Boolean b = paint.isAntiAlias(); |
2110 | b_paint_antialias = paint.isAntiAlias(); |
1702 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
2111 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
1703 | |
2112 | |
1704 | Boolean normal = false; |
2113 | Boolean normal = false; |
1705 | |
2114 | |
1706 | // create matrix for the manipulation |
2115 | // create matrix for the manipulation |
… | |
… | |
1709 | int middle_x = c[0] + (int) ((c[2] - c[0]) / 2); |
2118 | int middle_x = c[0] + (int) ((c[2] - c[0]) / 2); |
1710 | int middle_y = c[1] + (int) ((c[3] - c[1]) / 2); |
2119 | int middle_y = c[1] + (int) ((c[3] - c[1]) / 2); |
1711 | double d_x = ((c[2] - c[0]) / 6); |
2120 | double d_x = ((c[2] - c[0]) / 6); |
1712 | double d_y = ((c[3] - c[1]) / 6); |
2121 | double d_y = ((c[3] - c[1]) / 6); |
1713 | int angle = (int) (Math.toDegrees(Math.atan2(d_y, d_x))); |
2122 | int angle = (int) (Math.toDegrees(Math.atan2(d_y, d_x))); |
1714 | // System.out.println("arrow angle=" + angle); |
|
|
1715 | matrix.postTranslate(-Navit.oneway_arrow.getWidth() / 2, -Navit.oneway_arrow.getHeight() / 2); |
2123 | matrix.postTranslate(-Navit.oneway_arrow.getWidth() / 2, -Navit.oneway_arrow.getHeight() / 2); |
1716 | |
2124 | |
1717 | if (order > DRAW_ONEWAY_ARROWS_AT_ORDER) |
2125 | if (order > DRAW_ONEWAY_ARROWS_AT_ORDER) |
1718 | { |
2126 | { |
1719 | if (oneway == 1) |
2127 | if (oneway == 1) |
… | |
… | |
1754 | } |
2162 | } |
1755 | |
2163 | |
1756 | if (normal) |
2164 | if (normal) |
1757 | { |
2165 | { |
1758 | // normal line |
2166 | // normal line |
1759 | if (order > 13) |
2167 | if (order > DRAW_DETAIL_DASHES_AT_ORDER) |
1760 | { |
2168 | { |
1761 | paint.setPathEffect(dashed_map_lines__low); |
2169 | paint.setPathEffect(dashed_map_lines__low); |
1762 | } |
2170 | } |
1763 | else |
2171 | else |
1764 | { |
2172 | { |
1765 | paint.setPathEffect(dashed_map_lines__high); |
2173 | paint.setPathEffect(dashed_map_lines__high); |
1766 | } |
2174 | } |
1767 | Path path = new Path(); |
2175 | b_paint_path.reset(); |
1768 | path.moveTo(c[0], c[1]); |
2176 | b_paint_path.moveTo(c[0], c[1]); |
1769 | for (int i = 2; i < c.length; i += 2) |
2177 | for (int i = 2; i < c.length; i += 2) |
1770 | { |
2178 | { |
1771 | path.lineTo(c[i], c[i + 1]); |
2179 | b_paint_path.lineTo(c[i], c[i + 1]); |
1772 | } |
2180 | } |
1773 | |
2181 | |
1774 | draw_canvas.drawPath(path, paint); |
2182 | draw_canvas.drawPath(b_paint_path, paint); |
1775 | paint.setPathEffect(dashed_map_lines__no_dash); |
2183 | paint.setPathEffect(dashed_map_lines__no_dash); |
1776 | } |
2184 | } |
1777 | paint.setAntiAlias(b); |
2185 | paint.setAntiAlias(b_paint_antialias); |
1778 | } |
2186 | } |
1779 | |
2187 | |
1780 | protected void draw_polygon(Paint paint, int c[]) |
2188 | protected void draw_polygon(Paint paint, int c[]) |
1781 | { |
2189 | { |
1782 | paint.setStyle(Paint.Style.FILL); |
2190 | paint.setStyle(Paint.Style.FILL); |
1783 | Boolean b = paint.isAntiAlias(); |
2191 | b_paint_antialias = paint.isAntiAlias(); |
1784 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
2192 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
1785 | Path path = new Path(); |
2193 | b_paint_path.reset(); |
1786 | path.moveTo(c[0], c[1]); |
2194 | b_paint_path.moveTo(c[0], c[1]); |
1787 | for (int i = 2; i < c.length; i += 2) |
2195 | for (int i = 2; i < c.length; i += 2) |
1788 | { |
2196 | { |
1789 | path.lineTo(c[i], c[i + 1]); |
2197 | b_paint_path.lineTo(c[i], c[i + 1]); |
1790 | } |
2198 | } |
1791 | draw_canvas.drawPath(path, paint); |
2199 | draw_canvas.drawPath(b_paint_path, paint); |
1792 | paint.setAntiAlias(b); |
2200 | paint.setAntiAlias(b_paint_antialias); |
1793 | } |
2201 | } |
1794 | |
2202 | |
1795 | protected void draw_polygon2(Paint paint, int c[], int order, int oneway) |
2203 | protected void draw_polygon2(Paint paint, int c[], int order, int oneway) |
1796 | { |
2204 | { |
1797 | paint.setStyle(Paint.Style.FILL); |
2205 | paint.setStyle(Paint.Style.FILL); |
1798 | Boolean b = paint.isAntiAlias(); |
2206 | b_paint_antialias = paint.isAntiAlias(); |
1799 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
2207 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
1800 | Path path = new Path(); |
2208 | b_paint_path.reset(); |
1801 | path.moveTo(c[0], c[1]); |
2209 | b_paint_path.moveTo(c[0], c[1]); |
1802 | for (int i = 2; i < c.length; i += 2) |
2210 | for (int i = 2; i < c.length; i += 2) |
1803 | { |
2211 | { |
1804 | path.lineTo(c[i], c[i + 1]); |
2212 | b_paint_path.lineTo(c[i], c[i + 1]); |
1805 | } |
2213 | } |
1806 | |
2214 | |
1807 | if (order > DRAW_ONEWAY_ARROWS_AT_ORDER) |
2215 | if (order > DRAW_ONEWAY_ARROWS_AT_ORDER) |
1808 | { |
2216 | { |
1809 | if (oneway == 1) |
2217 | if (oneway == 1) |
… | |
… | |
1822 | return; |
2230 | return; |
1823 | } |
2231 | } |
1824 | } |
2232 | } |
1825 | } |
2233 | } |
1826 | |
2234 | |
1827 | draw_canvas.drawPath(path, paint); |
2235 | draw_canvas.drawPath(b_paint_path, paint); |
1828 | paint.setAntiAlias(b); |
2236 | paint.setAntiAlias(b_paint_antialias); |
1829 | } |
2237 | } |
1830 | |
2238 | |
1831 | protected void draw_rectangle(Paint paint, int x, int y, int w, int h) |
2239 | protected void draw_rectangle(Paint paint, int x, int y, int w, int h) |
1832 | { |
2240 | { |
1833 | //Log.e("NavitGraphics","draw_rectangle"); |
2241 | //Log.e("NavitGraphics","draw_rectangle"); |
1834 | Rect r = new Rect(x, y, x + w, y + h); |
2242 | Rect r = new Rect(x, y, x + w, y + h); |
1835 | paint.setStyle(Paint.Style.FILL); |
2243 | paint.setStyle(Paint.Style.FILL); |
1836 | Boolean b = paint.isAntiAlias(); |
2244 | b_paint_antialias = paint.isAntiAlias(); |
1837 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
2245 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
1838 | //paint.setStrokeWidth(0); |
2246 | //paint.setStrokeWidth(0); |
1839 | draw_canvas.drawRect(r, paint); |
2247 | draw_canvas.drawRect(r, paint); |
1840 | paint.setAntiAlias(b); |
2248 | paint.setAntiAlias(b_paint_antialias); |
1841 | } |
2249 | } |
1842 | |
2250 | |
1843 | protected void draw_circle(Paint paint, int x, int y, int r) |
2251 | protected void draw_circle(Paint paint, int x, int y, int r) |
1844 | { |
2252 | { |
1845 | //Log.e("NavitGraphics","draw_circle"); |
2253 | //Log.e("NavitGraphics","draw_circle"); |
1846 | // float fx = x; |
2254 | // float fx = x; |
1847 | // float fy = y; |
2255 | // float fy = y; |
1848 | // float fr = r / 2; |
2256 | // float fr = r / 2; |
1849 | paint.setStyle(Paint.Style.STROKE); |
2257 | paint.setStyle(Paint.Style.STROKE); |
1850 | Boolean b = paint.isAntiAlias(); |
2258 | b_paint_antialias = paint.isAntiAlias(); |
1851 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
2259 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
1852 | draw_canvas.drawCircle(x, y, r / 2, paint); |
2260 | draw_canvas.drawCircle(x, y, r / 2, paint); |
1853 | paint.setAntiAlias(b); |
2261 | paint.setAntiAlias(b_paint_antialias); |
1854 | } |
2262 | } |
1855 | |
2263 | |
1856 | protected void draw_text(Paint paint, int x, int y, String text, int size, int dx, int dy) |
2264 | protected void draw_text(Paint paint, int x, int y, String text, int size, int dx, int dy) |
1857 | { |
2265 | { |
1858 | // float fx = x; |
2266 | // float fx = x; |
… | |
… | |
1899 | if (paint.getTypeface() == null) |
2307 | if (paint.getTypeface() == null) |
1900 | { |
2308 | { |
1901 | try |
2309 | try |
1902 | { |
2310 | { |
1903 | paint.setTypeface(Navit.NavitStreetnameFont); |
2311 | paint.setTypeface(Navit.NavitStreetnameFont); |
|
|
2312 | // System.out.println("Calling setTypeface"); |
1904 | } |
2313 | } |
1905 | catch (Exception e) |
2314 | catch (Exception e) |
1906 | { |
2315 | { |
1907 | } |
2316 | } |
1908 | } |
2317 | } |
… | |
… | |
1914 | paint.setTypeface(null); |
2323 | paint.setTypeface(null); |
1915 | } |
2324 | } |
1916 | } |
2325 | } |
1917 | // FONT ------------------ |
2326 | // FONT ------------------ |
1918 | // FONT ------------------ |
2327 | // FONT ------------------ |
1919 | Boolean b = paint.isAntiAlias(); |
2328 | b_paint_antialias = paint.isAntiAlias(); |
1920 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
2329 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
1921 | if (dx == 0x10000 && dy == 0) |
2330 | if (dx == 0x10000 && dy == 0) |
1922 | { |
2331 | { |
1923 | draw_canvas.drawText(text, x, y, paint); |
2332 | draw_canvas.drawText(text, x, y, paint); |
1924 | } |
2333 | } |
1925 | else |
2334 | else |
1926 | { |
2335 | { |
1927 | Path path = new Path(); |
2336 | b_paint_path.reset(); |
1928 | path.moveTo(x, y); |
2337 | b_paint_path.moveTo(x, y); |
1929 | path.rLineTo(dx, dy); |
2338 | b_paint_path.rLineTo(dx, dy); |
1930 | paint.setTextAlign(android.graphics.Paint.Align.LEFT); |
2339 | paint.setTextAlign(android.graphics.Paint.Align.LEFT); |
1931 | draw_canvas.drawTextOnPath(text, path, 0, 0, paint); |
2340 | draw_canvas.drawTextOnPath(text, b_paint_path, 0, 0, paint); |
1932 | } |
2341 | } |
1933 | paint.setAntiAlias(b); |
2342 | paint.setAntiAlias(b_paint_antialias); |
1934 | } |
2343 | } |
1935 | |
2344 | |
1936 | protected void draw_image(Paint paint, int x, int y, Bitmap bitmap) |
2345 | protected void draw_image(Paint paint, int x, int y, Bitmap bitmap) |
1937 | { |
2346 | { |
1938 | //Log.e("NavitGraphics","draw_image"); |
2347 | //Log.e("NavitGraphics","draw_image"); |
… | |
… | |
1944 | protected void draw_bigmap(int yaw, int order, float clng, float clat, int x_, int y_, int mcx, int mcy, int px_, int py_, int valid) |
2353 | protected void draw_bigmap(int yaw, int order, float clng, float clat, int x_, int y_, int mcx, int mcy, int px_, int py_, int valid) |
1945 | { |
2354 | { |
1946 | if (Navit.bigmap_bitmap != null) |
2355 | if (Navit.bigmap_bitmap != null) |
1947 | { |
2356 | { |
1948 | // input: x,y --> screen coords of lat=0,lng=0 point!! |
2357 | // input: x,y --> screen coords of lat=0,lng=0 point!! |
1949 | |
2358 | /* |
1950 | //System.out.println("in:" + clat + "#" + clng); |
|
|
1951 | //String aaaa1 = CallbackGeoCalc(1, 1, 1); |
|
|
1952 | //System.out.println("out:" + aaaa1); |
|
|
1953 | //String aaaa2 = CallbackGeoCalc(2, clat, clng); |
|
|
1954 | //System.out.println("out:" + aaaa2); |
|
|
1955 | |
|
|
1956 | //int yaw2 = -yaw; |
|
|
1957 | //int x = (int) ((float) x_ * Math.cos(Math.toRadians(yaw2)) - (float) y_ * Math.sin(Math.toRadians(yaw2))); |
|
|
1958 | //int y = (int) ((float) x_ * Math.sin(Math.toRadians(yaw2)) + (float) y_ * Math.cos(Math.toRadians(yaw2))); |
|
|
1959 | |
|
|
1960 | //**int x = x_; |
|
|
1961 | //**int y = y_; |
|
|
1962 | |
|
|
1963 | //int scx = (int) ((float) scx_ * Math.cos(Math.toRadians(yaw2)) - (float) scy_ * Math.sin(Math.toRadians(yaw2))); |
|
|
1964 | //int scy = (int) ((float) scx_ * Math.sin(Math.toRadians(yaw2)) + (float) scy_ * Math.cos(Math.toRadians(yaw2))); |
|
|
1965 | int scx = (int) (draw_canvas.getWidth() / 2); |
2359 | * int scx = (int) (draw_canvas.getWidth() / 2); |
1966 | int scy = (int) (draw_canvas.getHeight() / 2); |
2360 | * int scy = (int) (draw_canvas.getHeight() / 2); |
1967 | |
|
|
1968 | //int px = (int) ((float) px_ * Math.cos(Math.toRadians(yaw2)) - (float) py_ * Math.sin(Math.toRadians(yaw2))); |
|
|
1969 | //int py = (int) ((float) px_ * Math.sin(Math.toRadians(yaw2)) + (float) py_ * Math.cos(Math.toRadians(yaw2))); |
|
|
1970 | int px = px_; |
2361 | * int px = px_; |
1971 | int py = py_; |
2362 | * int py = py_; |
1972 | |
2363 | */ |
1973 | // c.scale(5f, 5f, this.mCanvasWidth / 2, this.mCanvasHeight / 2); |
|
|
1974 | // c.rotate(13, this.mCanvasWidth / 2, this.mCanvasHeight / 2); |
|
|
1975 | |
|
|
1976 | //yaw = 30; |
|
|
1977 | //System.out.println("yaw=" + yaw); |
|
|
1978 | //System.out.println("x_=" + x_); |
|
|
1979 | //System.out.println("y_=" + y_); |
|
|
1980 | |
2364 | |
1981 | // calculate the scale |
2365 | // calculate the scale |
1982 | float scaleWidth = 1; |
2366 | float scaleWidth = 1; |
1983 | float scaleHeight = 1; |
2367 | float scaleHeight = 1; |
|
|
2368 | |
|
|
2369 | /* |
1984 | if (order == -1) |
2370 | * if (order == -1) |
1985 | { |
2371 | * { |
1986 | scaleWidth = scaleHeight = 0.8f * (1.5f / draw_factor); |
2372 | * scaleWidth = scaleHeight = 0.8f * (1.5f / draw_factor); |
1987 | } |
2373 | * } |
1988 | else if (order == -2) |
2374 | * else if (order == -2) |
1989 | { |
2375 | * { |
1990 | scaleWidth = scaleHeight = (float) ((1 / 2f) * 0.8f) * (1.5f / draw_factor); |
2376 | * scaleWidth = scaleHeight = (float) ((1 / 2f) * 0.8f) * (1.5f / draw_factor); |
1991 | } |
2377 | * } |
|
|
2378 | */ |
|
|
2379 | |
|
|
2380 | //System.out.println("bigmap order:" + (long) (order * 100)); |
|
|
2381 | scaleWidth = scaleHeight = BIGMAP_FACTOR / (float) order * (1.5f / draw_factor); |
|
|
2382 | //System.out.println("draw_factor:" + draw_factor); |
1992 | |
2383 | |
1993 | if ((scaleWidth == 0) || (scaleHeight == 0)) |
2384 | if ((scaleWidth == 0) || (scaleHeight == 0)) |
1994 | { |
2385 | { |
1995 | //System.out.println(" " + scaleWidth + " " + scaleHeight + " " + order); |
2386 | //System.out.println(" " + scaleWidth + " " + scaleHeight + " " + order); |
1996 | return; |
2387 | return; |
… | |
… | |
1999 | if (valid == 1) |
2390 | if (valid == 1) |
2000 | { |
2391 | { |
2001 | //System.out.println(" px " + px + " py " + py); |
2392 | //System.out.println(" px " + px + " py " + py); |
2002 | } |
2393 | } |
2003 | |
2394 | |
2004 | // createa matrix for the manipulation |
2395 | // create a matrix for the manipulation |
2005 | Matrix matrix = new Matrix(); |
2396 | Matrix matrix = new Matrix(); |
2006 | // resize the bit map |
|
|
2007 | //matrix.postScale(scaleWidth, scaleHeight); |
|
|
2008 | // rotate the Bitmap |
|
|
2009 | //matrix.setRotate(13, Navit.bigmap_bitmap.getWidth() / 2, Navit.bigmap_bitmap.getHeight() / 2); |
|
|
2010 | //int half_x = (int) ((Navit.bigmap_bitmap.getWidth() / 1.5f * draw_factor) / 2); |
|
|
2011 | //int half_y = (int) ((Navit.bigmap_bitmap.getHeight() / 1.5f * draw_factor) / 2); |
|
|
2012 | int half_x = (int) (Navit.bigmap_bitmap.getWidth() / 2); |
2397 | int half_x = (int) (Navit.bigmap_bitmap.getWidth() / 2); |
2013 | int half_y = (int) (Navit.bigmap_bitmap.getHeight() / 2); |
2398 | int half_y = (int) (Navit.bigmap_bitmap.getHeight() / 2); |
2014 | matrix.setScale(scaleWidth, scaleHeight, half_x, half_y); |
2399 | matrix.setScale(scaleWidth, scaleHeight, half_x, half_y); |
2015 | |
|
|
2016 | // matrix.postRotate(yaw); |
|
|
2017 | |
2400 | |
2018 | int usedMegs; |
2401 | int usedMegs; |
2019 | String usedMegsString; |
2402 | String usedMegsString; |
2020 | // int usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L); |
2403 | // int usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L); |
2021 | // String usedMegsString = String.format("00 - Memory Used: %d MB", usedMegs); |
2404 | // String usedMegsString = String.format("00 - Memory Used: %d MB", usedMegs); |
… | |
… | |
2074 | // usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L); |
2457 | // usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L); |
2075 | // usedMegsString = String.format(" - Memory Used: %d MB", usedMegs); |
2458 | // usedMegsString = String.format(" - Memory Used: %d MB", usedMegs); |
2076 | // System.out.println("" + usedMegsString); |
2459 | // System.out.println("" + usedMegsString); |
2077 | |
2460 | |
2078 | float top = 85.2f; |
2461 | float top = 85.2f; |
2079 | float bottom = -85.2f; |
2462 | //float bottom = -85.2f; |
2080 | float left = -180f; |
2463 | float left = -180f; |
2081 | float right = 180f; |
2464 | //float right = 180f; |
2082 | |
2465 | |
2083 | String left_top_on_screen_string = CallbackGeoCalc(2, top, left); |
2466 | String left_top_on_screen_string = CallbackGeoCalc(2, top, left); |
2084 | //String right_top_on_screen_string = CallbackGeoCalc(2, top, right); |
|
|
2085 | String tmp[] = left_top_on_screen_string.split(":", 2); |
2467 | String tmp[] = left_top_on_screen_string.split(":", 2); |
2086 | int pixel_top_left_x = Integer.parseInt(tmp[0]); |
2468 | int pixel_top_left_x = Integer.parseInt(tmp[0]); |
2087 | int pixel_top_left_y = Integer.parseInt(tmp[1]); |
2469 | int pixel_top_left_y = Integer.parseInt(tmp[1]); |
2088 | //int pixel_top_right_x = Integer.parseInt(right_top_on_screen_string.split(":", 2)[0]); |
|
|
2089 | //int pixel_top_right_y = Integer.parseInt(right_top_on_screen_string.split(":", 2)[1]); |
|
|
2090 | //double xx = pixel_top_left_x - pixel_top_right_x; |
|
|
2091 | //double yy = pixel_top_left_y - pixel_top_right_y; |
|
|
2092 | //double alpha = 0; |
|
|
2093 | //if (yy != 0) |
|
|
2094 | //{ |
|
|
2095 | // alpha = Math.atan(xx / yy); |
|
|
2096 | // alpha = Math.toDegrees(alpha); |
|
|
2097 | //} |
|
|
2098 | //System.out.println("alpha=" + alpha); |
|
|
2099 | |
2470 | |
2100 | // System.out.println("lt:" + left_top_on_screen_string + " rt:" + right_top_on_screen_string); |
2471 | //float p_karte_pixel_x; |
2101 | // left_top_on_screen_string = CallbackGeoCalc(2, bottom, left); |
2472 | //float p_karte_pixel_y; |
2102 | // right_top_on_screen_string = CallbackGeoCalc(2, bottom, right); |
|
|
2103 | // System.out.println("lb:" + left_top_on_screen_string + " rb:" + right_top_on_screen_string); |
|
|
2104 | |
2473 | |
|
|
2474 | // pixel point of 0/0 geo coord |
2105 | /* |
2475 | /* |
2106 | * right_top_on_screen_string = CallbackGeoCalc(2, 0.0f, 0.0f); |
2476 | * p_karte_pixel_x = bigmap_bitmap_temp.getWidth() / 2; |
2107 | * System.out.println("1lb:" + left_top_on_screen_string + " rb:" + right_top_on_screen_string); |
2477 | * p_karte_pixel_y = bigmap_bitmap_temp.getHeight() / 2; |
|
|
2478 | */ |
|
|
2479 | |
|
|
2480 | /* |
|
|
2481 | * if (!loc_12_valid) |
|
|
2482 | * { |
|
|
2483 | * // initialize them the first time |
|
|
2484 | * loc_1_x = x_; |
|
|
2485 | * loc_1_y = y_; |
|
|
2486 | * loc_2_x = mcx; |
|
|
2487 | * loc_2_y = mcy; |
|
|
2488 | * loc_12_valid = true; |
|
|
2489 | * } |
2108 | * |
2490 | * |
2109 | * right_top_on_screen_string = CallbackGeoCalc(2, 80.0f, 180.0f); |
2491 | * if ((loc_1_x == x_) && (loc_1_y == y_)) |
2110 | * System.out.println("2lb:" + left_top_on_screen_string + " rb:" + right_top_on_screen_string); |
2492 | * { |
|
|
2493 | * p_karte_pixel_x = p_karte_pixel_x - (loc_2_x - mcx); |
|
|
2494 | * p_karte_pixel_y = p_karte_pixel_y - (loc_2_y - mcy); |
|
|
2495 | * // System.out.println("SSSSSSSS SSSSSSSS"); |
|
|
2496 | * } |
|
|
2497 | * else |
|
|
2498 | * { |
|
|
2499 | * loc_2_x = mcx; |
|
|
2500 | * loc_2_y = mcy; |
|
|
2501 | * } |
2111 | * |
2502 | * |
2112 | * right_top_on_screen_string = CallbackGeoCalc(2, 0.0f, 0.0f); |
2503 | * loc_1_x = x_; |
2113 | * System.out.println("3lb:" + left_top_on_screen_string + " rb:" + right_top_on_screen_string); |
2504 | * loc_1_y = y_; |
2114 | * |
|
|
2115 | * right_top_on_screen_string = CallbackGeoCalc(2, -80.0f, -180.0f); |
|
|
2116 | * System.out.println("4lb:" + left_top_on_screen_string + " rb:" + right_top_on_screen_string); |
|
|
2117 | */ |
2505 | */ |
2118 | |
2506 | |
2119 | float p_karte_pixel_x; |
|
|
2120 | float p_karte_pixel_y; |
|
|
2121 | //p_karte_pixel_x = (clat - left) * ((float) (bigmap_bitmap_temp.getWidth()) / (float) (right - left)); |
|
|
2122 | //p_karte_pixel_y = (clng - top) * ((float) (bigmap_bitmap_temp.getHeight()) / (float) (bottom - top)); |
|
|
2123 | |
|
|
2124 | // pixel point of 0/0 geo coord |
|
|
2125 | p_karte_pixel_x = bigmap_bitmap_temp.getWidth() / 2; |
|
|
2126 | p_karte_pixel_y = bigmap_bitmap_temp.getHeight() / 2; |
|
|
2127 | |
|
|
2128 | if (!loc_12_valid) |
|
|
2129 | { |
|
|
2130 | // initialize them the first time |
|
|
2131 | loc_1_x = x_; |
|
|
2132 | loc_1_y = y_; |
|
|
2133 | loc_2_x = mcx; |
|
|
2134 | loc_2_y = mcy; |
|
|
2135 | loc_12_valid = true; |
|
|
2136 | } |
|
|
2137 | |
|
|
2138 | if ((loc_1_x == x_) && (loc_1_y == y_)) |
|
|
2139 | { |
|
|
2140 | p_karte_pixel_x = p_karte_pixel_x - (loc_2_x - mcx); |
|
|
2141 | p_karte_pixel_y = p_karte_pixel_y - (loc_2_y - mcy); |
|
|
2142 | // System.out.println("SSSSSSSS SSSSSSSS"); |
|
|
2143 | } |
|
|
2144 | else |
|
|
2145 | { |
|
|
2146 | loc_2_x = mcx; |
|
|
2147 | loc_2_y = mcy; |
|
|
2148 | } |
|
|
2149 | |
|
|
2150 | loc_1_x = x_; |
|
|
2151 | loc_1_y = y_; |
|
|
2152 | |
|
|
2153 | int ssschx = (int) (x_ - p_karte_pixel_x); |
2507 | //int ssschx = (int) (x_ - p_karte_pixel_x); |
2154 | int ssschy = (int) (y_ - p_karte_pixel_y); |
2508 | //int ssschy = (int) (y_ - p_karte_pixel_y); |
2155 | |
|
|
2156 | //System.out.println(" kpx " + p_karte_pixel_x + " kpy " + p_karte_pixel_y); |
|
|
2157 | //System.out.println(" sw " + scaleWidth + " sh " + scaleHeight); |
|
|
2158 | //System.out.println(" x " + x + " y " + y + " sx " + scx + " sy " + scy + " w " + draw_canvas.getWidth() + " h " + draw_canvas.getHeight()); |
|
|
2159 | |
2509 | |
2160 | // fill canvas with ocean color |
2510 | // fill canvas with ocean color |
2161 | draw_canvas.drawColor(Color.parseColor("#82C8EA")); |
2511 | draw_canvas.drawColor(Color.parseColor("#82C8EA")); |
2162 | |
2512 | |
2163 | // x , y |
|
|
2164 | // 556,355 -> 1822610,36020399 |
|
|
2165 | // |
|
|
2166 | // y ++ -> oben |
|
|
2167 | // y -- -> unten |
|
|
2168 | // x ++ -> rechts |
|
|
2169 | // x -- -> links |
|
|
2170 | |
|
|
2171 | int green_dot_x = scx; |
2513 | //int green_dot_x = scx; |
2172 | int green_dot_y = scy; |
2514 | //int green_dot_y = scy; |
2173 | loc_dot_valid = true; |
2515 | loc_dot_valid = true; |
2174 | |
2516 | |
2175 | int rotation_point_x = scx; |
2517 | //int rotation_point_x = scx; |
2176 | int rotation_point_y = scy; |
2518 | //int rotation_point_y = scy; |
2177 | |
|
|
2178 | if (valid == 1) |
|
|
2179 | { |
|
|
2180 | /* |
|
|
2181 | * if (order == -2) |
|
|
2182 | * { |
|
|
2183 | * rotation_point_x = (int) ((-x + 1822610f) / 100000f * 1.5f) - 150 + 50 + px + 70; |
|
|
2184 | * rotation_point_y = (int) ((y - 36020399f) / 100000f * 1.5f) + 350 + 270 + py - 312; |
|
|
2185 | * } |
|
|
2186 | * else if (order == -1) |
|
|
2187 | * { |
|
|
2188 | * rotation_point_x = (int) ((-x + 1822610f) / 100000f * 3f) - 550 + 120 + px + 373; |
|
|
2189 | * rotation_point_y = (int) ((y - 36020399f) / 100000f * 3f) + 260 + 500 + 90 + py - 8; |
|
|
2190 | * } |
|
|
2191 | */ |
|
|
2192 | |
|
|
2193 | green_dot_x = px; |
|
|
2194 | green_dot_y = py; |
|
|
2195 | |
|
|
2196 | rotation_point_x = px; |
|
|
2197 | rotation_point_y = py; |
|
|
2198 | //System.out.println("valid"); |
|
|
2199 | } |
|
|
2200 | //System.out.println("rotation_point_x=" + rotation_point_x); |
|
|
2201 | //System.out.println("rotation_point_y=" + rotation_point_y); |
|
|
2202 | |
2519 | |
2203 | /* |
2520 | /* |
2204 | * int new_x = 0; |
2521 | * if (valid == 1) |
2205 | * int new_y = 0; |
|
|
2206 | * if (order == -2) |
|
|
2207 | * { |
2522 | * { |
2208 | * new_x = (int) ((-x + 1822610f) / 100000f * 1.5f) - 150 + 50; |
2523 | * green_dot_x = px; |
2209 | * new_y = (int) ((y - 36020399f) / 100000f * 1.5f) + 350 + 270; |
2524 | * green_dot_y = py; |
2210 | * } |
2525 | * |
2211 | * else if (order == -1) |
2526 | * rotation_point_x = px; |
2212 | * { |
2527 | * rotation_point_y = py; |
2213 | * new_x = (int) ((-x + 1822610f) / 100000f * 3f) - 550 + 120; |
|
|
2214 | * new_y = (int) ((y - 36020399f) / 100000f * 3f) + 260 + 500 + 90; |
|
|
2215 | * } |
2528 | * } |
2216 | */ |
2529 | */ |
2217 | //System.out.println("nx=" + new_x); |
|
|
2218 | //System.out.println("ny=" + new_y); |
|
|
2219 | |
|
|
2220 | //if ((new_x != loc_dot_x) && (new_y != loc_dot_y)) |
|
|
2221 | //{ |
|
|
2222 | /* |
|
|
2223 | * if ((loc_dot_x2 == rotation_point_x) && (loc_dot_y2 == rotation_point_y)) |
|
|
2224 | * { |
|
|
2225 | * green_dot_x = rotation_point_x - (loc_dot_x - new_x); |
|
|
2226 | * green_dot_y = rotation_point_y - (loc_dot_y - new_y); |
|
|
2227 | * // System.out.println("============"); |
|
|
2228 | * // System.out.println("1 n " + new_x); |
|
|
2229 | * // System.out.println("2 n " + new_y); |
|
|
2230 | * // System.out.println("3 r " + rotation_point_x); |
|
|
2231 | * // System.out.println("4 r " + rotation_point_y); |
|
|
2232 | * // System.out.println("5 g " + green_dot_x); |
|
|
2233 | * // System.out.println("6 g " + green_dot_y); |
|
|
2234 | * // System.out.println("7 l " + loc_dot_x); |
|
|
2235 | * // System.out.println("8 l " + loc_dot_y); |
|
|
2236 | * } |
|
|
2237 | * //} |
|
|
2238 | * if ((loc_dot_x2 != rotation_point_x) && (loc_dot_y2 != rotation_point_y)) |
|
|
2239 | * { |
|
|
2240 | * loc_dot_x = new_x; |
|
|
2241 | * loc_dot_y = new_y; |
|
|
2242 | * } |
|
|
2243 | * loc_dot_x2 = rotation_point_x; |
|
|
2244 | * loc_dot_y2 = rotation_point_y; |
|
|
2245 | */ |
|
|
2246 | |
|
|
2247 | //int xx = (int) ((float) new_x * Math.cos(Math.toRadians(yaw)) - (float) new_y * Math.sin(Math.toRadians(yaw))); |
|
|
2248 | //int yy = (int) ((float) new_x * Math.sin(Math.toRadians(yaw)) + (float) new_y * Math.cos(Math.toRadians(yaw))); |
|
|
2249 | |
|
|
2250 | // |
2530 | // |
2251 | draw_canvas.save(); // SAVE |
2531 | draw_canvas.save(); // SAVE |
2252 | // |
2532 | // |
2253 | // *********** draw_canvas.translate(green_dot_x, green_dot_y); |
2533 | // *********** draw_canvas.translate(green_dot_x, green_dot_y); |
2254 | draw_canvas.translate(pixel_top_left_x, pixel_top_left_y); |
2534 | draw_canvas.translate(pixel_top_left_x, pixel_top_left_y); |
2255 | //draw_canvas.rotate(yaw, green_dot_x, green_dot_y); |
|
|
2256 | draw_canvas.rotate(yaw, 0, 0); |
2535 | draw_canvas.rotate(yaw, 0, 0); |
2257 | ////draw_canvas.drawBitmap(bigmap_bitmap_temp, new_x, new_y, null); |
|
|
2258 | |
2536 | |
2259 | //Paint paint4 = new Paint(); |
|
|
2260 | //paint4.setColor(Color.RED); |
|
|
2261 | //paint4.setStyle(Style.FILL); |
|
|
2262 | |
|
|
2263 | //int dx = ((draw_canvas.getWidth() / 2) - green_dot_x); |
|
|
2264 | //int dy = ((draw_canvas.getHeight() / 2) - green_dot_y); |
|
|
2265 | //int dx2 = (int) ((draw_canvas.getWidth() / 2) - p_karte_pixel_x); |
|
|
2266 | //int dy2 = (int) ((draw_canvas.getHeight() / 2) - p_karte_pixel_y); |
|
|
2267 | //draw_canvas.drawBitmap(bigmap_bitmap_temp, new_x - green_dot_x, new_y - green_dot_y, null); |
|
|
2268 | // ******** draw_canvas.drawBitmap(bigmap_bitmap_temp, ssschx - green_dot_x, ssschy - green_dot_y, null); |
|
|
2269 | // draw_canvas.drawBitmap(bigmap_bitmap_temp, ssschx, ssschy, null); |
|
|
2270 | draw_canvas.drawBitmap(bigmap_bitmap_temp, 0, 0, null); |
2537 | draw_canvas.drawBitmap(bigmap_bitmap_temp, 0, 0, null); |
2271 | |
|
|
2272 | //draw_canvas.drawCircle(pixel_top_left_x, pixel_top_left_y, 40, paint4); |
|
|
2273 | //draw_canvas.drawCircle(pixel_top_right_x, pixel_top_right_y, 40, paint4); |
|
|
2274 | //draw_canvas.drawLine(pixel_top_left_x, pixel_top_left_y, pixel_top_right_x, pixel_top_right_y, paint4); |
|
|
2275 | |
|
|
2276 | //draw_canvas.drawCircle(0, 0, 20, paint4); |
|
|
2277 | //paint4.setColor(Color.GREEN); |
|
|
2278 | //draw_canvas.drawCircle(ssschx, ssschy, 25, paint4); |
|
|
2279 | //paint4.setColor(Color.MAGENTA); |
|
|
2280 | //draw_canvas.drawCircle(ssschx - green_dot_x, ssschy - green_dot_y, 25, paint4); |
|
|
2281 | |
|
|
2282 | //System.out.println("schieb: " + (ssschx) + " " + (ssschy)); |
|
|
2283 | |
|
|
2284 | //Paint paint = new Paint(); |
|
|
2285 | //paint.setColor(Color.RED); |
|
|
2286 | //paint.setStyle(Style.FILL); |
|
|
2287 | //draw_canvas.drawCircle(rotation_point_x, rotation_point_y, 10, paint); |
|
|
2288 | //paint.setStyle(Style.STROKE); |
|
|
2289 | //paint.setStrokeWidth(3); |
|
|
2290 | //paint.setColor(Color.GREEN); |
|
|
2291 | //draw_canvas.drawCircle(green_dot_x, green_dot_y, 16, paint); |
|
|
2292 | //paint.setColor(Color.YELLOW); |
|
|
2293 | //draw_canvas.drawCircle(dx2, dy2, 26, paint); |
|
|
2294 | //paint.setColor(Color.GREEN); |
|
|
2295 | //draw_canvas.drawCircle(p_karte_pixel_x, p_karte_pixel_y, 36, paint); |
|
|
2296 | //int u = 40; |
|
|
2297 | //draw_canvas.drawRect(green_dot_x - u, green_dot_y - u, green_dot_x + u, green_dot_y + u, paint); |
|
|
2298 | //paint.setColor(Color.MAGENTA); |
|
|
2299 | //draw_canvas.drawRect(0 + new_x, 0 + new_y, bigmap_bitmap_temp.getWidth() + new_x, bigmap_bitmap_temp.getHeight() + new_y, paint); |
|
|
2300 | //draw_canvas.drawLine(bigmap_bitmap_temp.getWidth() / 2 + new_x, 0 + new_y, bigmap_bitmap_temp.getWidth() / 2 + new_x, bigmap_bitmap_temp.getHeight() + new_y, paint); |
|
|
2301 | //draw_canvas.drawLine(0 + new_x, bigmap_bitmap_temp.getHeight() / 2 + new_y, bigmap_bitmap_temp.getWidth() + new_x, bigmap_bitmap_temp.getHeight() / 2 + new_y, paint); |
|
|
2302 | |
|
|
2303 | //Paint paint2 = new Paint(); |
|
|
2304 | //paint2.setColor(Color.YELLOW); |
|
|
2305 | //paint2.setStyle(Style.STROKE); |
|
|
2306 | //paint2.setStrokeWidth(3); |
|
|
2307 | //draw_canvas.drawCircle(green_dot_x - new_x, green_dot_y - new_y, 15, paint2); |
|
|
2308 | |
2538 | |
2309 | // |
2539 | // |
2310 | draw_canvas.restore(); // RESTORE |
2540 | draw_canvas.restore(); // RESTORE |
2311 | // |
2541 | // |
2312 | |
|
|
2313 | //paint.setTextSize(30); |
|
|
2314 | //paint.setStrokeWidth(3); |
|
|
2315 | //paint.setColor(Color.BLACK); |
|
|
2316 | //paint.setStyle(Paint.Style.FILL); |
|
|
2317 | |
|
|
2318 | // draw_canvas.drawText("yaw:" + yaw, 480 / 2, 800 / 2, paint); |
|
|
2319 | // draw_canvas.drawText("mcx :" + mcx + "," + mcy, 480 / 2, (800 / 2) + 40, paint); |
|
|
2320 | // draw_canvas.drawText("x :" + x_ + "," + y_, (480 / 2) - 150, (800 / 2) + 80, paint); |
|
|
2321 | // draw_canvas.drawText("px :" + px_ + "," + py_, 480 / 2, (800 / 2) + 120, paint); |
|
|
2322 | // draw_canvas.drawText("sssschx :" + ssschx + "," + ssschy, (480 / 2) - 150, (800 / 2) + 160, paint); |
|
|
2323 | // draw_canvas.drawText("clat :" + clat + "," + clng, (480 / 2) - 150, (800 / 2) + 200, paint); |
|
|
2324 | |
|
|
2325 | // usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L); |
|
|
2326 | // usedMegsString = String.format(" - Memory Used: %d MB", usedMegs); |
|
|
2327 | // System.out.println("" + usedMegsString); |
|
|
2328 | |
|
|
2329 | bigmap_bitmap_temp.recycle(); |
2542 | bigmap_bitmap_temp.recycle(); |
2330 | |
|
|
2331 | // usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L); |
|
|
2332 | // usedMegsString = String.format(" - Memory Used: %d MB", usedMegs); |
|
|
2333 | // System.out.println("" + usedMegsString); |
|
|
2334 | |
|
|
2335 | bigmap_bitmap_temp = null; |
2543 | bigmap_bitmap_temp = null; |
2336 | |
|
|
2337 | // usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L); |
|
|
2338 | // usedMegsString = String.format(" - Memory Used: %d MB", usedMegs); |
|
|
2339 | // System.out.println("" + usedMegsString); |
|
|
2340 | |
|
|
2341 | //System.gc(); |
|
|
2342 | |
|
|
2343 | // usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L); |
|
|
2344 | // usedMegsString = String.format("FF - Memory Used: %d MB", usedMegs); |
|
|
2345 | // System.out.println("" + usedMegsString); |
|
|
2346 | |
|
|
2347 | //System.out.println("yaw:" + yaw + " o:" + order + " x:" + x + " y:" + y); |
|
|
2348 | } |
2544 | } |
2349 | } |
2545 | } |
2350 | |
2546 | |
2351 | protected void send_osd_values(String id, String text1, String text2, String text3, int i1, int i2, int i3, int i4, float f1, float f2, float f3) |
2547 | protected void send_osd_values(String id, String text1, String text2, String text3, int i1, int i2, int i3, int i4, float f1, float f2, float f3) |
2352 | { |
2548 | { |
2353 | // Log.e("NavitOSDJava", "" + id + " " + text1 + " " + text2 + " " + text3 + " " + i1 + " " + i2 + " " + i3 + " " + i4 + " " + f1 + " " + f2 + " " + f3); |
2549 | //System.out.println("NavitOSDJava:" + id + " " + text1 + " " + text2 + " " + text3 + " " + i1 + " " + i2 + " " + i3 + " " + i4 + " " + f1 + " " + f2 + " " + f3); |
|
|
2550 | //System.out.println("NavitOSDJava:" + last_paint_OSD); |
|
|
2551 | Boolean needed_value = false; |
2354 | try |
2552 | try |
2355 | { |
2553 | { |
2356 | if (id.equals("scale")) |
2554 | if (id.equals("scale")) |
2357 | { |
2555 | { |
2358 | if (text1 != null) |
2556 | if (text1 != null) |
… | |
… | |
2370 | { |
2568 | { |
2371 | Navit.OSD_scale.scale_valid = true; |
2569 | Navit.OSD_scale.scale_valid = true; |
2372 | Navit.OSD_scale.scale_text = text2; |
2570 | Navit.OSD_scale.scale_text = text2; |
2373 | } |
2571 | } |
2374 | } |
2572 | } |
|
|
2573 | needed_value = true; |
2375 | } |
2574 | } |
2376 | else if (id.equals("osd_text_draw")) |
2575 | else if (id.equals("osd_text_draw")) |
2377 | { |
2576 | { |
2378 | if ((text1 != null) && (text1.equals("draw_text"))) |
2577 | if ((text1 != null) && (text1.equals("draw_text"))) |
2379 | { |
2578 | { |
… | |
… | |
2381 | { |
2580 | { |
2382 | // text3 = 20:38 --> ETA time (+1 means next day!) |
2581 | // text3 = 20:38 --> ETA time (+1 means next day!) |
2383 | // System.out.println("destination_time:" + text3); |
2582 | // System.out.println("destination_time:" + text3); |
2384 | Navit.OSD_route_001.arriving_time = text3; |
2583 | Navit.OSD_route_001.arriving_time = text3; |
2385 | Navit.OSD_route_001.arriving_time_valid = true; |
2584 | Navit.OSD_route_001.arriving_time_valid = true; |
|
|
2585 | needed_value = true; |
2386 | } |
2586 | } |
2387 | else if ((text2 != null) && (text2.equals("navigation:nav_position:destination_length"))) |
2587 | else if ((text2 != null) && (text2.equals("navigation:nav_position:destination_length"))) |
2388 | { |
2588 | { |
2389 | // text3 = 575m -> driving distance to target |
2589 | // text3 = 575m -> driving distance to target |
2390 | // System.out.println("destination_length:" + text3); |
2590 | // System.out.println("destination_length:" + text3); |
2391 | Navit.OSD_route_001.driving_distance_to_target = text3; |
2591 | Navit.OSD_route_001.driving_distance_to_target = text3; |
2392 | Navit.OSD_route_001.driving_distance_to_target_valid = true; |
2592 | Navit.OSD_route_001.driving_distance_to_target_valid = true; |
|
|
2593 | needed_value = true; |
2393 | } |
2594 | } |
2394 | else if ((text2 != null) && (text2.length() > 10) && (text2.substring(0, 11).equals("navigation:"))) |
2595 | else if ((text2 != null) && (text2.length() > 10) && (text2.substring(0, 11).equals("navigation:"))) |
2395 | { |
2596 | { |
2396 | String[] tmp_string = text2.split(":", 3); |
2597 | String[] tmp_string = text2.split(":", 3); |
2397 | if (tmp_string.length == 3) |
2598 | if (tmp_string.length == 3) |
2398 | { |
2599 | { |
2399 | if (tmp_string[2].equals("length")) |
2600 | if (tmp_string[2].equals("length")) |
2400 | { |
2601 | { |
2401 | // "navigation:******:length" |
2602 | // "navigation:******:length" |
2402 | // text3 = 250m --> when to do the next turn |
2603 | // text3 = 250m --> when to do the next turn |
|
|
2604 | //System.out.println("nextturn_distance:" + text3); |
2403 | Navit.OSD_nextturn.nextturn_distance = text3; |
2605 | Navit.OSD_nextturn.nextturn_distance = text3; |
2404 | Navit.OSD_nextturn.nextturn_distance_valid = true; |
2606 | Navit.OSD_nextturn.nextturn_distance_valid = true; |
|
|
2607 | // we need to paint the OSD in any case |
|
|
2608 | last_paint_OSD = -1; |
|
|
2609 | needed_value = true; |
|
|
2610 | } |
|
|
2611 | else if (tmp_string[2].equals("street_name_systematic")) |
|
|
2612 | { |
|
|
2613 | // "navigation:******:street_name_systematic" |
|
|
2614 | //System.out.println("nextturn_streetname_systematic:" + text3); |
|
|
2615 | Navit.OSD_nextturn.nextturn_streetname_systematic = text3; |
|
|
2616 | needed_value = true; |
|
|
2617 | } |
|
|
2618 | else if (tmp_string[2].equals("street_name")) |
|
|
2619 | { |
|
|
2620 | // "navigation:******:street_name" |
|
|
2621 | //System.out.println("nextturn_streetname:" + text3); |
|
|
2622 | Navit.OSD_nextturn.nextturn_streetname = text3; |
|
|
2623 | needed_value = true; |
|
|
2624 | } |
|
|
2625 | } |
|
|
2626 | } |
|
|
2627 | else if ((text2 != null) && (text2.length() > 8) && (text2.substring(0, 9).equals("tracking:"))) |
|
|
2628 | { |
|
|
2629 | if (NavitGraphics.navit_route_status == 0) |
|
|
2630 | { |
|
|
2631 | if (text2.equals("tracking:street_name:")) |
|
|
2632 | { |
|
|
2633 | //System.out.println("t2" + text2 + text3); |
|
|
2634 | Navit.OSD_nextturn.nextturn_streetname = text3; |
|
|
2635 | last_paint_OSD = -1; |
|
|
2636 | needed_value = true; |
|
|
2637 | } |
|
|
2638 | else if (text2.equals("tracking:street_name_systematic:")) |
|
|
2639 | { |
|
|
2640 | //System.out.println("t1" + text2 + text3); |
|
|
2641 | Navit.OSD_nextturn.nextturn_streetname_systematic = text3; |
|
|
2642 | needed_value = true; |
2405 | } |
2643 | } |
2406 | } |
2644 | } |
2407 | } |
2645 | } |
2408 | else |
2646 | else |
2409 | { |
2647 | { |
… | |
… | |
2444 | // System.out.println("ResId: " + ResId); |
2682 | // System.out.println("ResId: " + ResId); |
2445 | Navit.OSD_nextturn.nextturn_image = BitmapFactory.decodeResource(Navit.res_, ResId); |
2683 | Navit.OSD_nextturn.nextturn_image = BitmapFactory.decodeResource(Navit.res_, ResId); |
2446 | Navit.OSD_nextturn.nextturn_image_valid = true; |
2684 | Navit.OSD_nextturn.nextturn_image_valid = true; |
2447 | } |
2685 | } |
2448 | } |
2686 | } |
|
|
2687 | needed_value = true; |
2449 | } |
2688 | } |
2450 | else if (id.equals("compass")) |
2689 | else if (id.equals("compass")) |
2451 | { |
2690 | { |
2452 | if ((text1 != null) && (text1.equals("text_and_dst_angle"))) |
2691 | if ((text1 != null) && (text1.equals("text_and_dst_angle"))) |
2453 | { |
2692 | { |
… | |
… | |
2469 | } |
2708 | } |
2470 | catch (Exception e) |
2709 | catch (Exception e) |
2471 | { |
2710 | { |
2472 | //e.printStackTrace(); |
2711 | //e.printStackTrace(); |
2473 | } |
2712 | } |
|
|
2713 | needed_value = true; |
2474 | } |
2714 | } |
2475 | else if ((text1 != null) && (text1.equals("direction"))) |
2715 | else if ((text1 != null) && (text1.equals("direction"))) |
2476 | { |
2716 | { |
2477 | try |
2717 | try |
2478 | { |
2718 | { |
2479 | // Navit.OSD_compass.angle_north = Float.parseFloat(text2); |
2719 | // Navit.OSD_compass.angle_north = Float.parseFloat(text2); |
2480 | Navit.OSD_compass.angle_north = i1; |
2720 | Navit.OSD_compass.angle_north = i1; |
2481 | Navit.OSD_compass.angle_north_valid = true; |
2721 | Navit.OSD_compass.angle_north_valid = true; |
|
|
2722 | needed_value = true; |
2482 | } |
2723 | } |
2483 | catch (Exception e) |
2724 | catch (Exception e) |
2484 | { |
2725 | { |
2485 | //e.printStackTrace(); |
2726 | //e.printStackTrace(); |
2486 | |
2727 | |
… | |
… | |
2491 | catch (Exception x) |
2732 | catch (Exception x) |
2492 | { |
2733 | { |
2493 | x.printStackTrace(); |
2734 | x.printStackTrace(); |
2494 | } |
2735 | } |
2495 | |
2736 | |
|
|
2737 | if (!needed_value) |
|
|
2738 | { |
|
|
2739 | // we got values that we dont use |
|
|
2740 | //System.out.println("xx paint 0 xx"); |
|
|
2741 | return; |
|
|
2742 | } |
|
|
2743 | |
|
|
2744 | if (NavitGraphics.MAP_DISPLAY_OFF) |
|
|
2745 | { |
2496 | // paint only every 300ms |
2746 | // paint only every 800ms |
2497 | if ((last_paint_OSD + 300) < System.currentTimeMillis()) |
2747 | if ((last_paint_OSD + 800) < System.currentTimeMillis()) |
2498 | { |
2748 | { |
2499 | try |
2749 | try |
2500 | { |
2750 | { |
2501 | //***** NavitAOSDJava.postInvalidate(); |
|
|
2502 | last_paint_OSD = System.currentTimeMillis(); |
2751 | last_paint_OSD = System.currentTimeMillis(); |
|
|
2752 | //System.out.println("xx paint 1 xx"); |
2503 | NavitOSDJava.draw_real(); |
2753 | NavitOSDJava.draw_real(); |
|
|
2754 | //NavitAOSDJava.postInvalidate(); |
2504 | } |
2755 | } |
2505 | catch (Exception r) |
2756 | catch (Exception r) |
2506 | { |
2757 | { |
2507 | //r.printStackTrace(); |
2758 | //r.printStackTrace(); |
|
|
2759 | } |
|
|
2760 | } |
|
|
2761 | } |
|
|
2762 | else |
|
|
2763 | { |
|
|
2764 | // paint only every 600ms |
|
|
2765 | if ((last_paint_OSD + 1200) < System.currentTimeMillis()) |
|
|
2766 | { |
|
|
2767 | try |
|
|
2768 | { |
|
|
2769 | last_paint_OSD = System.currentTimeMillis(); |
|
|
2770 | //System.out.println("xx paint 2 xx"); |
|
|
2771 | NavitOSDJava.draw_real(); |
|
|
2772 | //NavitAOSDJava.postInvalidate(); |
|
|
2773 | } |
|
|
2774 | catch (Exception r) |
|
|
2775 | { |
|
|
2776 | //r.printStackTrace(); |
|
|
2777 | } |
2508 | } |
2778 | } |
2509 | } |
2779 | } |
2510 | } |
2780 | } |
2511 | |
2781 | |
2512 | protected void draw_mode(int mode) |
2782 | protected void draw_mode(int mode) |
… | |
… | |
3591 | { |
3861 | { |
3592 | // set cache size for (map-)files |
3862 | // set cache size for (map-)files |
3593 | String s = msg.getData().getString("s"); |
3863 | String s = msg.getData().getString("s"); |
3594 | CallbackMessageChannel(55, s); |
3864 | CallbackMessageChannel(55, s); |
3595 | } |
3865 | } |
|
|
3866 | else if (msg.getData().getInt("Callback") == 9901) |
|
|
3867 | { |
|
|
3868 | // if follow mode is on, then dont show freeview streetname |
|
|
3869 | if (!Navit.PREF_follow_gps) |
|
|
3870 | { |
|
|
3871 | Navit.OSD_nextturn.nextturn_streetname_systematic = ""; |
|
|
3872 | Navit.OSD_nextturn.nextturn_streetname = NavitGraphics.CallbackGeoCalc(5, mCanvasWidth / 2, mCanvasHeight / 2); |
|
|
3873 | // System.out.println("location:" + Navit.OSD_nextturn.nextturn_streetname); |
|
|
3874 | NavitAOSDJava_.postInvalidate(); |
|
|
3875 | } |
|
|
3876 | } |
3596 | } |
3877 | } |
3597 | }; |
3878 | }; |
3598 | |
3879 | |
3599 | // |
3880 | // |
3600 | // |
3881 | // |
… | |
… | |
3624 | { |
3905 | { |
3625 | // id=1 -> route_status |
3906 | // id=1 -> route_status |
3626 | NavitGraphics.navit_route_status = i; |
3907 | NavitGraphics.navit_route_status = i; |
3627 | if (i == 0) |
3908 | if (i == 0) |
3628 | { |
3909 | { |
|
|
3910 | ZANaviBusySpinner.active = false; |
|
|
3911 | ZANaviBusySpinner.cancelAnim(); |
|
|
3912 | busyspinner_.setVisibility(View.INVISIBLE); |
|
|
3913 | busyspinnertext_.setText(""); |
|
|
3914 | busyspinnertext_.setVisibility(View.INVISIBLE); |
3629 | Navit.set_debug_messages1(""); |
3915 | Navit.set_debug_messages1(""); |
3630 | } |
3916 | } |
3631 | else if (i == 1) |
3917 | else if (i == 1) |
3632 | { |
3918 | { |
|
|
3919 | ZANaviBusySpinner.active = true; |
|
|
3920 | busyspinner_.setVisibility(View.VISIBLE); |
|
|
3921 | busyspinner_.postInvalidate(); |
|
|
3922 | busyspinnertext_.setText(Navit.get_text("Destination set")); // TRANS |
|
|
3923 | busyspinnertext_.setVisibility(View.VISIBLE); |
3633 | Navit.set_debug_messages1("Destination set"); |
3924 | Navit.set_debug_messages1("Destination set"); |
3634 | } |
3925 | } |
3635 | else if (i == 3) |
3926 | else if (i == 3) |
3636 | { |
3927 | { |
|
|
3928 | ZANaviBusySpinner.active = true; |
|
|
3929 | ZANaviBusySpinner.cancelAnim(); |
|
|
3930 | busyspinner_.setVisibility(View.VISIBLE); |
|
|
3931 | busyspinnertext_.setText(Navit.get_text("No route found / Route blocked")); // TRANS |
|
|
3932 | busyspinnertext_.setVisibility(View.VISIBLE); |
3637 | Navit.set_debug_messages1("No route found / Route blocked"); |
3933 | Navit.set_debug_messages1("No route found / Route blocked"); |
3638 | } |
3934 | } |
3639 | else if (i == 5) |
3935 | else if (i == 5) |
3640 | { |
3936 | { |
|
|
3937 | ZANaviBusySpinner.active = true; |
|
|
3938 | busyspinner_.setVisibility(View.VISIBLE); |
|
|
3939 | busyspinner_.postInvalidate(); |
|
|
3940 | busyspinnertext_.setText(Navit.get_text("Building route path")); // TRANS |
|
|
3941 | busyspinnertext_.setVisibility(View.VISIBLE); |
3641 | Navit.set_debug_messages1("Building route path"); |
3942 | Navit.set_debug_messages1("Building route path"); |
3642 | } |
3943 | } |
3643 | else if (i == 13) |
3944 | else if (i == 13) |
3644 | { |
3945 | { |
|
|
3946 | ZANaviBusySpinner.active = true; |
|
|
3947 | busyspinner_.setVisibility(View.VISIBLE); |
|
|
3948 | busyspinner_.postInvalidate(); |
|
|
3949 | busyspinnertext_.setText(Navit.get_text("Building route graph")); // TRANS |
|
|
3950 | busyspinnertext_.setVisibility(View.VISIBLE); |
3645 | Navit.set_debug_messages1("Building route graph"); |
3951 | Navit.set_debug_messages1("Building route graph"); |
3646 | } |
3952 | } |
3647 | else if (i == 17) |
3953 | else if (i == 17) |
3648 | { |
3954 | { |
|
|
3955 | ZANaviBusySpinner.active = false; |
|
|
3956 | ZANaviBusySpinner.cancelAnim(); |
|
|
3957 | busyspinner_.setVisibility(View.INVISIBLE); |
|
|
3958 | busyspinnertext_.setText(""); |
|
|
3959 | busyspinnertext_.setVisibility(View.INVISIBLE); |
3649 | Navit.set_debug_messages1("Route found"); |
3960 | Navit.set_debug_messages1("Route found"); |
3650 | } |
3961 | } |
3651 | else if (i == 33) |
3962 | else if (i == 33) |
3652 | { |
3963 | { |
|
|
3964 | ZANaviBusySpinner.active = false; |
|
|
3965 | ZANaviBusySpinner.cancelAnim(); |
|
|
3966 | busyspinner_.setVisibility(View.INVISIBLE); |
|
|
3967 | busyspinnertext_.setText(""); |
|
|
3968 | busyspinnertext_.setVisibility(View.INVISIBLE); |
3653 | Navit.set_debug_messages1("Route found"); |
3969 | Navit.set_debug_messages1("Route found"); |
3654 | } |
3970 | } |
3655 | } |
3971 | } |
3656 | else if (id == 2) |
3972 | else if (id == 2) |
3657 | { |
3973 | { |
… | |
… | |
3691 | NavitGraphics.navit_route_status = 0; |
4007 | NavitGraphics.navit_route_status = 0; |
3692 | } |
4008 | } |
3693 | else if (id == 5) |
4009 | else if (id == 5) |
3694 | { |
4010 | { |
3695 | Navit.set_debug_messages1("Waypoint reached"); |
4011 | Navit.set_debug_messages1("Waypoint reached"); |
|
|
4012 | } |
|
|
4013 | else if (id == 6) |
|
|
4014 | { |
|
|
4015 | // id=6 -> mean time for drawing map to screen (in 1/1000 of a second) |
|
|
4016 | Navit.set_debug_messages4("draw:" + (float) ((float) i / 1000f) + "s"); |
3696 | } |
4017 | } |
3697 | } |
4018 | } |
3698 | |
4019 | |
3699 | public static Bitmap rotate_and_scale_bitmap(Bitmap in, int w, int h, int angle) |
4020 | public static Bitmap rotate_and_scale_bitmap(Bitmap in, int w, int h, int angle) |
3700 | { |
4021 | { |