… | |
… | |
36 | * Boston, MA 02110-1301, USA. |
36 | * Boston, MA 02110-1301, USA. |
37 | */ |
37 | */ |
38 | |
38 | |
39 | package com.zoffcc.applications.zanavi; |
39 | package com.zoffcc.applications.zanavi; |
40 | |
40 | |
41 | import java.lang.reflect.Method; |
|
|
42 | import java.util.ArrayList; |
|
|
43 | import java.util.concurrent.LinkedBlockingQueue; |
41 | import java.util.concurrent.LinkedBlockingQueue; |
44 | |
42 | |
45 | import android.app.Activity; |
43 | import android.app.Activity; |
46 | import android.graphics.Bitmap; |
44 | import android.graphics.Bitmap; |
47 | import android.graphics.BitmapFactory; |
45 | import android.graphics.BitmapFactory; |
|
|
46 | import android.graphics.Camera; |
48 | import android.graphics.Canvas; |
47 | import android.graphics.Canvas; |
49 | import android.graphics.Color; |
48 | import android.graphics.Color; |
50 | import android.graphics.DashPathEffect; |
49 | import android.graphics.DashPathEffect; |
51 | import android.graphics.Matrix; |
50 | import android.graphics.Matrix; |
52 | import android.graphics.Paint; |
51 | import android.graphics.Paint; |
… | |
… | |
70 | import com.zoffcc.applications.zanavi.Navit.Navit_Address_Result_Struct; |
69 | import com.zoffcc.applications.zanavi.Navit.Navit_Address_Result_Struct; |
71 | import com.zoffcc.applications.zanavi.NavitAndroidOverlay.NavitAndroidOverlayBubble; |
70 | import com.zoffcc.applications.zanavi.NavitAndroidOverlay.NavitAndroidOverlayBubble; |
72 | |
71 | |
73 | public class NavitGraphics |
72 | public class NavitGraphics |
74 | { |
73 | { |
75 | private NavitGraphics parent_graphics; |
74 | private int parent_num; |
76 | private ArrayList overlays = new ArrayList(); |
75 | //private ArrayList overlays = new ArrayList(); |
77 | |
76 | |
78 | static Canvas draw_canvas_s; |
77 | static Canvas draw_canvas_s; |
79 | static Bitmap draw_bitmap_s; |
78 | static Bitmap draw_bitmap_s; |
80 | static Canvas draw_canvas_screen_s; |
79 | static Canvas draw_canvas_screen_s; |
81 | static Bitmap draw_bitmap_screen_s; |
80 | static Bitmap draw_bitmap_screen_s; |
|
|
81 | static Canvas draw_canvas_screen_s2; |
|
|
82 | static Bitmap draw_bitmap_screen_s2; |
82 | static View view_s; |
83 | static View view_s; |
83 | static int dl_thread_cur = 0; |
84 | static int dl_thread_cur = 0; |
84 | static int dl_thread_max = 1; |
85 | static int dl_thread_max = 1; |
85 | static DrawLinesThread[] dl_thread = new DrawLinesThread[dl_thread_max]; |
86 | static DrawLinesThread[] dl_thread = new DrawLinesThread[dl_thread_max]; |
86 | static Boolean draw_map_one_shot = false; |
87 | static Boolean draw_map_one_shot = false; |
87 | static Boolean draw_reset_factors = false; |
88 | static Boolean draw_reset_factors = false; |
88 | |
89 | |
|
|
90 | static Camera camera = new Camera(); |
|
|
91 | static Matrix cam_m = new Matrix(); |
|
|
92 | |
89 | private Canvas draw_canvas; |
93 | private Canvas draw_canvas; |
90 | private Bitmap draw_bitmap; |
94 | private Bitmap draw_bitmap; |
91 | private Canvas draw_canvas_screen; |
95 | private Canvas draw_canvas_screen; |
92 | private Bitmap draw_bitmap_screen; |
96 | private Bitmap draw_bitmap_screen; |
|
|
97 | private Canvas draw_canvas_screen2; |
|
|
98 | private Bitmap draw_bitmap_screen2; |
|
|
99 | |
|
|
100 | public final int map_bg_color = Color.parseColor("#FEF9EE"); |
93 | |
101 | |
94 | public final static DashPathEffect dashed_map_lines__high = new DashPathEffect(new float[] { 4, 2 }, 1); |
102 | public final static DashPathEffect dashed_map_lines__high = new DashPathEffect(new float[] { 4, 2 }, 1); |
95 | public final static DashPathEffect dashed_map_lines__low = new DashPathEffect(new float[] { 15, 11 }, 1); |
103 | public final static DashPathEffect dashed_map_lines__low = new DashPathEffect(new float[] { 15, 11 }, 1); |
96 | public final static DashPathEffect dashed_map_lines__no_dash = null; |
104 | public final static DashPathEffect dashed_map_lines__no_dash = null; |
97 | |
105 | |
… | |
… | |
108 | public final static DashPathEffect h006 = new DashPathEffect(new float[] { 6, 3 }, 1); |
116 | public final static DashPathEffect h006 = new DashPathEffect(new float[] { 6, 3 }, 1); |
109 | public final static DashPathEffect l006 = new DashPathEffect(new float[] { 6, 3 }, 1); |
117 | public final static DashPathEffect l006 = new DashPathEffect(new float[] { 6, 3 }, 1); |
110 | public final static DashPathEffect h007 = new DashPathEffect(new float[] { 6, 3 }, 1); |
118 | public final static DashPathEffect h007 = new DashPathEffect(new float[] { 6, 3 }, 1); |
111 | public final static DashPathEffect l007 = new DashPathEffect(new float[] { 7, 2 }, 1); |
119 | public final static DashPathEffect l007 = new DashPathEffect(new float[] { 7, 2 }, 1); |
112 | |
120 | |
|
|
121 | public static Paint paint_for_map_display = new Paint(); |
|
|
122 | public static Paint paint_sky_day = new Paint(); |
|
|
123 | public static Paint paint_sky_night = new Paint(); |
|
|
124 | public static Paint paint_sky_night_stars = new Paint(); |
|
|
125 | public static Paint paint_sky_twilight1 = new Paint(); |
|
|
126 | public static Paint paint_sky_twilight2 = new Paint(); |
|
|
127 | public static Paint paint_sky_twilight3 = new Paint(); |
|
|
128 | |
|
|
129 | public static final int max_stars = 7; |
|
|
130 | public static float[] stars_x = new float[max_stars + 1]; |
|
|
131 | public static float[] stars_y = new float[max_stars + 1]; |
|
|
132 | public static int[] stars_size = new int[max_stars + 1]; |
|
|
133 | |
113 | public final static DashPathEffect[] dashes__low = { null, l001, l002, l003, l004, l005, l006, l007 }; |
134 | public final static DashPathEffect[] dashes__low = { null, l001, l002, l003, l004, l005, l006, l007 }; |
114 | public final static DashPathEffect[] dashes__high = { null, h001, h002, h003, h004, h005, h006, h007 }; |
135 | public final static DashPathEffect[] dashes__high = { null, h001, h002, h003, h004, h005, h006, h007 }; |
115 | |
136 | |
116 | public static int navit_route_status = 0; |
137 | public static int navit_route_status = 0; |
117 | |
138 | |
… | |
… | |
126 | public static int mCanvasWidth = 1; |
147 | public static int mCanvasWidth = 1; |
127 | public static int mCanvasHeight = 1; |
148 | public static int mCanvasHeight = 1; |
128 | |
149 | |
129 | public static final Boolean DEBUG_TOUCH = false; |
150 | public static final Boolean DEBUG_TOUCH = false; |
130 | public static Boolean ZOOM_MODE_ACTIVE = false; |
151 | public static Boolean ZOOM_MODE_ACTIVE = false; |
131 | public static float ZOOM_MODE_SCALE = 0; |
152 | public static float ZOOM_MODE_SCALE = 1.0f; |
|
|
153 | public static Boolean DRAG_MODE_ACTIVE = false; |
|
|
154 | |
|
|
155 | public static float Global_Map_Zoomfactor = 1.0f; |
|
|
156 | public static float Global_Map_Rotationangle = 0; |
|
|
157 | public static int Global_Map_TransX = 0; |
|
|
158 | public static int Global_Map_TransY = 0; |
|
|
159 | public static Boolean Global_SmoothDrawing_stop = false; |
|
|
160 | public static Boolean Global_onTouch_fingerdown = false; |
132 | |
161 | |
133 | public static float draw_factor = 1.0f; |
162 | public static float draw_factor = 1.0f; |
134 | |
163 | |
135 | public static String debug_line_1 = ""; |
164 | public static String debug_line_1 = ""; |
136 | public static String debug_line_2 = ""; |
165 | public static String debug_line_2 = ""; |
… | |
… | |
164 | |
193 | |
165 | int bitmap_w; |
194 | int bitmap_w; |
166 | int bitmap_h; |
195 | int bitmap_h; |
167 | int pos_x; |
196 | int pos_x; |
168 | int pos_y; |
197 | int pos_y; |
|
|
198 | // |
|
|
199 | int vehicle_speed = 0; |
|
|
200 | int vehicle_pos_x = 0; |
|
|
201 | int vehicle_pos_y = 0; |
|
|
202 | int vehicle_direction = 0; |
|
|
203 | int vehicle_pos_x_delta = 0; |
|
|
204 | int vehicle_pos_y_delta = 0; |
|
|
205 | int vehicle_direction_delta = 0; |
169 | // drag pos |
206 | // drag pos |
170 | public static int d_pos_x_old = -1; |
207 | public static int d_pos_x_old = -1; |
171 | public static int d_pos_y_old = -1; |
208 | public static int d_pos_y_old = -1; |
172 | // drag post |
209 | // drag post |
173 | int pos_wraparound; |
210 | int pos_wraparound; |
174 | int overlay_disabled; |
211 | // int overlay_disabled; |
175 | float trackball_x, trackball_y; |
212 | float trackball_x, trackball_y; |
176 | View view; |
213 | View view; |
177 | RelativeLayout relativelayout; |
214 | RelativeLayout relativelayout; |
178 | // --obsolote --- // NavitCamera camera; |
215 | // --obsolote --- // NavitCamera camera; |
179 | Activity activity; |
216 | Activity activity; |
… | |
… | |
236 | private class SensorThread extends Thread |
273 | private class SensorThread extends Thread |
237 | { |
274 | { |
238 | private Boolean running; |
275 | private Boolean running; |
239 | private long last_down_action = 0L; |
276 | private long last_down_action = 0L; |
240 | private Boolean is_still_pressing; |
277 | private Boolean is_still_pressing; |
241 | private View v = null; |
278 | //private View v = null; |
242 | private NavitAndroidOverlay n_overlay = null; |
279 | //private NavitAndroidOverlay n_overlay = null; |
243 | private float prev_x; |
280 | private float prev_x; |
244 | private float prev_y; |
281 | private float prev_y; |
245 | private float x; |
282 | private float x; |
246 | private float y; |
283 | private float y; |
247 | |
284 | |
248 | SensorThread(long last_touch, View v, NavitAndroidOverlay n_ov, float x, float y) |
285 | SensorThread(long last_touch, float x, float y) |
249 | { |
286 | { |
250 | this.prev_x = x; |
287 | this.prev_x = x; |
251 | this.prev_y = y; |
288 | this.prev_y = y; |
252 | this.x = x; |
289 | this.x = x; |
253 | this.y = y; |
290 | this.y = y; |
254 | this.running = true; |
291 | this.running = true; |
255 | this.n_overlay = n_ov; |
292 | //this.n_overlay = n_ov; |
256 | this.v = v; |
293 | //this.v = v; |
257 | this.is_still_pressing = true; |
294 | this.is_still_pressing = true; |
258 | last_down_action = System.currentTimeMillis(); |
295 | last_down_action = System.currentTimeMillis(); |
259 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "SensorThread created"); |
296 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "SensorThread created"); |
260 | } |
297 | } |
261 | |
298 | |
… | |
… | |
284 | // ok, we have counted a long press on screen |
321 | // ok, we have counted a long press on screen |
285 | // do stuff and then stop this thread |
322 | // do stuff and then stop this thread |
286 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "SensorThread: LONG PRESS"); |
323 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "SensorThread: LONG PRESS"); |
287 | try |
324 | try |
288 | { |
325 | { |
|
|
326 | if (this.running) |
|
|
327 | { |
|
|
328 | if (!NavitAndroidOverlay.confirmed_bubble) |
|
|
329 | { |
|
|
330 | //Log.e("NavitGraphics", "do_longpress_action enter"); |
|
|
331 | NavitAndroidOverlayBubble b = new NavitAndroidOverlayBubble(); |
|
|
332 | b.x = (int) this.x; |
|
|
333 | b.y = (int) this.y; |
|
|
334 | NavitAOverlay.set_bubble(b); |
|
|
335 | NavitAOverlay.show_bubble(); |
|
|
336 | copy_map_buffer(); |
|
|
337 | //System.out.println("invalidate 009"); |
|
|
338 | Navit.NG__map_main.view.postInvalidate(); |
|
|
339 | //System.out.println("invalidate 010"); |
|
|
340 | NavitAOverlay.postInvalidate(); |
|
|
341 | } |
|
|
342 | } |
|
|
343 | // this is called!!! yes really!! via REFLECT (make it better, later) |
289 | // find the class, to get the method "do_longpress_action" |
344 | // find the class, to get the method "do_longpress_action" |
290 | // and then call the method |
345 | // and then call the method |
|
|
346 | |
291 | Class cls = this.v.getClass(); |
347 | // Class cls = this.v.getClass(); |
292 | //Log.e("NavitGraphics", "c=" + String.valueOf(cls)); |
348 | // //Log.e("NavitGraphics", "c=" + String.valueOf(cls)); |
293 | Class partypes[] = new Class[2]; |
349 | // Class partypes[] = new Class[2]; |
294 | partypes[0] = Float.TYPE; |
350 | // partypes[0] = Float.TYPE; |
295 | partypes[1] = Float.TYPE; |
351 | // partypes[1] = Float.TYPE; |
296 | Method meth = cls.getMethod("do_longpress_action", partypes); |
352 | // Method meth = cls.getMethod("do_longpress_action", partypes); |
297 | View methobj = this.v; |
353 | // View methobj = this.v; |
298 | Object arglist[] = new Object[2]; |
354 | // Object arglist[] = new Object[2]; |
299 | arglist[0] = new Float(this.x); |
355 | // arglist[0] = new Float(this.x); |
300 | arglist[1] = new Float(this.y); |
356 | // arglist[1] = new Float(this.y); |
|
|
357 | |
301 | if (running) |
358 | //if (running) |
302 | { |
359 | //{ |
303 | Object retobj = meth.invoke(methobj, arglist); |
360 | //Object retobj = meth.invoke(methobj, arglist); |
|
|
361 | //} |
304 | } |
362 | } |
305 | } |
|
|
306 | catch (Throwable e) |
363 | // catch (Throwable e) |
|
|
364 | catch (Exception e) |
307 | { |
365 | { |
308 | System.err.println(e); |
366 | System.err.println(e); |
309 | } |
367 | } |
310 | this.running = false; |
368 | this.running = false; |
311 | } |
369 | } |
… | |
… | |
329 | } |
387 | } |
330 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "SensorThread ended"); |
388 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "SensorThread ended"); |
331 | } |
389 | } |
332 | } |
390 | } |
333 | |
391 | |
334 | public static OverlayDrawThread overlay_draw_thread = null; |
392 | // public static OverlayDrawThread overlay_draw_thread = null; |
335 | |
393 | |
336 | public static class OverlayDrawThread extends Thread |
394 | public static class OverlayDrawThread extends Thread |
337 | { |
395 | { |
338 | private Boolean running = true; |
396 | private Boolean running = true; |
339 | private Boolean redraw = false; |
397 | private Boolean redraw = false; |
… | |
… | |
361 | // after xxx milliseconds of delay, stop drawing the map! |
419 | // after xxx milliseconds of delay, stop drawing the map! |
362 | // most likely the device is too slow, or there are too much items to draw |
420 | // most likely the device is too slow, or there are too much items to draw |
363 | try |
421 | try |
364 | { |
422 | { |
365 | //Log.e("NavitGraphics", "## stop map drawing x1: NOW ##" + System.currentTimeMillis()); |
423 | //Log.e("NavitGraphics", "## stop map drawing x1: NOW ##" + System.currentTimeMillis()); |
366 | NavitGraphics.CallbackMessageChannel(50, ""); |
424 | //***NavitGraphics.CallbackMessageChannel(50, ""); |
367 | //Message msg = new Message(); |
425 | //Message msg = new Message(); |
368 | //Bundle b = new Bundle(); |
426 | //Bundle b = new Bundle(); |
369 | //b.putInt("Callback", 50); |
427 | //b.putInt("Callback", 50); |
370 | //msg.setData(b); |
428 | //msg.setData(b); |
371 | //callback_handler.sendMessage(msg); |
429 | //callback_handler.sendMessage(msg); |
… | |
… | |
434 | { |
492 | { |
435 | this.redraw = false; |
493 | this.redraw = false; |
436 | } |
494 | } |
437 | } |
495 | } |
438 | |
496 | |
439 | public NavitGraphics(Activity activity, NavitGraphics parent, int x, int y, int w, int h, int alpha, int wraparound, int use_camera) |
497 | public NavitGraphics(Activity activity, int parent, int x, int y, int w, int h, int alpha, int wraparound, int use_camera) |
440 | { |
498 | { |
441 | |
|
|
442 | System.out.println("GC001--"); |
|
|
443 | |
|
|
444 | if (parent == null) |
499 | if (parent == 0) |
445 | { |
500 | { |
446 | System.out.println("GC002--"); |
|
|
447 | this.gr_type = 1; |
501 | this.gr_type = 1; |
448 | |
502 | |
449 | this.activity = activity; |
503 | this.activity = activity; |
450 | view = new View(activity) |
504 | view = new View(activity) |
451 | { |
505 | { |
… | |
… | |
461 | static final int PRESS = 3; |
515 | static final int PRESS = 3; |
462 | |
516 | |
463 | @Override |
517 | @Override |
464 | protected void onDraw(Canvas canvas) |
518 | protected void onDraw(Canvas canvas) |
465 | { |
519 | { |
466 | //System.out.println("*******DRAW INIT*******"); |
520 | //System.out.println("*******DRAW INIT******* " + gr_type); |
467 | super.onDraw(canvas); |
521 | super.onDraw(canvas); |
468 | |
522 | |
469 | if (!MAP_DISPLAY_OFF) |
523 | if (!MAP_DISPLAY_OFF) |
470 | { |
524 | { |
471 | if (draw_reset_factors) |
525 | if (draw_reset_factors) |
472 | { |
526 | { |
473 | //System.out.println("+ reset factors +"); |
527 | //System.out.println("DO__DRAW:Java:reset factors"); |
474 | draw_reset_factors = false; |
528 | draw_reset_factors = false; |
475 | pos_x = 0; |
529 | pos_x = 0; |
476 | pos_y = 0; |
530 | pos_y = 0; |
477 | ZOOM_MODE_ACTIVE = false; |
531 | ZOOM_MODE_ACTIVE = false; |
478 | ZOOM_MODE_SCALE = 0; |
532 | ZOOM_MODE_SCALE = 1.0f; |
479 | } |
533 | } |
480 | |
534 | |
481 | //if (draw_map_one_shot) |
535 | //System.out.println("DO__DRAW:Java:onDraw:draw bitmap to SCREEN"); |
|
|
536 | //System.out.println("DO__DRAW:Java:onDraw:gzf=" + Global_Map_Zoomfactor + " scale=" + ZOOM_MODE_SCALE); |
|
|
537 | //System.out.println("DO__DRAW:Java:onDraw:gx=" + Global_Map_TransX + " pos_x=" + pos_x); |
|
|
538 | //System.out.println("DO__DRAW:Java:onDraw:gy=" + Global_Map_TransY + " pos_y=" + pos_y); |
|
|
539 | |
|
|
540 | if (Navit.PREF_show_3d_map) |
|
|
541 | { |
|
|
542 | draw_canvas_screen2.save(); |
|
|
543 | if ((ZOOM_MODE_ACTIVE) || (Global_Map_Zoomfactor != 1.0f)) |
|
|
544 | { |
|
|
545 | draw_canvas_screen2.scale(ZOOM_MODE_SCALE * Global_Map_Zoomfactor, ZOOM_MODE_SCALE * Global_Map_Zoomfactor, Global_Map_TransX + this.touch_now_center.x, Global_Map_TransY + this.touch_now_center.y); |
|
|
546 | } |
|
|
547 | else if (Global_Map_Rotationangle != 0.0f) |
|
|
548 | { |
|
|
549 | draw_canvas_screen2.rotate(Global_Map_Rotationangle, Navit.NG__vehicle.vehicle_pos_x, Navit.NG__vehicle.vehicle_pos_y); |
|
|
550 | } |
|
|
551 | draw_canvas_screen2.translate(Global_Map_TransX + pos_x, Global_Map_TransY + pos_y); |
|
|
552 | draw_canvas_screen2.drawColor(map_bg_color); // fill with yellow-ish bg color |
|
|
553 | // draw the bitmap in the offscreen buffer (offset 30 pixels to center!!) |
|
|
554 | draw_canvas_screen2.drawBitmap(draw_bitmap_screen, 0, 0, paint_for_map_display); |
|
|
555 | canvas.save(); |
|
|
556 | canvas.drawColor(map_bg_color); // fill with yellow-ish bg color |
|
|
557 | |
|
|
558 | // 3D modus ----------------- |
|
|
559 | canvas.concat(cam_m); |
|
|
560 | // 3D modus ----------------- |
|
|
561 | |
|
|
562 | // draw bitmap to screen |
|
|
563 | canvas.drawBitmap(draw_bitmap_screen2, 0, 0, paint_for_map_display); |
|
|
564 | |
|
|
565 | // ------ DEBUG ------- |
|
|
566 | // ------ DEBUG ------- |
|
|
567 | // Paint paint79 = new Paint(); |
|
|
568 | // paint79.setColor(Color.MAGENTA); |
|
|
569 | // paint79.setStrokeWidth(16); |
|
|
570 | // paint79.setStyle(Style.STROKE); |
|
|
571 | // // float y_point = (bitmap_h - (bitmap_h * 0.7f)); |
|
|
572 | // float y_point = bitmap_h * 0.7f; |
|
|
573 | // canvas.drawLine(bitmap_w / 2, y_point - 20, bitmap_w / 2, y_point + 20, paint79); |
|
|
574 | // canvas.drawLine(bitmap_w / 2 - 100, y_point, bitmap_w / 2 + 100, y_point, paint79); |
482 | //{ |
575 | // |
483 | if (ZOOM_MODE_ACTIVE) |
576 | // Paint paint78 = new Paint(); |
|
|
577 | // paint78.setColor(Color.RED); |
|
|
578 | // paint78.setStrokeWidth(20); |
|
|
579 | // paint78.setStyle(Style.STROKE); |
|
|
580 | // canvas.drawRect(30, 30, this.getWidth() - 30, this.getHeight() - 30, paint78); |
|
|
581 | // ------ DEBUG ------- |
|
|
582 | // ------ DEBUG ------- |
|
|
583 | |
|
|
584 | canvas.restore(); |
|
|
585 | draw_canvas_screen2.restore(); |
|
|
586 | |
|
|
587 | float h_scaled = this.getHeight() * 0.27f; |
|
|
588 | if (Navit.is_night) |
|
|
589 | { |
|
|
590 | if (Navit.is_twilight) |
|
|
591 | { |
|
|
592 | // draw twilight |
|
|
593 | // elevation -> -0.83 to -10.00 |
|
|
594 | float a = h_scaled / 10f * (float) (-Navit.elevation); |
|
|
595 | float b = h_scaled / 10f * (float) ((-Navit.elevation / 2f) + 5); |
|
|
596 | canvas.drawRect(0, 0, this.getWidth(), a, paint_sky_twilight1); |
|
|
597 | canvas.drawRect(0, a, this.getWidth(), b, paint_sky_twilight2); |
|
|
598 | canvas.drawRect(0, b, this.getWidth(), h_scaled, paint_sky_twilight3); |
|
|
599 | } |
|
|
600 | else |
|
|
601 | { |
|
|
602 | // draw sky - at night |
|
|
603 | canvas.drawRect(0, 0, this.getWidth(), h_scaled, paint_sky_night); |
|
|
604 | // stars |
|
|
605 | canvas.drawCircle(NavitGraphics.stars_x[0] * this.getWidth(), NavitGraphics.stars_y[0] * h_scaled, NavitGraphics.stars_size[0], paint_sky_night_stars); |
|
|
606 | canvas.drawCircle(NavitGraphics.stars_x[1] * this.getWidth(), NavitGraphics.stars_y[1] * h_scaled, NavitGraphics.stars_size[1], paint_sky_night_stars); |
|
|
607 | canvas.drawCircle(NavitGraphics.stars_x[2] * this.getWidth(), NavitGraphics.stars_y[2] * h_scaled, NavitGraphics.stars_size[2], paint_sky_night_stars); |
|
|
608 | canvas.drawCircle(NavitGraphics.stars_x[3] * this.getWidth(), NavitGraphics.stars_y[3] * h_scaled, NavitGraphics.stars_size[3], paint_sky_night_stars); |
|
|
609 | canvas.drawCircle(NavitGraphics.stars_x[4] * this.getWidth(), NavitGraphics.stars_y[4] * h_scaled, NavitGraphics.stars_size[4], paint_sky_night_stars); |
|
|
610 | canvas.drawCircle(NavitGraphics.stars_x[5] * this.getWidth(), NavitGraphics.stars_y[5] * h_scaled, NavitGraphics.stars_size[5], paint_sky_night_stars); |
|
|
611 | canvas.drawCircle(NavitGraphics.stars_x[6] * this.getWidth(), NavitGraphics.stars_y[6] * h_scaled, NavitGraphics.stars_size[6], paint_sky_night_stars); |
|
|
612 | canvas.drawCircle(NavitGraphics.stars_x[7] * this.getWidth(), NavitGraphics.stars_y[7] * h_scaled, NavitGraphics.stars_size[7], paint_sky_night_stars); |
|
|
613 | } |
|
|
614 | } |
|
|
615 | else |
|
|
616 | { |
|
|
617 | // draw sky - at day |
|
|
618 | canvas.drawRect(0, 0, this.getWidth(), h_scaled, paint_sky_day); |
|
|
619 | } |
|
|
620 | } |
|
|
621 | else |
484 | { |
622 | { |
485 | canvas.save(); |
623 | canvas.save(); |
486 | canvas.scale(ZOOM_MODE_SCALE, ZOOM_MODE_SCALE, this.touch_now_center.x, this.touch_now_center.y); |
624 | if ((ZOOM_MODE_ACTIVE) || (Global_Map_Zoomfactor != 1.0f)) |
487 | } |
|
|
488 | canvas.drawBitmap(draw_bitmap_screen, pos_x, pos_y, null); |
|
|
489 | // System.out.println("*******DRAW DRAW*******"); |
|
|
490 | if (ZOOM_MODE_ACTIVE) |
|
|
491 | { |
625 | { |
|
|
626 | canvas.scale(ZOOM_MODE_SCALE * Global_Map_Zoomfactor, ZOOM_MODE_SCALE * Global_Map_Zoomfactor, Global_Map_TransX + this.touch_now_center.x, Global_Map_TransY + this.touch_now_center.y); |
|
|
627 | } |
|
|
628 | else if (Global_Map_Rotationangle != 0.0f) |
|
|
629 | { |
|
|
630 | canvas.rotate(Global_Map_Rotationangle, Navit.NG__vehicle.vehicle_pos_x, Navit.NG__vehicle.vehicle_pos_y); |
|
|
631 | } |
|
|
632 | canvas.translate(Global_Map_TransX + pos_x, Global_Map_TransY + pos_y); |
|
|
633 | canvas.drawColor(map_bg_color); // fill with yellow-ish bg color |
|
|
634 | // draw bitmap to screen |
|
|
635 | canvas.drawBitmap(draw_bitmap_screen, 0, 0, paint_for_map_display); |
492 | canvas.restore(); |
636 | canvas.restore(); |
493 | } |
637 | } |
494 | //draw_map_one_shot = false; |
|
|
495 | //} |
|
|
496 | } |
|
|
497 | |
|
|
498 | if (overlay_disabled == 0) |
|
|
499 | { |
|
|
500 | //Log.e("NavitGraphics", "view -> onDraw 1"); |
|
|
501 | // assume we ARE in map view mode! |
|
|
502 | in_map = true; |
|
|
503 | |
|
|
504 | if (!MAP_DISPLAY_OFF) |
|
|
505 | { |
|
|
506 | Object overlays_array[]; |
|
|
507 | overlays_array = overlays.toArray(); |
|
|
508 | //int ov_count = 0; |
|
|
509 | for (Object overlay : overlays_array) |
|
|
510 | { |
|
|
511 | //ov_count++; |
|
|
512 | //Log.e("NavitGraphics", "view -> onDraw 2:" + ov_count); |
|
|
513 | |
|
|
514 | NavitGraphics overlay_graphics = (NavitGraphics) overlay; |
|
|
515 | if (overlay_graphics.overlay_disabled == 0) |
|
|
516 | { |
|
|
517 | //Log.e("NavitGraphics", "view -> onDraw 3:" + ov_count); |
|
|
518 | |
|
|
519 | int x = overlay_graphics.pos_x; |
|
|
520 | int y = overlay_graphics.pos_y; |
|
|
521 | if (overlay_graphics.pos_wraparound != 0 && x < 0) x += bitmap_w; |
|
|
522 | if (overlay_graphics.pos_wraparound != 0 && y < 0) y += bitmap_h; |
|
|
523 | canvas.drawBitmap(overlay_graphics.draw_bitmap, x, y, null); |
|
|
524 | } |
|
|
525 | } |
|
|
526 | } |
|
|
527 | } |
638 | } |
528 | } |
639 | } |
529 | |
640 | |
530 | @Override |
641 | @Override |
531 | protected void onSizeChanged(int w, int h, int oldw, int oldh) |
642 | protected void onSizeChanged(int w, int h, int oldw, int oldh) |
532 | { |
643 | { |
533 | mCanvasWidth = w; |
644 | mCanvasWidth = w; |
534 | mCanvasHeight = h; |
645 | mCanvasHeight = h; |
535 | |
646 | |
536 | Log.e("Navit", "NavitGraphics -> onSizeChanged pixels x=" + w + " pixels y=" + h); |
647 | //Log.e("Navit", "NavitGraphics -> onSizeChanged pixels x=" + w + " pixels y=" + h); |
537 | Log.e("Navit", "NavitGraphics -> onSizeChanged dpi=" + Navit.metrics.densityDpi); |
648 | //Log.e("Navit", "NavitGraphics -> onSizeChanged dpi=" + Navit.metrics.densityDpi); |
538 | Log.e("Navit", "NavitGraphics -> onSizeChanged density=" + Navit.metrics.density); |
649 | //Log.e("Navit", "NavitGraphics -> onSizeChanged density=" + Navit.metrics.density); |
539 | Log.e("Navit", "NavitGraphics -> onSizeChanged scaledDensity=" + Navit.metrics.scaledDensity); |
650 | //Log.e("Navit", "NavitGraphics -> onSizeChanged scaledDensity=" + Navit.metrics.scaledDensity); |
540 | super.onSizeChanged(w, h, oldw, oldh); |
651 | super.onSizeChanged(w, h, oldw, oldh); |
541 | if (draw_bitmap != null) |
652 | if (draw_bitmap != null) |
542 | { |
653 | { |
543 | // try to avoid out of memory errors |
654 | // try to avoid out of memory errors |
544 | draw_bitmap.recycle(); |
655 | draw_bitmap.recycle(); |
|
|
656 | draw_bitmap = null; |
545 | } |
657 | } |
546 | |
658 | |
547 | if (draw_bitmap_screen != null) |
659 | if (draw_bitmap_screen != null) |
548 | { |
660 | { |
549 | // try to avoid out of memory errors |
661 | // try to avoid out of memory errors |
550 | draw_bitmap_screen.recycle(); |
662 | draw_bitmap_screen.recycle(); |
|
|
663 | draw_bitmap_screen = null; |
|
|
664 | } |
|
|
665 | |
|
|
666 | if (draw_bitmap_screen2 != null) |
|
|
667 | { |
|
|
668 | // try to avoid out of memory errors |
|
|
669 | draw_bitmap_screen2.recycle(); |
|
|
670 | draw_bitmap_screen2 = null; |
551 | } |
671 | } |
552 | |
672 | |
553 | try |
673 | try |
554 | { |
674 | { |
555 | draw_bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); |
675 | draw_bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); |
… | |
… | |
558 | { |
678 | { |
559 | int usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L); |
679 | int usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L); |
560 | String usedMegsString = String.format(" - Memory Used: %d MB", usedMegs); |
680 | String usedMegsString = String.format(" - Memory Used: %d MB", usedMegs); |
561 | System.out.println("" + usedMegsString); |
681 | System.out.println("" + usedMegsString); |
562 | System.out.println("@@@@@@@@ out of VM Memory @@@@@@@@"); |
682 | System.out.println("@@@@@@@@ out of VM Memory @@@@@@@@"); |
|
|
683 | draw_bitmap = null; |
|
|
684 | draw_canvas = null; |
|
|
685 | System.gc(); |
563 | System.gc(); |
686 | System.gc(); |
564 | usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L); |
687 | usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L); |
565 | usedMegsString = String.format(" - Memory Used: %d MB", usedMegs); |
688 | usedMegsString = String.format(" - Memory Used: %d MB", usedMegs); |
566 | System.out.println("" + usedMegsString); |
689 | System.out.println("" + usedMegsString); |
567 | // try again |
690 | // try again |
… | |
… | |
576 | { |
699 | { |
577 | int usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L); |
700 | int usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L); |
578 | String usedMegsString = String.format(" - Memory Used: %d MB", usedMegs); |
701 | String usedMegsString = String.format(" - Memory Used: %d MB", usedMegs); |
579 | System.out.println("" + usedMegsString); |
702 | System.out.println("" + usedMegsString); |
580 | System.out.println("@@@@@@@@ out of VM Memory @@@@@@@@"); |
703 | System.out.println("@@@@@@@@ out of VM Memory @@@@@@@@"); |
|
|
704 | draw_bitmap_screen = null; |
|
|
705 | draw_canvas_screen = null; |
|
|
706 | System.gc(); |
581 | System.gc(); |
707 | System.gc(); |
582 | usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L); |
708 | usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L); |
583 | usedMegsString = String.format(" - Memory Used: %d MB", usedMegs); |
709 | usedMegsString = String.format(" - Memory Used: %d MB", usedMegs); |
584 | System.out.println("" + usedMegsString); |
710 | System.out.println("" + usedMegsString); |
585 | // try again |
711 | // try again |
586 | draw_bitmap_screen = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); |
712 | draw_bitmap_screen = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); |
587 | } |
713 | } |
588 | |
714 | |
|
|
715 | try |
|
|
716 | { |
|
|
717 | draw_bitmap_screen2 = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); |
|
|
718 | } |
|
|
719 | catch (OutOfMemoryError e) |
|
|
720 | { |
|
|
721 | int usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L); |
|
|
722 | String usedMegsString = String.format(" - Memory Used: %d MB", usedMegs); |
|
|
723 | System.out.println("" + usedMegsString); |
|
|
724 | System.out.println("@@@@@@@@ out of VM Memory @@@@@@@@"); |
|
|
725 | draw_bitmap_screen2 = null; |
|
|
726 | draw_canvas_screen2 = null; |
|
|
727 | System.gc(); |
|
|
728 | System.gc(); |
|
|
729 | usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L); |
|
|
730 | usedMegsString = String.format(" - Memory Used: %d MB", usedMegs); |
|
|
731 | System.out.println("" + usedMegsString); |
|
|
732 | // try again |
|
|
733 | draw_bitmap_screen2 = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); |
|
|
734 | } |
|
|
735 | |
589 | draw_canvas = new Canvas(draw_bitmap); |
736 | draw_canvas = new Canvas(draw_bitmap); |
590 | draw_canvas_screen = new Canvas(draw_bitmap_screen); |
737 | draw_canvas_screen = new Canvas(draw_bitmap_screen); |
|
|
738 | draw_canvas_screen2 = new Canvas(draw_bitmap_screen2); |
591 | if (gr_type == 1) |
739 | if (gr_type == 1) |
592 | { |
740 | { |
593 | System.out.println("*map*gra*"); |
741 | //System.out.println("*map*gra*"); |
594 | draw_bitmap_s = draw_bitmap; |
742 | draw_bitmap_s = draw_bitmap; |
595 | draw_canvas_s = draw_canvas; |
743 | draw_canvas_s = draw_canvas; |
596 | draw_bitmap_screen_s = draw_bitmap_screen; |
744 | draw_bitmap_screen_s = draw_bitmap_screen; |
597 | draw_canvas_screen_s = draw_canvas_screen; |
745 | draw_canvas_screen_s = draw_canvas_screen; |
|
|
746 | draw_bitmap_screen_s2 = draw_bitmap_screen2; |
|
|
747 | draw_canvas_screen_s2 = draw_canvas_screen2; |
598 | } |
748 | } |
599 | bitmap_w = w; |
749 | bitmap_w = w; |
600 | bitmap_h = h; |
750 | bitmap_h = h; |
601 | SizeChangedCallback(w, h); |
751 | SizeChangedCallback(w, h); |
602 | |
752 | |
|
|
753 | // 3D modus ----------------- |
|
|
754 | NavitGraphics.camera.save(); |
|
|
755 | //NavitGraphics.camera.translate(0, 0, 40); |
|
|
756 | NavitGraphics.camera.rotateX(65); |
|
|
757 | NavitGraphics.camera.getMatrix(NavitGraphics.cam_m); |
|
|
758 | NavitGraphics.camera.restore(); |
|
|
759 | // C-Code: (50 + offset) * height / 100 // offset = 30% |
|
|
760 | //float y_point = (bitmap_h - (bitmap_h * 0.7f)); |
|
|
761 | float y_offset = 0; // 20 |
|
|
762 | float y_point = bitmap_h * 0.7f; |
|
|
763 | NavitGraphics.cam_m.preTranslate(-bitmap_w / 2, -y_offset - y_point); |
|
|
764 | NavitGraphics.cam_m.postTranslate(bitmap_w / 2, y_offset + y_point); |
|
|
765 | NavitGraphics.cam_m.postScale(2.5f, 2.5f, bitmap_w / 2, y_offset + y_point); |
|
|
766 | //NavitGraphics.cam_m.postTranslate(0, 50); |
|
|
767 | // 3D modus ----------------- |
|
|
768 | |
603 | draw_factor = 1.0f; |
769 | draw_factor = 1.0f; |
604 | if (Navit.my_display_density.compareTo("mdpi") == 0) |
770 | if (Navit.my_display_density.compareTo("mdpi") == 0) |
605 | { |
771 | { |
606 | draw_factor = 1.0f; |
772 | draw_factor = 1.0f; |
607 | } |
773 | } |
… | |
… | |
615 | } |
781 | } |
616 | |
782 | |
617 | if (Navit.first_ever_startup) |
783 | if (Navit.first_ever_startup) |
618 | { |
784 | { |
619 | Navit.first_ever_startup = false; |
785 | Navit.first_ever_startup = false; |
620 | System.out.println(""); |
786 | //System.out.println(""); |
621 | System.out.println("*** Zoom out FULL (#startup#) ***"); |
787 | //System.out.println("*** Zoom out FULL (#startup#) ***"); |
622 | System.out.println(""); |
788 | //System.out.println(""); |
623 | Message msg = new Message(); |
789 | Message msg = new Message(); |
624 | Bundle b = new Bundle(); |
790 | Bundle b = new Bundle(); |
625 | b.putInt("Callback", 8); |
791 | b.putInt("Callback", 8); |
626 | msg.setData(b); |
792 | msg.setData(b); |
627 | callback_handler.sendMessage(msg); |
793 | callback_handler.sendMessage(msg); |
628 | } |
794 | } |
629 | } |
795 | } |
630 | |
796 | |
631 | public void do_longpress_action(float x, float y) |
|
|
632 | { |
|
|
633 | // this is called!!! yes really!! via REFLECT (make it better, later) |
|
|
634 | if (!NavitAndroidOverlay.confirmed_bubble) |
|
|
635 | { |
|
|
636 | Log.e("NavitGraphics", "do_longpress_action enter"); |
|
|
637 | NavitAndroidOverlayBubble b = new NavitAndroidOverlayBubble(); |
|
|
638 | b.x = (int) x; |
|
|
639 | b.y = (int) y; |
|
|
640 | NavitAOverlay.set_bubble(b); |
|
|
641 | NavitAOverlay.show_bubble(); |
|
|
642 | // draw_map_one_shot = true; |
|
|
643 | copy_map_buffer(); |
|
|
644 | this.postInvalidate(); |
|
|
645 | NavitAOverlay.invalidate(); |
|
|
646 | } |
|
|
647 | } |
|
|
648 | |
|
|
649 | @Override |
797 | @Override |
650 | public boolean onTouchEvent(MotionEvent event) |
798 | public boolean onTouchEvent(MotionEvent event) |
651 | { |
799 | { |
652 | PointF touch_now2 = null; |
800 | PointF touch_now2 = null; |
653 | PointF touch_start2 = null; |
801 | PointF touch_start2 = null; |
… | |
… | |
675 | |
823 | |
676 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "event x=" + event.getX() + " y=" + event.getY()); |
824 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "event x=" + event.getX() + " y=" + event.getY()); |
677 | |
825 | |
678 | if (switch_value == MotionEvent.ACTION_DOWN) |
826 | if (switch_value == MotionEvent.ACTION_DOWN) |
679 | { |
827 | { |
|
|
828 | Global_onTouch_fingerdown = true; |
|
|
829 | |
680 | this.touch_now.set(event.getX(), event.getY()); |
830 | this.touch_now.set(event.getX(), event.getY()); |
681 | this.touch_start.set(event.getX(), event.getY()); |
831 | this.touch_start.set(event.getX(), event.getY()); |
682 | this.touch_prev.set(event.getX(), event.getY()); |
832 | this.touch_prev.set(event.getX(), event.getY()); |
683 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_DOWN start"); |
833 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_DOWN start"); |
|
|
834 | //System.out.println("DO__DRAW:Java:ACTION DOWN start"); |
684 | |
835 | |
685 | d_pos_x_old = pos_x; |
836 | d_pos_x_old = pos_x; |
686 | d_pos_y_old = pos_y; |
837 | d_pos_y_old = pos_y; |
687 | //Log.e("NavitGraphics", "pos_x=" + pos_x); |
838 | //Log.e("NavitGraphics", "pos_x=" + pos_x); |
688 | //Log.e("NavitGraphics", "pos_y=" + pos_y); |
839 | //Log.e("NavitGraphics", "pos_y=" + pos_y); |
|
|
840 | |
|
|
841 | // cancel previous map drawing |
|
|
842 | //System.out.println("DO__DRAW:Java:cancel map drawing"); |
|
|
843 | // CallbackMessageChannel(50, ""); |
|
|
844 | CallbackMessageChannelReal(50, ""); |
689 | |
845 | |
690 | if (in_map) |
846 | if (in_map) |
691 | { |
847 | { |
692 | if (!NavitAOverlay.get_show_bubble()) |
848 | if (!NavitAOverlay.get_show_bubble()) |
693 | { |
849 | { |
694 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "hide bubble X1"); |
850 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "hide bubble X1"); |
695 | NavitAOverlay.hide_bubble(); |
851 | NavitAOverlay.hide_bubble(); |
696 | // remember last press on screen time |
852 | // remember last press on screen time |
697 | last_touch_on_screen = event.getEventTime(); // System.currentTimeMillis(); |
853 | last_touch_on_screen = event.getEventTime(); // System.currentTimeMillis(); |
698 | touch_sensor_thread = new SensorThread(last_touch_on_screen, this, NavitAOverlay, this.touch_now.x, this.touch_now.y); |
854 | touch_sensor_thread = new SensorThread(last_touch_on_screen, this.touch_now.x, this.touch_now.y); |
699 | touch_sensor_thread.start(); |
855 | touch_sensor_thread.start(); |
700 | } |
856 | } |
701 | } |
857 | } |
702 | |
858 | |
703 | wait_for_redraw_map = true; |
859 | wait_for_redraw_map = true; |
… | |
… | |
730 | } |
886 | } |
731 | catch (Exception e) |
887 | catch (Exception e) |
732 | { |
888 | { |
733 | } |
889 | } |
734 | // hold all map drawing ----------- |
890 | // hold all map drawing ----------- |
|
|
891 | |
|
|
892 | //System.out.println("DO__DRAW:Java:ACTION DOWN end"); |
|
|
893 | |
735 | } |
894 | } |
736 | else if ((switch_value == MotionEvent.ACTION_UP) || (switch_value == _ACTION_POINTER_UP_)) |
895 | else if ((switch_value == MotionEvent.ACTION_UP) || (switch_value == _ACTION_POINTER_UP_)) |
737 | { |
896 | { |
738 | this.touch_now.set(event.getX(), event.getY()); |
897 | this.touch_now.set(event.getX(), event.getY()); |
739 | touch_now2 = touch_now; |
898 | touch_now2 = touch_now; |
740 | touch_start2 = touch_start; |
899 | touch_start2 = touch_start; |
|
|
900 | |
|
|
901 | //System.out.println("DO__DRAW:Java:ACTION UP start"); |
|
|
902 | |
741 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_UP start"); |
903 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_UP start"); |
742 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "xxxxxxxxxx"); |
904 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "xxxxxxxxxx"); |
743 | try |
905 | try |
744 | { |
906 | { |
745 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "sensor thread stop X1"); |
907 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "sensor thread stop X1"); |
… | |
… | |
807 | if (DEBUG_TOUCH) System.out.println("wait_for_redraw_map=false 9"); |
969 | if (DEBUG_TOUCH) System.out.println("wait_for_redraw_map=false 9"); |
808 | NavitGraphics.wait_for_redraw_map = false; |
970 | NavitGraphics.wait_for_redraw_map = false; |
809 | try |
971 | try |
810 | { |
972 | { |
811 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "overlay thread stop X1"); |
973 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "overlay thread stop X1"); |
812 | NavitAndroidOverlay.overlay_draw_thread1.stop_redraw(); |
974 | //NavitAndroidOverlay.overlay_draw_thread1.stop_redraw(); |
813 | NavitAndroidOverlay.overlay_draw_thread1.stop_me(); |
975 | //NavitAndroidOverlay.overlay_draw_thread1.stop_me(); |
814 | NavitAndroidOverlay.overlay_draw_thread1 = null; |
976 | //NavitAndroidOverlay.overlay_draw_thread1 = null; |
815 | } |
977 | } |
816 | catch (Exception e) |
978 | catch (Exception e) |
817 | { |
979 | { |
818 | //e.printStackTrace(); |
980 | //e.printStackTrace(); |
819 | } |
981 | } |
820 | try |
982 | try |
821 | { |
983 | { |
|
|
984 | //System.out.println("invalidate 011"); |
822 | NavitAOverlay_s.postInvalidate(); |
985 | NavitAOverlay_s.postInvalidate(); |
823 | } |
986 | } |
824 | catch (Exception e) |
987 | catch (Exception e) |
825 | { |
988 | { |
826 | e.printStackTrace(); |
989 | e.printStackTrace(); |
… | |
… | |
886 | { |
1049 | { |
887 | } |
1050 | } |
888 | |
1051 | |
889 | // MotionCallback(x, y); |
1052 | // MotionCallback(x, y); |
890 | |
1053 | |
891 | System.out.println("motion call back JAVA -START-"); |
1054 | //System.out.println("DO__DRAW:Java:motion call back JAVA -START-"); |
892 | // -- new call -- |
1055 | // -- new call -- |
893 | if (dl_thread[0] != null) |
1056 | // if (dl_thread[0] != null) |
894 | { |
1057 | // { |
895 | dl_thread[0].motion_callback((int) this.touch_start.x, (int) this.touch_start.y, (int) this.touch_now.x, (int) this.touch_now.y); |
1058 | // dl_thread[0].motion_callback((int) this.touch_start.x, (int) this.touch_start.y, (int) this.touch_now.x, (int) this.touch_now.y); |
896 | } |
1059 | // } |
897 | // -- old call -- |
1060 | // -- old call -- |
898 | // MotionCallback((int) this.touch_start.x, (int) this.touch_start.y, (int) this.touch_now.x, (int) this.touch_now.y); |
1061 | MotionCallback((int) this.touch_start.x, (int) this.touch_start.y, (int) this.touch_now.x, (int) this.touch_now.y); |
899 | System.out.println("motion call back JAVA --END--"); |
1062 | //System.out.println("DO__DRAW:Java:motion call back JAVA --END--"); |
900 | |
1063 | |
901 | //msg2 = new Message(); |
1064 | //msg2 = new Message(); |
902 | //b2 = new Bundle(); |
1065 | //b2 = new Bundle(); |
903 | //b2.putInt("Callback", 23); |
1066 | //b2.putInt("Callback", 23); |
904 | //b2.putInt("x",(int) this.touch_start.x); |
1067 | //b2.putInt("x",(int) this.touch_start.x); |
… | |
… | |
914 | //{ |
1077 | //{ |
915 | //} |
1078 | //} |
916 | |
1079 | |
917 | // ??? // ButtonCallback(0, 1, x, y); // up |
1080 | // ??? // ButtonCallback(0, 1, x, y); // up |
918 | |
1081 | |
919 | try |
1082 | if (!Navit.PREF_follow_gps) |
920 | { |
1083 | { |
921 | // try to show current location/streetname |
1084 | Navit.cwthr.CallbackGeoCalc2(1, 0, mCanvasWidth / 2, mCanvasHeight / 2); |
922 | Message msg1 = new Message(); |
|
|
923 | Bundle b1 = new Bundle(); |
|
|
924 | b1.putInt("Callback", 9901); |
|
|
925 | msg1.setData(b1); |
|
|
926 | NavitGraphics.callback_handler_s.sendMessage(msg1); |
|
|
927 | } |
1085 | } |
|
|
1086 | |
|
|
1087 | // try |
|
|
1088 | // { |
|
|
1089 | // // try to show current location/streetname |
|
|
1090 | // Message msg1 = new Message(); |
|
|
1091 | // Bundle b1 = new Bundle(); |
|
|
1092 | // b1.putInt("Callback", 9901); |
|
|
1093 | // msg1.setData(b1); |
|
|
1094 | // NavitGraphics.callback_handler_s.sendMessage(msg1); |
|
|
1095 | // } |
928 | catch (Exception e) |
1096 | // catch (Exception e) |
|
|
1097 | // { |
929 | { |
1098 | // |
930 | |
1099 | // } |
931 | } |
|
|
932 | |
1100 | |
933 | touch_mode = NONE; |
1101 | touch_mode = NONE; |
934 | } |
1102 | } |
935 | else |
1103 | else |
936 | { |
1104 | { |
937 | if (touch_mode == ZOOM) |
1105 | if (touch_mode == ZOOM) |
938 | { |
1106 | { |
939 | // end of "pinch zoom" move |
1107 | // end of "pinch zoom" move |
940 | // ZOOM_MODE_ACTIVE = false; // wait for redraw !! |
1108 | // ZOOM_MODE_ACTIVE = false; // wait for redraw !! |
941 | // ZOOM_MODE_SCALE = 0; // wait for redraw !! |
1109 | // ZOOM_MODE_SCALE = 1.0f; // wait for redraw !! |
942 | |
1110 | |
943 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "onTouch zoom"); |
1111 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "onTouch zoom"); |
944 | |
1112 | |
945 | float newDist = spacing(event); |
1113 | float newDist = spacing(event); |
946 | float scale = 0; |
1114 | float scale = 1.0f; |
947 | if (newDist > 10f) |
1115 | if (newDist > 10f) |
948 | { |
1116 | { |
949 | scale = newDist / oldDist; |
1117 | scale = newDist / oldDist; |
950 | } |
1118 | } |
951 | |
1119 | |
… | |
… | |
1115 | if (DEBUG_TOUCH) System.out.println("wait_for_redraw_map=false 10"); |
1283 | if (DEBUG_TOUCH) System.out.println("wait_for_redraw_map=false 10"); |
1116 | NavitGraphics.wait_for_redraw_map = false; |
1284 | NavitGraphics.wait_for_redraw_map = false; |
1117 | try |
1285 | try |
1118 | { |
1286 | { |
1119 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "overlay thread stop X10"); |
1287 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "overlay thread stop X10"); |
1120 | NavitAndroidOverlay.overlay_draw_thread1.stop_redraw(); |
1288 | //NavitAndroidOverlay.overlay_draw_thread1.stop_redraw(); |
1121 | NavitAndroidOverlay.overlay_draw_thread1.stop_me(); |
1289 | //NavitAndroidOverlay.overlay_draw_thread1.stop_me(); |
1122 | NavitAndroidOverlay.overlay_draw_thread1 = null; |
1290 | //NavitAndroidOverlay.overlay_draw_thread1 = null; |
1123 | } |
1291 | } |
1124 | catch (Exception e) |
1292 | catch (Exception e) |
1125 | { |
1293 | { |
1126 | //e.printStackTrace(); |
1294 | //e.printStackTrace(); |
1127 | } |
1295 | } |
1128 | try |
1296 | try |
1129 | { |
1297 | { |
|
|
1298 | //System.out.println("invalidate 012"); |
1130 | NavitAOverlay_s.postInvalidate(); |
1299 | NavitAOverlay_s.postInvalidate(); |
1131 | } |
1300 | } |
1132 | catch (Exception e) |
1301 | catch (Exception e) |
1133 | { |
1302 | { |
1134 | e.printStackTrace(); |
1303 | e.printStackTrace(); |
… | |
… | |
1153 | if (switch_value == MotionEvent.ACTION_UP) |
1322 | if (switch_value == MotionEvent.ACTION_UP) |
1154 | { |
1323 | { |
1155 | // pos_x = d_pos_x_old; // wait for redraw !! |
1324 | // pos_x = d_pos_x_old; // wait for redraw !! |
1156 | // pos_y = d_pos_y_old; // wait for redraw !! |
1325 | // pos_y = d_pos_y_old; // wait for redraw !! |
1157 | |
1326 | |
|
|
1327 | //Log.e("NavitGraphics", "DO__DRAW:Java:Final Up action"); |
|
|
1328 | //copy_backwards_map_buffer(); |
|
|
1329 | //draw_reset_factors = true; |
|
|
1330 | //this.invalidate(); |
|
|
1331 | |
|
|
1332 | //System.out.println("DO__DRAW:Java:xchange global factors"); |
|
|
1333 | Global_Map_TransX = Global_Map_TransX + pos_x; |
|
|
1334 | Global_Map_TransY = Global_Map_TransY + pos_y; |
|
|
1335 | Global_Map_Rotationangle = 0f; |
|
|
1336 | Global_Map_Zoomfactor = Global_Map_Zoomfactor * ZOOM_MODE_SCALE; |
|
|
1337 | |
|
|
1338 | //System.out.println("DO__DRAW:Java:reset local factors"); |
|
|
1339 | pos_x = 0; |
|
|
1340 | pos_y = 0; |
|
|
1341 | ZOOM_MODE_ACTIVE = false; |
|
|
1342 | ZOOM_MODE_SCALE = 1.0f; |
|
|
1343 | |
1158 | try |
1344 | try |
1159 | { |
1345 | { |
1160 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "sensor thread stop final88"); |
1346 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "sensor thread stop final88"); |
1161 | touch_sensor_thread.stop_me(); |
1347 | touch_sensor_thread.stop_me(); |
1162 | } |
1348 | } |
1163 | catch (Exception e) |
1349 | catch (Exception e) |
1164 | { |
1350 | { |
1165 | |
1351 | |
1166 | } |
1352 | } |
|
|
1353 | |
|
|
1354 | Global_onTouch_fingerdown = false; |
1167 | |
1355 | |
1168 | // allow all map drawing ----------- |
1356 | // allow all map drawing ----------- |
1169 | Message msg2 = new Message(); |
1357 | Message msg2 = new Message(); |
1170 | Bundle b2 = new Bundle(); |
1358 | Bundle b2 = new Bundle(); |
1171 | b2.putInt("Callback", 70); |
1359 | b2.putInt("Callback", 70); |
… | |
… | |
1177 | catch (Exception e) |
1365 | catch (Exception e) |
1178 | { |
1366 | { |
1179 | } |
1367 | } |
1180 | // allow all map drawing ----------- |
1368 | // allow all map drawing ----------- |
1181 | } |
1369 | } |
|
|
1370 | |
|
|
1371 | //System.out.println("DO__DRAW:Java:ACTION UP end"); |
|
|
1372 | |
1182 | } |
1373 | } |
1183 | else if (switch_value == MotionEvent.ACTION_MOVE) |
1374 | else if (switch_value == MotionEvent.ACTION_MOVE) |
1184 | { |
1375 | { |
|
|
1376 | //System.out.println("DO__DRAW:Java:ACTION MOVE start"); |
|
|
1377 | |
1185 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_MOVE"); |
1378 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_MOVE"); |
1186 | |
1379 | |
1187 | if (touch_mode == DRAG) |
1380 | if (touch_mode == DRAG) |
1188 | { |
1381 | { |
1189 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "mode = DRAG"); |
1382 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "mode = DRAG"); |
… | |
… | |
1247 | |
1440 | |
1248 | } |
1441 | } |
1249 | |
1442 | |
1250 | pos_x = (int) (this.touch_now.x - this.touch_start.x); |
1443 | pos_x = (int) (this.touch_now.x - this.touch_start.x); |
1251 | pos_y = (int) (this.touch_now.y - this.touch_start.y); |
1444 | pos_y = (int) (this.touch_now.y - this.touch_start.y); |
1252 | dl_thread[dl_thread_cur].add_lines2(null, null, 0, 0, 98); |
1445 | //**dl_thread[dl_thread_cur].add_lines2(null, null, 0, 0, 98); |
1253 | //draw_map_one_shot = true; |
1446 | //draw_map_one_shot = true; |
1254 | //copy_map_buffer(); |
1447 | //copy_map_buffer(); |
|
|
1448 | //System.out.println("invalidate 013"); |
1255 | this.invalidate(); |
1449 | this.invalidate(); |
1256 | // this.postInvalidate(); |
1450 | // this.postInvalidate(); |
1257 | // DRAG ----------- new -------------- |
1451 | // DRAG ----------- new -------------- |
1258 | // DRAG ----------- new -------------- |
1452 | // DRAG ----------- new -------------- |
1259 | // DRAG ----------- new -------------- |
1453 | // DRAG ----------- new -------------- |
… | |
… | |
1283 | // were are in the middle of a zooming action here ---------- |
1477 | // were are in the middle of a zooming action here ---------- |
1284 | // were are in the middle of a zooming action here ---------- |
1478 | // were are in the middle of a zooming action here ---------- |
1285 | |
1479 | |
1286 | this.touch_now_center = calc_center(event); |
1480 | this.touch_now_center = calc_center(event); |
1287 | float newDist = spacing(event); |
1481 | float newDist = spacing(event); |
1288 | float scale = 0; |
1482 | float scale = 1.0f; |
1289 | try |
1483 | try |
1290 | { |
1484 | { |
1291 | scale = newDist / oldDist; |
1485 | scale = newDist / oldDist; |
1292 | } |
1486 | } |
1293 | catch (Exception ee) |
1487 | catch (Exception ee) |
1294 | { |
1488 | { |
1295 | |
1489 | |
1296 | } |
1490 | } |
|
|
1491 | |
|
|
1492 | if (scale != 0) |
|
|
1493 | { |
1297 | ZOOM_MODE_SCALE = scale; |
1494 | ZOOM_MODE_SCALE = scale; |
|
|
1495 | } |
|
|
1496 | else |
|
|
1497 | { |
|
|
1498 | ZOOM_MODE_SCALE = 1.0f; |
|
|
1499 | } |
|
|
1500 | |
1298 | ZOOM_MODE_ACTIVE = true; |
1501 | ZOOM_MODE_ACTIVE = true; |
1299 | dl_thread[dl_thread_cur].add_lines2(null, null, 0, 0, 98); |
1502 | //**dl_thread[dl_thread_cur].add_lines2(null, null, 0, 0, 98); |
1300 | //draw_map_one_shot = true; |
1503 | //draw_map_one_shot = true; |
1301 | //copy_map_buffer(); |
1504 | //copy_map_buffer(); |
|
|
1505 | //System.out.println("invalidate 014"); |
1302 | this.invalidate(); |
1506 | this.invalidate(); |
1303 | // Log.e("NavitGraphics", "x:" + this.touch_now.x + " y:" + this.touch_now.y); |
1507 | // Log.e("NavitGraphics", "x:" + this.touch_now.x + " y:" + this.touch_now.y); |
1304 | // were are in the middle of a zooming action here ---------- |
1508 | // were are in the middle of a zooming action here ---------- |
1305 | // were are in the middle of a zooming action here ---------- |
1509 | // were are in the middle of a zooming action here ---------- |
1306 | } |
1510 | } |
|
|
1511 | |
|
|
1512 | //System.out.println("DO__DRAW:Java:ACTION MOVE end"); |
|
|
1513 | |
1307 | } |
1514 | } |
1308 | else if (switch_value == _ACTION_POINTER_DOWN_) |
1515 | else if (switch_value == _ACTION_POINTER_DOWN_) |
1309 | { |
1516 | { |
|
|
1517 | //System.out.println("DO__DRAW:Java:ACTION POINTER DOWN start"); |
1310 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_POINTER_DOWN"); |
1518 | if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_POINTER_DOWN"); |
1311 | |
1519 | |
1312 | oldDist = spacing(event); |
1520 | oldDist = spacing(event); |
1313 | if (oldDist > 10f) |
1521 | if (oldDist > 10f) |
1314 | { |
1522 | { |
… | |
… | |
1317 | // zoom action starts here -------- |
1525 | // zoom action starts here -------- |
1318 | // zoom action starts here -------- |
1526 | // zoom action starts here -------- |
1319 | // zoom action starts here -------- |
1527 | // zoom action starts here -------- |
1320 | // zoom action starts here -------- |
1528 | // zoom action starts here -------- |
1321 | } |
1529 | } |
|
|
1530 | |
|
|
1531 | //System.out.println("DO__DRAW:Java:ACTION POINTER DOWN end"); |
|
|
1532 | |
1322 | } |
1533 | } |
1323 | return true; |
1534 | return true; |
1324 | } |
1535 | } |
1325 | |
1536 | |
1326 | private float spacing(PointF a, PointF b) |
1537 | private float spacing(PointF a, PointF b) |
… | |
… | |
1412 | |
1623 | |
1413 | @Override |
1624 | @Override |
1414 | protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) |
1625 | protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) |
1415 | { |
1626 | { |
1416 | super.onFocusChanged(gainFocus, direction, previouslyFocusedRect); |
1627 | super.onFocusChanged(gainFocus, direction, previouslyFocusedRect); |
1417 | Log.e("NavitGraphics", "FocusChange " + gainFocus); |
1628 | //Log.e("NavitGraphics", "FocusChange " + gainFocus); |
1418 | } |
1629 | } |
1419 | }; |
1630 | }; |
1420 | |
1631 | |
1421 | view.setFocusable(true); |
1632 | view.setFocusable(true); |
1422 | view.setFocusableInTouchMode(true); |
1633 | view.setFocusableInTouchMode(true); |
… | |
… | |
1432 | //{ |
1643 | //{ |
1433 | // SetCamera(use_camera); |
1644 | // SetCamera(use_camera); |
1434 | //} |
1645 | //} |
1435 | relativelayout.addView(view); |
1646 | relativelayout.addView(view); |
1436 | |
1647 | |
|
|
1648 | // vehicle view |
|
|
1649 | RelativeLayout.LayoutParams NavitVehicleGraph_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); |
|
|
1650 | relativelayout.addView(Navit.NG__vehicle.view, NavitVehicleGraph_lp); |
|
|
1651 | Navit.NG__vehicle.view.bringToFront(); |
|
|
1652 | Navit.NG__vehicle.view.postInvalidate(); |
|
|
1653 | // vehicle view |
|
|
1654 | |
1437 | // android overlay |
1655 | // android overlay |
1438 | Log.e("Navit", "create android overlay"); |
1656 | //Log.e("Navit", "create android overlay"); |
1439 | NavitAOverlay = new NavitAndroidOverlay(relativelayout.getContext()); |
1657 | NavitAOverlay = new NavitAndroidOverlay(relativelayout.getContext()); |
1440 | NavitAOverlay_s = NavitAOverlay; |
1658 | NavitAOverlay_s = NavitAOverlay; |
1441 | RelativeLayout.LayoutParams NavitAOverlay_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); |
1659 | RelativeLayout.LayoutParams NavitAOverlay_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); |
1442 | relativelayout.addView(NavitAOverlay, NavitAOverlay_lp); |
1660 | relativelayout.addView(NavitAOverlay, NavitAOverlay_lp); |
1443 | NavitAOverlay.bringToFront(); |
1661 | NavitAOverlay.bringToFront(); |
1444 | NavitAOverlay.invalidate(); |
1662 | NavitAOverlay.postInvalidate(); |
1445 | // android overlay |
1663 | // android overlay |
1446 | |
1664 | |
1447 | // android OSDJava |
1665 | // android OSDJava |
1448 | Log.e("Navit", "create android OSDJava"); |
1666 | //Log.e("Navit", "create android OSDJava"); |
1449 | NavitAOSDJava = new NavitOSDJava(relativelayout.getContext()); |
1667 | NavitAOSDJava = new NavitOSDJava(relativelayout.getContext()); |
1450 | NavitAOSDJava_ = NavitAOSDJava; |
1668 | NavitAOSDJava_ = NavitAOSDJava; |
1451 | RelativeLayout.LayoutParams NavitAOSDJava_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); |
1669 | RelativeLayout.LayoutParams NavitAOSDJava_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); |
1452 | relativelayout.addView(NavitAOSDJava, NavitAOSDJava_lp); |
1670 | relativelayout.addView(NavitAOSDJava, NavitAOSDJava_lp); |
1453 | NavitAOSDJava.bringToFront(); |
1671 | NavitAOSDJava.bringToFront(); |
1454 | NavitAOSDJava.invalidate(); |
1672 | NavitAOSDJava.postInvalidate(); |
1455 | // android OSDJava |
1673 | // android OSDJava |
1456 | |
1674 | |
1457 | // android Messages TextView |
1675 | // android Messages TextView |
1458 | Log.e("Navit", "create android Messages TextView"); |
1676 | //Log.e("Navit", "create android Messages TextView"); |
1459 | NavitMsgTv = new TextView(relativelayout.getContext()); |
1677 | NavitMsgTv = new TextView(relativelayout.getContext()); |
1460 | NavitMsgTv_ = NavitMsgTv; |
1678 | NavitMsgTv_ = NavitMsgTv; |
1461 | RelativeLayout.LayoutParams NavitMsgTv_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); |
1679 | RelativeLayout.LayoutParams NavitMsgTv_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); |
1462 | // NavitMsgTv_lp.height = 50; |
1680 | // NavitMsgTv_lp.height = 50; |
1463 | NavitMsgTv_lp.leftMargin = 120; |
1681 | NavitMsgTv_lp.leftMargin = 120; |
… | |
… | |
1467 | NavitMsgTv.setLines(4); |
1685 | NavitMsgTv.setLines(4); |
1468 | NavitMsgTv.setTextSize(12); |
1686 | NavitMsgTv.setTextSize(12); |
1469 | NavitMsgTv.setTextColor(Color.argb(255, 200, 200, 200)); // almost white |
1687 | NavitMsgTv.setTextColor(Color.argb(255, 200, 200, 200)); // almost white |
1470 | relativelayout.addView(NavitMsgTv, NavitMsgTv_lp); |
1688 | relativelayout.addView(NavitMsgTv, NavitMsgTv_lp); |
1471 | NavitMsgTv.bringToFront(); |
1689 | NavitMsgTv.bringToFront(); |
1472 | NavitMsgTv.invalidate(); |
1690 | NavitMsgTv.postInvalidate(); |
1473 | // android Messages TextView |
1691 | // android Messages TextView |
1474 | |
1692 | |
1475 | // android Speech Messages TextView |
1693 | // android Speech Messages TextView |
1476 | Log.e("Navit", "create android Speech Messages TextView"); |
1694 | //Log.e("Navit", "create android Speech Messages TextView"); |
1477 | NavitMsgTv2 = new TextView(relativelayout.getContext()); |
1695 | NavitMsgTv2 = new TextView(relativelayout.getContext()); |
1478 | NavitMsgTv2_ = NavitMsgTv2; |
1696 | NavitMsgTv2_ = NavitMsgTv2; |
1479 | RelativeLayout.LayoutParams NavitMsgTv_lp2 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); |
1697 | RelativeLayout.LayoutParams NavitMsgTv_lp2 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); |
1480 | NavitMsgTv_lp2.leftMargin = 10; |
1698 | NavitMsgTv_lp2.leftMargin = 10; |
1481 | NavitMsgTv_lp2.rightMargin = 10; |
1699 | NavitMsgTv_lp2.rightMargin = 10; |
… | |
… | |
1493 | sc.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); |
1711 | sc.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); |
1494 | NavitMsgTv2.setGravity(Gravity.BOTTOM); |
1712 | NavitMsgTv2.setGravity(Gravity.BOTTOM); |
1495 | relativelayout.addView(sc, NavitMsgTv_lp3); |
1713 | relativelayout.addView(sc, NavitMsgTv_lp3); |
1496 | |
1714 | |
1497 | NavitMsgTv2.bringToFront(); |
1715 | NavitMsgTv2.bringToFront(); |
1498 | NavitMsgTv2.invalidate(); |
1716 | NavitMsgTv2.postInvalidate(); |
1499 | NavitMsgTv2.setEnabled(false); |
1717 | NavitMsgTv2.setEnabled(false); |
1500 | NavitMsgTv2.setVisibility(View.GONE); |
1718 | NavitMsgTv2.setVisibility(View.GONE); |
1501 | // android Speech Messages TextView |
1719 | // android Speech Messages TextView |
1502 | |
1720 | |
1503 | // busy spinner view on top of everything |
1721 | // busy spinner view on top of everything |
1504 | ZANaviBusySpinner busyspinner = new ZANaviBusySpinner(relativelayout.getContext()); |
1722 | ZANaviBusySpinner busyspinner = new ZANaviBusySpinner(relativelayout.getContext()); |
1505 | busyspinner_ = busyspinner; |
1723 | busyspinner_ = busyspinner; |
1506 | RelativeLayout.LayoutParams ZANaviBusySpinner_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); |
1724 | RelativeLayout.LayoutParams ZANaviBusySpinner_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); |
1507 | relativelayout.addView(busyspinner, ZANaviBusySpinner_lp); |
1725 | relativelayout.addView(busyspinner, ZANaviBusySpinner_lp); |
1508 | busyspinner.bringToFront(); |
1726 | busyspinner.bringToFront(); |
1509 | busyspinner.invalidate(); |
1727 | busyspinner.postInvalidate(); |
1510 | busyspinner.setVisibility(View.INVISIBLE); |
1728 | busyspinner.setVisibility(View.INVISIBLE); |
1511 | |
1729 | |
1512 | ZANaviBusyText busyspinnertext = new ZANaviBusyText(relativelayout.getContext()); |
1730 | ZANaviBusyText busyspinnertext = new ZANaviBusyText(relativelayout.getContext()); |
1513 | busyspinnertext_ = busyspinnertext; |
1731 | busyspinnertext_ = busyspinnertext; |
1514 | RelativeLayout.LayoutParams ZANaviBusyText_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); |
1732 | RelativeLayout.LayoutParams ZANaviBusyText_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); |
1515 | relativelayout.addView(busyspinnertext, ZANaviBusyText_lp); |
1733 | relativelayout.addView(busyspinnertext, ZANaviBusyText_lp); |
1516 | busyspinnertext.bringToFront(); |
1734 | busyspinnertext.bringToFront(); |
1517 | busyspinnertext.invalidate(); |
1735 | busyspinnertext.postInvalidate(); |
1518 | busyspinnertext.setVisibility(View.INVISIBLE); |
1736 | busyspinnertext.setVisibility(View.INVISIBLE); |
1519 | // busy spinner view on top of everything |
1737 | // busy spinner view on top of everything |
1520 | |
1738 | |
1521 | // big map overlay |
1739 | // big map overlay |
1522 | // NavitGlobalMap_ = new NavitGlobalMap(relativelayout.getContext()); |
1740 | // NavitGlobalMap_ = new NavitGlobalMap(relativelayout.getContext()); |
… | |
… | |
1527 | // big map overlay |
1745 | // big map overlay |
1528 | |
1746 | |
1529 | activity.setContentView(relativelayout); |
1747 | activity.setContentView(relativelayout); |
1530 | view.requestFocus(); |
1748 | view.requestFocus(); |
1531 | } |
1749 | } |
|
|
1750 | // parent == 0 --------------- |
1532 | else |
1751 | else |
1533 | // parent == null --------------- |
1752 | // parent == 1 --------------- |
1534 | { |
1753 | { |
1535 | if (draw_bitmap != null) |
1754 | if (draw_bitmap != null) |
1536 | { |
1755 | { |
1537 | // try to avoid out of memory errors |
1756 | // try to avoid out of memory errors |
1538 | draw_bitmap.recycle(); |
1757 | draw_bitmap.recycle(); |
… | |
… | |
1560 | bitmap_h = h; |
1779 | bitmap_h = h; |
1561 | pos_x = x; |
1780 | pos_x = x; |
1562 | pos_y = y; |
1781 | pos_y = y; |
1563 | pos_wraparound = wraparound; |
1782 | pos_wraparound = wraparound; |
1564 | draw_canvas = new Canvas(draw_bitmap); |
1783 | draw_canvas = new Canvas(draw_bitmap); |
1565 | parent.overlays.add(this); |
1784 | |
|
|
1785 | this.activity = activity; |
|
|
1786 | view = new View(activity) |
|
|
1787 | { |
|
|
1788 | protected void onDraw(Canvas canvas) |
|
|
1789 | { |
|
|
1790 | //System.out.println("V.Draw x"); |
|
|
1791 | //System.out.println("V.Draw x="+NG__vehicle.vehicle_pos_x+" y="+NG__vehicle.vehicle_pos_y); |
|
|
1792 | //System.out.println("V.Draw d=" + Navit.nav_arrow_stopped.getDensity()); |
|
|
1793 | //System.out.println("V.Draw w=" + Navit.nav_arrow_stopped.getWidth()); |
|
|
1794 | //System.out.println("V.Draw h=" + Navit.nav_arrow_stopped.getHeight()); |
|
|
1795 | super.onDraw(canvas); |
|
|
1796 | |
|
|
1797 | if (!NavitGraphics.MAP_DISPLAY_OFF) |
|
|
1798 | { |
|
|
1799 | if (Navit.NG__vehicle.vehicle_speed < 3) |
|
|
1800 | { |
|
|
1801 | canvas.drawBitmap(Navit.nav_arrow_stopped, Navit.NG__vehicle.vehicle_pos_x - Navit.nav_arrow_stopped.getWidth() / 2, Navit.NG__vehicle.vehicle_pos_y - Navit.nav_arrow_stopped.getHeight() / 2, null); |
|
|
1802 | } |
|
|
1803 | else |
|
|
1804 | { |
|
|
1805 | if (Navit.NG__vehicle.vehicle_direction != 0) |
|
|
1806 | { |
|
|
1807 | canvas.save(); |
|
|
1808 | // rotate nav icon if needed |
|
|
1809 | canvas.rotate(Navit.NG__vehicle.vehicle_direction, Navit.NG__vehicle.vehicle_pos_x, Navit.NG__vehicle.vehicle_pos_y); |
|
|
1810 | } |
|
|
1811 | // offset shadow x+2 , y+8 |
|
|
1812 | canvas.drawBitmap(Navit.nav_arrow_moving_shadow, 2 + Navit.NG__vehicle.vehicle_pos_x - Navit.nav_arrow_moving.getWidth() / 2, 8 + Navit.NG__vehicle.vehicle_pos_y - Navit.nav_arrow_moving.getHeight() / 2, null); |
|
|
1813 | canvas.drawBitmap(Navit.nav_arrow_moving, Navit.NG__vehicle.vehicle_pos_x - Navit.nav_arrow_moving.getWidth() / 2, Navit.NG__vehicle.vehicle_pos_y - Navit.nav_arrow_moving.getHeight() / 2, null); |
|
|
1814 | if (Navit.NG__vehicle.vehicle_direction != 0) |
|
|
1815 | { |
|
|
1816 | canvas.restore(); |
|
|
1817 | } |
|
|
1818 | } |
|
|
1819 | |
|
|
1820 | // paint the sweep spot of the vehicle position!! |
|
|
1821 | // Paint paint22 = new Paint(); |
|
|
1822 | // paint22.setStyle(Paint.Style.FILL); |
|
|
1823 | // paint22.setStrokeWidth(0); |
|
|
1824 | // paint22.setColor(Color.RED); |
|
|
1825 | // canvas.drawCircle(Navit.NG__vehicle.vehicle_pos_x, Navit.NG__vehicle.vehicle_pos_y, 5, paint22); |
|
|
1826 | // paint the sweep spot of the vehicle position!! |
|
|
1827 | } |
|
|
1828 | } |
|
|
1829 | |
|
|
1830 | @Override |
|
|
1831 | protected void onSizeChanged(int w, int h, int oldw, int oldh) |
|
|
1832 | { |
|
|
1833 | System.out.println("new width=" + w + " new height=" + h); |
|
|
1834 | } |
|
|
1835 | }; |
|
|
1836 | |
1566 | } // END IF: parent == null --------------- |
1837 | } // END IF: parent == 1 --------------- |
|
|
1838 | |
1567 | parent_graphics = parent; |
1839 | parent_num = parent; |
1568 | } |
1840 | } |
1569 | |
1841 | |
1570 | public Handler callback_handler = new Handler() |
1842 | public Handler callback_handler = new Handler() |
1571 | { |
1843 | { |
1572 | public void handleMessage(Message msg) |
1844 | public void handleMessage(Message msg) |
… | |
… | |
1916 | { |
2188 | { |
1917 | // update the route path and route graph (e.g. after setting new roadblocks) |
2189 | // update the route path and route graph (e.g. after setting new roadblocks) |
1918 | // this destroys the route graph and calcs everything totally new! |
2190 | // this destroys the route graph and calcs everything totally new! |
1919 | CallbackMessageChannel(73, ""); |
2191 | CallbackMessageChannel(73, ""); |
1920 | } |
2192 | } |
|
|
2193 | |
|
|
2194 | else if (msg.getData().getInt("Callback") == 74) |
|
|
2195 | { |
|
|
2196 | // allow demo vechile to move |
|
|
2197 | CallbackMessageChannel(74, ""); |
|
|
2198 | } |
|
|
2199 | else if (msg.getData().getInt("Callback") == 75) |
|
|
2200 | { |
|
|
2201 | // stop demo vechile |
|
|
2202 | CallbackMessageChannel(75, ""); |
|
|
2203 | } |
|
|
2204 | |
1921 | } |
2205 | } |
1922 | }; |
2206 | }; |
1923 | |
2207 | |
|
|
2208 | public static native void TimeoutCallback(int del, int id); |
|
|
2209 | |
|
|
2210 | public static native void SizeChangedCallbackReal(int w, int h); |
|
|
2211 | |
1924 | public native void SizeChangedCallback(int w, int h); |
2212 | public static void SizeChangedCallback(int w, int h) |
|
|
2213 | { |
|
|
2214 | Navit.cwthr.SizeChangedCallback(w, h); |
|
|
2215 | } |
1925 | |
2216 | |
1926 | // public native void ButtonCallback(int pressed, int button, int x, int y); |
2217 | // public native void ButtonCallback(int pressed, int button, int x, int y); |
1927 | |
2218 | |
1928 | public static native void MotionCallback(int x1, int y1, int x2, int y2); |
2219 | public static native void MotionCallbackReal(int x1, int y1, int x2, int y2); |
|
|
2220 | |
|
|
2221 | public static void MotionCallback(int x1, int y1, int x2, int y2) |
|
|
2222 | { |
|
|
2223 | Navit.cwthr.MotionCallback(x1, y1, x2, y2); |
|
|
2224 | } |
1929 | |
2225 | |
1930 | // public native void KeypressCallback(String s); |
2226 | // public native void KeypressCallback(String s); |
1931 | |
2227 | |
1932 | // private int SizeChangedCallbackID, ButtonCallbackID, MotionCallbackID, KeypressCallbackID; |
2228 | // private int SizeChangedCallbackID, ButtonCallbackID, MotionCallbackID, KeypressCallbackID; |
1933 | |
2229 | |
… | |
… | |
1964 | */ |
2260 | */ |
1965 | |
2261 | |
1966 | public void NavitSetGrObj() |
2262 | public void NavitSetGrObj() |
1967 | { |
2263 | { |
1968 | // set the (static) graphics object (this is bad, please fix me!!) |
2264 | // set the (static) graphics object (this is bad, please fix me!!) |
1969 | Navit.N_NavitGraphics = this; |
2265 | // **disabled** Navit.N_NavitGraphics = this; |
1970 | } |
2266 | } |
1971 | |
2267 | |
1972 | protected void draw_polyline(Paint paint, int c[]) |
2268 | protected void draw_polyline(Paint paint, int c[]) |
1973 | { |
2269 | { |
1974 | // Log.e("NavitGraphics","draw_polyline"); |
2270 | // Log.e("NavitGraphics","draw_polyline"); |
… | |
… | |
1986 | draw_canvas.drawPath(b_paint_path, paint); |
2282 | draw_canvas.drawPath(b_paint_path, paint); |
1987 | paint.setAntiAlias(b_paint_antialias); |
2283 | paint.setAntiAlias(b_paint_antialias); |
1988 | //paint.setPathEffect(dashed_map_lines__no_dash); |
2284 | //paint.setPathEffect(dashed_map_lines__no_dash); |
1989 | } |
2285 | } |
1990 | |
2286 | |
1991 | protected void draw_polyline2(Paint paint, int c[], int order, int oneway) |
2287 | protected void draw_polyline2__NEW(Paint paint, int c[], int order, int oneway) |
1992 | { |
2288 | { |
1993 | if (dl_thread[0] == null) |
2289 | if (dl_thread[0] == null) |
1994 | { |
2290 | { |
1995 | int ii = 0; |
2291 | int ii = 0; |
1996 | for (ii = 0; ii < NavitGraphics.dl_thread_max; ii++) |
2292 | for (ii = 0; ii < NavitGraphics.dl_thread_max; ii++) |
… | |
… | |
2064 | return; |
2360 | return; |
2065 | } |
2361 | } |
2066 | } |
2362 | } |
2067 | } |
2363 | } |
2068 | |
2364 | |
2069 | protected void draw_polyline2__ORIG(Paint paint, int c[], int order, int oneway) |
2365 | protected void draw_polyline2(Paint paint, int c[], int order, int oneway) |
2070 | { |
2366 | { |
2071 | // Log.e("NavitGraphics", "draw_polyline2 count=" + c.length); |
2367 | // Log.e("NavitGraphics", "draw_polyline2 count=" + c.length); |
2072 | if (!Navit.PREF_gui_oneway_arrows) |
2368 | if (!Navit.PREF_gui_oneway_arrows) |
2073 | { |
2369 | { |
2074 | return; |
2370 | return; |
… | |
… | |
2085 | int len = (c[0] - c[2]) * (c[1] - c[3]); |
2381 | int len = (c[0] - c[2]) * (c[1] - c[3]); |
2086 | if (len < 0) |
2382 | if (len < 0) |
2087 | { |
2383 | { |
2088 | len = -len; |
2384 | len = -len; |
2089 | } |
2385 | } |
|
|
2386 | |
2090 | if (len > (2000)) |
2387 | if (len > (1600)) |
2091 | { |
2388 | { |
2092 | paint.setStyle(Paint.Style.STROKE); |
2389 | paint.setStyle(Paint.Style.STROKE); |
2093 | b_paint_antialias = paint.isAntiAlias(); |
2390 | b_paint_antialias = paint.isAntiAlias(); |
2094 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
2391 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
2095 | |
2392 | |
2096 | // create matrix for the manipulation |
2393 | // create matrix for the manipulation |
2097 | matrix_oneway_arrows = new Matrix(); |
2394 | matrix_oneway_arrows = new Matrix(); |
2098 | |
2395 | |
2099 | int middle_x = c[0] + (int) ((c[2] - c[0]) / 2); |
2396 | // calc this in c-code !! will be much faster!! |
2100 | int middle_y = c[1] + (int) ((c[3] - c[1]) / 2); |
2397 | // calc this in c-code !! will be much faster!! |
|
|
2398 | // calc this in c-code !! will be much faster!! |
2101 | double d_x = ((c[2] - c[0]) / 6); |
2399 | double d_x = ((c[2] - c[0])); |
2102 | double d_y = ((c[3] - c[1]) / 6); |
2400 | double d_y = ((c[3] - c[1])); |
|
|
2401 | int middle_x = c[0] + (int) (d_x / 6); |
|
|
2402 | int middle_y = c[1] + (int) (d_y / 6); |
2103 | int angle = (int) (Math.toDegrees(Math.atan2(d_y, d_x))); |
2403 | int angle = (int) (Math.toDegrees(Math.atan2(d_y, d_x))); |
|
|
2404 | // calc this in c-code !! will be much faster!! |
|
|
2405 | // calc this in c-code !! will be much faster!! |
|
|
2406 | // calc this in c-code !! will be much faster!! |
|
|
2407 | |
2104 | // System.out.println("arrow angle=" + angle); |
2408 | // System.out.println("arrow angle=" + angle); |
2105 | matrix_oneway_arrows.postTranslate(-Navit.oneway_arrow.getWidth() / 2, -Navit.oneway_arrow.getHeight() / 2); |
2409 | matrix_oneway_arrows.postTranslate(-Navit.oneway_arrow.getWidth() / 2, -Navit.oneway_arrow.getHeight() / 2); |
|
|
2410 | |
|
|
2411 | //System.out.println("order=" + order); |
|
|
2412 | // resize the Bitmap |
|
|
2413 | if (order > 16) |
|
|
2414 | { |
|
|
2415 | matrix_oneway_arrows.postScale(4.5f, 4.5f); |
|
|
2416 | } |
|
|
2417 | else if (order > 14) |
|
|
2418 | { |
|
|
2419 | matrix_oneway_arrows.postScale(1.5f, 1.5f); |
|
|
2420 | } |
2106 | |
2421 | |
2107 | if (oneway == 1) |
2422 | if (oneway == 1) |
2108 | { |
2423 | { |
2109 | // rotate the Bitmap |
2424 | // rotate the Bitmap |
2110 | matrix_oneway_arrows.postRotate(angle); |
2425 | matrix_oneway_arrows.postRotate(angle); |
… | |
… | |
2265 | return; |
2580 | return; |
2266 | } |
2581 | } |
2267 | if (line_type == 97) |
2582 | if (line_type == 97) |
2268 | { |
2583 | { |
2269 | // start drawing from queue |
2584 | // start drawing from queue |
2270 | System.out.println("start drawing"); |
2585 | //System.out.println("start drawing"); |
2271 | start_drawing = true; |
2586 | start_drawing = true; |
2272 | // and wake up from sleeping |
2587 | // and wake up from sleeping |
2273 | this.interrupt(); |
2588 | this.interrupt(); |
2274 | return; |
2589 | return; |
2275 | } |
2590 | } |
… | |
… | |
2353 | case 3: |
2668 | case 3: |
2354 | draw_polyline2_threads(l2.paint, l2.c, l2.order, l2.width); |
2669 | draw_polyline2_threads(l2.paint, l2.c, l2.order, l2.width); |
2355 | counter++; |
2670 | counter++; |
2356 | break; |
2671 | break; |
2357 | case 96: |
2672 | case 96: |
2358 | System.out.println("refresh map (layers)"); |
2673 | //System.out.println("refresh map (layers)"); |
2359 | // draw_map_one_shot = true; |
2674 | // draw_map_one_shot = true; |
2360 | //copy_map_buffer(); |
2675 | //copy_map_buffer(); |
2361 | //draw_reset_factors = true; |
2676 | //draw_reset_factors = true; |
2362 | //view_s.postInvalidate(); |
2677 | //view_s.postInvalidate(); |
2363 | break; |
2678 | break; |
2364 | case 99: |
2679 | case 99: |
2365 | System.out.println("refresh map"); |
2680 | //System.out.println("refresh map OLDOLD"); |
2366 | // draw_map_one_shot = true; |
2681 | // draw_map_one_shot = true; |
2367 | copy_map_buffer(); |
2682 | copy_map_buffer(); |
2368 | draw_reset_factors = true; |
2683 | draw_reset_factors = true; |
|
|
2684 | //System.out.println("invalidate 015"); |
2369 | view_s.postInvalidate(); |
2685 | view_s.postInvalidate(); |
2370 | try |
2686 | try |
2371 | { |
2687 | { |
2372 | Thread.sleep(800); |
2688 | Thread.sleep(800); |
2373 | } |
2689 | } |
… | |
… | |
2402 | } |
2718 | } |
2403 | } |
2719 | } |
2404 | } |
2720 | } |
2405 | } |
2721 | } |
2406 | |
2722 | |
2407 | protected void draw_polyline3(Paint paint, int c[], int order, int width) |
2723 | protected void draw_polyline3___NEW(Paint paint, int c[], int order, int width) |
2408 | { |
2724 | { |
2409 | if (dl_thread[0] == null) |
2725 | if (dl_thread[0] == null) |
2410 | { |
2726 | { |
2411 | int ii = 0; |
2727 | int ii = 0; |
2412 | for (ii = 0; ii < NavitGraphics.dl_thread_max; ii++) |
2728 | for (ii = 0; ii < NavitGraphics.dl_thread_max; ii++) |
… | |
… | |
2460 | } |
2776 | } |
2461 | |
2777 | |
2462 | // draw normal polylines -> this function gets called the most!! XX-thousand times |
2778 | // draw normal polylines -> this function gets called the most!! XX-thousand times |
2463 | // draw normal polylines -> this function gets called the most!! XX-thousand times |
2779 | // draw normal polylines -> this function gets called the most!! XX-thousand times |
2464 | // draw normal polylines -> this function gets called the most!! XX-thousand times |
2780 | // draw normal polylines -> this function gets called the most!! XX-thousand times |
2465 | protected void draw_polyline3___ORIG(Paint paint, int c[], int order, int width) |
2781 | protected void draw_polyline3(int c[], int order, int width, int dashes, int r, int g, int b, int a) |
2466 | { |
2782 | { |
|
|
2783 | |
|
|
2784 | Paint paint2 = new Paint(); |
|
|
2785 | paint2.setARGB(a, r, g, b); |
|
|
2786 | set_dashes(paint2, dashes, order); |
|
|
2787 | |
2467 | // Log.e("NavitGraphics","draw_polyline3"); |
2788 | //Log.e("NavitGraphics","draw_polyline3"); |
2468 | paint.setStyle(Paint.Style.STROKE); |
2789 | paint2.setStyle(Paint.Style.STROKE); |
2469 | b_paint_antialias = paint.isAntiAlias(); |
2790 | //b_paint_antialias = paint.isAntiAlias(); |
2470 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
2791 | paint2.setAntiAlias(Navit.PREF_use_anti_aliasing); |
2471 | wsave_003 = paint.getStrokeWidth(); |
2792 | //wsave_003 = paint.getStrokeWidth(); |
2472 | paint.setStrokeWidth(width); |
2793 | paint2.setStrokeWidth(width); |
2473 | |
2794 | |
2474 | if (order > DRAW_MORE_DETAILS_AT_ORDER) |
2795 | if (order > DRAW_MORE_DETAILS_AT_ORDER) |
2475 | { |
2796 | { |
2476 | paint.setStyle(Paint.Style.FILL); |
2797 | paint2.setStyle(Paint.Style.FILL); |
2477 | paint.setStrokeWidth(0); |
2798 | paint2.setStrokeWidth(0); |
2478 | draw_canvas.drawCircle(c[0], c[1], (width / 2), paint); |
2799 | draw_canvas.drawCircle(c[0], c[1], (width / 2), paint2); |
2479 | } |
2800 | } |
2480 | for (int i = 2; i < c.length; i += 2) |
2801 | for (int i = 2; i < c.length; i += 2) |
2481 | { |
2802 | { |
2482 | if (order > DRAW_MORE_DETAILS_AT_ORDER) |
2803 | if (order > DRAW_MORE_DETAILS_AT_ORDER) |
2483 | { |
2804 | { |
2484 | //if (i < (c.length - 2)) |
2805 | //if (i < (c.length - 2)) |
2485 | //{ |
2806 | //{ |
2486 | paint.setStyle(Paint.Style.FILL); |
2807 | paint2.setStyle(Paint.Style.FILL); |
2487 | paint.setStrokeWidth(0); |
2808 | paint2.setStrokeWidth(0); |
2488 | draw_canvas.drawCircle(c[i], c[i + 1], (width / 2), paint); |
2809 | draw_canvas.drawCircle(c[i], c[i + 1], (width / 2), paint2); |
2489 | //} |
2810 | //} |
2490 | paint.setStyle(Paint.Style.STROKE); |
2811 | paint2.setStyle(Paint.Style.STROKE); |
2491 | paint.setStrokeWidth(width); |
2812 | paint2.setStrokeWidth(width); |
2492 | } |
2813 | } |
2493 | draw_canvas.drawLine(c[i - 2], c[i - 1], c[i], c[i + 1], paint); |
2814 | draw_canvas.drawLine(c[i - 2], c[i - 1], c[i], c[i + 1], paint2); |
2494 | } |
2815 | } |
2495 | paint.setAntiAlias(b_paint_antialias); |
2816 | //paint.setAntiAlias(b_paint_antialias); |
2496 | paint.setStrokeWidth(wsave_003); |
2817 | //paint.setStrokeWidth(wsave_003); |
2497 | //paint.setPathEffect(dashed_map_lines__no_dash); |
|
|
2498 | } |
2818 | } |
2499 | |
2819 | |
2500 | // draw normal polylines -> this function gets called the most!! XX-thousand times |
2820 | // draw normal polylines -> this function gets called the most!! XX-thousand times |
2501 | // draw normal polylines -> this function gets called the most!! XX-thousand times |
2821 | // draw normal polylines -> this function gets called the most!! XX-thousand times |
2502 | // draw normal polylines -> this function gets called the most!! XX-thousand times |
2822 | // draw normal polylines -> this function gets called the most!! XX-thousand times |
2503 | |
2823 | |
2504 | protected void draw_polyline4__ORIG(Paint paint, int c[], int order, int width, int type) |
2824 | protected void draw_polyline4(int c[], int order, int width, int type, int dashes, int r, int g, int b, int a) |
2505 | { |
2825 | { |
2506 | // type:0 -> normal line |
2826 | // type:0 -> normal line |
2507 | // type:1 -> underground (tunnel) |
2827 | // type:1 -> underground (tunnel) |
2508 | // type:2 -> bridge |
2828 | // type:2 -> bridge |
2509 | |
2829 | |
|
|
2830 | if (type > 90) |
|
|
2831 | { |
|
|
2832 | if (type == 96) |
|
|
2833 | { |
|
|
2834 | //System.out.println("refresh map (layers)"); |
|
|
2835 | // draw_map_one_shot = true; |
|
|
2836 | //copy_map_buffer(); |
|
|
2837 | //draw_reset_factors = true; |
|
|
2838 | //view_s.postInvalidate(); |
|
|
2839 | } |
|
|
2840 | else if (type == 99) |
|
|
2841 | { |
|
|
2842 | //System.out.println("refresh map"); |
|
|
2843 | //// draw_map_one_shot = true; |
|
|
2844 | //copy_map_buffer(); |
|
|
2845 | //draw_reset_factors = true; |
|
|
2846 | //view_s.postInvalidate(); |
|
|
2847 | } |
|
|
2848 | else if (type == 95) |
|
|
2849 | { |
|
|
2850 | //System.out.println("cancel map"); |
|
|
2851 | // draw_map_one_shot = true; |
|
|
2852 | //copy_backwards_map_buffer(); |
|
|
2853 | //draw_reset_factors = true; |
|
|
2854 | //view_s.postInvalidate(); |
|
|
2855 | } |
|
|
2856 | return; |
|
|
2857 | } |
|
|
2858 | |
|
|
2859 | Paint paint2 = new Paint(); |
|
|
2860 | paint2.setARGB(a, r, g, b); |
|
|
2861 | set_dashes(paint2, dashes, order); |
|
|
2862 | |
2510 | b_paint_antialias = paint.isAntiAlias(); |
2863 | //b_paint_antialias = paint.isAntiAlias(); |
2511 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
2864 | paint2.setAntiAlias(Navit.PREF_use_anti_aliasing); |
2512 | wsave_004 = paint.getStrokeWidth(); |
2865 | //wsave_004 = paint.getStrokeWidth(); |
2513 | |
2866 | |
2514 | if (order <= DRAW_MORE_DETAILS_TUNNEL_BRIDGES_AT_ORDER) |
2867 | if (order <= DRAW_MORE_DETAILS_TUNNEL_BRIDGES_AT_ORDER) |
2515 | { |
2868 | { |
2516 | type = 0; |
2869 | type = 0; |
2517 | } |
2870 | } |
… | |
… | |
2519 | if (type == 2) |
2872 | if (type == 2) |
2520 | { |
2873 | { |
2521 | // bridge |
2874 | // bridge |
2522 | // |
2875 | // |
2523 | //int csave = paint.getColor(); |
2876 | //int csave = paint.getColor(); |
2524 | paint.setAlpha(120); // 0 .. 255 // 255 -> no seethru |
2877 | paint2.setAlpha(120); // 0 .. 255 // 255 -> no seethru |
2525 | paint.setStyle(Paint.Style.STROKE); |
2878 | paint2.setStyle(Paint.Style.STROKE); |
2526 | paint.setStrokeWidth(width + 2); |
2879 | paint2.setStrokeWidth(width + 2); |
2527 | // paint.setColor(Color.BLACK); |
2880 | // paint.setColor(Color.BLACK); |
2528 | if (order > DRAW_DETAIL_DASHES_AT_ORDER) |
2881 | if (order > DRAW_DETAIL_DASHES_AT_ORDER) |
2529 | { |
2882 | { |
2530 | paint.setStrokeWidth(width + 4); |
2883 | paint2.setStrokeWidth(width + 4); |
2531 | } |
2884 | } |
2532 | for (int i = 2; i < c.length; i += 2) |
2885 | for (int i = 2; i < c.length; i += 2) |
2533 | { |
2886 | { |
2534 | draw_canvas.drawLine(c[i - 2], c[i - 1], c[i], c[i + 1], paint); |
2887 | draw_canvas.drawLine(c[i - 2], c[i - 1], c[i], c[i + 1], paint2); |
2535 | } |
2888 | } |
2536 | //paint.setColor(csave); |
2889 | //paint.setColor(csave); |
2537 | |
2890 | |
2538 | // -- circles -- |
2891 | // -- circles -- |
2539 | /* |
2892 | /* |
… | |
… | |
2550 | */ |
2903 | */ |
2551 | // -- circles -- |
2904 | // -- circles -- |
2552 | } |
2905 | } |
2553 | |
2906 | |
2554 | // --------------------------------------- |
2907 | // --------------------------------------- |
2555 | paint.setStyle(Paint.Style.STROKE); |
2908 | paint2.setStyle(Paint.Style.STROKE); |
2556 | paint.setStrokeWidth(width); |
2909 | paint2.setStrokeWidth(width); |
2557 | |
2910 | |
2558 | if (type == 1) |
2911 | if (type == 1) |
2559 | { |
2912 | { |
2560 | // tunnel |
2913 | // tunnel |
2561 | paint.setAlpha(70); // 0 .. 255 // 255 -> no seethru |
2914 | paint2.setAlpha(70); // 0 .. 255 // 255 -> no seethru |
2562 | if (order > DRAW_DETAIL_DASHES_AT_ORDER) |
2915 | if (order > DRAW_DETAIL_DASHES_AT_ORDER) |
2563 | { |
2916 | { |
2564 | paint.setPathEffect(dashed_map_lines__low); |
2917 | paint2.setPathEffect(dashed_map_lines__low); |
2565 | } |
2918 | } |
2566 | else |
2919 | else |
2567 | { |
2920 | { |
2568 | paint.setPathEffect(dashed_map_lines__high); |
2921 | paint2.setPathEffect(dashed_map_lines__high); |
2569 | } |
2922 | } |
2570 | } |
2923 | } |
2571 | else if (type == 2) |
2924 | else if (type == 2) |
2572 | { |
2925 | { |
2573 | // bridge |
2926 | // bridge |
2574 | paint.setAlpha(70); // 0 .. 255 // 255 -> no seethru |
2927 | paint2.setAlpha(70); // 0 .. 255 // 255 -> no seethru |
2575 | } |
2928 | } |
2576 | |
2929 | |
2577 | paint.setStyle(Paint.Style.STROKE); |
2930 | paint2.setStyle(Paint.Style.STROKE); |
2578 | paint.setStrokeWidth(width); |
2931 | paint2.setStrokeWidth(width); |
2579 | for (int i = 2; i < c.length; i += 2) |
2932 | for (int i = 2; i < c.length; i += 2) |
2580 | { |
2933 | { |
2581 | draw_canvas.drawLine(c[i - 2], c[i - 1], c[i], c[i + 1], paint); |
2934 | draw_canvas.drawLine(c[i - 2], c[i - 1], c[i], c[i + 1], paint2); |
2582 | } |
2935 | } |
2583 | |
2936 | |
2584 | paint.setPathEffect(dashed_map_lines__no_dash); |
2937 | //paint.setPathEffect(dashed_map_lines__no_dash); |
2585 | paint.setAntiAlias(b_paint_antialias); |
2938 | //paint.setAntiAlias(b_paint_antialias); |
2586 | paint.setStrokeWidth(wsave_004); |
2939 | //paint.setStrokeWidth(wsave_004); |
2587 | } |
2940 | } |
2588 | |
2941 | |
2589 | protected void draw_polyline4(Paint paint, int c[], int order, int width, int type) |
2942 | protected void draw_polyline4__NEW(Paint paint, int c[], int order, int width, int type) |
2590 | { |
2943 | { |
2591 | if (dl_thread[0] == null) |
2944 | if (dl_thread[0] == null) |
2592 | { |
2945 | { |
2593 | int ii = 0; |
2946 | int ii = 0; |
2594 | for (ii = 0; ii < NavitGraphics.dl_thread_max; ii++) |
2947 | for (ii = 0; ii < NavitGraphics.dl_thread_max; ii++) |
… | |
… | |
2857 | //Log.e("NavitGraphics","draw_rectangle"); |
3210 | //Log.e("NavitGraphics","draw_rectangle"); |
2858 | Rect r = new Rect(x, y, x + w, y + h); |
3211 | Rect r = new Rect(x, y, x + w, y + h); |
2859 | paint.setStyle(Paint.Style.FILL); |
3212 | paint.setStyle(Paint.Style.FILL); |
2860 | b_paint_antialias = paint.isAntiAlias(); |
3213 | b_paint_antialias = paint.isAntiAlias(); |
2861 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
3214 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
2862 | //paint.setStrokeWidth(0); |
3215 | //paint.setStrokeWidth(0);d |
2863 | draw_canvas.drawRect(r, paint); |
3216 | draw_canvas.drawRect(r, paint); |
2864 | paint.setAntiAlias(b_paint_antialias); |
3217 | paint.setAntiAlias(b_paint_antialias); |
2865 | } |
3218 | } |
2866 | |
3219 | |
2867 | protected void draw_circle(Paint paint, int x, int y, int r) |
3220 | protected void draw_circle(Paint paint, int x, int y, int r) |
2868 | { |
3221 | { |
2869 | //Log.e("NavitGraphics","draw_circle"); |
3222 | // Log.e("NavitGraphics", "draw_circle " + x + " " + y + " " + r); |
2870 | // float fx = x; |
3223 | // float fx = x; |
2871 | // float fy = y; |
3224 | // float fy = y; |
2872 | // float fr = r / 2; |
3225 | // float fr = r / 2; |
2873 | paint.setStyle(Paint.Style.STROKE); |
3226 | paint.setStyle(Paint.Style.STROKE); |
2874 | b_paint_antialias = paint.isAntiAlias(); |
3227 | b_paint_antialias = paint.isAntiAlias(); |
2875 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
3228 | paint.setAntiAlias(Navit.PREF_use_anti_aliasing); |
2876 | draw_canvas.drawCircle(x, y, r / 2, paint); |
3229 | draw_canvas.drawCircle(x, y, r / 2, paint); |
2877 | paint.setAntiAlias(b_paint_antialias); |
3230 | paint.setAntiAlias(b_paint_antialias); |
2878 | } |
3231 | } |
2879 | |
3232 | |
2880 | protected void draw_text(Paint paint, int x, int y, String text, int size, int dx, int dy) |
3233 | protected void draw_text__NEW(Paint paint, int x, int y, String text, int size, int dx, int dy) |
2881 | { |
3234 | { |
2882 | if (dl_thread[0] == null) |
3235 | if (dl_thread[0] == null) |
2883 | { |
3236 | { |
2884 | int ii = 0; |
3237 | int ii = 0; |
2885 | for (ii = 0; ii < NavitGraphics.dl_thread_max; ii++) |
3238 | for (ii = 0; ii < NavitGraphics.dl_thread_max; ii++) |
… | |
… | |
2905 | if (paint.getTypeface() == null) |
3258 | if (paint.getTypeface() == null) |
2906 | { |
3259 | { |
2907 | try |
3260 | try |
2908 | { |
3261 | { |
2909 | paint.setTypeface(Navit.NavitStreetnameFont); |
3262 | paint.setTypeface(Navit.NavitStreetnameFont); |
2910 | System.out.println("Calling setTypeface"); |
3263 | //System.out.println("Calling setTypeface"); |
2911 | } |
3264 | } |
2912 | catch (Exception e) |
3265 | catch (Exception e) |
2913 | { |
3266 | { |
2914 | //e.printStackTrace(); |
3267 | //e.printStackTrace(); |
2915 | } |
3268 | } |
… | |
… | |
2974 | if (paint.getTypeface() == null) |
3327 | if (paint.getTypeface() == null) |
2975 | { |
3328 | { |
2976 | try |
3329 | try |
2977 | { |
3330 | { |
2978 | paint.setTypeface(Navit.NavitStreetnameFont); |
3331 | paint.setTypeface(Navit.NavitStreetnameFont); |
2979 | System.out.println("Calling setTypeface"); |
3332 | //System.out.println("Calling setTypeface"); |
2980 | } |
3333 | } |
2981 | catch (Exception e) |
3334 | catch (Exception e) |
2982 | { |
3335 | { |
2983 | //e.printStackTrace(); |
3336 | //e.printStackTrace(); |
2984 | } |
3337 | } |
… | |
… | |
3007 | paint.setTextAlign(android.graphics.Paint.Align.LEFT); |
3360 | paint.setTextAlign(android.graphics.Paint.Align.LEFT); |
3008 | draw_canvas_s.drawTextOnPath(text, b_paint_path_, 0, 0, paint); |
3361 | draw_canvas_s.drawTextOnPath(text, b_paint_path_, 0, 0, paint); |
3009 | } |
3362 | } |
3010 | } |
3363 | } |
3011 | |
3364 | |
3012 | protected void draw_text__ORIG(Paint paint, int x, int y, String text, int size, int dx, int dy) |
3365 | protected void draw_text(Paint paint, int x, int y, String text, int size, int dx, int dy) |
3013 | { |
3366 | { |
3014 | // float fx = x; |
3367 | // float fx = x; |
3015 | // float fy = y; |
3368 | // float fy = y; |
3016 | //Log.e("NavitGraphics","Text size "+size + " vs " + paint.getTextSize()); |
3369 | //Log.e("NavitGraphics","Text size "+size + " vs " + paint.getTextSize()); |
3017 | if (Navit.PREF_map_font_size != 2) |
3370 | if (Navit.PREF_map_font_size != 2) |
… | |
… | |
3055 | if (paint.getTypeface() == null) |
3408 | if (paint.getTypeface() == null) |
3056 | { |
3409 | { |
3057 | try |
3410 | try |
3058 | { |
3411 | { |
3059 | paint.setTypeface(Navit.NavitStreetnameFont); |
3412 | paint.setTypeface(Navit.NavitStreetnameFont); |
3060 | System.out.println("Calling setTypeface"); |
3413 | //System.out.println("Calling setTypeface"); |
3061 | } |
3414 | } |
3062 | catch (Exception e) |
3415 | catch (Exception e) |
3063 | { |
3416 | { |
3064 | //e.printStackTrace(); |
3417 | //e.printStackTrace(); |
3065 | } |
3418 | } |
… | |
… | |
3291 | bigmap_bitmap_temp.recycle(); |
3644 | bigmap_bitmap_temp.recycle(); |
3292 | bigmap_bitmap_temp = null; |
3645 | bigmap_bitmap_temp = null; |
3293 | } |
3646 | } |
3294 | } |
3647 | } |
3295 | |
3648 | |
3296 | 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) |
3649 | public static 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) |
3297 | { |
3650 | { |
3298 | //System.out.println("NavitOSDJava:" + id + " " + text1 + " " + text2 + " " + text3 + " " + i1 + " " + i2 + " " + i3 + " " + i4 + " " + f1 + " " + f2 + " " + f3); |
3651 | //System.out.println("NavitOSDJava:" + id + " " + text1 + " " + text2 + " " + text3 + " " + i1 + " " + i2 + " " + i3 + " " + i4 + " " + f1 + " " + f2 + " " + f3); |
3299 | //System.out.println("NavitOSDJava:" + last_paint_OSD); |
3652 | //System.out.println("NavitOSDJava:" + last_paint_OSD); |
3300 | Boolean needed_value = false; |
3653 | Boolean needed_value = false; |
3301 | try |
3654 | try |
… | |
… | |
3528 | } |
3881 | } |
3529 | } |
3882 | } |
3530 | |
3883 | |
3531 | static void copy_map_buffer() |
3884 | static void copy_map_buffer() |
3532 | { |
3885 | { |
|
|
3886 | // stop any smooth drawing/moving first! |
|
|
3887 | Global_SmoothDrawing_stop = true; |
|
|
3888 | |
|
|
3889 | //System.out.println("DO__DRAW:Java:reset GLOBAL factors"); |
|
|
3890 | Global_Map_TransX = 0; |
|
|
3891 | Global_Map_TransY = 0; |
|
|
3892 | Global_Map_Rotationangle = 0f; |
|
|
3893 | Global_Map_Zoomfactor = 1.0f; |
|
|
3894 | try |
|
|
3895 | { |
3533 | draw_canvas_screen_s.drawBitmap(draw_bitmap_s, 0, 0, null); |
3896 | draw_canvas_screen_s.drawBitmap(draw_bitmap_s, 0, 0, null); |
|
|
3897 | } |
|
|
3898 | catch (Exception e) |
|
|
3899 | { |
|
|
3900 | // if screen is rotated, bitmaps are not valid, and this would crash |
|
|
3901 | // find a better solution later!! |
|
|
3902 | } |
3534 | } |
3903 | } |
3535 | |
3904 | |
|
|
3905 | static void copy_backwards_map_buffer() |
|
|
3906 | { |
|
|
3907 | // draw_canvas_screen_s.drawColor(Color.parseColor("#FEF9EE")); // fill with yellow-ish bg color |
|
|
3908 | |
|
|
3909 | //if (ZOOM_MODE_ACTIVE) |
|
|
3910 | //{ |
|
|
3911 | // draw_canvas_screen_s.save(); |
|
|
3912 | // draw_canvas_screen_s.scale(ZOOM_MODE_SCALE, ZOOM_MODE_SCALE, touch_now_center.x, touch_now_center.y); |
|
|
3913 | //} |
|
|
3914 | //draw_canvas_screen_s.drawBitmap(draw_bitmap_screen_s, pos_x, pos_y, null); |
|
|
3915 | //if (ZOOM_MODE_ACTIVE) |
|
|
3916 | //{ |
|
|
3917 | // draw_canvas_screen_s.restore(); |
|
|
3918 | //} |
|
|
3919 | } |
|
|
3920 | |
3536 | protected void draw_mode(int mode) |
3921 | protected void draw_mode(int mode) |
3537 | { |
3922 | { |
3538 | //Log.e("NavitGraphics", "draw_mode mode=" + mode + " parent_graphics=" |
3923 | //Log.e("NavitGraphics", "draw_mode mode=" + mode + " parent_graphics=" + String.valueOf(parent_graphics)); |
3539 | // + String.valueOf(parent_graphics)); |
|
|
3540 | |
3924 | |
3541 | if (mode == 2 && parent_graphics == null) |
|
|
3542 | { |
|
|
3543 | // view.invalidate(); |
|
|
3544 | } |
|
|
3545 | |
|
|
3546 | if (mode == 1 || (mode == 0 && parent_graphics != null)) |
3925 | if (mode == 1 || (mode == 0 && parent_num != 0)) |
3547 | { |
3926 | { |
3548 | draw_bitmap.eraseColor(0); |
3927 | draw_bitmap.eraseColor(0); |
3549 | } |
3928 | } |
3550 | |
3929 | |
|
|
3930 | //if ((parent_num != 0) && ((mode == 2) || (mode == 4))) |
|
|
3931 | //{ |
|
|
3932 | // vehicle graphics overlay |
|
|
3933 | // copy_map_buffer(); |
|
|
3934 | // Paint paint43 = new Paint(); |
|
|
3935 | // paint43.setStyle(Paint.Style.STROKE); |
|
|
3936 | // paint43.setAntiAlias(Navit.PREF_use_anti_aliasing); |
|
|
3937 | // paint43.setStrokeWidth(12); |
|
|
3938 | // paint43.setColor(Color.RED); |
|
|
3939 | // draw_canvas.drawLine(0, 0, 50, 50, paint43); |
|
|
3940 | //} |
|
|
3941 | |
3551 | } |
3942 | } |
3552 | |
3943 | |
3553 | protected void draw_drag(int x, int y) |
3944 | protected void draw_drag(int x, int y) |
3554 | { |
3945 | { |
3555 | //Log.e("NavitGraphics","draw_drag"); |
3946 | // Log.e("NavitGraphics","draw_drag"+pos_x+" "+pos_y+" "+x+" "+y); |
3556 | pos_x = x; |
3947 | pos_x = x; |
3557 | pos_y = y; |
3948 | pos_y = y; |
3558 | } |
3949 | } |
3559 | |
3950 | |
3560 | protected void overlay_disable(int disable) |
3951 | protected void overlay_disable(int disable) |
3561 | { |
3952 | { |
|
|
3953 | // UNUSED ------ |
|
|
3954 | |
3562 | //Log.e("NavitGraphics","overlay_disable"); |
3955 | //Log.e("NavitGraphics","overlay_disable"); |
3563 | // assume we are NOT in map view mode! |
3956 | // assume we are NOT in map view mode! |
3564 | // -> always in map mode now !!!! # in_map = false; |
3957 | // -> always in map mode now !!!! # in_map = false; |
3565 | |
3958 | |
3566 | // check if overlay has been initialized yet |
3959 | // check if overlay has been initialized yet |
3567 | //if (NavitAOverlay != null) |
3960 | //if (NavitAOverlay != null) |
3568 | //{ |
3961 | //{ |
3569 | // NavitAOverlay.hide_bubble(); |
3962 | // NavitAOverlay.hide_bubble(); |
3570 | //} |
3963 | //} |
3571 | |
3964 | |
3572 | overlay_disabled = disable; |
3965 | // overlay_disabled = disable; |
3573 | } |
3966 | } |
3574 | |
3967 | |
3575 | protected void overlay_resize(int x, int y, int w, int h, int alpha, int wraparond) |
3968 | protected void overlay_resize(int x, int y, int w, int h, int alpha, int wraparond) |
3576 | { |
3969 | { |
3577 | //Log.e("NavitGraphics","overlay_resize"); |
3970 | // UNUSED ------ |
|
|
3971 | |
|
|
3972 | //Log.e("NavitGraphics", "overlay_resize: " + x + "" + y + "" + w + "" + h); |
3578 | pos_x = x; |
3973 | //pos_x = x; |
3579 | pos_y = y; |
3974 | //pos_y = y; |
3580 | } |
3975 | } |
3581 | |
3976 | |
3582 | public static String getLocalizedString(String text) |
3977 | public static String getLocalizedString(String text) |
3583 | { |
3978 | { |
3584 | String ret = CallbackLocalizedString(text); |
3979 | String ret = CallbackLocalizedString(text); |
… | |
… | |
4473 | } |
4868 | } |
4474 | |
4869 | |
4475 | /** |
4870 | /** |
4476 | * generic message channel to C-code |
4871 | * generic message channel to C-code |
4477 | */ |
4872 | */ |
4478 | public static native int CallbackMessageChannel(int i, String s); |
4873 | public static native void CallbackMessageChannelReal(int i, String s); |
|
|
4874 | |
|
|
4875 | public static native int GetThreadId(); |
|
|
4876 | |
|
|
4877 | public static void CallbackMessageChannel(int i, String s) |
|
|
4878 | { |
|
|
4879 | Navit.cwthr.CallbackMessageChannel(i, s); |
|
|
4880 | } |
4479 | |
4881 | |
4480 | /** |
4882 | /** |
4481 | * return search result from C-code |
4883 | * return search result from C-code |
4482 | */ |
4884 | */ |
4483 | public void fillStringArray(String s) |
4885 | public void fillStringArray(String s) |
… | |
… | |
4584 | // |
4986 | // |
4585 | // |
4987 | // |
4586 | // |
4988 | // |
4587 | // get route_status value from C-lib |
4989 | // get route_status value from C-lib |
4588 | /* |
4990 | /* |
|
|
4991 | * |
|
|
4992 | * 0 -> 1 -> 13 -> 5 -> 17 -> 5 ... 33 -> 5 -> 33 -> 5 ... |
|
|
4993 | * |
4589 | * route_status_no_destination=0, # 0 --> no dest. set |
4994 | * route_status_no_destination=0, # 0 --> no dest. set |
4590 | * route_status_destination_set=1, # 1 |
4995 | * route_status_destination_set=1, # 1 |
4591 | * route_status_not_found=1|2, # 3 --> no route to destination found / route blocked |
4996 | * route_status_not_found=1|2, # 3 --> no route to destination found / route blocked |
4592 | * route_status_building_path=1|4, # 5 |
4997 | * route_status_building_path=1|4, # 5 |
4593 | * route_status_building_graph=1|4|8, # 13 |
4998 | * route_status_building_graph=1|4|8, # 13 |
… | |
… | |
4625 | CallbackMessageChannel(55, s); |
5030 | CallbackMessageChannel(55, s); |
4626 | } |
5031 | } |
4627 | else if (msg.getData().getInt("Callback") == 9901) |
5032 | else if (msg.getData().getInt("Callback") == 9901) |
4628 | { |
5033 | { |
4629 | // if follow mode is on, then dont show freeview streetname |
5034 | // if follow mode is on, then dont show freeview streetname |
4630 | if (!Navit.PREF_follow_gps) |
5035 | //if (!Navit.PREF_follow_gps) |
4631 | { |
5036 | //{ |
4632 | Navit.OSD_nextturn.nextturn_streetname_systematic = ""; |
|
|
4633 | |
|
|
4634 | Navit.OSD_nextturn.nextturn_streetname = NavitGraphics.CallbackGeoCalc(8, mCanvasWidth / 2, mCanvasHeight / 2); |
|
|
4635 | |
|
|
4636 | if (Navit.PREF_item_dump) |
|
|
4637 | { |
|
|
4638 | // -------- DEBUG ------- DEBUG --------- |
|
|
4639 | // -------- DEBUG ------- DEBUG --------- |
|
|
4640 | // -------- DEBUG ------- DEBUG --------- |
|
|
4641 | Navit.debug_item_dump = NavitGraphics.CallbackGeoCalc(9, mCanvasWidth / 2, mCanvasHeight / 2); |
5037 | // Navit.cwthr.CallbackGeoCalc2(1, 0, mCanvasWidth / 2, mCanvasHeight / 2); |
4642 | // -------- DEBUG ------- DEBUG --------- |
|
|
4643 | // -------- DEBUG ------- DEBUG --------- |
|
|
4644 | // -------- DEBUG ------- DEBUG --------- |
|
|
4645 | } |
5038 | //} |
4646 | |
|
|
4647 | // System.out.println("location:" + Navit.OSD_nextturn.nextturn_streetname); |
|
|
4648 | NavitAOSDJava_.postInvalidate(); |
|
|
4649 | } |
5039 | } |
|
|
5040 | else if (msg.getData().getInt("Callback") == 98001) |
|
|
5041 | { |
|
|
5042 | int id = msg.getData().getInt("id"); |
|
|
5043 | int i = msg.getData().getInt("i"); |
|
|
5044 | return_generic_int_real(id, i); |
|
|
5045 | } |
|
|
5046 | else if (msg.getData().getInt("Callback") == 9001) |
|
|
5047 | { |
|
|
5048 | busyspinner_.setVisibility(View.INVISIBLE); |
|
|
5049 | busyspinnertext_.setVisibility(View.INVISIBLE); |
|
|
5050 | } |
|
|
5051 | else if (msg.getData().getInt("Callback") == 9002) |
|
|
5052 | { |
|
|
5053 | busyspinner_.setVisibility(View.VISIBLE); |
|
|
5054 | busyspinnertext_.setVisibility(View.VISIBLE); |
4650 | } |
5055 | } |
4651 | } |
5056 | } |
4652 | }; |
5057 | }; |
4653 | |
5058 | |
4654 | // |
5059 | // |
… | |
… | |
4659 | // i=2 -> geo a,b (lat,lng) -> pixel string "x(int)#y(int)" |
5064 | // i=2 -> geo a,b (lat,lng) -> pixel string "x(int)#y(int)" |
4660 | public static native String CallbackGeoCalc(int i, float a, float b); |
5065 | public static native String CallbackGeoCalc(int i, float a, float b); |
4661 | |
5066 | |
4662 | public static void send_generic_text(int id, String text) |
5067 | public static void send_generic_text(int id, String text) |
4663 | { |
5068 | { |
|
|
5069 | //System.out.println("send_generic_text"); |
|
|
5070 | |
4664 | if (id == 1) |
5071 | if (id == 1) |
4665 | { |
5072 | { |
4666 | // speech textblock |
5073 | // speech textblock |
4667 | if (NavitGraphics.NavitMsgTv2_.getVisibility() == View.VISIBLE) |
5074 | if (NavitGraphics.NavitMsgTv2_.getVisibility() == View.VISIBLE) |
4668 | { |
5075 | { |
… | |
… | |
4671 | } |
5078 | } |
4672 | } |
5079 | } |
4673 | |
5080 | |
4674 | public static void return_generic_int(int id, int i) |
5081 | public static void return_generic_int(int id, int i) |
4675 | { |
5082 | { |
|
|
5083 | try |
|
|
5084 | { |
|
|
5085 | Message msg1 = new Message(); |
|
|
5086 | Bundle b1 = new Bundle(); |
|
|
5087 | b1.putInt("Callback", 98001); |
|
|
5088 | b1.putInt("id", id); |
|
|
5089 | b1.putInt("i", i); |
|
|
5090 | msg1.setData(b1); |
|
|
5091 | NavitGraphics.callback_handler_s.sendMessage(msg1); |
|
|
5092 | } |
|
|
5093 | catch (Exception e) |
|
|
5094 | { |
|
|
5095 | } |
|
|
5096 | } |
|
|
5097 | |
|
|
5098 | public static void set_vehicle_values(int x, int y, int angle, int speed) |
|
|
5099 | { |
|
|
5100 | // stop any smooth drawing/moving first! |
|
|
5101 | //System.out.println("set vehicle pos..."); |
|
|
5102 | //--> don't set here // Global_SmoothDrawing_stop = true; |
|
|
5103 | last_vehicle_position_timestamp = System.currentTimeMillis(); |
|
|
5104 | |
|
|
5105 | Navit.NG__vehicle.vehicle_speed = speed; |
|
|
5106 | Navit.NG__vehicle.vehicle_pos_x = x; |
|
|
5107 | Navit.NG__vehicle.vehicle_pos_y = y; |
|
|
5108 | Navit.NG__vehicle.vehicle_direction = angle; |
|
|
5109 | } |
|
|
5110 | |
|
|
5111 | public static int ddx_last = 0; |
|
|
5112 | public static int ddy_last = 0; |
|
|
5113 | public static float dda_last = 0; |
|
|
5114 | public static float ddx = 0; |
|
|
5115 | public static float ddy = 0; |
|
|
5116 | public static float dda = 0f; |
|
|
5117 | public static long last_vehicle_position_timestamp = 0L; |
|
|
5118 | public static final int Vehicle_updates_interval = 1000; // normal android phone gives position every 1000ms (=1 sec) |
|
|
5119 | public static int Vehicle_smooth_moves_count = 3; // how many intermediate moves do we want to draw |
|
|
5120 | public static int Vehicle_smooth_move_delay = 180; |
|
|
5121 | public static final int max_turn_angle = 190; |
|
|
5122 | |
|
|
5123 | public static void set_vehicle_values_delta(int dx, int dy, int dangle2) |
|
|
5124 | { |
|
|
5125 | Navit.NG__vehicle.vehicle_pos_x_delta = dx; |
|
|
5126 | Navit.NG__vehicle.vehicle_pos_y_delta = dy; |
|
|
5127 | int dangle = dangle2; |
|
|
5128 | if (dangle2 > max_turn_angle) |
|
|
5129 | { |
|
|
5130 | // try to turn the correct way, sometimes there seems to be errors! |
|
|
5131 | dangle = dangle2 - 360; |
|
|
5132 | } |
|
|
5133 | else if (dangle2 < -max_turn_angle) |
|
|
5134 | { |
|
|
5135 | // try to turn the correct way, sometimes there seems to be errors! |
|
|
5136 | dangle = dangle2 + 360; |
|
|
5137 | } |
|
|
5138 | |
|
|
5139 | Navit.NG__vehicle.vehicle_direction_delta = dangle; |
|
|
5140 | |
|
|
5141 | Global_SmoothDrawing_stop = false; |
|
|
5142 | |
|
|
5143 | if (!Navit.PREF_use_smooth_drawing) |
|
|
5144 | { |
|
|
5145 | // disbaled via prefs |
|
|
5146 | return; |
|
|
5147 | } |
|
|
5148 | |
|
|
5149 | //if (Navit.NG__vehicle.vehicle_speed < 3) |
|
|
5150 | //{ |
|
|
5151 | // // too slow, dont use smooth moving |
|
|
5152 | // return; |
|
|
5153 | //} |
|
|
5154 | |
|
|
5155 | if (Navit.NG__vehicle.vehicle_speed > 12) |
|
|
5156 | { |
|
|
5157 | Vehicle_smooth_moves_count = 4; |
|
|
5158 | Vehicle_smooth_move_delay = 210; |
|
|
5159 | } |
|
|
5160 | else |
|
|
5161 | { |
|
|
5162 | Vehicle_smooth_moves_count = 3; |
|
|
5163 | Vehicle_smooth_move_delay = 160; |
|
|
5164 | } |
|
|
5165 | |
|
|
5166 | if (System.currentTimeMillis() > last_vehicle_position_timestamp + 2100L) |
|
|
5167 | { |
|
|
5168 | // last vehicle position was too long ago (2.1 secs ago, or longer) |
|
|
5169 | return; |
|
|
5170 | } |
|
|
5171 | |
|
|
5172 | if (Global_onTouch_fingerdown) |
|
|
5173 | { |
|
|
5174 | // dont use smooth moving while user moves the map |
|
|
5175 | return; |
|
|
5176 | } |
|
|
5177 | |
|
|
5178 | //System.out.println("angle1:dx=" + dx + " dy=" + dy + " da=" + dangle2); |
|
|
5179 | //System.out.println("angle2:dx=" + dx + " dy=" + dy + " da=" + dangle); |
|
|
5180 | |
|
|
5181 | if ((Math.abs(dangle) < 2) && (Math.abs(dx) < 1) && (Math.abs(dy) < 1)) |
|
|
5182 | { |
|
|
5183 | // the move is very small only |
|
|
5184 | return; |
|
|
5185 | } |
|
|
5186 | |
|
|
5187 | dda = (float) dangle / (float) (Vehicle_smooth_moves_count); |
|
|
5188 | dda_last = dangle - (Vehicle_smooth_moves_count * dda); |
|
|
5189 | |
|
|
5190 | ddx = dx / (float) (Vehicle_smooth_moves_count); |
|
|
5191 | ddy = dy / (float) (Vehicle_smooth_moves_count); |
|
|
5192 | ddx_last = dx - Vehicle_smooth_moves_count * ((int) ddx); |
|
|
5193 | ddy_last = dy - Vehicle_smooth_moves_count * ((int) ddy); |
|
|
5194 | |
|
|
5195 | //System.out.println("angle:ddx=" + ddx + " ddy=" + ddy + " dda=" + dda); |
|
|
5196 | //System.out.println("angle:ddx_l=" + ddx_last + " ddy_l=" + ddy_last + " dda_l=" + dda_last); |
|
|
5197 | |
|
|
5198 | // now move the map (to have smooth driving) |
|
|
5199 | //System.out.println("--set_vehicle_values_delta-- START"); |
|
|
5200 | final Thread t = new Thread(new Runnable() |
|
|
5201 | { |
|
|
5202 | int cur_count = 0; |
|
|
5203 | |
|
|
5204 | public void run() |
|
|
5205 | { |
|
|
5206 | for (cur_count = 0; cur_count < Vehicle_smooth_moves_count; cur_count++) |
|
|
5207 | { |
|
|
5208 | if (Global_SmoothDrawing_stop == false) |
|
|
5209 | { |
|
|
5210 | // dont delay the first smooth move! |
|
|
5211 | if (cur_count != 0) |
|
|
5212 | { |
|
|
5213 | try |
|
|
5214 | { |
|
|
5215 | Thread.sleep(Vehicle_smooth_move_delay); |
|
|
5216 | } |
|
|
5217 | catch (InterruptedException e) |
|
|
5218 | { |
|
|
5219 | // e.printStackTrace(); |
|
|
5220 | } |
|
|
5221 | } |
|
|
5222 | |
|
|
5223 | } |
|
|
5224 | |
|
|
5225 | if (Global_SmoothDrawing_stop == false) |
|
|
5226 | { |
|
|
5227 | //System.out.println("smooth move #" + (cur_count + 1) + " delay=" + Vehicle_smooth_move_delay); |
|
|
5228 | if (cur_count == (Vehicle_smooth_moves_count - 1)) |
|
|
5229 | { |
|
|
5230 | Global_Map_TransX = Global_Map_TransX - ddx_last; |
|
|
5231 | Global_Map_TransY = Global_Map_TransY - ddy_last; |
|
|
5232 | Global_Map_Rotationangle = Global_Map_Rotationangle - dda_last; |
|
|
5233 | } |
|
|
5234 | else |
|
|
5235 | { |
|
|
5236 | Global_Map_TransX = Global_Map_TransX - (int) (ddx); |
|
|
5237 | Global_Map_TransY = Global_Map_TransY - (int) (ddy); |
|
|
5238 | Global_Map_Rotationangle = Global_Map_Rotationangle - dda; |
|
|
5239 | } |
|
|
5240 | Navit.NG__map_main.view.postInvalidate(); |
|
|
5241 | } |
|
|
5242 | } |
|
|
5243 | //System.out.println("--set_vehicle_values_delta-- SLEEP - END"); |
|
|
5244 | } |
|
|
5245 | }); |
|
|
5246 | t.start(); |
|
|
5247 | //System.out.println("translate, rotate"); |
|
|
5248 | //System.out.println("--set_vehicle_values_delta-- END"); |
|
|
5249 | } |
|
|
5250 | |
|
|
5251 | public static void return_generic_int_real(int id, int i) |
|
|
5252 | { |
4676 | // System.out.println("id=" + id + " i=" + i); |
5253 | //System.out.println("id=" + id + " i=" + i); |
4677 | |
5254 | |
4678 | if (id == 1) |
5255 | if (id == 1) |
4679 | { |
5256 | { |
4680 | // id=1 -> route_status |
5257 | // id=1 -> route_status |
4681 | NavitGraphics.navit_route_status = i; |
5258 | NavitGraphics.navit_route_status = i; |
4682 | if (i == 0) |
5259 | if (i == 0) |
4683 | { |
5260 | { |
4684 | ZANaviBusySpinner.active = false; |
5261 | ZANaviBusySpinner.active = false; |
4685 | ZANaviBusySpinner.cancelAnim(); |
5262 | ZANaviBusySpinner.cancelAnim(); |
4686 | busyspinner_.setVisibility(View.INVISIBLE); |
5263 | busyspinner_.setVisibility(View.INVISIBLE); |
|
|
5264 | busyspinnertext_.setVisibility(View.INVISIBLE); |
4687 | busyspinnertext_.setText(""); |
5265 | busyspinnertext_.setText(""); |
4688 | busyspinnertext_.setVisibility(View.INVISIBLE); |
|
|
4689 | Navit.set_debug_messages1(""); |
5266 | Navit.set_debug_messages1(""); |
4690 | } |
5267 | } |
4691 | else if (i == 1) |
5268 | else if (i == 1) |
4692 | { |
5269 | { |
4693 | ZANaviBusySpinner.active = true; |
5270 | ZANaviBusySpinner.active = true; |
|
|
5271 | busyspinnertext_.setText(Navit.get_text("Destination set")); // TRANS |
4694 | busyspinner_.setVisibility(View.VISIBLE); |
5272 | busyspinner_.setVisibility(View.VISIBLE); |
|
|
5273 | busyspinnertext_.setVisibility(View.VISIBLE); |
|
|
5274 | //System.out.println("invalidate 017"); |
4695 | busyspinner_.postInvalidate(); |
5275 | busyspinner_.postInvalidate(); |
4696 | busyspinnertext_.setText(Navit.get_text("Destination set")); // TRANS |
|
|
4697 | busyspinnertext_.setVisibility(View.VISIBLE); |
|
|
4698 | Navit.set_debug_messages1("Destination set"); |
5276 | Navit.set_debug_messages1("Destination set"); |
4699 | } |
5277 | } |
4700 | else if (i == 3) |
5278 | else if (i == 3) |
4701 | { |
5279 | { |
4702 | ZANaviBusySpinner.active = true; |
5280 | ZANaviBusySpinner.active = true; |
… | |
… | |
4706 | busyspinnertext_.setVisibility(View.VISIBLE); |
5284 | busyspinnertext_.setVisibility(View.VISIBLE); |
4707 | Navit.set_debug_messages1("No route found / Route blocked"); |
5285 | Navit.set_debug_messages1("No route found / Route blocked"); |
4708 | } |
5286 | } |
4709 | else if (i == 5) |
5287 | else if (i == 5) |
4710 | { |
5288 | { |
|
|
5289 | // status "5" is now ignored in c-code!!! |
4711 | ZANaviBusySpinner.active = true; |
5290 | ZANaviBusySpinner.active = true; |
4712 | busyspinner_.setVisibility(View.VISIBLE); |
5291 | busyspinner_.setVisibility(View.VISIBLE); |
|
|
5292 | //System.out.println("invalidate 018"); |
4713 | busyspinner_.postInvalidate(); |
5293 | busyspinner_.postInvalidate(); |
4714 | busyspinnertext_.setText(Navit.get_text("Building route path")); // TRANS |
5294 | busyspinnertext_.setText(Navit.get_text("Building route path")); // TRANS |
4715 | busyspinnertext_.setVisibility(View.VISIBLE); |
5295 | busyspinnertext_.setVisibility(View.VISIBLE); |
4716 | Navit.set_debug_messages1("Building route path"); |
5296 | Navit.set_debug_messages1("Building route path"); |
4717 | } |
5297 | } |
4718 | else if (i == 13) |
5298 | else if (i == 13) |
4719 | { |
5299 | { |
4720 | ZANaviBusySpinner.active = true; |
5300 | ZANaviBusySpinner.active = true; |
4721 | busyspinner_.setVisibility(View.VISIBLE); |
5301 | busyspinner_.setVisibility(View.VISIBLE); |
|
|
5302 | //System.out.println("invalidate 019"); |
4722 | busyspinner_.postInvalidate(); |
5303 | busyspinner_.postInvalidate(); |
4723 | busyspinnertext_.setText(Navit.get_text("Building route graph")); // TRANS |
5304 | busyspinnertext_.setText(Navit.get_text("Building route graph")); // TRANS |
4724 | busyspinnertext_.setVisibility(View.VISIBLE); |
5305 | busyspinnertext_.setVisibility(View.VISIBLE); |
4725 | Navit.set_debug_messages1("Building route graph"); |
5306 | Navit.set_debug_messages1("Building route graph"); |
4726 | } |
5307 | } |
… | |
… | |
4743 | Navit.set_debug_messages1("Route found"); |
5324 | Navit.set_debug_messages1("Route found"); |
4744 | } |
5325 | } |
4745 | } |
5326 | } |
4746 | else if (id == 2) |
5327 | else if (id == 2) |
4747 | { |
5328 | { |
|
|
5329 | if (i == 1) |
|
|
5330 | { |
4748 | // id=2 -> map draw finished |
5331 | // id=2,1 -> map draw finished |
4749 | if (DEBUG_TOUCH) System.out.println("wait_for_redraw_map=false xx1"); |
5332 | if (DEBUG_TOUCH) System.out.println("wait_for_redraw_map=false xx1"); |
4750 | NavitGraphics.wait_for_redraw_map = false; |
5333 | NavitGraphics.wait_for_redraw_map = false; |
4751 | try |
5334 | try |
4752 | { |
5335 | { |
4753 | NavitAndroidOverlay.overlay_draw_thread1.stop_redraw(); |
5336 | //NavitAndroidOverlay.overlay_draw_thread1.stop_redraw(); |
4754 | NavitAndroidOverlay.overlay_draw_thread1.stop_me(); |
5337 | //NavitAndroidOverlay.overlay_draw_thread1.stop_me(); |
4755 | NavitAndroidOverlay.overlay_draw_thread1 = null; |
5338 | //NavitAndroidOverlay.overlay_draw_thread1 = null; |
4756 | } |
5339 | } |
4757 | catch (Exception e) |
5340 | catch (Exception e) |
4758 | { |
5341 | { |
4759 | // e.printStackTrace(); |
5342 | // e.printStackTrace(); |
4760 | } |
5343 | } |
4761 | try |
5344 | try |
4762 | { |
5345 | { |
4763 | System.out.println("remove wait text"); |
5346 | //System.out.println("DO__DRAW:Java:remove wait text"); |
|
|
5347 | //System.out.println("invalidate 020"); |
4764 | NavitAOverlay_s.postInvalidate(); |
5348 | NavitAOverlay_s.postInvalidate(); |
4765 | } |
5349 | } |
4766 | catch (Exception e) |
5350 | catch (Exception e) |
4767 | { |
5351 | { |
4768 | e.printStackTrace(); |
5352 | e.printStackTrace(); |
|
|
5353 | } |
|
|
5354 | } |
|
|
5355 | else if (i == 3) |
|
|
5356 | { |
|
|
5357 | // id=2,3 -> mapdraw cancel signal |
|
|
5358 | //System.out.println("DO__DRAW:Java:cancel map"); |
|
|
5359 | // draw_map_one_shot = true; |
|
|
5360 | //copy_backwards_map_buffer(); |
|
|
5361 | //draw_reset_factors = true; |
|
|
5362 | //view_s.postInvalidate(); |
|
|
5363 | |
|
|
5364 | } |
|
|
5365 | else if (i == 2) |
|
|
5366 | { |
|
|
5367 | // id=2,2 -> mapdraw ready signal |
|
|
5368 | //System.out.println("DO__DRAW:Java:refresh map"); |
|
|
5369 | // draw_map_one_shot = true; |
|
|
5370 | |
|
|
5371 | if ((Navit.PREF_use_smooth_drawing) && (Navit.NG__vehicle.vehicle_speed > 12)) |
|
|
5372 | { |
|
|
5373 | // delay vehicle and map update just a tiny little bit here!! -- very experimental, also delays gps position !!! |
|
|
5374 | final Thread t2 = new Thread(new Runnable() |
|
|
5375 | { |
|
|
5376 | public void run() |
|
|
5377 | { |
|
|
5378 | try |
|
|
5379 | { |
|
|
5380 | Thread.sleep(450); |
|
|
5381 | } |
|
|
5382 | catch (InterruptedException e) |
|
|
5383 | { |
|
|
5384 | // e.printStackTrace(); |
|
|
5385 | } |
|
|
5386 | |
|
|
5387 | if (!Global_onTouch_fingerdown) |
|
|
5388 | { |
|
|
5389 | copy_map_buffer(); |
|
|
5390 | draw_reset_factors = true; |
|
|
5391 | view_s.postInvalidate(); |
|
|
5392 | } |
|
|
5393 | } |
|
|
5394 | }); |
|
|
5395 | t2.start(); |
|
|
5396 | } |
|
|
5397 | else |
|
|
5398 | { |
|
|
5399 | copy_map_buffer(); |
|
|
5400 | draw_reset_factors = true; |
|
|
5401 | view_s.postInvalidate(); |
|
|
5402 | } |
4769 | } |
5403 | } |
4770 | } |
5404 | } |
4771 | else if (id == 3) |
5405 | else if (id == 3) |
4772 | { |
5406 | { |
4773 | // id=3 -> new scale (zoom) number |
5407 | // id=3 -> new scale (zoom) number |