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

Contents of /navit/navit/android/src/com/zoffcc/applications/zanavi/NavitGraphics.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 50 - (show annotations) (download)
Wed Jun 22 07:33:35 2016 UTC (7 years, 9 months ago) by zoff99
File size: 261816 byte(s)
v2.0.51
1 /**
2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2011 - 2015 Zoff <zoff@zoff.cc>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 /**
21 * Navit, a modular navigation system.
22 * Copyright (C) 2005-2008 Navit Team
23 *
24 * This program is free software; you can redistribute it and/or
25 * modify it under the terms of the GNU General Public License
26 * version 2 as published by the Free Software Foundation.
27 *
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
32 *
33 * You should have received a copy of the GNU General Public License
34 * along with this program; if not, write to the
35 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
36 * Boston, MA 02110-1301, USA.
37 */
38
39 package com.zoffcc.applications.zanavi;
40
41 import java.io.File;
42 import java.io.IOException;
43 import java.io.InputStream;
44 import java.util.ArrayList;
45 import java.util.List;
46 import java.util.concurrent.LinkedBlockingQueue;
47
48 import android.annotation.SuppressLint;
49 import android.content.Intent;
50 import android.content.pm.PackageManager;
51 import android.content.pm.ResolveInfo;
52 import android.graphics.Bitmap;
53 import android.graphics.BitmapFactory;
54 import android.graphics.Camera;
55 import android.graphics.Canvas;
56 import android.graphics.Color;
57 import android.graphics.DashPathEffect;
58 import android.graphics.Matrix;
59 import android.graphics.Paint;
60 import android.graphics.Paint.Cap;
61 import android.graphics.Paint.Join;
62 import android.graphics.Paint.Style;
63 import android.graphics.Path;
64 import android.graphics.PointF;
65 import android.graphics.PorterDuff;
66 import android.graphics.Rect;
67 import android.os.Bundle;
68 import android.os.Debug;
69 import android.os.Handler;
70 import android.os.Message;
71 import android.speech.RecognizerIntent;
72 import android.support.v7.app.ActionBarActivity;
73 import android.util.FloatMath;
74 import android.util.Log;
75 import android.util.TypedValue;
76 import android.view.GestureDetector;
77 import android.view.GestureDetector.SimpleOnGestureListener;
78 import android.view.Gravity;
79 import android.view.KeyEvent;
80 import android.view.MotionEvent;
81 import android.view.View;
82 import android.view.ViewGroup;
83 import android.widget.Button;
84 import android.widget.FrameLayout;
85 import android.widget.ImageButton;
86 import android.widget.ImageView;
87 import android.widget.RelativeLayout;
88 import android.widget.ScrollView;
89 import android.widget.Scroller;
90 import android.widget.TextView;
91
92 import com.zoffcc.applications.zanavi.Navit.Navit_Address_Result_Struct;
93 import com.zoffcc.applications.zanavi.NavitAndroidOverlay.NavitAndroidOverlayBubble;
94
95 public class NavitGraphics
96 {
97 private int parent_num;
98 //private ArrayList overlays = new ArrayList();
99
100 static Canvas draw_canvas_s;
101 static Bitmap draw_bitmap_s;
102 static Canvas draw_canvas_screen_s;
103 static Bitmap draw_bitmap_screen_s;
104 static Canvas draw_canvas_screen_s2;
105 static Bitmap draw_bitmap_screen_s2;
106 //static SurfaceView2 view_s;
107 static View view_s;
108 static int dl_thread_cur = 0;
109 static int dl_thread_max = 1;
110 static DrawLinesThread[] dl_thread = new DrawLinesThread[dl_thread_max];
111 static Boolean draw_map_one_shot = false;
112 static Boolean draw_reset_factors = false;
113 static Boolean Global_Map_in_onDraw = false;
114
115 static int lower_than_center_percent = 0;
116
117 static int touch_pointerCount = 0;
118 static int touch_pointerCount_old = 0;
119 static boolean touch_pointerCount_passed_zero = true;
120
121 // static Boolean synch_drawing_for_map = false;
122 private static final Object synch_drawing_for_map = new Object();
123 static ZANaviLinearLayout OSD_new = null;
124
125 // DPI ---------------------------------------------
126 // DPI ---------------------------------------------
127 // DPI ---------------------------------------------
128 static int Global_want_dpi = 210;
129 static int Global_want_dpi_other = 210;
130 static float Global_dpi_factor = 1; // will be calculated correctly later
131 static float Global_dpi_factor_better = 1;
132 static int Global_Scaled_DPI_normal = 240; // we will scale the whole screen to 240 dpi on high dpi devices
133 // DPI ---------------------------------------------
134 // DPI ---------------------------------------------
135 // DPI ---------------------------------------------
136
137 static Camera camera = new Camera();
138 static Matrix cam_m = new Matrix();
139 static Matrix cam_m_vehicle = new Matrix();
140 static float strech_factor_3d_map = 1.2f; // ORIG = 2.2f
141 static int rotate_3d_map_angle = 44; // ORIG = 61
142 static float h_scaled = 20; // ORIG = xx set later!!
143
144 private Canvas draw_canvas;
145 private Bitmap draw_bitmap;
146 private Canvas draw_canvas_screen;
147 private Bitmap draw_bitmap_screen;
148 private Canvas draw_canvas_screen2;
149 private Bitmap draw_bitmap_screen2;
150
151 private float view_srec_x = 0;
152 private float view_srec_y = 0;
153
154 static Path path_preview = new Path();
155 static Paint paint_preview = new Paint();
156 public static Canvas preview_canvas = null;
157 public static Bitmap preview_bitmap = null;
158 static int preview_map_width = 1200;
159 static int preview_map_height = 1200;
160 static float preview_map_my_lat = 0.0f;
161 static float preview_map_my_lon = 0.0f;
162 static int prev_pos_x;
163 static int prev_pos_y;
164 static int preview_map_last_pos_x = 0;
165 static int preview_map_last_pos_y = 0;
166 static float preview_coord_factor = 1.0f;
167 static boolean preview_map_drawn = false;
168 static int scroller_last = 0;
169 static int fling_damper_factor = 3;
170
171 static ZANaviOSDDebug01 debug_text_view = null;
172
173 public static final int map_bg_color = Color.parseColor("#FEF9EE");
174 final Paint paint_bg_color = new Paint(Color.parseColor("#FEF9EE"));
175
176 public final static DashPathEffect dashed_map_lines__high = new DashPathEffect(new float[] { 4, 2 }, 1);
177 public final static DashPathEffect dashed_map_lines__low = new DashPathEffect(new float[] { 15, 11 }, 1);
178 public final static DashPathEffect dashed_map_lines__no_dash = null;
179
180 public final static DashPathEffect h001 = new DashPathEffect(new float[] { 6, 3 }, 1);
181 public final static DashPathEffect l001 = new DashPathEffect(new float[] { 6, 3 }, 1);
182 public final static DashPathEffect h002 = new DashPathEffect(new float[] { 6, 3 }, 1);
183 public final static DashPathEffect l002 = new DashPathEffect(new float[] { 6, 3 }, 1);
184 public final static DashPathEffect h003 = new DashPathEffect(new float[] { 6, 3 }, 1);
185 public final static DashPathEffect l003 = new DashPathEffect(new float[] { 6, 3 }, 1);
186 public final static DashPathEffect h004 = new DashPathEffect(new float[] { 6, 3 }, 1);
187 public final static DashPathEffect l004 = new DashPathEffect(new float[] { 6, 3 }, 1);
188 public final static DashPathEffect h005 = new DashPathEffect(new float[] { 6, 3 }, 1);
189 public final static DashPathEffect l005 = new DashPathEffect(new float[] { 6, 3 }, 1);
190 public final static DashPathEffect h006 = new DashPathEffect(new float[] { 6, 3 }, 1);
191 public final static DashPathEffect l006 = new DashPathEffect(new float[] { 6, 3 }, 1);
192 public final static DashPathEffect h007 = new DashPathEffect(new float[] { 6, 3 }, 1);
193 public final static DashPathEffect l007 = new DashPathEffect(new float[] { 7, 2 }, 1);
194
195 public static Paint paint_for_map_display = new Paint();
196 public static Paint paint_sky_day = new Paint();
197 public static Paint paint_sky_night = new Paint();
198 public static Paint paint_sky_night_stars = new Paint();
199 public static Paint paint_sky_twilight1 = new Paint();
200 public static Paint paint_sky_twilight2 = new Paint();
201 public static Paint paint_sky_twilight3 = new Paint();
202
203 public static final int max_stars = 7;
204 public static float[] stars_x = new float[max_stars + 1];
205 public static float[] stars_y = new float[max_stars + 1];
206 public static int[] stars_size = new int[max_stars + 1];
207
208 public final static DashPathEffect[] dashes__low = { null, l001, l002, l003, l004, l005, l006, l007 };
209 public final static DashPathEffect[] dashes__high = { null, h001, h002, h003, h004, h005, h006, h007 };
210
211 public static int navit_route_status = 0;
212
213 public final float BIGMAP_FACTOR = (10465f / 2f) * 0.8f;
214 Paint paint_maptile = new Paint();
215 Matrix matrix_maptile = new Matrix();
216
217 static Paint strokeTextPaint = new Paint();
218 static double s_factor = 1;
219 static int s_strokTextSize = 8;
220 static int s_strokTextSize_min = 3;
221
222 public static long last_paint_OSD = 0;
223
224 public static Boolean wait_for_redraw_map = false;
225
226 public static Boolean MAP_DISPLAY_OFF = false;
227
228 public static int mCanvasWidth = 1;
229 public static int mCanvasHeight = 1;
230 public static int mCanvasWidth_overspill = 1;
231 public static int mCanvasHeight_overspill = 1;
232
233 public static final Boolean DEBUG_TOUCH = false;
234 public static Boolean ZOOM_MODE_ACTIVE = false;
235 public static float ZOOM_MODE_SCALE = 1.0f;
236 public static Boolean DRAG_MODE_ACTIVE = false;
237
238 // ----------------- DEBUG ----------------
239 // ----------------- DEBUG ----------------
240 // ----------------- DEBUG ----------------
241 public static final Boolean DEBUG_SMOOTH_DRIVING = false; // for debugging only, set this to "false" on release builds!!
242 // ----------------- DEBUG ----------------
243 // ----------------- DEBUG ----------------
244 // ----------------- DEBUG ----------------
245
246 static boolean map_c_drawing = false;
247
248 private static long smooth_driving_ts001 = 0L;
249 private static long smooth_driving_ts002 = 0L;
250 private static long smooth_driving_ts002a = 0L;
251 private static long smooth_driving_ts003 = 0L;
252 private static long smooth_driving_tmptmp = 0L;
253
254 public static float Global_Map_Zoomfactor = 1.0f;
255 public static float Global_Map_Rotationangle = 0;
256 public static float Global_Map_TransX = 0;
257 public static float Global_Map_TransY = 0;
258 public static Boolean Global_SmoothDrawing_stop = false;
259 public static Boolean Global_onTouch_fingerdown = false;
260
261 public static float draw_factor = 1.0f;
262
263 public static String debug_line_1 = "";
264 public static String debug_line_2 = "";
265 public static String debug_line_3 = "";
266 public static String debug_line_4 = "";
267
268 public static final int DRAW_ONEWAY_ARROWS_AT_ORDER = 13;
269 public static final int DRAW_DETAIL_DASHES_AT_ORDER = 13;
270 public static final int DRAW_MORE_DETAILS_AT_ORDER = 9;
271 public static final int DRAW_MORE_DETAILS_TUNNEL_BRIDGES_AT_ORDER = 8;
272
273 public static long[] OverlayDrawThread_cancel_drawing_timeout__options = { 300L, 900L, 2100L, 20000L }; // 900L normal, 300L short, 2100L long
274 public static int[] OverlayDrawThread_cancel_thread_sleep_time__options = { 100, 200, 400, 400 };
275 public static long[] OverlayDrawThread_cancel_thread_timeout__options = { 3000L, 3000L, 3000L, 22000L };
276
277 public static long OverlayDrawThread_cancel_drawing_timeout = OverlayDrawThread_cancel_drawing_timeout__options[1];
278 public static int OverlayDrawThread_cancel_thread_sleep_time = OverlayDrawThread_cancel_thread_sleep_time__options[1];
279 public static long OverlayDrawThread_cancel_thread_timeout = OverlayDrawThread_cancel_thread_timeout__options[1];
280
281 int loc_dot_x = 0;
282 int loc_dot_y = 0;
283 int loc_dot_x2 = 0;
284 int loc_dot_y2 = 0;
285 int loc_1_x = 0;
286 int loc_1_y = 0;
287 int loc_2_x = 0;
288 int loc_2_y = 0;
289 Boolean loc_12_valid = false;
290 Boolean loc_dot_valid = false;
291 int gr_type = 0; // 0 -> dummy, 1 -> map
292
293 int bitmap_w;
294 int bitmap_h;
295 int pos_x;
296 int pos_y;
297 //
298 int vehicle_speed = 0;
299 int vehicle_pos_x = 0;
300 int vehicle_pos_y = 0;
301 int vehicle_direction = 0;
302 int vehicle_pos_x_delta = 0;
303 int vehicle_pos_y_delta = 0;
304 int vehicle_direction_delta = 0;
305 int vehicle_zoom_delta = 0;
306 // drag pos
307 public static int d_pos_x_old = -1;
308 public static int d_pos_y_old = -1;
309 // drag post
310 int pos_wraparound;
311 // int overlay_disabled;
312 float trackball_x, trackball_y;
313 View view;
314 RelativeLayout relativelayout;
315 // --obsolote --- // NavitCamera camera;
316 ActionBarActivity activity;
317
318 private Bitmap bigmap_bitmap_temp = null;
319 private Matrix matrix_oneway_arrows = null;
320 private float wsave_003 = 0f;
321 private float wsave_004 = 0f;
322 private Boolean b_paint_antialias = true;
323 private Path b_paint_path = new Path();
324
325 public static Boolean in_map = true; // always in map mode, now
326
327 // for menu key
328 private static long time_for_long_press = 300L;
329 private static long interval_for_long_press = 200L;
330
331 // for touch screen
332 private long last_touch_on_screen = 0L;
333 private static long long_press_on_screen_interval = 1000L;
334 static float long_press_on_screen_max_distance = 8f;
335
336 // Overlay View for Android
337 //
338 // here you can draw all the nice things you want
339 // and get touch events for it (without touching C-code)
340 public NavitAndroidOverlay NavitAOverlay = null;
341 public static NavitAndroidOverlay NavitAOverlay_s = null;
342 private NavitOSDJava NavitAOSDJava = null;
343 public static NavitOSDJava NavitAOSDJava_ = null;
344 private TextView NavitMsgTv = null;
345 public static TextView NavitMsgTv_ = null;
346 public ZANaviBusySpinner busyspinner = null;
347 public static ZANaviBusySpinner busyspinner_ = null;
348 public ZANaviBusyText busyspinnertext = null;
349 public static ZANaviBusyText busyspinnertext_ = null;
350
351 // public static EmulatedMenuView emu_menu_view;
352
353 PointF touch_now_center = new PointF(0, 0);
354
355 private TextView NavitMsgTv2 = null;
356 public static TextView NavitMsgTv2_ = null;
357
358 public static ScrollView NavitMsgTv2sc_ = null;
359 public static RelativeLayout no_maps_container = null;
360 public static RelativeLayout whats_here_container_wrap = null;
361 public static ImageView whats_here_pointer_image = null;
362 public static RelativeLayout.LayoutParams params_whats_here_container_wrap = new RelativeLayout.LayoutParams(10, 10);
363 public static RelativeLayout.LayoutParams params_whats_here_pointer_image = new RelativeLayout.LayoutParams(10, 10);
364 public static ImageButton whats_here_button_add_to;
365 public static ImageButton whats_here_button_whats;
366 public static ImageButton whats_here_button_drive;
367 public static TextView whats_here_text;
368 // public static String whats_here_text_string = "";
369
370 Scroller mScroller = null;
371 int scroller_last_x = 0;
372 int scroller_last_y = 0;
373 boolean scroller_active = false;
374
375 public static NavitGlobalMap NavitGlobalMap_ = null;
376
377 public void SetCamera(int use_camera)
378 {
379 // ------ obsolete
380
381 /*
382 * if (use_camera != 0 && camera == null)
383 * {
384 * // activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
385 * camera = new NavitCamera(activity);
386 * relativelayout.addView(camera);
387 * relativelayout.bringChildToFront(view);
388 * }
389 */
390 }
391
392 public static SensorThread touch_sensor_thread = null;
393
394 private class SensorThread extends Thread
395 {
396 private Boolean running;
397 private long last_down_action = 0L;
398 private Boolean is_still_pressing;
399 //private View v = null;
400 //private NavitAndroidOverlay n_overlay = null;
401 private float prev_x;
402 private float prev_y;
403 private float x;
404 private float y;
405
406 SensorThread(long last_touch, float x, float y)
407 {
408 this.prev_x = x;
409 this.prev_y = y;
410 this.x = x;
411 this.y = y;
412 this.running = true;
413 //this.n_overlay = n_ov;
414 //this.v = v;
415 this.is_still_pressing = true;
416 last_down_action = System.currentTimeMillis();
417 if (DEBUG_TOUCH) Log.e("NavitGraphics", "SensorThread created last_down_action=" + last_down_action);
418 }
419
420 public void down()
421 {
422 this.is_still_pressing = true;
423 }
424
425 // public void up()
426 // {
427 // this.is_still_pressing=false;
428 // }
429
430 public void stop_me()
431 {
432 this.running = false;
433 }
434
435 public void run()
436 {
437 if (DEBUG_TOUCH) Log.e("NavitGraphics", "SensorThread started");
438 while (this.running)
439 {
440 if (DEBUG_TOUCH) Log.e("NavitGraphics", "while loop:last_down_action=" + this.last_down_action + " currentTimeMillis=" + System.currentTimeMillis() + " long_press_on_screen_interval=" + long_press_on_screen_interval);
441 if ((System.currentTimeMillis() - this.last_down_action) > long_press_on_screen_interval)
442 {
443 // ok, we have counted a long press on screen
444 // do stuff and then stop this thread
445 if (DEBUG_TOUCH) Log.e("NavitGraphics", "SensorThread: LONG PRESS");
446 try
447 {
448 if (this.running)
449 {
450 if (!NavitAndroidOverlay.confirmed_bubble)
451 {
452 //Log.e("NavitGraphics", "do_longpress_action enter");
453 NavitAndroidOverlayBubble b = new NavitAndroidOverlayBubble();
454 b.x = (int) this.x;
455 b.y = (int) this.y;
456 NavitAOverlay.set_bubble(b);
457 NavitAOverlay.show_bubble();
458 copy_map_buffer();
459 //System.out.println("invalidate 009");
460 // System.out.println("DO__DRAW:Java:postInvalidate 004");
461 // SYN //
462 Navit.NG__map_main.view.postInvalidate();
463 // map_postInvalidate();
464 //SurfaceView2 vw = (SurfaceView2) Navit.NG__map_main.view;
465 //vw.paint_me();
466 //System.out.println("invalidate 010");
467 NavitAOverlay.postInvalidate();
468 }
469 }
470 // this is called!!! yes really!! via REFLECT (make it better, later)
471 // find the class, to get the method "do_longpress_action"
472 // and then call the method
473
474 // Class cls = this.v.getClass();
475 // //Log.e("NavitGraphics", "c=" + String.valueOf(cls));
476 // Class partypes[] = new Class[2];
477 // partypes[0] = Float.TYPE;
478 // partypes[1] = Float.TYPE;
479 // Method meth = cls.getMethod("do_longpress_action", partypes);
480 // View methobj = this.v;
481 // Object arglist[] = new Object[2];
482 // arglist[0] = new Float(this.x);
483 // arglist[1] = new Float(this.y);
484
485 //if (running)
486 //{
487 //Object retobj = meth.invoke(methobj, arglist);
488 //}
489 }
490 // catch (Throwable e)
491 catch (Exception e)
492 {
493 System.err.println(e);
494 }
495 this.running = false;
496 }
497 else if (!this.is_still_pressing)
498 {
499 if (DEBUG_TOUCH) Log.e("NavitGraphics", "SensorThread: stopped pressing");
500 this.running = false;
501 }
502 else
503 {
504 // Log.e("NavitGraphics", "SensorThread running");
505 try
506 {
507 Thread.sleep(50);
508 }
509 catch (InterruptedException e)
510 {
511 // e.printStackTrace();
512 }
513 }
514 }
515 if (DEBUG_TOUCH) Log.e("NavitGraphics", "SensorThread ended");
516 }
517 }
518
519 // public static OverlayDrawThread overlay_draw_thread = null;
520
521 public static class OverlayDrawThread extends Thread
522 {
523 private Boolean running = true;
524 private Boolean redraw = false;
525 private long start_timestamp = 0L;
526
527 OverlayDrawThread()
528 {
529 // Log.e("NavitGraphics", "OverlayDrawThread created");
530 start_timestamp = System.currentTimeMillis();
531 }
532
533 public void run()
534 {
535 this.running = true;
536 this.redraw = true;
537
538 // start_timestamp = System.currentTimeMillis();
539 // Log.e("NavitGraphics", "OverlayDrawThread starting"+start_timestamp);
540
541 while (this.running)
542 {
543
544 if (System.currentTimeMillis() > (start_timestamp + OverlayDrawThread_cancel_drawing_timeout))
545 {
546 // after xxx milliseconds of delay, stop drawing the map!
547 // most likely the device is too slow, or there are too much items to draw
548 try
549 {
550 //Log.e("NavitGraphics", "## stop map drawing x1: NOW ##" + System.currentTimeMillis());
551 //***NavitGraphics.CallbackMessageChannel(50, "");
552 //Message msg = new Message();
553 //Bundle b = new Bundle();
554 //b.putInt("Callback", 50);
555 //msg.setData(b);
556 //callback_handler.sendMessage(msg);
557 //Log.e("NavitGraphics", "## stop map drawing x2: NOW ##" + System.currentTimeMillis());
558 this.running = false;
559 break;
560 }
561 catch (Exception e)
562 {
563 e.printStackTrace();
564 }
565 }
566
567 if (System.currentTimeMillis() > (start_timestamp + OverlayDrawThread_cancel_thread_timeout))
568 {
569 // just to be safe, stop after 5 seconds
570 this.running = false;
571 }
572
573 //Log.e("NavitGraphics", "OverlayDrawThread running");
574 if (this.redraw)
575 {
576 // Log.e("NavitGraphics", "OverlayDrawThread -> redraw");
577 try
578 {
579 //NavitAOverlay_s.invalidate();
580 Message msg = Navit.Navit_progress_h.obtainMessage();
581 Bundle b = new Bundle();
582 msg.what = 16;
583 msg.setData(b);
584 Navit.Navit_progress_h.sendMessage(msg);
585 }
586 catch (Exception e)
587 {
588 e.printStackTrace();
589 }
590 //this.redraw = false;
591 }
592
593 try
594 {
595 Thread.sleep(OverlayDrawThread_cancel_thread_sleep_time);
596 }
597 catch (InterruptedException e)
598 {
599 e.printStackTrace();
600 }
601 }
602
603 //Log.e("NavitGraphics", "OverlayDrawThread finished");
604 }
605
606 public void redraw_overlay()
607 {
608 //Log.e("NavitGraphics", "OverlayDrawThread set redraw");
609 this.redraw = true;
610 }
611
612 public void stop_me()
613 {
614 this.running = false;
615 }
616
617 public void stop_redraw()
618 {
619 this.redraw = false;
620 }
621 }
622
623 public static void init_3d_mode()
624 {
625 // 3D modus -----------------
626 NavitGraphics.cam_m.reset();
627 NavitGraphics.camera.save();
628 //NavitGraphics.camera.translate(0, 0, 40);
629 NavitGraphics.camera.rotateX(rotate_3d_map_angle);
630 NavitGraphics.camera.getMatrix(NavitGraphics.cam_m);
631 NavitGraphics.camera.restore();
632 // C-Code: (50 + offset) * height / 100 // offset = 30%
633 //float y_point = (bitmap_h - (bitmap_h * 0.7f));
634 float y_offset = 0; // 20
635 float y_point = Navit.NG__map_main.bitmap_h * 0.7f;
636 NavitGraphics.cam_m.preTranslate(-Navit.NG__map_main.bitmap_w / 2, -y_offset - y_point);
637 NavitGraphics.cam_m.postTranslate(Navit.NG__map_main.bitmap_w / 2, y_offset + y_point);
638 NavitGraphics.cam_m.postScale(strech_factor_3d_map, strech_factor_3d_map, Navit.NG__map_main.bitmap_w / 2, y_offset + y_point);
639 //
640 Matrix matrix_tmp = new Matrix();
641 //RectF src_rect = new RectF(0, 0, Navit.NG__map_main.bitmap_w, Navit.NG__map_main.bitmap_h);
642 //RectF dst_rect = new RectF(0, 0, Navit.NG__map_main.bitmap_w, Navit.NG__map_main.bitmap_h);
643 float[] src = new float[8];
644 float[] dst = new float[8];
645 src[0] = 0;
646 src[1] = 0;
647 src[2] = Navit.NG__map_main.bitmap_w;
648 src[3] = 0;
649 src[4] = Navit.NG__map_main.bitmap_w;
650 src[5] = Navit.NG__map_main.bitmap_h;
651 src[6] = 0;
652 src[7] = Navit.NG__map_main.bitmap_h;
653 //
654 float _3d_skew_factor_top = 0f;
655 float _3d_skew_factor_bottom = 0.8f;
656 dst[0] = 0 + ((float) (Navit.NG__map_main.bitmap_w) * _3d_skew_factor_top);
657 dst[1] = 0;
658 dst[2] = Navit.NG__map_main.bitmap_w - ((float) (Navit.NG__map_main.bitmap_w) * _3d_skew_factor_top);
659 dst[3] = 0;
660 dst[4] = Navit.NG__map_main.bitmap_w + ((float) (Navit.NG__map_main.bitmap_w) * _3d_skew_factor_bottom);
661 dst[5] = Navit.NG__map_main.bitmap_h;
662 dst[6] = 0f - ((float) (Navit.NG__map_main.bitmap_w) * _3d_skew_factor_bottom);
663 dst[7] = Navit.NG__map_main.bitmap_h;
664 //
665 matrix_tmp.setPolyToPoly(src, 0, dst, 0, 4);
666 //*boolean bb = false;
667 //*bb = NavitGraphics.cam_m.setConcat(matrix_tmp, cam_m);
668 //*System.out.println("matrix b=" + bb);
669 //
670 //NavitGraphics.cam_m.postTranslate(0, 50);
671 //
672 float[] pts = new float[2];
673 pts[0] = Navit.NG__map_main.bitmap_w / 2; // x0
674 pts[1] = 0; // y0
675 cam_m.mapPoints(pts); // now transform the points with the 3d matrix
676 //System.out.println("x1=" + pts[0] + " y1=" + pts[1]);
677 // -- offset for horizon --
678 NavitGraphics.h_scaled = pts[1] + 1; // y coord of upper border after transformation with matrix (plus extra 15 pixels that scrolling looks better)
679 //
680 //
681 // --- vehicle matrix
682 cam_m_vehicle.reset();
683 NavitGraphics.camera.save();
684 NavitGraphics.camera.rotateX(rotate_3d_map_angle);
685 NavitGraphics.camera.getMatrix(NavitGraphics.cam_m_vehicle);
686 NavitGraphics.camera.restore();
687 NavitGraphics.cam_m_vehicle.preTranslate(-Navit.NG__map_main.bitmap_w / 2, -y_offset - y_point);
688 NavitGraphics.cam_m_vehicle.postTranslate(Navit.NG__map_main.bitmap_w / 2, y_offset + y_point);
689 NavitGraphics.cam_m_vehicle.postScale(strech_factor_3d_map, strech_factor_3d_map, Navit.NG__map_main.bitmap_w / 2, y_offset + y_point);
690 //matrix_tmp.reset();
691 //matrix_tmp.preScale(1 / strech_factor_3d_map, 1 / strech_factor_3d_map, Navit.NG__map_main.bitmap_w / 2, y_offset + y_point);
692 //NavitGraphics.cam_m_vehicle.setConcat(matrix_tmp, NavitGraphics.cam_m_vehicle);
693 // --- vehicle matrix
694 //
695 // 3D modus -----------------
696
697 }
698
699 @SuppressLint("NewApi")
700 public NavitGraphics(ActionBarActivity activity, int parent, int x, int y, int w, int h, int alpha, int wraparound, int use_camera)
701 {
702 mScroller = new Scroller(activity);
703
704 paint_maptile.setFilterBitmap(false);
705 paint_maptile.setAntiAlias(false);
706 paint_maptile.setDither(false);
707
708 paint_bg_color.setColor(Color.parseColor("#FEF9EE"));
709 paint_bg_color.setAntiAlias(false);
710 paint_bg_color.setDither(false);
711
712 STT_B_list[0] = null;
713 STT_B_list[1] = null;
714 STT_B_list[2] = null;
715 STT_B_list[3] = null;
716 STT_B_list[4] = null;
717
718 // paint_preview.setColor(Color.parseColor("#D2D2D2"));
719 paint_preview.setColor(Color.parseColor("#AA8E8E8E")); // semi-transparent gray
720 // paint_preview.setColor(Color.RED);
721 paint_preview.setAntiAlias(false);
722 paint_preview.setDither(false);
723 paint_preview.setStyle(Paint.Style.STROKE);
724 paint_preview.setStrokeWidth(dp_to_px(3));
725
726 // shadow for text on map --------------
727 s_factor = 1;
728 if ((Navit.metrics.densityDpi >= 320) && (!Navit.p.PREF_shrink_on_high_dpi))
729 {
730 s_factor = (double) Navit.metrics.densityDpi / (double) NavitGraphics.Global_Scaled_DPI_normal;
731 // s_factor = 1.4;
732 }
733
734 // s_strokTextSize = (int) (8f);
735 // s_strokTextSize_min = (int) (4f * s_factor);
736
737 // width of the text shadow for strings on map -----------
738 s_strokTextSize = dp_to_px(2);
739 s_strokTextSize_min = dp_to_px(2);
740 // width of the text shadow for strings on map -----------
741
742 strokeTextPaint.setARGB(255, 255, 255, 255);
743 strokeTextPaint.setTextAlign(android.graphics.Paint.Align.LEFT);
744 strokeTextPaint.setStyle(Paint.Style.STROKE);
745 strokeTextPaint.setStrokeWidth(s_strokTextSize);
746 strokeTextPaint.setFilterBitmap(false);
747 strokeTextPaint.setAntiAlias(true);
748 strokeTextPaint.setDither(false);
749 // shadow for text on map --------------
750
751 if (parent == 0)
752 {
753 this.gr_type = 1;
754
755 int hh = Navit.metrics.heightPixels;
756 int ww = Navit.metrics.widthPixels;
757
758 preview_map_width = (int) ((float) ww * 0.6f);
759 if (hh > ww)
760 {
761 preview_map_width = (int) ((float) hh * 0.6f);
762 }
763 preview_map_height = preview_map_width;
764 System.out.println("preview_map[view] = " + ww + "x" + hh);
765 System.out.println("preview_map[fling] = " + preview_map_width + "x" + preview_map_height);
766
767 preview_bitmap = Bitmap.createBitmap(preview_map_width, preview_map_height, Bitmap.Config.ARGB_8888);
768 // preview_bitmap.setDensity(Global_want_dpi / 8);
769 preview_canvas = new Canvas(preview_bitmap);
770 // preview_canvas.setDensity(Global_want_dpi / 4);
771 System.out.println("Global_want_dpi=" + Global_want_dpi + ":" + Navit.metrics.densityDpi + ":" + NavitGraphics.Global_dpi_factor + ":" + NavitGraphics.Global_dpi_factor_better);
772 System.out.println("preview_coord_factor=" + preview_coord_factor);
773
774 this.activity = activity;
775 view = (View) new view_map_custom(activity)
776 {
777 int touch_mode = NONE;
778 float oldDist = 0;
779 PointF touch_now = new PointF(0, 0);
780 // PointF touch_now_center = new PointF(0, 0);
781 PointF touch_start = new PointF(0, 0);
782 PointF touch_prev = new PointF(0, 0);
783 static final int NONE = 0;
784 static final int DRAG = 1;
785 static final int ZOOM = 2;
786 static final int PRESS = 3;
787
788 Paint paint_fling_line = new Paint();
789 Paint paint_fling_line2 = new Paint();
790
791 boolean fling_start = false;
792
793 float a__;
794 float b__;
795
796 Message msg2 = new Message();
797 Bundle b2 = new Bundle();
798
799 // public void surfaceCreated(SurfaceHolder holder)
800 // {
801 // System.out.println("surfaceCreated");
802 // }
803 //
804 // public void surfaceDestroyed(SurfaceHolder holder)
805 // {
806 // System.out.println("surfaceDestroyed");
807 // }
808
809 // Map ----------------------------
810 // Map ----------------------------
811 // Map ----------------------------
812 @Override
813 protected void onDraw(Canvas canvas)
814 {
815 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
816
817 // System.out.println("DO__DRAW:onDraw():- enter");
818 // if (2 == 1 + 1)
819 // {
820 // return;
821 // }
822 // **** // System.out.println("draw main map:isHardwareAccelerated=" + canvas.isHardwareAccelerated());
823
824 // System.out.println("onDraw:MMMMMMMMMMMMMMMMMMMMMM");
825 // SYN //
826 synchronized (synch_drawing_for_map)
827 {
828 // System.out.println("onDraw:MMMMMMMMMMMMMMMMMMMMMM(s)");
829 // System.out.println("DO__DRAW:onDraw():- start");
830 //System.out.println("*******DRAW INIT******* " + gr_type);
831 //super.onDraw(canvas);
832
833 if (!MAP_DISPLAY_OFF)
834 {
835
836 Global_Map_in_onDraw = true;
837
838 if (draw_reset_factors)
839 {
840 //System.out.println("DO__DRAW:Java:reset factors");
841 draw_reset_factors = false;
842 pos_x = 0;
843 // System.out.println("px reset:001");
844 pos_y = 0;
845 ZOOM_MODE_ACTIVE = false;
846 ZOOM_MODE_SCALE = 1.0f;
847 }
848
849 //System.out.println("DO__DRAW:Java:onDraw:draw bitmap to SCREEN");
850 //System.out.println("DO__DRAW:Java:onDraw:gzf=" + Global_Map_Zoomfactor + " scale=" + ZOOM_MODE_SCALE);
851 //System.out.println("DO__DRAW:Java:onDraw:gx=" + Global_Map_TransX + " pos_x=" + pos_x);
852 //System.out.println("DO__DRAW:Java:onDraw:gy=" + Global_Map_TransY + " pos_y=" + pos_y);
853
854 if (Navit.p.PREF_show_3d_map)
855 {
856 draw_canvas_screen2.save();
857
858 // if (Navit.GFX_OVERSPILL)
859 // {
860 // // compensate overspill
861 // // canvas.translate(-mCanvasWidth_overspill, -mCanvasHeight_overspill);
862 // // System.out.println("overspill");
863 // }
864
865 if ((ZOOM_MODE_ACTIVE) || (Global_Map_Zoomfactor != 1.0f))
866 {
867 if (Navit.GFX_OVERSPILL)
868 {
869 draw_canvas_screen2.scale(ZOOM_MODE_SCALE * Global_Map_Zoomfactor, ZOOM_MODE_SCALE * Global_Map_Zoomfactor, Global_Map_TransX + Navit.NG__map_main.touch_now_center.x + mCanvasWidth_overspill, Global_Map_TransY + Navit.NG__map_main.touch_now_center.y + mCanvasHeight_overspill);
870 }
871 else
872 {
873 draw_canvas_screen2.scale(ZOOM_MODE_SCALE * Global_Map_Zoomfactor, ZOOM_MODE_SCALE * Global_Map_Zoomfactor, Global_Map_TransX + Navit.NG__map_main.touch_now_center.x, Global_Map_TransY + Navit.NG__map_main.touch_now_center.y);
874 }
875 }
876
877 if (Global_Map_Rotationangle != 0.0f)
878 {
879 draw_canvas_screen2.rotate(Global_Map_Rotationangle, Navit.NG__vehicle.vehicle_pos_x, Navit.NG__vehicle.vehicle_pos_y);
880 }
881
882 if (Global_Map_Zoomfactor == 1.0f)
883 {
884 draw_canvas_screen2.translate(Global_Map_TransX + pos_x, Global_Map_TransY + pos_y);
885 }
886 else
887 {
888 draw_canvas_screen2.translate((Global_Map_TransX + pos_x) / Global_Map_Zoomfactor, (Global_Map_TransY + pos_y) / Global_Map_Zoomfactor);
889 }
890
891 //System.out.println("DO__DRAW:onDraw():drawBitmap start");
892 draw_canvas_screen2.drawColor(map_bg_color); // fill with yellow-ish bg color
893
894 // --------------- CLEAR MAP ---------------
895 // --------------- CLEAR MAP ---------------
896 //System.out.println("CLEAR MAP:001");
897 // draw_canvas_screen2.drawColor(Color.RED);
898 // --------------- CLEAR MAP ---------------
899 // --------------- CLEAR MAP ---------------
900
901 // draw_canvas_screen2.drawColor(Color.GREEN); // fill with yellow-ish bg color
902 // draw the bitmap in the offscreen buffer (offset 30 pixels to center!!)
903 draw_canvas_screen2.drawBitmap(draw_bitmap_screen, 0, 0, paint_for_map_display);
904 //System.out.println("DO__DRAW:onDraw():drawBitmap end");
905
906 canvas.save();
907 canvas.drawColor(map_bg_color); // fill with yellow-ish bg color
908
909 // --------------- CLEAR MAP ---------------
910 // --------------- CLEAR MAP ---------------
911 //System.out.println("CLEAR MAP:002");
912 // canvas.drawColor(Color.GREEN);
913 // --------------- CLEAR MAP ---------------
914 // --------------- CLEAR MAP ---------------
915
916 // 3D modus -----------------
917 canvas.concat(cam_m);
918 // 3D modus -----------------
919
920 // draw bitmap to screen
921 canvas.drawBitmap(draw_bitmap_screen2, -mCanvasWidth_overspill, -mCanvasHeight_overspill, paint_for_map_display);
922
923 // ------ DEBUG -------
924 // ------ DEBUG -------
925 // ------ DEBUG -------
926 // ------ DEBUG -------
927 // Paint paint79 = new Paint();
928 // paint79.setColor(Color.MAGENTA);
929 // paint79.setStrokeWidth(16);
930 // paint79.setStyle(Style.STROKE);
931 // // float y_point = (bitmap_h - (bitmap_h * 0.7f));
932 // float y_point = bitmap_h * 0.7f;
933 // canvas.drawLine(bitmap_w / 2, y_point - 20, bitmap_w / 2, y_point + 20, paint79);
934 // canvas.drawLine(bitmap_w / 2 - 100, y_point, bitmap_w / 2 + 100, y_point, paint79);
935 //
936 // Paint paint78 = new Paint();
937 // paint78.setColor(Color.RED);
938 // paint78.setStrokeWidth(20);
939 // paint78.setStyle(Style.STROKE);
940 // canvas.drawRect(30, 30, this.getWidth() - 30, this.getHeight() - 30, paint78);
941 // ------ DEBUG -------
942 // ------ DEBUG -------
943 // ------ DEBUG -------
944 // ------ DEBUG -------
945
946 canvas.restore();
947 draw_canvas_screen2.restore();
948
949 if (Navit.is_night)
950 {
951 if (Navit.is_twilight)
952 {
953 // draw twilight
954 // elevation -> -0.83 to -10.00
955 a__ = h_scaled / 10f * (float) (-Navit.elevation);
956 b__ = h_scaled / 10f * (float) ((-Navit.elevation / 2f) + 5);
957 canvas.drawRect(0, 0, this.getWidth(), a__, paint_sky_twilight1);
958 canvas.drawRect(0, a__, this.getWidth(), b__, paint_sky_twilight2);
959 canvas.drawRect(0, b__, this.getWidth(), h_scaled, paint_sky_twilight3);
960 }
961 else
962 {
963 // draw sky - at night
964 canvas.drawRect(0, 0, this.getWidth(), h_scaled, paint_sky_night);
965 // stars
966 canvas.drawCircle(NavitGraphics.stars_x[0] * this.getWidth(), NavitGraphics.stars_y[0] * h_scaled, NavitGraphics.stars_size[0], paint_sky_night_stars);
967 canvas.drawCircle(NavitGraphics.stars_x[1] * this.getWidth(), NavitGraphics.stars_y[1] * h_scaled, NavitGraphics.stars_size[1], paint_sky_night_stars);
968 canvas.drawCircle(NavitGraphics.stars_x[2] * this.getWidth(), NavitGraphics.stars_y[2] * h_scaled, NavitGraphics.stars_size[2], paint_sky_night_stars);
969 canvas.drawCircle(NavitGraphics.stars_x[3] * this.getWidth(), NavitGraphics.stars_y[3] * h_scaled, NavitGraphics.stars_size[3], paint_sky_night_stars);
970 canvas.drawCircle(NavitGraphics.stars_x[4] * this.getWidth(), NavitGraphics.stars_y[4] * h_scaled, NavitGraphics.stars_size[4], paint_sky_night_stars);
971 canvas.drawCircle(NavitGraphics.stars_x[5] * this.getWidth(), NavitGraphics.stars_y[5] * h_scaled, NavitGraphics.stars_size[5], paint_sky_night_stars);
972 canvas.drawCircle(NavitGraphics.stars_x[6] * this.getWidth(), NavitGraphics.stars_y[6] * h_scaled, NavitGraphics.stars_size[6], paint_sky_night_stars);
973 canvas.drawCircle(NavitGraphics.stars_x[7] * this.getWidth(), NavitGraphics.stars_y[7] * h_scaled, NavitGraphics.stars_size[7], paint_sky_night_stars);
974 }
975 }
976 else
977 {
978 // draw sky - at day
979 canvas.drawRect(0, 0, this.getWidth(), h_scaled, paint_sky_day);
980 }
981 }
982 else
983 {
984 canvas.drawPaint(paint_bg_color);
985 // --------------- CLEAR MAP ---------------
986 // --------------- CLEAR MAP ---------------
987 //System.out.println("CLEAR MAP:003");
988 // canvas.drawColor(Color.BLUE);
989 // --------------- CLEAR MAP ---------------
990 // --------------- CLEAR MAP ---------------
991
992 preview_map_drawn = false;
993
994 // ----------------------------------------------------------------------------------
995 // ----------------------------------------------------------------------------------
996 // ----------------------------------------------------------------------------------
997 // scroller - fling ----
998 // scroller - fling ----
999 // scroller - fling ----
1000 if (mScroller.computeScrollOffset())
1001 {
1002 if ((touch_mode != ZOOM) && (touch_pointerCount_passed_zero))
1003 {
1004 if (fling_start)
1005 {
1006 // System.out.println("FLING:" + "fling_start=true");
1007
1008 fling_start = false;
1009 ClearPreview_bitmap();
1010
1011 preview_map_my_lat = 0.0f;
1012 preview_map_my_lon = 0.0f;
1013
1014 prev_pos_x = pos_x;
1015 prev_pos_y = pos_y;
1016 // System.out.println("prev_pos_x=" + prev_pos_x + " prev_pos_y=" + prev_pos_y);
1017 // System.out.println("prev_ fx=" + mScroller.getFinalX() + " fy=" + mScroller.getFinalY());
1018
1019 String lat_lon = NavitGraphics.CallbackGeoCalc(1, ((((float) this.getWidth() / 2) - (float) prev_pos_x + ((float) mScroller.getFinalX() / fling_damper_factor)) + (float) NavitGraphics.mCanvasWidth_overspill) * (float) NavitGraphics.Global_dpi_factor, ((((float) this.getHeight() / 2) - (float) prev_pos_y + ((float) mScroller.getFinalY() / fling_damper_factor)) + (float) NavitGraphics.mCanvasHeight_overspill) * (float) NavitGraphics.Global_dpi_factor);
1020 try
1021 {
1022 String tmp[] = lat_lon.split(":", 2);
1023 preview_map_my_lat = Float.parseFloat(tmp[0]);
1024 preview_map_my_lon = Float.parseFloat(tmp[1]);
1025 }
1026 catch (Exception e)
1027 {
1028 e.printStackTrace();
1029 }
1030
1031 // System.out.println("Navit.GlobalScaleLevel=" + Navit.GlobalScaleLevel);
1032 if (Navit.GlobalScaleLevel > 3700)
1033 {
1034 // no preview map anymore!
1035 }
1036 else if (Navit.GlobalScaleLevel > 1200)
1037 {
1038 DrawLowqualMap_wrapper("" + preview_map_my_lat + "#" + preview_map_my_lon + "#" + 5, (int) (preview_map_width / preview_coord_factor), (int) (preview_map_height / preview_coord_factor), 11, Navit.GlobalScaleLevel, 80000);
1039 }
1040 else if (Navit.GlobalScaleLevel > 400)
1041 {
1042 DrawLowqualMap_wrapper("" + preview_map_my_lat + "#" + preview_map_my_lon + "#" + 6, (int) (preview_map_width / preview_coord_factor), (int) (preview_map_height / preview_coord_factor), 11, Navit.GlobalScaleLevel, 20000);
1043 }
1044 else if (Navit.GlobalScaleLevel > 140)
1045 {
1046 DrawLowqualMap_wrapper("" + preview_map_my_lat + "#" + preview_map_my_lon + "#" + 9, (int) (preview_map_width / preview_coord_factor), (int) (preview_map_height / preview_coord_factor), 11, Navit.GlobalScaleLevel, 5000);
1047 }
1048 else
1049 {
1050 DrawLowqualMap_wrapper("" + preview_map_my_lat + "#" + preview_map_my_lon + "#" + 15, (int) (preview_map_width / preview_coord_factor), (int) (preview_map_height / preview_coord_factor), 11, Navit.GlobalScaleLevel, 2000);
1051 }
1052 }
1053
1054 // System.out.println("FLING:004:" + mScroller.getCurrX() + ":" + mScroller.getCurrY() + ":" + pos_x + ":" + pos_y + ":" + ZOOM_MODE_ACTIVE);
1055 if (touch_pointerCount < 2)
1056 {
1057 pos_x = pos_x - ((mScroller.getCurrX() - scroller_last_x) / fling_damper_factor);
1058 pos_y = pos_y - ((mScroller.getCurrY() - scroller_last_y) / fling_damper_factor);
1059 scroller_last_x = mScroller.getCurrX();
1060 scroller_last_y = mScroller.getCurrY();
1061 // scrollTo(mScroller.getCurrX(), mScroller.getCurrY());
1062 // touch_mode = NONE;
1063
1064 if (preview_bitmap != null)
1065 {
1066 // ORIG // canvas.drawBitmap(preview_bitmap, (0) + ((this.getWidth() / 2) + ((mScroller.getFinalX() - mScroller.getCurrX()) / fling_damper_factor)) - (preview_map_width / 2), (0) + ((this.getHeight() / 2) + ((mScroller.getFinalY() - mScroller.getCurrY()) / fling_damper_factor)) - (preview_map_height / 2), null);
1067 preview_map_last_pos_x = ((this.getWidth() / 2) + (mScroller.getFinalX() / fling_damper_factor) + (pos_x - prev_pos_x)) - (preview_map_width / 2);
1068 preview_map_last_pos_y = ((this.getHeight() / 2) + (mScroller.getFinalY() / fling_damper_factor) + (pos_y - prev_pos_y)) - (preview_map_height / 2);
1069 canvas.drawBitmap(preview_bitmap, preview_map_last_pos_x, preview_map_last_pos_y, null);
1070 ////System.out.println("CLEAR MAP:006:FL");
1071 preview_map_drawn = true;
1072 }
1073 // canvas.drawLine(this.getWidth() / 2, this.getHeight() / 2, (this.getWidth() / 2) + (mScroller.getFinalX() / fling_damper_factor), (this.getHeight() / 2) + (mScroller.getFinalY() / fling_damper_factor), paint_fling_line);
1074 // ++ // canvas.drawLine(this.getWidth() / 2, this.getHeight() / 2, (this.getWidth() / 2) - (mScroller.getFinalX() / fling_damper_factor), (this.getHeight() / 2) - (mScroller.getFinalY() / fling_damper_factor), paint_fling_line2);
1075
1076 scroller_active = true;
1077 this.postInvalidate();
1078 }
1079 }
1080 else
1081 {
1082 scroller_active = false;
1083 this.postInvalidate();
1084 }
1085 }
1086 else
1087 {
1088 if (scroller_active)
1089 {
1090 cancel_preview_map_drawing();
1091
1092 if (touch_pointerCount_passed_zero)
1093 {
1094 // System.out.println("FLING:005aa:" + mScroller.getCurrX() + ":" + mScroller.getCurrY() + ":" + pos_x + ":" + pos_y + ":" + ZOOM_MODE_ACTIVE);
1095
1096 if (preview_bitmap != null)
1097 {
1098 preview_map_last_pos_x = ((this.getWidth() / 2) + (mScroller.getFinalX() / fling_damper_factor) + (pos_x - prev_pos_x)) - (preview_map_width / 2);
1099 preview_map_last_pos_y = ((this.getHeight() / 2) + (mScroller.getFinalY() / fling_damper_factor) + (pos_y - prev_pos_y)) - (preview_map_height / 2);
1100 canvas.drawBitmap(preview_bitmap, preview_map_last_pos_x, preview_map_last_pos_y, null);
1101 //System.out.println("CLEAR MAP:007:FL");
1102 preview_map_drawn = true;
1103 }
1104
1105 scroller_last_x = 0;
1106 scroller_last_y = 0;
1107
1108 MotionCallback(0, 0, pos_x, pos_y);
1109 //System.out.println("FLING:005aa22:" + mScroller.getStartX() + ":" + mScroller.getStartY() + ":" + mScroller.getCurrX() + ":" + mScroller.getCurrY());
1110
1111 Global_Map_TransX = Global_Map_TransX + pos_x;
1112 Global_Map_TransY = Global_Map_TransY + pos_y;
1113 Global_Map_Rotationangle = 0f;
1114 Global_Map_Zoomfactor = Global_Map_Zoomfactor * ZOOM_MODE_SCALE;
1115 ZOOM_MODE_ACTIVE = false;
1116 ZOOM_MODE_SCALE = 1.0f;
1117
1118 scroller_active = false;
1119
1120 try
1121 {
1122 if (DEBUG_TOUCH) Log.e("NavitGraphics", "sensor thread stop 9797X99");
1123 //touch_sensor_thread.down();
1124 touch_sensor_thread.stop_me();
1125 // touch_sensor_thread.stop();
1126 }
1127 catch (Exception e)
1128 {
1129
1130 }
1131
1132 Global_onTouch_fingerdown = false;
1133 NavitGraphics.wait_for_redraw_map = false;
1134
1135 // allow all map drawing -----------
1136 msg2 = new Message();
1137 b2 = new Bundle();
1138 b2.putInt("Callback", 70);
1139 msg2.setData(b2);
1140 try
1141 {
1142 callback_handler.sendMessage(msg2);
1143 }
1144 catch (Exception e)
1145 {
1146 }
1147 // allow all map drawing -----------
1148
1149 pos_x = 0;
1150 pos_y = 0;
1151 this.postInvalidate();
1152
1153 scroller_last = 3;
1154 }
1155 }
1156 else
1157 // draw the preview map bitmap all the time (its crazy, i know)
1158 {
1159 // if (preview_bitmap != null)
1160 // {
1161 // canvas.drawBitmap(preview_bitmap,
1162 // ((this.getWidth() / 2) + (mScroller.getFinalX() /fling_damper_factor) + (pos_x - prev_pos_x) ) - (preview_map_width / 2),
1163 // ((this.getHeight() / 2) + (mScroller.getFinalY() / fling_damper_factor) + (pos_y - prev_pos_y) ) - (preview_map_height / 2),
1164 // null);
1165 // }
1166
1167 // System.out.println("CLEAR MAP:008:FLx");
1168 }
1169 }
1170
1171 // System.out.println("CLEAR MAP:024:scroller_last=" + scroller_last);
1172
1173 if (scroller_last == 1)
1174 {
1175 ClearPreview_bitmap();
1176 // System.out.println("CLEAR MAP:022:clear");
1177 }
1178
1179 if (preview_map_drawn != true)
1180 {
1181 preview_map_drawn = false;
1182 if (touch_mode != ZOOM)
1183 {
1184 if (preview_bitmap != null)
1185 {
1186 // ORIG // canvas.drawBitmap(preview_bitmap, (0) + ((this.getWidth() / 2) + ((mScroller.getFinalX() - mScroller.getCurrX()) / fling_damper_factor)) - (preview_map_width / 2), (0) + ((this.getHeight() / 2) + ((mScroller.getFinalY() - mScroller.getCurrY()) / fling_damper_factor)) - (preview_map_height / 2), null);
1187 canvas.drawBitmap(preview_bitmap, preview_map_last_pos_x, preview_map_last_pos_y, null);
1188 // canvas.drawColor(Color.GREEN);
1189 //System.out.println("CLEAR MAP:009:FL");
1190 }
1191 }
1192 else
1193 {
1194 ClearPreview_bitmap();
1195 // System.out.println("CLEAR MAP:021:clear");
1196 }
1197 }
1198
1199 // scroller - fling ----
1200 // scroller - fling ----
1201 // scroller - fling ----
1202 // ----------------------------------------------------------------------------------
1203 // ----------------------------------------------------------------------------------
1204 // ----------------------------------------------------------------------------------
1205
1206 if (scroller_last > 0)
1207 {
1208 scroller_last--;
1209 }
1210
1211 // ---------- 2D map -----------------------------------
1212 //
1213 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:onDraw:draw bitmap to SCREEN 2D -- START ------");
1214 canvas.save();
1215
1216 if (Navit.GFX_OVERSPILL)
1217 {
1218 // compensate overspill
1219 canvas.translate(-mCanvasWidth_overspill, -mCanvasHeight_overspill);
1220 // System.out.println("overspill");
1221 }
1222
1223 if ((ZOOM_MODE_ACTIVE) || (Global_Map_Zoomfactor != 1.0f))
1224 {
1225 if (Navit.GFX_OVERSPILL)
1226 {
1227 canvas.scale(ZOOM_MODE_SCALE * Global_Map_Zoomfactor, ZOOM_MODE_SCALE * Global_Map_Zoomfactor, Global_Map_TransX + Navit.NG__map_main.touch_now_center.x + mCanvasWidth_overspill, Global_Map_TransY + Navit.NG__map_main.touch_now_center.y + mCanvasHeight_overspill);
1228 }
1229 else
1230 {
1231 canvas.scale(ZOOM_MODE_SCALE * Global_Map_Zoomfactor, ZOOM_MODE_SCALE * Global_Map_Zoomfactor, Global_Map_TransX + Navit.NG__map_main.touch_now_center.x, Global_Map_TransY + Navit.NG__map_main.touch_now_center.y);
1232 }
1233 }
1234
1235 if (Global_Map_Rotationangle != 0.0f)
1236 {
1237 canvas.rotate(Global_Map_Rotationangle, Navit.NG__vehicle.vehicle_pos_x, Navit.NG__vehicle.vehicle_pos_y);
1238 }
1239
1240 if (Global_Map_Zoomfactor == 1.0f)
1241 {
1242 canvas.translate(Global_Map_TransX + pos_x, Global_Map_TransY + pos_y);
1243 }
1244 else
1245 {
1246 canvas.translate((Global_Map_TransX + pos_x) / Global_Map_Zoomfactor, (Global_Map_TransY + pos_y) / Global_Map_Zoomfactor);
1247 }
1248
1249 //System.out.println("DO__DRAW:onDraw():drawBitmap2D start");
1250 // canvas.drawColor(map_bg_color); // fill with yellow-ish bg color
1251 // draw bitmap to screen
1252 // canvas.drawBitmap(draw_bitmap_screen, 0, 0, paint_for_map_display);
1253 canvas.drawBitmap(draw_bitmap_screen, 0, 0, null);
1254 //System.out.println("DO__DRAW:onDraw():drawBitmap2D end");
1255 //System.out.println("CLEAR MAP:010:bs");
1256
1257 canvas.restore();
1258 // if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:onDraw:draw bitmap to SCREEN 2D -- READY ------");
1259 }
1260
1261 // draw vehicle also (it seems on newer android API the vehicle view does not get updated automatically anymore)
1262 if (!Navit.PAINT_OLD_API)
1263 {
1264 Navit.NG__vehicle.view.postInvalidate();
1265 }
1266
1267 Global_Map_in_onDraw = false;
1268
1269 // ----------------------------------------------------------------------------------
1270 // ----------------------------------------------------------------------------------
1271 // ----------------------------------------------------------------------------------
1272 // scroller - fling ----
1273 // scroller - fling ----
1274 // scroller - fling ----
1275
1276 // scroller - fling ----
1277 // scroller - fling ----
1278 // scroller - fling ----
1279 // ----------------------------------------------------------------------------------
1280 // ----------------------------------------------------------------------------------
1281 // ----------------------------------------------------------------------------------
1282
1283 }
1284 //System.out.println("DO__DRAW:onDraw():- end");
1285 }
1286
1287 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
1288 }
1289
1290 @Override
1291 public void init_view()
1292 {
1293 System.out.println("INIT Custom Map View");
1294
1295 paint_fling_line.setARGB(160, 120, 99, 99);
1296 paint_fling_line.setStyle(Paint.Style.STROKE);
1297 paint_fling_line.setStrokeWidth(dp_to_px(45));
1298 paint_fling_line.setAntiAlias(true);
1299 paint_fling_line.setDither(true);
1300
1301 paint_fling_line2.setARGB(200, 200, 99, 99);
1302 paint_fling_line2.setStyle(Paint.Style.STROKE);
1303 paint_fling_line2.setStrokeWidth(dp_to_px(30));
1304 paint_fling_line2.setAntiAlias(true);
1305 paint_fling_line2.setDither(true);
1306 }
1307
1308 @SuppressLint("NewApi")
1309 @Override
1310 protected void onSizeChanged(int w, int h, int oldw, int oldh)
1311 {
1312 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
1313
1314 if ((w == 0) || (h == 0))
1315 {
1316 return;
1317 }
1318
1319 // -- bottom bar --
1320 try
1321 {
1322 final FrameLayout a = (FrameLayout) Navit.Global_Navit_Object.findViewById(R.id.bottom_bar_slide);
1323 final RelativeLayout.LayoutParams pp22 = (RelativeLayout.LayoutParams) a.getLayoutParams();
1324 // System.out.println("hhh:1=" + a.getHeight());
1325 // System.out.println("hhh:3=" + pp22.topMargin);
1326
1327 Navit.map_view_height = h;
1328
1329 // map height + toolbar height + 80dp for topbar
1330 Navit.cur_y_margin_bottom_bar_touch = h + Navit.actionBarHeight + Navit.bottom_bar_px - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom
1331
1332 // System.out.println("hhh:4=map(h)=" + h + " actionbar(h)=" + Navit.actionBarHeight + " streetname(h)=" + Navit.bottom_bar_px);
1333
1334 pp22.setMargins(0, (int) Navit.cur_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom
1335 a.setLayoutParams(pp22);
1336 a.requestLayout();
1337 }
1338 catch (Exception e)
1339 {
1340 Navit.cur_y_margin_bottom_bar_touch = h + Navit.actionBarHeight + Navit.bottom_bar_px - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom
1341 }
1342 Navit.bottom_y_margin_bottom_bar_touch = Navit.cur_y_margin_bottom_bar_touch;
1343 // -- bottom bar --
1344
1345 mCanvasWidth = w;
1346 mCanvasHeight = h;
1347 int h_dpi = h;
1348 int w_dpi = w;
1349
1350 int oldw_overspill = oldw;
1351 int oldh_overspill = oldh;
1352 int w_overspill = w;
1353 int h_overspill = h;
1354
1355 if (Navit.GFX_OVERSPILL)
1356 {
1357 // if (w > h)
1358 // {
1359 // oldw_overspill = oldw;
1360 // oldh_overspill = oldw;
1361 // w_overspill = w;
1362 // h_overspill = w;
1363 // }
1364 // else if (h > w)
1365 // {
1366 // oldw_overspill = oldh;
1367 // oldh_overspill = oldh;
1368 // w_overspill = h;
1369 // h_overspill = h;
1370 // }
1371 // else
1372 // {
1373 // // w == h square screen? :-)
1374 // }
1375
1376 oldw_overspill = (int) ((double) (oldw_overspill) * Navit.OVERSPILL_FACTOR);
1377 oldh_overspill = (int) ((double) (oldh_overspill) * Navit.OVERSPILL_FACTOR);
1378 w_overspill = (int) ((double) (w_overspill) * Navit.OVERSPILL_FACTOR);
1379 h_overspill = (int) ((double) (h_overspill) * Navit.OVERSPILL_FACTOR);
1380
1381 }
1382
1383 // --------- set position of vehicle on screen to x pixel from map bottom ---------
1384 lower_than_center_percent = dp_to_px(10); // default value
1385 if (w > h)
1386 {
1387 lower_than_center_percent = dp_to_px(10); // old: 18; // default for landscape mode
1388 }
1389
1390 int min_height_map_in_px = getResources().getDimensionPixelSize(R.dimen.min_map_height_in_dp);
1391 if (h < min_height_map_in_px)
1392 {
1393 // lower_than_center_percent = 1; // if we have not much height -> put vehicle in the middle of the screen
1394 lower_than_center_percent = dp_to_px(10);
1395 }
1396
1397 if (Navit.GFX_OVERSPILL)
1398 {
1399 lower_than_center_percent = (int) ((float) lower_than_center_percent * Navit.OVERSPILL_FACTOR);
1400 }
1401
1402 Message msg33 = new Message();
1403 Bundle b33 = new Bundle();
1404 b33.putInt("Callback", 103);
1405 if (Navit.p.PREF_show_vehicle_in_center)
1406 {
1407 b33.putString("s", "0");
1408 }
1409 else
1410 {
1411 b33.putString("s", "" + lower_than_center_percent);
1412 }
1413 msg33.setData(b33);
1414 try
1415 {
1416 NavitGraphics.callback_handler.sendMessage(msg33);
1417 }
1418 catch (Exception e88)
1419 {
1420 }
1421 // --------- set position of vehicle on screen to x% lower than screen center ---------
1422
1423 // System.out.println("Graphics: old:" + w + " x " + h + " old:" + oldw + " x " + oldh);
1424 // System.out.println("Graphics: ovs:" + w_overspill + " x " + h_overspill + " old:" + oldw_overspill + " x " + oldh_overspill);
1425
1426 if (((w_overspill - mCanvasWidth) % 2) != 0)
1427 {
1428 oldw_overspill++;
1429 w_overspill++;
1430 }
1431
1432 if (((h_overspill - mCanvasHeight) % 2) != 0)
1433 {
1434 oldh_overspill++;
1435 h_overspill++;
1436 }
1437
1438 mCanvasWidth_overspill = (w_overspill - mCanvasWidth) / 2;
1439 mCanvasHeight_overspill = (h_overspill - mCanvasHeight) / 2;
1440
1441 // System.out.println("Graphics: ovs:" + (mCanvasWidth_overspill) + " x " + (mCanvasHeight_overspill));
1442
1443 // DPI
1444 int have_dpi = Navit.metrics.densityDpi;
1445 if (Global_want_dpi == have_dpi)
1446 {
1447 Global_dpi_factor = 1;
1448 }
1449 {
1450 Global_dpi_factor = ((float) Global_want_dpi / (float) have_dpi);
1451 }
1452 h_dpi = (int) ((float) h_overspill * Global_dpi_factor);
1453 w_dpi = (int) ((float) w_overspill * Global_dpi_factor);
1454 // System.out.println("Global_dpi_factor=" + Global_dpi_factor + " h_dpi=" + h_dpi + " w_dpi=" + w_dpi);
1455
1456 Global_dpi_factor_better = Navit.Global_Navit_Object.getResources().getDisplayMetrics().density;
1457 // DPI
1458
1459 // check if we need to hide actionbar icons ---------------------
1460 try
1461 {
1462 Navit.Global_Navit_Object.invalidateOptionsMenu();
1463 }
1464 catch (Exception e)
1465 {
1466 }
1467 // check if we need to hide actionbar icons ---------------------
1468
1469 super.onSizeChanged(w, h, oldw, oldh);
1470
1471 if (draw_bitmap != null)
1472 {
1473 // System.out.println("Graphics: draw_bitmap new:" + w_overspill + " x " + h_overspill + " old:" + oldw_overspill + " x " + oldh_overspill);
1474
1475 // try to avoid out of memory errors
1476 if ((oldw_overspill >= w_overspill) && (oldh_overspill >= h_overspill))
1477 {
1478 // System.out.println("Graphics: draw_bitmap: reuse");
1479 }
1480 else
1481 {
1482 // System.out.println("Graphics: draw_bitmap: create new");
1483 draw_bitmap.recycle();
1484 draw_bitmap = null;
1485 }
1486 }
1487
1488 boolean recycle = false;
1489
1490 if (draw_bitmap_screen != null)
1491 {
1492 // System.out.println("Graphics: draw_bitmap_screen new:" + w_overspill + " x " + h_overspill + " old:" + oldw_overspill + " x " + oldh_overspill);
1493
1494 // try to avoid out of memory errors
1495 if ((oldw_overspill >= w_overspill) && (oldh_overspill >= h_overspill))
1496 {
1497 recycle = true;
1498 }
1499 else
1500 {
1501 draw_bitmap_screen.recycle();
1502 draw_bitmap_screen = null;
1503 }
1504 }
1505
1506 if (draw_bitmap_screen2 != null)
1507 {
1508 // System.out.println("Graphics: draw_bitmap_screen2 new:" + w_overspill + " x " + h_overspill + " old:" + oldw_overspill + " x " + oldh_overspill);
1509
1510 // try to avoid out of memory errors
1511 if ((oldw_overspill >= w_overspill) && (oldh_overspill >= h_overspill))
1512 {
1513
1514 }
1515 else
1516 {
1517 draw_bitmap_screen2.recycle();
1518 draw_bitmap_screen2 = null;
1519 }
1520 }
1521
1522 if (draw_bitmap == null)
1523 {
1524 try
1525 {
1526 // ------ ???????????????????????
1527 // ------ ???????????????????????
1528 // ------ ???????????????????????
1529 // ------ ???????????????????????
1530 // ------ ???????????????????????
1531 // ------ ???????????????????????
1532 // ------ ???????????????????????
1533 // ------ ???????????????????????
1534 draw_bitmap = Bitmap.createBitmap(w_dpi, h_dpi, Bitmap.Config.ARGB_8888); // _dpi or not ??????????????????????????
1535 System.out.println("_BITM_:need w-h=" + w_dpi + "-" + h_dpi + " have w-h=" + mCanvasWidth + "-" + mCanvasHeight);
1536 // ------ ???????????????????????
1537 // ------ ???????????????????????
1538 // ------ ???????????????????????
1539 // ------ ???????????????????????
1540 // ------ ???????????????????????
1541 // ------ ???????????????????????
1542 // ------ ???????????????????????
1543 // draw_bitmap.setDensity(Global_want_dpi);
1544 }
1545 catch (OutOfMemoryError e)
1546 {
1547 int usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L);
1548 String usedMegsString = String.format(" - Memory Used: %d MB", usedMegs);
1549 System.out.println("" + usedMegsString);
1550 System.out.println("@@@@@@@@ out of VM Memory @@@@@@@@");
1551 draw_bitmap = null;
1552 draw_canvas = null;
1553 System.gc();
1554 System.gc();
1555 usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L);
1556 usedMegsString = String.format(" - Memory Used: %d MB", usedMegs);
1557 System.out.println("" + usedMegsString);
1558 // try again
1559 // draw_bitmap = Bitmap.createBitmap(w_overspill, h_overspill, Bitmap.Config.ARGB_8888);
1560 draw_bitmap = Bitmap.createBitmap(w_dpi, h_dpi, Bitmap.Config.ARGB_8888);
1561 //draw_bitmap.setDensity(Global_want_dpi);
1562 }
1563 }
1564
1565 // view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
1566
1567 if (draw_bitmap_screen == null)
1568 {
1569 try
1570 {
1571 draw_bitmap_screen = Bitmap.createBitmap(w_overspill, h_overspill, Bitmap.Config.ARGB_8888);
1572 // DPI
1573 //draw_bitmap_screen.setDensity(Global_want_dpi);
1574 }
1575 catch (OutOfMemoryError e)
1576 {
1577 int usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L);
1578 String usedMegsString = String.format(" - Memory Used: %d MB", usedMegs);
1579 System.out.println("" + usedMegsString);
1580 System.out.println("@@@@@@@@ out of VM Memory @@@@@@@@");
1581 draw_bitmap_screen = null;
1582 draw_canvas_screen = null;
1583 System.gc();
1584 System.gc();
1585 usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L);
1586 usedMegsString = String.format(" - Memory Used: %d MB", usedMegs);
1587 System.out.println("" + usedMegsString);
1588 // try again
1589 draw_bitmap_screen = Bitmap.createBitmap(w_overspill, h_overspill, Bitmap.Config.ARGB_8888);
1590 //draw_bitmap_screen.setDensity(Global_want_dpi);
1591 }
1592 }
1593
1594 if (draw_bitmap_screen2 == null)
1595 {
1596 try
1597 {
1598 draw_bitmap_screen2 = Bitmap.createBitmap(w_overspill, h_overspill, Bitmap.Config.ARGB_8888);
1599 // DPI
1600 //draw_bitmap_screen2.setDensity(Global_want_dpi);
1601 }
1602 catch (OutOfMemoryError e)
1603 {
1604 int usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L);
1605 String usedMegsString = String.format(" - Memory Used: %d MB", usedMegs);
1606 System.out.println("" + usedMegsString);
1607 System.out.println("@@@@@@@@ out of VM Memory @@@@@@@@");
1608 draw_bitmap_screen2 = null;
1609 draw_canvas_screen2 = null;
1610 System.gc();
1611 System.gc();
1612 usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L);
1613 usedMegsString = String.format(" - Memory Used: %d MB", usedMegs);
1614 System.out.println("" + usedMegsString);
1615 // try again
1616 draw_bitmap_screen2 = Bitmap.createBitmap(w_overspill, h_overspill, Bitmap.Config.ARGB_8888);
1617 //draw_bitmap_screen2.setDensity(Global_want_dpi);
1618 }
1619 }
1620
1621 draw_canvas = new Canvas(draw_bitmap);
1622 // DPI
1623 draw_canvas.setDensity(Global_want_dpi);
1624
1625 draw_canvas_screen = new Canvas(draw_bitmap_screen);
1626 // DPI
1627 //draw_canvas_screen.setDensity(Global_want_dpi);
1628
1629 draw_canvas_screen2 = new Canvas(draw_bitmap_screen2);
1630
1631 /*
1632 * draw_canvas.drawColor(Color.BLACK);
1633 * draw_canvas_screen.drawColor(Color.BLACK);
1634 * draw_canvas_screen2.drawColor(Color.BLACK);
1635 */
1636
1637 // DPI
1638 //draw_canvas_screen2.setDensity(Global_want_dpi);
1639 if (gr_type == 1)
1640 {
1641 //System.out.println("*map*gra*");
1642 draw_bitmap_s = draw_bitmap;
1643 draw_canvas_s = draw_canvas;
1644 draw_bitmap_screen_s = draw_bitmap_screen;
1645 draw_canvas_screen_s = draw_canvas_screen;
1646 draw_bitmap_screen_s2 = draw_bitmap_screen2;
1647 draw_canvas_screen_s2 = draw_canvas_screen2;
1648
1649 if (recycle)
1650 {
1651 draw_canvas.drawColor(Color.BLACK);
1652 draw_canvas_screen.drawColor(Color.BLACK);
1653 draw_canvas_screen2.drawColor(Color.BLACK);
1654 }
1655 }
1656 bitmap_w = w;
1657 bitmap_h = h;
1658
1659 // DPI
1660 SizeChangedCallback(w_dpi, h_dpi, draw_bitmap_s);
1661 //SizeChangedCallback(w, h);
1662
1663 // 3D modus -----------------
1664 init_3d_mode();
1665 // 3D modus -----------------
1666
1667 draw_factor = 1.0f;
1668 if (Navit.my_display_density.compareTo("mdpi") == 0)
1669 {
1670 draw_factor = 1.0f;
1671 }
1672 else if (Navit.my_display_density.compareTo("ldpi") == 0)
1673 {
1674 draw_factor = 0.7f;
1675 }
1676 else if (Navit.my_display_density.compareTo("hdpi") == 0)
1677 {
1678 draw_factor = 1.5f;
1679 }
1680
1681 if (Navit.first_ever_startup)
1682 {
1683 Navit.first_ever_startup = false;
1684 //System.out.println("");
1685 //System.out.println("*** Zoom out FULL (#startup#) ***");
1686 //System.out.println("");
1687 Message msg = new Message();
1688 Bundle b = new Bundle();
1689 b.putInt("Callback", 8);
1690 msg.setData(b);
1691 callback_handler.sendMessage(msg);
1692 }
1693
1694 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
1695 }
1696
1697 void printSamples(MotionEvent ev)
1698 {
1699 final int historySize = ev.getHistorySize();
1700 final int pointerCount = ev.getPointerCount();
1701 for (int h = 0; h < historySize; h++)
1702 {
1703 System.out.printf("At time %d:", ev.getHistoricalEventTime(h));
1704 for (int p = 0; p < pointerCount; p++)
1705 {
1706 System.out.printf(" pointer %d: (%f,%f)", ev.getPointerId(p), ev.getHistoricalX(p, h), ev.getHistoricalY(p, h));
1707 }
1708 }
1709 System.out.printf("At time %d:", ev.getEventTime());
1710 for (int p = 0; p < pointerCount; p++)
1711 {
1712 System.out.printf(" pointer %d: (%f,%f)", ev.getPointerId(p), ev.getX(p), ev.getY(p));
1713 }
1714 }
1715
1716 GestureDetector mGD = new GestureDetector(getContext(), new SimpleOnGestureListener()
1717 {
1718
1719 @Override
1720 public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
1721 {
1722 // beware, it can scroll to infinity
1723 // scrollBy((int) distanceX, (int) distanceY);
1724 //System.out.println("FLING:001:" + distanceX + ":" + distanceY);
1725 return true;
1726 }
1727
1728 @Override
1729 public boolean onFling(MotionEvent e1, MotionEvent e2, float vX, float vY)
1730 {
1731 if (touch_mode != ZOOM)
1732 {
1733 //System.out.println("FLING:002:" + vX + ":" + vY);
1734 mScroller.fling(getScrollX(), getScrollY(), -(int) vX, -(int) vY, -5000, 5000, -5000, 5000);
1735 invalidate(); // don't remember if it's needed
1736 }
1737 else
1738 {
1739 mScroller.forceFinished(true);
1740 }
1741 return true;
1742 }
1743
1744 @Override
1745 public boolean onDown(MotionEvent e)
1746 {
1747 if (!mScroller.isFinished())
1748 {
1749 // is flinging
1750 mScroller.forceFinished(true); // to stop flinging on touch
1751 }
1752 return true; // else won't work
1753 }
1754 });
1755
1756 @Override
1757 public boolean onTouchEvent(MotionEvent event)
1758 {
1759 PointF touch_now2 = null;
1760 PointF touch_start2 = null;
1761 PointF touch_prev2 = null;
1762 PointF touch_last_load_tiles2 = null;
1763
1764 super.onTouchEvent(event);
1765
1766 if (DEBUG_TOUCH) Log.e("NavitGraphics", "onTouchEvent");
1767 if (DEBUG_TOUCH) Log.e("NavitGraphics", "systime1:" + System.currentTimeMillis());
1768 if (DEBUG_TOUCH) Log.e("NavitGraphics", "eventtime1:" + event.getEventTime());
1769
1770 int action = event.getAction();
1771 int x = (int) event.getX();
1772 int y = (int) event.getY();
1773
1774 int _ACTION_POINTER_UP_ = MotionEvent.ACTION_POINTER_UP;
1775 int _ACTION_POINTER_DOWN_ = MotionEvent.ACTION_POINTER_DOWN;
1776 int _ACTION_MASK_ = MotionEvent.ACTION_MASK;
1777
1778 // calculate value
1779 int switch_value = (event.getAction() & _ACTION_MASK_);
1780 // Log.e("NavitGraphics", "FLING:switch_value=" + switch_value);
1781 // Log.e("NavitGraphics", "FLING:getAction=" + action);
1782 // Log.e("NavitGraphics", "FLING:ACTION_CANCEL=" + MotionEvent.ACTION_CANCEL);
1783 // Log.e("NavitGraphics", "FLING:_ACTION_MASK_=" + _ACTION_MASK_);
1784 // if (DEBUG_TOUCH)
1785 // calculate value
1786
1787 if (switch_value == 0)
1788 {
1789 touch_pointerCount_passed_zero = true;
1790 // System.out.println("FLING:003:stat:RESET ************");
1791 }
1792 else
1793 {
1794 if (touch_pointerCount_passed_zero)
1795 {
1796 if (event.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN)
1797 {
1798 // System.out.println("FLING:003:stat:second pointer touched DOWN ============");
1799 touch_pointerCount_passed_zero = false;
1800 }
1801 }
1802 }
1803
1804 // System.out.println("FLING:003:stat:count_old=" + touch_pointerCount + ":count=" + event.getPointerCount() + ":action_index=" + event.getActionIndex() + ":passed_zero=" + touch_pointerCount_passed_zero);
1805 touch_pointerCount_old = touch_pointerCount;
1806 touch_pointerCount = event.getPointerCount();
1807
1808 if (touch_pointerCount_passed_zero)
1809 {
1810 boolean ret_2 = mGD.onTouchEvent(event);
1811 if (ret_2)
1812 {
1813 if (touch_mode == ZOOM)
1814 {
1815 // dont use gesture while already zooming
1816 }
1817 else
1818 {
1819 // if gesture used, then don't do anything else
1820 if (mScroller.computeScrollOffset())
1821 {
1822 // System.out.println("FLING:003:xxxxxxxx ++FLING++ " + pos_x + ":" + pos_y);
1823 fling_start = true;
1824 return true;
1825 }
1826 else
1827 {
1828 //System.out.println("FLING:003:aa *GE touch* " + pos_x + ":" + pos_y);
1829 }
1830 }
1831 }
1832 else
1833 {
1834 //System.out.println("FLING:003:cc *normal touch* " + pos_x + ":" + pos_y);
1835 }
1836 }
1837
1838 // if (NavitAndroidOverlay.voice_rec_bar_visible)
1839 // {
1840 // if (action == MotionEvent.ACTION_UP)
1841 // {
1842 // NavitAndroidOverlay.voice_rec_bar_visible = false;
1843 // //System.out.println("xx paint 15 xx");
1844 // NavitAOverlay_s.postInvalidate();
1845 // }
1846 // else
1847 // {
1848 // if (event.getPointerCount() < 2)
1849 // {
1850 // NavitAndroidOverlay.voice_rec_bar_x = x;
1851 // NavitAndroidOverlay.voice_rec_bar_y = y;
1852 //
1853 // if (NavitAndroidOverlay.voice_rec_bar_x > NavitAndroidOverlay.voice_rec_bar_limit)
1854 // {
1855 // NavitAndroidOverlay.voice_rec_bar_visible = false;
1856 // NavitAndroidOverlay.voice_rec_bar_visible2 = true;
1857 // //System.out.println("xx paint 16 xx");
1858 // NavitAOverlay_s.postInvalidate();
1859 //
1860 // // open voice search screen
1861 // try
1862 // {
1863 // Message msg = Navit.Navit_progress_h.obtainMessage();
1864 // Bundle b = new Bundle();
1865 // msg.what = 19;
1866 // msg.setData(b);
1867 // Navit.Navit_progress_h.sendMessage(msg);
1868 // }
1869 // catch (Exception e)
1870 // {
1871 // e.printStackTrace();
1872 // }
1873 // }
1874 // else
1875 // {
1876 // //System.out.println("xx paint 17 xx");
1877 // NavitAOverlay_s.postInvalidate();
1878 // }
1879 // }
1880 // else
1881 // {
1882 // NavitAndroidOverlay.voice_rec_bar_visible = false;
1883 // //System.out.println("xx paint 18 xx");
1884 // NavitAOverlay_s.postInvalidate();
1885 // }
1886 // }
1887 //
1888 // // dont do anything else with this event
1889 // return true;
1890 // }
1891
1892 if (DEBUG_TOUCH) Log.e("NavitGraphics", "event x=" + event.getX() + " y=" + event.getY());
1893
1894 if (switch_value == MotionEvent.ACTION_DOWN)
1895 {
1896 Global_onTouch_fingerdown = true;
1897
1898 this.touch_now.set(event.getX(), event.getY());
1899 this.touch_start.set(event.getX(), event.getY());
1900 this.touch_prev.set(event.getX(), event.getY());
1901 if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_DOWN start");
1902 //System.out.println("DO__DRAW:Java:ACTION DOWN start");
1903
1904 d_pos_x_old = pos_x;
1905 d_pos_y_old = pos_y;
1906 //Log.e("NavitGraphics", "pos_x=" + pos_x);
1907 //Log.e("NavitGraphics", "pos_y=" + pos_y);
1908
1909 // cancel previous map drawing
1910 //System.out.println("DO__DRAW:Java:cancel map drawing");
1911 // CallbackMessageChannel(50, "");
1912 CallbackMessageChannelReal(50, "");
1913
1914 if (in_map)
1915 {
1916 if (!NavitAOverlay.get_show_bubble())
1917 {
1918 if (DEBUG_TOUCH) Log.e("NavitGraphics", "hide bubble X1");
1919 NavitAOverlay.hide_bubble();
1920 // remember last press on screen time
1921 last_touch_on_screen = event.getEventTime(); // System.currentTimeMillis();
1922 touch_sensor_thread = new SensorThread(last_touch_on_screen, this.touch_now.x, this.touch_now.y);
1923 touch_sensor_thread.start();
1924 }
1925 }
1926
1927 wait_for_redraw_map = true;
1928 if (DEBUG_TOUCH) System.out.println("wait_for_redraw_map=true");
1929
1930 // down
1931 // Message msg = new Message();
1932 // Bundle b = new Bundle();
1933 // b.putInt("Callback", 21);
1934 // b.putInt("x", x);
1935 // b.putInt("y", y);
1936 // msg.setData(b);
1937 // callback_handler.sendMessage(msg);
1938 // ButtonCallback(ButtonCallbackID, 1, 1, x, y); // down
1939
1940 // wait_for_redraw_map = false;
1941
1942 touch_mode = DRAG;
1943
1944 if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_DOWN end");
1945
1946 // hold all map drawing -----------
1947 Message msg = new Message();
1948 Bundle b = new Bundle();
1949 b.putInt("Callback", 69);
1950 msg.setData(b);
1951 try
1952 {
1953 callback_handler.sendMessage(msg);
1954 }
1955 catch (Exception e)
1956 {
1957 }
1958 // hold all map drawing -----------
1959
1960 //System.out.println("DO__DRAW:Java:ACTION DOWN end");
1961
1962 }
1963 else if ((switch_value == MotionEvent.ACTION_UP) || (switch_value == _ACTION_POINTER_UP_))
1964 {
1965 this.touch_now.set(event.getX(), event.getY());
1966 touch_now2 = touch_now;
1967 touch_start2 = touch_start;
1968
1969 //System.out.println("DO__DRAW:Java:ACTION UP start");
1970
1971 if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_UP start");
1972 if (DEBUG_TOUCH) Log.e("NavitGraphics", "xxxxxxxxxx");
1973 try
1974 {
1975 if (DEBUG_TOUCH) Log.e("NavitGraphics", "sensor thread stop X1");
1976 //touch_sensor_thread.down();
1977 touch_sensor_thread.stop_me();
1978 // touch_sensor_thread.stop();
1979 }
1980 catch (Exception e)
1981 {
1982
1983 }
1984 // if it was a real longpress, dont hide the bubble
1985 long real_event_time = event.getEventTime();
1986 // long real_event_time = System.currentTimeMillis();
1987 if ((in_map) && ((real_event_time - last_touch_on_screen) > long_press_on_screen_interval))
1988 {
1989 // real long press
1990 }
1991 else
1992 {
1993 if (DEBUG_TOUCH) Log.e("NavitGraphics", "hide bubble 1");
1994 NavitAOverlay.hide_bubble();
1995 }
1996
1997 if ((touch_mode == DRAG) && (spacing(touch_start2, touch_now2) < long_press_on_screen_max_distance))
1998 {
1999 // just a single press down
2000 touch_mode = PRESS;
2001
2002 try
2003 {
2004 if (DEBUG_TOUCH) Log.e("NavitGraphics", "touch_sensor_thread.stop 1");
2005 //touch_sensor_thread.down();
2006 touch_sensor_thread.stop_me();
2007 // touch_sensor_thread.stop();
2008 }
2009 catch (Exception e)
2010 {
2011
2012 }
2013
2014 // was it a long press? or normal quick touch?
2015 //if ((in_map) && ((System.currentTimeMillis() - last_touch_on_screen) > long_press_on_screen_interval))
2016 //{
2017 // Log.e("NavitGraphics", "onTouch up (LONG PRESS 1)");
2018 // do_longpress_action(touch_now.x, touch_now.y);
2019 //}
2020 //else
2021 //{
2022 //Log.e("NavitGraphics", "onTouch up (quick touch)");
2023 //wait_for_redraw_map = true;
2024 //System.out.println("wait_for_redraw_map=true 2");
2025
2026 //*ButtonCallback(ButtonCallbackID, 0, 1, x, y); // up
2027
2028 // quick touch --> here we could repeat the last spoken direction ...
2029 // quick touch --> here we could repeat the last spoken direction ...
2030 // quick touch --> here we could repeat the last spoken direction ...
2031 // quick touch --> here we could repeat the last spoken direction ...
2032 // quick touch --> here we could repeat the last spoken direction ...
2033 // quick touch --> here we could repeat the last spoken direction ...
2034 // quick touch --> here we could repeat the last spoken direction ...
2035 // quick touch --> here we could repeat the last spoken direction ...
2036
2037 if (DEBUG_TOUCH) System.out.println("wait_for_redraw_map=false 9");
2038 NavitGraphics.wait_for_redraw_map = false;
2039 try
2040 {
2041 if (DEBUG_TOUCH) Log.e("NavitGraphics", "overlay thread stop X1");
2042 //NavitAndroidOverlay.overlay_draw_thread1.stop_redraw();
2043 //NavitAndroidOverlay.overlay_draw_thread1.stop_me();
2044 //NavitAndroidOverlay.overlay_draw_thread1 = null;
2045 }
2046 catch (Exception e)
2047 {
2048 //e.printStackTrace();
2049 }
2050 try
2051 {
2052 //System.out.println("invalidate 011");
2053 //System.out.println("xx paint 19 xx");
2054 NavitAOverlay_s.postInvalidate();
2055 }
2056 catch (Exception e)
2057 {
2058 e.printStackTrace();
2059 }
2060 //}
2061 touch_mode = NONE;
2062 }
2063 else
2064 {
2065 if (touch_mode == DRAG)
2066 {
2067 touch_now2 = touch_now;
2068 touch_start2 = touch_start;
2069
2070 if (DEBUG_TOUCH) Log.e("NavitGraphics", "onTouch move");
2071
2072 try
2073 {
2074 if (DEBUG_TOUCH) Log.e("NavitGraphics", "sensor thread stop X2");
2075 //touch_sensor_thread.down();
2076 touch_sensor_thread.stop_me();
2077 // touch_sensor_thread.stop();
2078 }
2079 catch (Exception e)
2080 {
2081
2082 }
2083
2084 // if we drag, hide the bubble --> NO !!
2085 // NavitAOverlay.hide_bubble();
2086
2087 // wait_for_redraw_map = true;
2088 //System.out.println("wait_for_redraw_map=true 3");
2089
2090 // DRAG ----------- new END --------------
2091 // DRAG ----------- new END --------------
2092 // DRAG ----------- new END --------------
2093 // this.touch_start
2094 // this.touch_now
2095 //pos_x = (int) (this.touch_now.x - this.touch_start.x);
2096 //pos_y = (int) (this.touch_now.y - this.touch_start.y);
2097
2098 // pos_x = d_pos_x_old; // wait for redraw !!
2099 // pos_y = d_pos_y_old; // wait for redraw !!
2100
2101 // ??? // ButtonCallback(1, 1, (int) this.touch_start.x, (int) this.touch_start.y); // down
2102 //this.invalidate();
2103 //this.postInvalidate();
2104 // DRAG ----------- new END --------------
2105 // DRAG ----------- new END --------------
2106 // DRAG ----------- new END --------------
2107
2108 // allow all map drawing -----------
2109 Message msg2 = new Message();
2110 Bundle b2 = new Bundle();
2111 b2.putInt("Callback", 70);
2112 msg2.setData(b2);
2113 try
2114 {
2115 callback_handler.sendMessage(msg2);
2116 }
2117 catch (Exception e)
2118 {
2119 }
2120
2121 // MotionCallback(x, y);
2122
2123 //System.out.println("DO__DRAW:Java:motion call back JAVA -START-");
2124 // -- new call --
2125 // if (dl_thread[0] != null)
2126 // {
2127 // 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);
2128 // }
2129 // -- old call --
2130 MotionCallback((int) this.touch_start.x, (int) this.touch_start.y, (int) this.touch_now.x, (int) this.touch_now.y);
2131 //System.out.println("DO__DRAW:Java:motion call back JAVA --END--");
2132
2133 //msg2 = new Message();
2134 //b2 = new Bundle();
2135 //b2.putInt("Callback", 23);
2136 //b2.putInt("x",(int) this.touch_start.x);
2137 //b2.putInt("y",(int) this.touch_start.y);
2138 //b2.putInt("x2",(int) this.touch_now.x);
2139 //b2.putInt("y2",(int) this.touch_now.y);
2140 //msg2.setData(b2);
2141 //try
2142 //{
2143 // callback_handler.sendMessage(msg2);
2144 //}
2145 //catch (Exception e)
2146 //{
2147 //}
2148
2149 // ??? // ButtonCallback(0, 1, x, y); // up
2150
2151 if (!Navit.p.PREF_follow_gps)
2152 {
2153 if (Navit.GFX_OVERSPILL)
2154 {
2155 Navit.cwthr.CallbackGeoCalc2(1, 0, NavitGraphics.Global_dpi_factor * (mCanvasWidth / 2 + NavitGraphics.mCanvasWidth_overspill), NavitGraphics.Global_dpi_factor * (mCanvasHeight / 2 + NavitGraphics.mCanvasHeight_overspill));
2156 }
2157 else
2158 {
2159 Navit.cwthr.CallbackGeoCalc2(1, 0, NavitGraphics.Global_dpi_factor * mCanvasWidth / 2, NavitGraphics.Global_dpi_factor * mCanvasHeight / 2);
2160 }
2161 }
2162
2163 // try
2164 // {
2165 // // try to show current location/streetname
2166 // Message msg1 = new Message();
2167 // Bundle b1 = new Bundle();
2168 // b1.putInt("Callback", 9901);
2169 // msg1.setData(b1);
2170 // NavitGraphics.callback_handler_s.sendMessage(msg1);
2171 // }
2172 // catch (Exception e)
2173 // {
2174 //
2175 // }
2176
2177 touch_mode = NONE;
2178 }
2179 else
2180 {
2181 if (touch_mode == ZOOM)
2182 {
2183 // end of "pinch zoom" move
2184 // ZOOM_MODE_ACTIVE = false; // wait for redraw !!
2185 // ZOOM_MODE_SCALE = 1.0f; // wait for redraw !!
2186
2187 if (DEBUG_TOUCH) Log.e("NavitGraphics", "onTouch zoom");
2188
2189 float newDist = spacing(event);
2190 float scale = 1.0f;
2191 // if (newDist > 10f)
2192 if (newDist > (Navit.swipeMaxOffPath / 2))
2193 {
2194 scale = newDist / oldDist;
2195 }
2196
2197 if (scale > 1.0f)
2198 {
2199 wait_for_redraw_map = true;
2200 if (DEBUG_TOUCH) System.out.println("wait_for_redraw_map=true 4");
2201
2202 try
2203 {
2204 if (DEBUG_TOUCH) Log.e("NavitGraphics", "sensor thread stop X3");
2205 //touch_sensor_thread.down();
2206 touch_sensor_thread.stop_me();
2207 // touch_sensor_thread.stop();
2208 }
2209 catch (Exception e)
2210 {
2211
2212 }
2213 if (DEBUG_TOUCH) Log.e("NavitGraphics", "hide bubble 2");
2214 // if we drag, hide the bubble
2215 NavitAOverlay.hide_bubble();
2216
2217 // zoom in
2218 if (scale < 0.1f)
2219 {
2220 scale = 0.1f;
2221 }
2222 else if (scale > 6)
2223 {
2224 scale = 6;
2225 }
2226
2227 // pos_x = d_pos_x_old; // wait for redraw !!
2228 // pos_y = d_pos_y_old; // wait for redraw !!
2229
2230 Message msg = new Message();
2231 Bundle b = new Bundle();
2232 b.putInt("Callback", 61);
2233 //System.out.println("sc1:" + Navit.GlobalScaleLevel);
2234 Navit.GlobalScaleLevel = (int) (Navit.GlobalScaleLevel / scale);
2235 //System.out.println("sc1.1:" + Navit.GlobalScaleLevel);
2236
2237 Navit.NG__map_main.touch_now_center = calc_center(event);
2238 // zzzzzzzzzzzzz;
2239 if (Navit.GFX_OVERSPILL)
2240 {
2241 b.putString("s", (int) ((Navit.NG__map_main.touch_now_center.x + mCanvasWidth_overspill) * Global_dpi_factor) + "#" + (int) ((Navit.NG__map_main.touch_now_center.y + mCanvasHeight_overspill) * Global_dpi_factor) + "#" + Integer.toString(Navit.GlobalScaleLevel));
2242 }
2243 else
2244 {
2245 b.putString("s", (int) ((Navit.NG__map_main.touch_now_center.x) * Global_dpi_factor) + "#" + (int) ((Navit.NG__map_main.touch_now_center.y) * Global_dpi_factor) + "#" + Integer.toString(Navit.GlobalScaleLevel));
2246 }
2247 msg.setData(b);
2248 try
2249 {
2250 callback_handler.sendMessage(msg);
2251 //System.out.println("touch: set zoom(in) level: " + Navit.GlobalScaleLevel);
2252 }
2253 catch (Exception e)
2254 {
2255 }
2256
2257 // next lines are a hack, without it screen will not get updated anymore!
2258 //*ButtonCallback(ButtonCallbackID, 1, 1, x, y); // down
2259 //*MotionCallback(MotionCallbackID, x + 15, y);
2260 //*MotionCallback(MotionCallbackID, x - 15, y);
2261 //*ButtonCallback(ButtonCallbackID, 0, 1, x, y); // up
2262 //*this.postInvalidate();
2263
2264 try
2265 {
2266 if (DEBUG_TOUCH) Log.e("NavitGraphics", "sensor thread stop X4");
2267 //touch_sensor_thread.down();
2268 touch_sensor_thread.stop_me();
2269 // touch_sensor_thread.stop();
2270 }
2271 catch (Exception e)
2272 {
2273
2274 }
2275 // if we drag, hide the bubble
2276 if (DEBUG_TOUCH) Log.e("NavitGraphics", "hide bubble X3");
2277 NavitAOverlay.hide_bubble();
2278
2279 if (DEBUG_TOUCH) Log.e("NavitGraphics", "onTouch zoom in");
2280 }
2281 else if (scale < 1.0f)
2282 {
2283 wait_for_redraw_map = true;
2284 if (DEBUG_TOUCH) System.out.println("wait_for_redraw_map=true 5");
2285
2286 try
2287 {
2288 if (DEBUG_TOUCH) Log.e("NavitGraphics", "sensor thread stop X5");
2289 //touch_sensor_thread.down();
2290 touch_sensor_thread.stop_me();
2291 // touch_sensor_thread.stop();
2292 }
2293 catch (Exception e)
2294 {
2295
2296 }
2297 if (DEBUG_TOUCH) Log.e("NavitGraphics", "hide bubble 3");
2298 // if we drag, hide the bubble
2299 NavitAOverlay.hide_bubble();
2300
2301 // zoom out
2302
2303 if (scale < 0.07f)
2304 {
2305 scale = 0.07f;
2306 }
2307 else if (scale > 6)
2308 {
2309 scale = 6;
2310 }
2311
2312 // pos_x = d_pos_x_old; // wait for redraw !!
2313 // pos_y = d_pos_y_old; // wait for redraw !!
2314
2315 Message msg = new Message();
2316 Bundle b = new Bundle();
2317 b.putInt("Callback", 61);
2318 //System.out.println("sc2:" + Navit.GlobalScaleLevel);
2319 Navit.GlobalScaleLevel = (int) (Navit.GlobalScaleLevel / scale);
2320
2321 if (Navit.GlobalScaleLevel == ((int) (Navit.GlobalScaleLevel / scale)))
2322 {
2323 // movement was too small for (int) change. so change it anyway
2324 Navit.GlobalScaleLevel++;
2325 }
2326
2327 if (Navit.GlobalScaleLevel < 2)
2328 {
2329 Navit.GlobalScaleLevel = 2;
2330 }
2331 //System.out.println("sc2.1:" + Navit.GlobalScaleLevel);
2332 Navit.NG__map_main.touch_now_center = calc_center(event);
2333
2334 if (Navit.GFX_OVERSPILL)
2335 {
2336 b.putString("s", (int) ((Navit.NG__map_main.touch_now_center.x + mCanvasWidth_overspill) * Global_dpi_factor) + "#" + (int) ((Navit.NG__map_main.touch_now_center.y + mCanvasHeight_overspill) * Global_dpi_factor) + "#" + Integer.toString(Navit.GlobalScaleLevel));
2337 }
2338 else
2339 {
2340 b.putString("s", (int) ((Navit.NG__map_main.touch_now_center.x) * Global_dpi_factor) + "#" + (int) ((Navit.NG__map_main.touch_now_center.y) * Global_dpi_factor) + "#" + Integer.toString(Navit.GlobalScaleLevel));
2341 }
2342 msg.setData(b);
2343 try
2344 {
2345 callback_handler.sendMessage(msg);
2346 //System.out.println("touch: set zoom(out) level: " + Navit.GlobalScaleLevel);
2347 }
2348 catch (Exception e)
2349 {
2350 }
2351
2352 // next lines are a hack, without it screen will not get updated anymore!
2353 //*ButtonCallback(ButtonCallbackID, 1, 1, x, y); // down
2354 //*MotionCallback(MotionCallbackID, x + 15, y);
2355 //*MotionCallback(MotionCallbackID, x - 15, y);
2356 //*ButtonCallback(ButtonCallbackID, 0, 1, x, y); // up
2357 //*this.postInvalidate();
2358
2359 try
2360 {
2361 if (DEBUG_TOUCH) Log.e("NavitGraphics", "sensor thread stop X6");
2362 //touch_sensor_thread.down();
2363 touch_sensor_thread.stop_me();
2364 // touch_sensor_thread.stop();
2365 }
2366 catch (Exception e)
2367 {
2368
2369 }
2370 if (DEBUG_TOUCH) Log.e("NavitGraphics", "hide bubble 4");
2371 // if we drag, hide the bubble
2372 NavitAOverlay.hide_bubble();
2373
2374 if (DEBUG_TOUCH) Log.e("NavitGraphics", "onTouch zoom out");
2375 }
2376 else
2377 {
2378 // pos_x = d_pos_x_old; // wait for redraw !!
2379 // pos_y = d_pos_y_old; // wait for redraw !!
2380
2381 // move was not zoom-out OR zoom-in
2382 // so just ignore and remove any pending stuff
2383 if (DEBUG_TOUCH) System.out.println("wait_for_redraw_map=false 10");
2384 NavitGraphics.wait_for_redraw_map = false;
2385 try
2386 {
2387 if (DEBUG_TOUCH) Log.e("NavitGraphics", "overlay thread stop X10");
2388 //NavitAndroidOverlay.overlay_draw_thread1.stop_redraw();
2389 //NavitAndroidOverlay.overlay_draw_thread1.stop_me();
2390 //NavitAndroidOverlay.overlay_draw_thread1 = null;
2391 }
2392 catch (Exception e)
2393 {
2394 //e.printStackTrace();
2395 }
2396 try
2397 {
2398 //System.out.println("invalidate 012");
2399 //System.out.println("xx paint 20 xx");
2400 NavitAOverlay_s.postInvalidate();
2401 }
2402 catch (Exception e)
2403 {
2404 e.printStackTrace();
2405 }
2406 }
2407 touch_mode = NONE;
2408 }
2409 else
2410 {
2411 if (DEBUG_TOUCH) Log.d("NavitGraphics", "touch_mode=NONE (END of ZOOM part 2)");
2412 touch_mode = NONE;
2413 }
2414 }
2415 }
2416
2417 //Log.e("NavitGraphics", "pos_x=" + pos_x);
2418 //Log.e("NavitGraphics", "pos_y=" + pos_y);
2419 //Log.e("NavitGraphics", "d_pos_x_old=" + d_pos_x_old);
2420 //Log.e("NavitGraphics", "d_pos_y_old=" + d_pos_y_old);
2421
2422 // on final "UP" action, always reset the display center
2423 if (switch_value == MotionEvent.ACTION_UP)
2424 {
2425 // pos_x = d_pos_x_old; // wait for redraw !!
2426 // pos_y = d_pos_y_old; // wait for redraw !!
2427
2428 //Log.e("NavitGraphics", "DO__DRAW:Java:Final Up action");
2429 //copy_backwards_map_buffer();
2430 //draw_reset_factors = true;
2431 //this.invalidate();
2432
2433 //System.out.println("DO__DRAW:Java:xchange global factors");
2434 Global_Map_TransX = Global_Map_TransX + pos_x;
2435 Global_Map_TransY = Global_Map_TransY + pos_y;
2436 Global_Map_Rotationangle = 0f;
2437 Global_Map_Zoomfactor = Global_Map_Zoomfactor * ZOOM_MODE_SCALE;
2438
2439 //System.out.println("DO__DRAW:Java:reset local factors");
2440 pos_x = 0;
2441 // System.out.println("px reset:003");
2442 pos_y = 0;
2443 ZOOM_MODE_ACTIVE = false;
2444 ZOOM_MODE_SCALE = 1.0f;
2445
2446 try
2447 {
2448 if (DEBUG_TOUCH) Log.e("NavitGraphics", "sensor thread stop final88");
2449 touch_sensor_thread.stop_me();
2450 }
2451 catch (Exception e)
2452 {
2453
2454 }
2455
2456 Global_onTouch_fingerdown = false;
2457
2458 // allow all map drawing -----------
2459 Message msg2 = new Message();
2460 Bundle b2 = new Bundle();
2461 b2.putInt("Callback", 70);
2462 msg2.setData(b2);
2463 try
2464 {
2465 callback_handler.sendMessage(msg2);
2466 }
2467 catch (Exception e)
2468 {
2469 }
2470 // allow all map drawing -----------
2471 }
2472
2473 //System.out.println("DO__DRAW:Java:ACTION UP end");
2474
2475 }
2476 else if (switch_value == MotionEvent.ACTION_MOVE)
2477 {
2478 //System.out.println("DO__DRAW:Java:ACTION MOVE start");
2479
2480 if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_MOVE");
2481
2482 if (touch_mode == DRAG)
2483 {
2484 if (DEBUG_TOUCH) Log.e("NavitGraphics", "mode = DRAG");
2485
2486 this.touch_now.set(event.getX(), event.getY());
2487 touch_now2 = touch_now;
2488 touch_start2 = touch_start;
2489 touch_prev2 = touch_prev;
2490 this.touch_prev.set(event.getX(), event.getY());
2491
2492 // try
2493 // {
2494 // //touch_sensor_thread.down();
2495 // touch_sensor_thread.stop_me();
2496 // // touch_sensor_thread.stop();
2497 // }
2498 // catch (Exception e)
2499 // {
2500 //
2501 // }
2502
2503 if (DEBUG_TOUCH) Log.e("NavitGraphics", "systime2:" + System.currentTimeMillis());
2504 if (DEBUG_TOUCH) Log.e("NavitGraphics", "eventtime2:" + event.getEventTime());
2505 if (DEBUG_TOUCH) Log.e("NavitGraphics", "last touch screen:" + last_touch_on_screen);
2506 // if ((System.currentTimeMillis() - last_touch_on_screen) > long_press_on_screen_interval)
2507 // {
2508 // Log.e("NavitGraphics", "onTouch up (LONG PRESS 2) ***** 11 *****");
2509 // // do_longpress_action(touch_now.x, touch_now.y);
2510 // }
2511
2512 if ((in_map) && (spacing(touch_start2, touch_now2) < long_press_on_screen_max_distance))
2513 {
2514 // now its still a PRESS, because we have not moved around too much!
2515
2516 if (DEBUG_TOUCH) Log.e("NavitGraphics", "in move: still a PRESS action");
2517
2518 // is it a still ongoing long press?
2519 if ((System.currentTimeMillis() - last_touch_on_screen) > long_press_on_screen_interval)
2520 {
2521 if (DEBUG_TOUCH) Log.e("NavitGraphics", "onTouch up (LONG PRESS 2) ***** 22 *****");
2522 // do_longpress_action(touch_now.x, touch_now.y);
2523 }
2524 }
2525 else
2526 {
2527 if (DEBUG_TOUCH) Log.e("NavitGraphics", "onTouch move2");
2528 // MotionCallback(MotionCallbackID, x, y);
2529 // DRAG ----------- new --------------
2530 // DRAG ----------- new --------------
2531 // DRAG ----------- new --------------
2532
2533 try
2534 {
2535 if (DEBUG_TOUCH) Log.e("NavitGraphics", "sensor thread stop X6");
2536 //touch_sensor_thread.down();
2537 touch_sensor_thread.stop_me();
2538 // touch_sensor_thread.stop();
2539 }
2540 catch (Exception e)
2541 {
2542
2543 }
2544
2545 pos_x = (int) (this.touch_now.x - this.touch_start.x);
2546 // System.out.println("px set:004");
2547 pos_y = (int) (this.touch_now.y - this.touch_start.y);
2548 //**dl_thread[dl_thread_cur].add_lines2(null, null, 0, 0, 98);
2549 //draw_map_one_shot = true;
2550 //copy_map_buffer();
2551 //System.out.println("invalidate 013");
2552 this.invalidate();
2553 //this.paint_me();
2554 // this.postInvalidate();
2555 // DRAG ----------- new --------------
2556 // DRAG ----------- new --------------
2557 // DRAG ----------- new --------------
2558
2559 }
2560 }
2561 else if (touch_mode == ZOOM)
2562 {
2563 this.touch_now.set(event.getX(), event.getY());
2564 this.touch_prev.set(event.getX(), event.getY());
2565
2566 if (DEBUG_TOUCH) Log.e("NavitGraphics", "zoom 2");
2567
2568 if (DEBUG_TOUCH) Log.e("NavitGraphics", "hide bubble 73");
2569 NavitAOverlay.hide_bubble();
2570 try
2571 {
2572 if (DEBUG_TOUCH) Log.e("NavitGraphics", "touch_sensor_thread.stop 73");
2573 touch_sensor_thread.stop_me();
2574 }
2575 catch (Exception e)
2576 {
2577 }
2578 if (DEBUG_TOUCH) Log.e("NavitGraphics", "hide bubble 74");
2579 NavitAOverlay.hide_bubble();
2580
2581 // were are in the middle of a zooming action here ----------
2582 // were are in the middle of a zooming action here ----------
2583
2584 Navit.NG__map_main.touch_now_center = calc_center(event);
2585 float newDist = spacing(event);
2586 float scale = 1.0f;
2587 try
2588 {
2589 scale = newDist / oldDist;
2590 }
2591 catch (Exception ee)
2592 {
2593
2594 }
2595
2596 if (scale != 0)
2597 {
2598 ZOOM_MODE_SCALE = scale;
2599 }
2600 else
2601 {
2602 ZOOM_MODE_SCALE = 1.0f;
2603 }
2604
2605 ZOOM_MODE_ACTIVE = true;
2606 //**dl_thread[dl_thread_cur].add_lines2(null, null, 0, 0, 98);
2607 //draw_map_one_shot = true;
2608 //copy_map_buffer();
2609 //System.out.println("invalidate 014");
2610 this.invalidate();
2611 //this.paint_me();
2612 // Log.e("NavitGraphics", "x:" + this.touch_now.x + " y:" + this.touch_now.y);
2613 // were are in the middle of a zooming action here ----------
2614 // were are in the middle of a zooming action here ----------
2615 }
2616
2617 //System.out.println("DO__DRAW:Java:ACTION MOVE end");
2618
2619 }
2620 else if (switch_value == _ACTION_POINTER_DOWN_)
2621 {
2622 //System.out.println("DO__DRAW:Java:ACTION POINTER DOWN start");
2623 if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION_POINTER_DOWN");
2624
2625 oldDist = spacing(event);
2626 // if (oldDist > 10f)
2627 if (oldDist > (Navit.swipeMaxOffPath / 2))
2628 {
2629 touch_mode = ZOOM;
2630 if (DEBUG_TOUCH) Log.e("NavitGraphics", "--> zoom");
2631 // zoom action starts here --------
2632 // zoom action starts here --------
2633 // zoom action starts here --------
2634 // zoom action starts here --------
2635 }
2636
2637 //System.out.println("DO__DRAW:Java:ACTION POINTER DOWN end");
2638
2639 }
2640 else
2641 {
2642 // most likely an ACTION_CANCEL !
2643
2644 if (DEBUG_TOUCH) Log.e("NavitGraphics", "ACTION=" + action);
2645
2646 try
2647 {
2648 if (DEBUG_TOUCH) Log.e("NavitGraphics", "sensor thread stop 88X6");
2649 //touch_sensor_thread.down();
2650 touch_sensor_thread.stop_me();
2651 // touch_sensor_thread.stop();
2652 }
2653 catch (Exception e)
2654 {
2655
2656 }
2657
2658 NavitGraphics.wait_for_redraw_map = false;
2659
2660 pos_x = 0;
2661 // System.out.println("px reset:005");
2662 pos_y = 0;
2663 ZOOM_MODE_ACTIVE = false;
2664 ZOOM_MODE_SCALE = 1.0f;
2665
2666 Global_onTouch_fingerdown = false;
2667
2668 // allow all map drawing -----------
2669 Message msg2 = new Message();
2670 Bundle b2 = new Bundle();
2671 b2.putInt("Callback", 70);
2672 msg2.setData(b2);
2673 try
2674 {
2675 callback_handler.sendMessage(msg2);
2676 }
2677 catch (Exception e)
2678 {
2679 }
2680 // allow all map drawing -----------
2681
2682 if (DEBUG_TOUCH) Log.e("NavitGraphics", "hide bubble 883");
2683 NavitAOverlay.hide_bubble();
2684
2685 touch_mode = NONE;
2686 last_touch_on_screen = System.currentTimeMillis();
2687
2688 this.invalidate();
2689 //this.paint_me();
2690 }
2691 return true;
2692 }
2693
2694 private float spacing(PointF a, PointF b)
2695 {
2696 float x = a.x - b.x;
2697 float y = a.y - b.y;
2698 return FloatMath.sqrt(x * x + y * y);
2699 }
2700
2701 public PointF calc_center(MotionEvent event)
2702 {
2703 //float x;
2704 //float y;
2705 PointF ret = new PointF(0, 0);
2706 try
2707 {
2708 float y0 = 0;
2709 float y1 = 0;
2710 float x0 = 0;
2711 float x1 = 0;
2712
2713 x0 = event.getX(0);
2714 y0 = event.getY(0);
2715 try
2716 {
2717 x1 = event.getX(1);
2718 y1 = event.getY(1);
2719 }
2720 catch (Exception ex)
2721 {
2722 ex.printStackTrace();
2723 }
2724 ret.x = x0 - ((x0 - x1) / 2);
2725 ret.y = y0 - ((y0 - y1) / 2);
2726 }
2727 catch (Exception ex)
2728 {
2729 ex.printStackTrace();
2730 ret.x = event.getX(0);
2731 ret.y = event.getY(0);
2732 }
2733 return ret;
2734 }
2735
2736 public float spacing(MotionEvent event)
2737 {
2738 float x;
2739 float y;
2740 try
2741 {
2742 float y0 = 0;
2743 float y1 = 0;
2744 float x0 = 0;
2745 float x1 = 0;
2746
2747 x0 = event.getX(0);
2748 y0 = event.getY(0);
2749 try
2750 {
2751 x1 = event.getX(1);
2752 y1 = event.getY(1);
2753 }
2754 catch (Exception ex)
2755 {
2756 ex.printStackTrace();
2757 }
2758 x = x0 - x1;
2759 y = y0 - y1;
2760 }
2761 catch (Exception ex)
2762 {
2763 ex.printStackTrace();
2764 x = 0;
2765 y = 0;
2766 }
2767 return FloatMath.sqrt(x * x + y * y);
2768 }
2769
2770 @Override
2771 public boolean onKeyDown(int keyCode, KeyEvent event)
2772 {
2773 //if (keyCode == KeyEvent.KEYCODE_BACK)
2774 //{
2775 // // override back button, so it does NOT quit the application
2776 // return true;
2777 //}
2778 return super.onKeyDown(keyCode, event);
2779 }
2780
2781 @Override
2782 protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect)
2783 {
2784 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
2785
2786 super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
2787 //Log.e("NavitGraphics", "FocusChange " + gainFocus);
2788
2789 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
2790 }
2791 };
2792
2793 ((view_map_custom) view).init_view();
2794
2795 view.setFocusable(true);
2796 view.setFocusableInTouchMode(true);
2797 view.setKeepScreenOn(true);
2798 // x4x relativelayout = new RelativeLayout(activity);
2799
2800 if (this.gr_type == 1)
2801 {
2802 view_s = view;
2803 }
2804
2805 //if (use_camera != 0)
2806 //{
2807 // SetCamera(use_camera);
2808 //}
2809 // x4x relativelayout.addView(view);
2810
2811 // replace the mapview with real mapview!
2812 View dummy_map = activity.findViewById(R.id.gui_gr_map);
2813 ViewGroup parent_tmp = (ViewGroup) dummy_map.getParent();
2814 int index = parent_tmp.indexOfChild(dummy_map);
2815 parent_tmp.removeView(dummy_map);
2816 parent_tmp.addView(view, index);
2817 view.bringToFront();
2818 view.postInvalidate();
2819
2820 // vehicle view
2821 // x4x RelativeLayout.LayoutParams NavitVehicleGraph_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
2822 // x4x relativelayout.addView(Navit.NG__vehicle.view, NavitVehicleGraph_lp);
2823 // x4x Navit.NG__vehicle.view.bringToFront();
2824 // x4x Navit.NG__vehicle.view.postInvalidate();
2825 // vehicle view
2826
2827 // replace the vehicleview with real vehicleview!
2828 View dummy_v = activity.findViewById(R.id.gui_gr_vehicle);
2829 ViewGroup parent_v = (ViewGroup) dummy_v.getParent();
2830 int index_v = parent_v.indexOfChild(dummy_v);
2831 parent_v.removeView(dummy_v);
2832 parent_v.addView(Navit.NG__vehicle.view, index_v);
2833 Navit.NG__vehicle.view.bringToFront();
2834 Navit.NG__vehicle.view.postInvalidate();
2835
2836 // android overlay
2837 //Log.e("Navit", "create android overlay");
2838 // x4x NavitAOverlay = new NavitAndroidOverlay(relativelayout.getContext());
2839 // x4x NavitAOverlay_s = NavitAOverlay;
2840 // x4x RelativeLayout.LayoutParams NavitAOverlay_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
2841 // x4x relativelayout.addView(NavitAOverlay, NavitAOverlay_lp);
2842 // x4x NavitAOverlay.bringToFront();
2843 // x4x NavitAOverlay.postInvalidate();
2844
2845 NavitAOverlay = (NavitAndroidOverlay) activity.findViewById(R.id.NavitAOverlay);
2846 NavitAOverlay.bringToFront();
2847 NavitAOverlay.postInvalidate();
2848 NavitAOverlay_s = NavitAOverlay;
2849
2850 // android overlay
2851
2852 // android OSDJava
2853 //Log.e("Navit", "create android OSDJava");
2854 //**//NavitAOSDJava = new NavitOSDJava(relativelayout.getContext());
2855 //**//NavitAOSDJava_ = NavitAOSDJava;
2856 //**//RelativeLayout.LayoutParams NavitAOSDJava_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
2857 //**//relativelayout.addView(NavitAOSDJava, NavitAOSDJava_lp);
2858 //**//NavitAOSDJava.bringToFront();
2859 //**//NavitAOSDJava.postInvalidate();
2860
2861 // OSD new -------------------------------------------------------
2862 // OSD new -------------------------------------------------------
2863 // OSD new -------------------------------------------------------
2864 // x4x LayoutInflater inflater = activity.getLayoutInflater();
2865 // x4x OSD_new = (ZANaviLinearLayout) inflater.inflate(R.layout.zanavi_osd, relativelayout, false);
2866 // x4x RelativeLayout.LayoutParams NavitAOSDJava_lp2 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
2867 // x4x relativelayout.addView(OSD_new, NavitAOSDJava_lp2);
2868 // x4x OSD_new.bringToFront();
2869
2870 OSD_new = (ZANaviLinearLayout) activity.findViewById(R.id.OSD_new);
2871 OSD_new.bringToFront();
2872
2873 // OSD new -------------------------------------------------------
2874 // OSD new -------------------------------------------------------
2875 // OSD new -------------------------------------------------------
2876
2877 // android OSDJava
2878
2879 // android Messages TextView
2880 //Log.e("Navit", "create android Messages TextView");
2881 // x4x NavitMsgTv = new TextView(relativelayout.getContext());
2882 // x4x NavitMsgTv_ = NavitMsgTv;
2883 // x4x RelativeLayout.LayoutParams NavitMsgTv_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
2884 // NavitMsgTv_lp.height = 50;
2885 // x4x NavitMsgTv_lp.leftMargin = 120;
2886 // x4x NavitMsgTv_lp.topMargin = 176;
2887 // NavitMsgTv.setHeight(10);
2888
2889 NavitMsgTv = (TextView) activity.findViewById(R.id.NavitMsgTv);
2890 NavitMsgTv_ = NavitMsgTv;
2891 int tc = Color.argb(125, 0, 0, 0); // half transparent black
2892 NavitMsgTv.setBackgroundColor(tc);
2893 NavitMsgTv.setLines(4);
2894 NavitMsgTv.setTextSize(12);
2895 NavitMsgTv.setTextColor(Color.argb(255, 200, 200, 200)); // almost white
2896 // x4x relativelayout.addView(NavitMsgTv, NavitMsgTv_lp);
2897 NavitMsgTv.bringToFront();
2898 NavitMsgTv.postInvalidate();
2899 // android Messages TextView
2900
2901 // android Speech Messages TextView
2902 //Log.e("Navit", "create android Speech Messages TextView");
2903 // x4x NavitMsgTv2 = new TextView(relativelayout.getContext());
2904 // x4x NavitMsgTv2_ = NavitMsgTv2;
2905 // x4x RelativeLayout.LayoutParams NavitMsgTv_lp2 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
2906 // x4x NavitMsgTv_lp2.leftMargin = 10;
2907 // x4x NavitMsgTv_lp2.rightMargin = 10;
2908 NavitMsgTv2 = (TextView) activity.findViewById(R.id.NavitMsgTv2cc);
2909 NavitMsgTv2_ = NavitMsgTv2;
2910 int tc2 = Color.argb(125, 0, 0, 0); // half transparent black
2911 NavitMsgTv2.setBackgroundColor(tc2);
2912 NavitMsgTv2.setTextSize(15);
2913 NavitMsgTv2.setTextColor(Color.argb(255, 200, 200, 200)); // almost white
2914
2915 // x4x ScrollView sc = new ScrollView(relativelayout.getContext());
2916 NavitMsgTv2sc_ = (ScrollView) activity.findViewById(R.id.NavitMsgTv2);
2917
2918 NavitMsgTv2sc_.bringToFront();
2919 NavitMsgTv2sc_.postInvalidate();
2920 NavitMsgTv2sc_.setEnabled(false);
2921 NavitMsgTv2sc_.setVisibility(View.GONE);
2922
2923 // x4x RelativeLayout.LayoutParams NavitMsgTv_lp3 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
2924 // x4x sc.addView(NavitMsgTv2, NavitMsgTv_lp2);
2925 // x4x sc.setFadingEdgeLength(20);
2926 // x4x sc.setScrollbarFadingEnabled(true);
2927 NavitMsgTv2sc_.setHorizontalScrollBarEnabled(true);
2928 NavitMsgTv2sc_.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
2929 NavitMsgTv2.setGravity(Gravity.BOTTOM);
2930 // x4x relativelayout.addView(sc, NavitMsgTv_lp3);
2931
2932 NavitMsgTv2.bringToFront();
2933 NavitMsgTv2.postInvalidate();
2934 NavitMsgTv2.setEnabled(false);
2935 NavitMsgTv2.setVisibility(View.GONE);
2936 // android Speech Messages TextView
2937
2938 // busy spinner view on top of everything
2939 // x4x ZANaviBusySpinner busyspinner = new ZANaviBusySpinner(relativelayout.getContext());
2940 // x4x busyspinner_ = busyspinner;
2941 // x4x RelativeLayout.LayoutParams ZANaviBusySpinner_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
2942 // x4x relativelayout.addView(busyspinner, ZANaviBusySpinner_lp);
2943 // x4x busyspinner.bringToFront();
2944 // x4x busyspinner.postInvalidate();
2945 // x4x busyspinner.setVisibility(View.INVISIBLE);
2946
2947 ZANaviBusySpinner busyspinner = (ZANaviBusySpinner) activity.findViewById(R.id.busyspinner);
2948 busyspinner_ = busyspinner;
2949 busyspinner.bringToFront();
2950 busyspinner.postInvalidate();
2951 busyspinner.setVisibility(View.INVISIBLE);
2952
2953 // x4x ZANaviBusyText busyspinnertext = new ZANaviBusyText(relativelayout.getContext());
2954 // x4x busyspinnertext_ = busyspinnertext;
2955 // x4x RelativeLayout.LayoutParams ZANaviBusyText_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
2956 // x4x relativelayout.addView(busyspinnertext, ZANaviBusyText_lp);
2957 // x4x busyspinnertext.bringToFront();
2958 // x4x busyspinnertext.postInvalidate();
2959 // x4x busyspinnertext.setVisibility(View.INVISIBLE);
2960
2961 ZANaviBusyText busyspinnertext = (ZANaviBusyText) activity.findViewById(R.id.busyspinnertext);
2962 busyspinnertext_ = busyspinnertext;
2963 busyspinnertext.bringToFront();
2964 busyspinnertext.postInvalidate();
2965 busyspinnertext.setVisibility(View.INVISIBLE);
2966 // busy spinner view on top of everything
2967
2968 // big map overlay
2969 // NavitGlobalMap_ = new NavitGlobalMap(relativelayout.getContext());
2970 // RelativeLayout.LayoutParams NavitGlobalMap_lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
2971 // relativelayout.addView(NavitGlobalMap_, NavitGlobalMap_lp);
2972 // NavitGlobalMap_.bringToFront();
2973 // NavitGlobalMap_.invalidate();
2974 // big map overlay
2975
2976 // emu_menu_view = new EmulatedMenuView(relativelayout.getContext(), Navit.Global_Navit_Object);
2977 // RelativeLayout.LayoutParams emvlp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
2978 // emvlp.setMargins(dp_to_px(40), dp_to_px(30), dp_to_px(40), dp_to_px(30));
2979 // relativelayout.addView(emu_menu_view, emvlp);
2980 // emu_menu_view.bringToFront();
2981 // emu_menu_view.setVisibility(View.INVISIBLE);
2982
2983 // -------------------------------------------------------
2984 // -------------------------------------------------------
2985 // replace the view with real debug text view
2986
2987 if (Navit.NAVIT_DEBUG_TEXT_VIEW)
2988 {
2989 debug_text_view = new ZANaviOSDDebug01(activity);
2990
2991 View dummy_v2 = activity.findViewById(R.id.debug_text);
2992 ViewGroup parent_v2 = (ViewGroup) dummy_v2.getParent();
2993 int index_v2 = parent_v.indexOfChild(dummy_v2);
2994 parent_v2.removeView(dummy_v2);
2995 parent_v2.addView(debug_text_view, index_v2);
2996 debug_text_view.bringToFront();
2997 debug_text_view.postInvalidate();
2998 // debug_text_view.setDrawingCacheEnabled(true);
2999 }
3000 else
3001 {
3002 View dummy_v2 = activity.findViewById(R.id.debug_text);
3003 ViewGroup parent_v2 = (ViewGroup) dummy_v2.getParent();
3004 int index_v2 = parent_v.indexOfChild(dummy_v2);
3005 parent_v2.removeView(dummy_v2);
3006 }
3007 // -------------------------------------------------------
3008 // -------------------------------------------------------
3009
3010 Button no_maps_button = (Button) activity.findViewById(R.id.no_maps_button);
3011 no_maps_button.setOnClickListener(new View.OnClickListener()
3012 {
3013 public void onClick(View v)
3014 {
3015 try
3016 {
3017 Message msg = Navit.Navit_progress_h.obtainMessage();
3018 Bundle b = new Bundle();
3019 msg.what = 31;
3020 msg.setData(b);
3021 Navit.Navit_progress_h.sendMessage(msg);
3022 }
3023 catch (Exception e)
3024 {
3025 }
3026 }
3027 });
3028
3029 // Navit.Global_Navit_Object.glSurfaceView.bringToFront();
3030
3031 View view_srec = (View) activity.findViewById(R.id.view_srec);
3032
3033 // Disable button if no recognition service is present
3034 PackageManager pm = activity.getPackageManager();
3035 List<ResolveInfo> activities = pm.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
3036 if (activities.size() == 0)
3037 {
3038 // NO speech recognition installed
3039 view_srec.setVisibility(View.INVISIBLE);
3040 }
3041 else
3042 {
3043 // speech recognition is installed
3044 view_srec.bringToFront();
3045 view_srec.setOnTouchListener(new View.OnTouchListener()
3046 {
3047
3048 @Override
3049 public boolean onTouch(View v, MotionEvent m)
3050 {
3051 if ((view_srec_x == 0) || (view_srec_y == 0))
3052 {
3053 try
3054 {
3055 view_srec_x = v.getX();
3056 view_srec_y = v.getY();
3057 }
3058 catch (NoSuchMethodError e4)
3059 {
3060 }
3061
3062 }
3063
3064 int a = m.getAction();
3065 if (a == MotionEvent.ACTION_DOWN)
3066 {
3067 try
3068 {
3069 if ((view_srec_x != 0) && (view_srec_y != 0))
3070 {
3071 v.setX(view_srec_x + dp_to_px(0));
3072 v.setY(view_srec_y + dp_to_px(3));
3073 }
3074 }
3075 catch (NoSuchMethodError e2)
3076 {
3077 }
3078 }
3079 else if (a == MotionEvent.ACTION_UP)
3080 {
3081 try
3082 {
3083 if ((view_srec_x != 0) && (view_srec_y != 0))
3084 {
3085 v.setX(view_srec_x);
3086 v.setY(view_srec_y);
3087 }
3088 }
3089 catch (NoSuchMethodError e2)
3090 {
3091 }
3092 }
3093 return false;
3094 }
3095 });
3096
3097 view_srec.setOnClickListener(new View.OnClickListener()
3098 {
3099 public void onClick(View v)
3100 {
3101 try
3102 {
3103 // open voice search screen
3104 Message msg = Navit.Navit_progress_h.obtainMessage();
3105 Bundle b = new Bundle();
3106 msg.what = 19;
3107 msg.setData(b);
3108 Navit.Navit_progress_h.sendMessage(msg);
3109 }
3110 catch (Exception e)
3111 {
3112 }
3113 }
3114 });
3115 }
3116
3117 View vv_compass = (View) activity.findViewById(R.id.osd_compass_new);
3118 vv_compass.bringToFront();
3119
3120 vv_compass.setOnClickListener(new View.OnClickListener()
3121 {
3122 public void onClick(View v)
3123 {
3124 try
3125 {
3126 if (NavitAndroidOverlay.measure_mode)
3127 {
3128 NavitAndroidOverlay.measure_mode = false;
3129 NavitAndroidOverlay.cleanup_measure_mode();
3130 ZANaviLinearLayout.redraw_OSD(1);
3131 ZANaviLinearLayout.redraw_OSD(2);
3132 }
3133 else
3134 {
3135 NavitAndroidOverlay.measure_mode = true;
3136 ZANaviLinearLayout.redraw_OSD(1);
3137 ZANaviLinearLayout.redraw_OSD(2);
3138 }
3139 }
3140 catch (Exception e)
3141 {
3142 }
3143 }
3144 });
3145
3146 View vv_speeding = (View) activity.findViewById(R.id.view_speeding);
3147 vv_speeding.bringToFront();
3148
3149 View vv_laneassist = (View) activity.findViewById(R.id.view_laneassist);
3150 vv_laneassist.bringToFront();
3151
3152 whats_here_container_wrap = (RelativeLayout) activity.findViewById(R.id.whats_here_container_wrap);
3153 whats_here_container_wrap.bringToFront();
3154 params_whats_here_container_wrap = (android.widget.RelativeLayout.LayoutParams) whats_here_container_wrap.getLayoutParams();
3155
3156 whats_here_pointer_image = (ImageView) activity.findViewById(R.id.whats_here_pointer_image);
3157 whats_here_pointer_image.bringToFront();
3158 params_whats_here_pointer_image = (android.widget.RelativeLayout.LayoutParams) whats_here_pointer_image.getLayoutParams();
3159
3160 whats_here_button_add_to = (ImageButton) activity.findViewById(R.id.whats_here_button_add_to);
3161 whats_here_button_whats = (ImageButton) activity.findViewById(R.id.whats_here_button_whats);
3162 whats_here_button_drive = (ImageButton) activity.findViewById(R.id.whats_here_button_drive);
3163 whats_here_text = (TextView) activity.findViewById(R.id.whats_here_text);
3164
3165 whats_here_button_add_to.setOnClickListener(new View.OnClickListener()
3166 {
3167 public void onClick(View v)
3168 {
3169 try
3170 {
3171 NavitGraphics.NavitAOverlay_s.addto_button_clicked();
3172 }
3173 catch (Exception e)
3174 {
3175 }
3176 }
3177 });
3178
3179 whats_here_button_drive.setOnClickListener(new View.OnClickListener()
3180 {
3181 public void onClick(View v)
3182 {
3183 try
3184 {
3185 NavitGraphics.NavitAOverlay_s.drive_button_clicked();
3186 }
3187 catch (Exception e)
3188 {
3189 }
3190 }
3191 });
3192
3193 whats_here_button_whats.setOnClickListener(new View.OnClickListener()
3194 {
3195 public void onClick(View v)
3196 {
3197 try
3198 {
3199 NavitGraphics.NavitAOverlay_s.whats_button_clicked();
3200 }
3201 catch (Exception e)
3202 {
3203 }
3204 }
3205 });
3206
3207 no_maps_container = (RelativeLayout) activity.findViewById(R.id.no_maps_container);
3208 no_maps_container.bringToFront();
3209 try
3210 {
3211 NavitGraphics.no_maps_container.setVisibility(View.INVISIBLE);
3212 try
3213 {
3214 NavitGraphics.no_maps_container.setActivated(false);
3215 }
3216 catch (NoSuchMethodError e)
3217 {
3218 }
3219 }
3220 catch (Exception ee3)
3221 {
3222 }
3223
3224 View vv_bottom_bar = (View) activity.findViewById(R.id.bottom_bar_slide);
3225 vv_bottom_bar.bringToFront();
3226
3227 vv_bottom_bar = (View) activity.findViewById(R.id.bottom_bar_container);
3228 vv_bottom_bar.bringToFront();
3229
3230 // x4x activity.setContentView(relativelayout);
3231 // view.setDrawingCacheEnabled(true);
3232 // view.buildDrawingCache();
3233 view.requestFocus();
3234
3235 // force re-layout -----------------
3236 try
3237 {
3238 activity.getWindow().getDecorView().findViewById(android.R.id.content).invalidate();
3239 }
3240 catch (Exception e)
3241 {
3242 }
3243 // force re-layout -----------------
3244
3245 // **** // activity.getWindow().getDecorView().setBackground(null);
3246 // **** // activity.getWindow().getDecorView().setBackgroundDrawable(null);
3247 }
3248 // parent == 0 ---------------
3249 else
3250 // parent == 1 ---------------
3251 {
3252 if (draw_bitmap != null)
3253 {
3254 // try to avoid out of memory errors
3255 draw_bitmap.recycle();
3256 }
3257
3258 //int h_dpi_v = (int) ((float) h * Global_dpi_factor);
3259 //int w_dpi_v = (int) ((float) w * Global_dpi_factor);
3260
3261 try
3262 {
3263 // DPI
3264 draw_bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
3265 }
3266 catch (OutOfMemoryError e)
3267 {
3268 int usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L);
3269 String usedMegsString = String.format(" - Memory Used: %d MB", usedMegs);
3270 System.out.println("" + usedMegsString);
3271 System.out.println("@@@@@@@@ out of VM Memory @@@@@@@@");
3272 System.gc();
3273 System.gc();
3274 usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L);
3275 usedMegsString = String.format(" - Memory Used: %d MB", usedMegs);
3276 System.out.println("" + usedMegsString);
3277 // try again
3278 draw_bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
3279 }
3280
3281 bitmap_w = w;
3282 bitmap_h = h;
3283 pos_x = x;
3284 // System.out.println("px set:006");
3285 pos_y = y;
3286 pos_wraparound = wraparound;
3287 draw_canvas = new Canvas(draw_bitmap);
3288 // DPI
3289 //draw_canvas.setDensity(Global_want_dpi);
3290
3291 this.activity = activity;
3292 view = new View(activity)
3293 {
3294 // Vehicle ---------------------------
3295 // Vehicle ---------------------------
3296 // Vehicle ---------------------------
3297 protected void onDraw(Canvas canvas)
3298 {
3299 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0, "V");
3300
3301 // System.out.println("V.Draw x");
3302 // System.out.println("onDraw:VVVVVVVVVVVVVVVVVVVVVV");
3303
3304 //System.out.println("V.Draw x="+NG__vehicle.vehicle_pos_x+" y="+NG__vehicle.vehicle_pos_y);
3305 //System.out.println("V.Draw d=" + Navit.nav_arrow_stopped.getDensity());
3306 //System.out.println("V.Draw w=" + Navit.nav_arrow_stopped.getWidth());
3307 //System.out.println("V.Draw h=" + Navit.nav_arrow_stopped.getHeight());
3308 //super.onDraw(canvas);
3309
3310 if (!NavitGraphics.MAP_DISPLAY_OFF)
3311 {
3312 if (Navit.DEBUG_DRAW_VEHICLE)
3313 {
3314 if (Navit.NG__vehicle.vehicle_speed < 3)
3315 {
3316 if (Navit.p.PREF_show_3d_map)
3317 {
3318 // 3D modus -----------------
3319 canvas.save();
3320 //if (Navit.PREF_show_vehicle_3d)
3321 //{
3322 canvas.concat(cam_m_vehicle);
3323
3324 if (Navit.GFX_OVERSPILL)
3325 {
3326 canvas.drawBitmap(Navit.nav_arrow_stopped_small, Navit.NG__vehicle.vehicle_pos_x - (Navit.nav_arrow_stopped_small.getWidth() / 2) - NavitGraphics.mCanvasWidth_overspill, Navit.NG__vehicle.vehicle_pos_y - (Navit.nav_arrow_stopped_small.getHeight() / 2) - NavitGraphics.mCanvasHeight_overspill, null);
3327 }
3328 else
3329 {
3330 canvas.drawBitmap(Navit.nav_arrow_stopped_small, Navit.NG__vehicle.vehicle_pos_x - Navit.nav_arrow_stopped_small.getWidth() / 2, Navit.NG__vehicle.vehicle_pos_y - Navit.nav_arrow_stopped_small.getHeight() / 2, null);
3331 }
3332 //}
3333 //// 3D modus -----------------
3334 //else
3335 //{
3336 // 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);
3337 //}
3338 }
3339 else
3340 {
3341 if (Navit.GFX_OVERSPILL)
3342 {
3343 canvas.drawBitmap(Navit.nav_arrow_stopped, Navit.NG__vehicle.vehicle_pos_x - (Navit.nav_arrow_stopped.getWidth() / 2) - NavitGraphics.mCanvasWidth_overspill, Navit.NG__vehicle.vehicle_pos_y - (Navit.nav_arrow_stopped.getHeight() / 2) - NavitGraphics.mCanvasHeight_overspill, null);
3344 }
3345 else
3346 {
3347 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);
3348 }
3349 }
3350 if (Navit.p.PREF_show_3d_map)
3351 {
3352 // 3D modus -----------------
3353 canvas.restore();
3354 // 3D modus -----------------
3355 }
3356 }
3357 else
3358 // speed >= 3 -----------
3359 {
3360 if ((Navit.NG__vehicle.vehicle_direction != 0) || (Navit.p.PREF_show_3d_map))
3361 {
3362 canvas.save();
3363 }
3364
3365 if (Navit.NG__vehicle.vehicle_direction != 0)
3366 {
3367 // rotate nav icon if needed
3368 canvas.rotate(Navit.NG__vehicle.vehicle_direction, Navit.NG__vehicle.vehicle_pos_x, Navit.NG__vehicle.vehicle_pos_y);
3369 }
3370
3371 if (Navit.p.PREF_show_3d_map)
3372 {
3373 // 3D modus -----------------
3374 //if (Navit.PREF_show_vehicle_3d)
3375 //{
3376 canvas.concat(cam_m_vehicle);
3377
3378 if (Navit.GFX_OVERSPILL)
3379 {
3380 canvas.drawBitmap(Navit.nav_arrow_moving_shadow_small, 2 + Navit.NG__vehicle.vehicle_pos_x - (Navit.nav_arrow_moving_shadow_small.getWidth() / 2) - NavitGraphics.mCanvasWidth_overspill, 8 + Navit.NG__vehicle.vehicle_pos_y - (Navit.nav_arrow_moving_shadow_small.getHeight() / 2) - NavitGraphics.mCanvasHeight_overspill, null);
3381 canvas.drawBitmap(Navit.nav_arrow_moving_small, Navit.NG__vehicle.vehicle_pos_x - (Navit.nav_arrow_moving_small.getWidth() / 2) - NavitGraphics.mCanvasWidth_overspill, Navit.NG__vehicle.vehicle_pos_y - (Navit.nav_arrow_moving_small.getHeight() / 2) - NavitGraphics.mCanvasHeight_overspill, null);
3382 }
3383 else
3384 {
3385 // offset shadow x+2 , y+8
3386 canvas.drawBitmap(Navit.nav_arrow_moving_shadow_small, 2 + Navit.NG__vehicle.vehicle_pos_x - Navit.nav_arrow_moving_shadow_small.getWidth() / 2, 8 + Navit.NG__vehicle.vehicle_pos_y - Navit.nav_arrow_moving_shadow_small.getHeight() / 2, null);
3387 canvas.drawBitmap(Navit.nav_arrow_moving_small, Navit.NG__vehicle.vehicle_pos_x - Navit.nav_arrow_moving_small.getWidth() / 2, Navit.NG__vehicle.vehicle_pos_y - Navit.nav_arrow_moving_small.getHeight() / 2, null);
3388 }
3389 //}
3390 //// 3D modus -----------------
3391 //else
3392 //{
3393 // // offset shadow x+2 , y+8
3394 // canvas.drawBitmap(Navit.nav_arrow_moving_shadow, 2 + Navit.NG__vehicle.vehicle_pos_x - Navit.nav_arrow_moving_shadow.getWidth() / 2, 8 + Navit.NG__vehicle.vehicle_pos_y - Navit.nav_arrow_moving_shadow.getHeight() / 2, null);
3395 // 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);
3396 //}
3397 }
3398 else
3399 // 2D map -----
3400 {
3401 // offset shadow x+2 , y+8
3402 if (Navit.GFX_OVERSPILL)
3403 {
3404 canvas.drawBitmap(Navit.nav_arrow_moving_shadow, 2 + Navit.NG__vehicle.vehicle_pos_x - Navit.nav_arrow_moving_shadow.getWidth() / 2 - NavitGraphics.mCanvasWidth_overspill, 8 + Navit.NG__vehicle.vehicle_pos_y - Navit.nav_arrow_moving_shadow.getHeight() / 2 - NavitGraphics.mCanvasHeight_overspill, null);
3405 if (Navit.tunnel_extrapolation)
3406 {
3407 canvas.drawBitmap(Navit.nav_arrow_moving_grey, Navit.NG__vehicle.vehicle_pos_x - Navit.nav_arrow_moving_grey.getWidth() / 2 - NavitGraphics.mCanvasWidth_overspill, Navit.NG__vehicle.vehicle_pos_y - Navit.nav_arrow_moving_grey.getHeight() / 2 - NavitGraphics.mCanvasHeight_overspill, null);
3408 }
3409 else
3410 {
3411 canvas.drawBitmap(Navit.nav_arrow_moving, Navit.NG__vehicle.vehicle_pos_x - Navit.nav_arrow_moving.getWidth() / 2 - NavitGraphics.mCanvasWidth_overspill, Navit.NG__vehicle.vehicle_pos_y - Navit.nav_arrow_moving.getHeight() / 2 - NavitGraphics.mCanvasHeight_overspill, null);
3412 }
3413 }
3414 else
3415 {
3416 canvas.drawBitmap(Navit.nav_arrow_moving_shadow, 2 + Navit.NG__vehicle.vehicle_pos_x - Navit.nav_arrow_moving_shadow.getWidth() / 2, 8 + Navit.NG__vehicle.vehicle_pos_y - Navit.nav_arrow_moving_shadow.getHeight() / 2, null);
3417 if (Navit.tunnel_extrapolation)
3418 {
3419 canvas.drawBitmap(Navit.nav_arrow_moving_grey, Navit.NG__vehicle.vehicle_pos_x - Navit.nav_arrow_moving_grey.getWidth() / 2, Navit.NG__vehicle.vehicle_pos_y - Navit.nav_arrow_moving_grey.getHeight() / 2, null);
3420 }
3421 else
3422 {
3423 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);
3424 }
3425 }
3426 }
3427
3428 if ((Navit.NG__vehicle.vehicle_direction != 0) || (Navit.p.PREF_show_3d_map))
3429 {
3430 canvas.restore();
3431 }
3432 }
3433
3434 // paint the sweep spot of the vehicle position!!
3435 // Paint paint22 = new Paint();
3436 // paint22.setStyle(Paint.Style.FILL);
3437 // paint22.setStrokeWidth(0);
3438 // paint22.setColor(Color.RED);
3439 // if (Navit.GFX_OVERSPILL)
3440 // {
3441 // canvas.drawCircle(Navit.NG__vehicle.vehicle_pos_x - mCanvasWidth_overspill, Navit.NG__vehicle.vehicle_pos_y - mCanvasHeight_overspill, 5, paint22);
3442 // }
3443 // else
3444 // {
3445 // canvas.drawCircle(Navit.NG__vehicle.vehicle_pos_x, Navit.NG__vehicle.vehicle_pos_y, 5, paint22);
3446 // }
3447 // paint the sweep spot of the vehicle position!!
3448 }
3449 }
3450 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1, "V");
3451 }
3452
3453 @Override
3454 protected void onSizeChanged(int w, int h, int oldw, int oldh)
3455 {
3456 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
3457 System.out.println("VV:new width=" + w + " new height=" + h);
3458 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
3459 }
3460 };
3461
3462 } // END IF: parent == 1 ---------------
3463
3464 parent_num = parent;
3465
3466 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
3467 }
3468
3469 public static native void TimeoutCallback(int del, int id);
3470
3471 public static native void SizeChangedCallbackReal(int w, int h, Bitmap main_map_bitmap);
3472
3473 // DrawLowqualMap_wrapper("" + my_lat + "#" + my_lon + "#" + 18, 400, 400, 11, 8192, 100000);
3474 public static void DrawLowqualMap_wrapper(String latlonzoom, int w, int h, int fontsize, int scale, int selection_range)
3475 {
3476 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
3477 Navit.cwthr.DrawLowqualMap_wrapper(latlonzoom, w, h, fontsize, scale, selection_range);
3478 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
3479 }
3480
3481 public static void SizeChangedCallback(int w, int h, Bitmap main_map_bitmap)
3482 {
3483 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
3484 Navit.cwthr.SizeChangedCallback(w, h, main_map_bitmap);
3485 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
3486 }
3487
3488 // public native void ButtonCallback(int pressed, int button, int x, int y);
3489
3490 public static native void MotionCallbackReal(int x1, int y1, int x2, int y2, int draw);
3491
3492 public static void MotionCallback(int x1, int y1, int x2, int y2)
3493 {
3494 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
3495
3496 Navit.cwthr.MotionCallback((int) (x1 * Global_dpi_factor), (int) (y1 * Global_dpi_factor), (int) (x2 * Global_dpi_factor), (int) (y2 * Global_dpi_factor));
3497
3498 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
3499 }
3500
3501 // public native void KeypressCallback(String s);
3502
3503 // private int SizeChangedCallbackID, ButtonCallbackID, MotionCallbackID, KeypressCallbackID;
3504
3505 // private int count;
3506 /*
3507 * public void setSizeChangedCallback(int id)
3508 * {
3509 * SizeChangedCallbackID = id;
3510 * }
3511 */
3512
3513 /*
3514 * public void setButtonCallback(int id)
3515 * {
3516 * ButtonCallbackID = id;
3517 * }
3518 */
3519
3520 /*
3521 * public void setMotionCallback(int id)
3522 * {
3523 * MotionCallbackID = id;
3524 * Navit.setMotionCallback(id, this);
3525 * }
3526 */
3527
3528 /*
3529 * public void setKeypressCallback(int id)
3530 * {
3531 * KeypressCallbackID = id;
3532 * // set callback id also in main intent (for menus)
3533 * Navit.setKeypressCallback(id, this);
3534 * }
3535 */
3536
3537 public static native void DrawLowqualMap(String latlonzoom, int width, int height, int font_size, int scale, int sel_range);
3538
3539 public void NavitSetGrObj()
3540 {
3541 // set the (static) graphics object (this is bad, please fix me!!)
3542 // **disabled** Navit.N_NavitGraphics = this;
3543 }
3544
3545 Paint paint_dr_polyl = new Paint();
3546
3547 protected void draw_polyline(int c[], int width, int r, int g, int b, int a)
3548 {
3549 paint_dr_polyl.setARGB(a, r, g, b);
3550 paint_dr_polyl.setStrokeWidth(width);
3551 paint_dr_polyl.setStyle(Paint.Style.STROKE);
3552
3553 // Log.e("NavitGraphics","draw_polyline");
3554 // paint.setStyle(Paint.Style.STROKE);
3555 //b_paint_antialias = paint.isAntiAlias();
3556 paint_dr_polyl.setAntiAlias(Navit.p.PREF_use_anti_aliasing);
3557 //paint.setStrokeWidth(0);
3558 b_paint_path.reset();
3559 b_paint_path.moveTo(c[0], c[1]);
3560 for (int i = 2; i < c.length; i += 2)
3561 {
3562 b_paint_path.lineTo(c[i], c[i + 1]);
3563 }
3564 //global_path.close();
3565 draw_canvas.drawPath(b_paint_path, paint_dr_polyl);
3566 //*paint.setAntiAlias(b_paint_antialias);
3567 //paint.setPathEffect(dashed_map_lines__no_dash);
3568 }
3569
3570 protected void draw_polyline2__NEW(Paint paint, int c[], int order, int oneway)
3571 {
3572 if (dl_thread[0] == null)
3573 {
3574 int ii = 0;
3575 for (ii = 0; ii < NavitGraphics.dl_thread_max; ii++)
3576 {
3577 NavitGraphics.dl_thread[ii] = new NavitGraphics.DrawLinesThread(ii);
3578 NavitGraphics.dl_thread[ii].start();
3579 }
3580 }
3581
3582 if (dl_thread_cur + 1 < dl_thread_max)
3583 {
3584 dl_thread_cur++;
3585 }
3586 else
3587 {
3588 dl_thread_cur = 0;
3589 }
3590 dl_thread[dl_thread_cur].add_lines3(paint, c, order, oneway);
3591 }
3592
3593 static void draw_polyline2_threads(Paint paint, int c[], int order, int oneway)
3594 {
3595 if (!Navit.p.PREF_gui_oneway_arrows)
3596 {
3597 return;
3598 }
3599
3600 // line less than 44px -> dont draw arrow!
3601 int len = (c[0] - c[2]) * (c[1] - c[3]);
3602 if (len < 0)
3603 {
3604 len = -len;
3605 }
3606 if (len > (2000))
3607 {
3608 paint.setStyle(Paint.Style.STROKE);
3609 paint.setAntiAlias(Navit.p.PREF_use_anti_aliasing);
3610
3611 // create matrix for the manipulation
3612 Matrix matrix_oneway_arrows2 = new Matrix();
3613
3614 int middle_x = c[0] + (int) ((c[2] - c[0]) / 2);
3615 int middle_y = c[1] + (int) ((c[3] - c[1]) / 2);
3616 double d_x = ((c[2] - c[0]) / 6);
3617 double d_y = ((c[3] - c[1]) / 6);
3618 int angle = (int) (Math.toDegrees(Math.atan2(d_y, d_x)));
3619 // System.out.println("arrow angle=" + angle);
3620 matrix_oneway_arrows2.postTranslate(-Navit.oneway_arrow.getWidth() / 2, -Navit.oneway_arrow.getHeight() / 2);
3621
3622 if (oneway == 1)
3623 {
3624 // rotate the Bitmap
3625 matrix_oneway_arrows2.postRotate(angle);
3626 }
3627 else if (oneway == 2)
3628 {
3629 // rotate the Bitmap
3630 matrix_oneway_arrows2.postRotate(angle + 180);
3631 }
3632
3633 if (oneway > 0)
3634 {
3635 if (c.length == 4)
3636 {
3637 matrix_oneway_arrows2.postTranslate(middle_x, middle_y);
3638 draw_canvas_s.drawBitmap(Navit.oneway_arrow, matrix_oneway_arrows2, paint);
3639 }
3640 }
3641 else
3642 {
3643 return;
3644 }
3645 }
3646 }
3647
3648 int len_dr_polyl2;
3649 double d_x_dr_polyl2;
3650 double d_y_dr_polyl2;
3651 int bow_move_x;
3652 int bow_move_y;
3653 int middle_x_dr_polyl2;
3654 int middle_y_dr_polyl2;
3655 int angle_dr_polyl2;
3656 int angle_dr_polyl2_move;
3657 double bow_scale_move;
3658 Matrix matrix_oneway_arrows2 = new Matrix();
3659
3660 protected void draw_polyline2(int c[], int order, int oneway)
3661 {
3662 // Log.e("NavitGraphics", "draw_polyline2 count=" + c.length);
3663 if (!Navit.p.PREF_gui_oneway_arrows)
3664 {
3665 return;
3666 }
3667
3668 // Paint paint = new Paint();
3669
3670 // Boolean normal = false;
3671 // Matrix matrix = null;
3672
3673 // this gets already checked in c-source!!
3674 //if (order > DRAW_ONEWAY_ARROWS_AT_ORDER)
3675 //{
3676
3677 // line less than 28px -> dont draw arrow!
3678 len_dr_polyl2 = (c[0] - c[2]) * (c[1] - c[3]);
3679 if (len_dr_polyl2 < 0)
3680 {
3681 len_dr_polyl2 = -len_dr_polyl2;
3682 }
3683
3684 if (len_dr_polyl2 > (800))
3685 {
3686 // paint.setStyle(Paint.Style.STROKE);
3687 // b_paint_antialias = paint.isAntiAlias();
3688 // paint.setAntiAlias(Navit.PREF_use_anti_aliasing);
3689
3690 // create matrix for the manipulation
3691 matrix_oneway_arrows2.reset();
3692
3693 // calc this in c-code !! will be much faster!!
3694 // calc this in c-code !! will be much faster!!
3695 // calc this in c-code !! will be much faster!!
3696 d_x_dr_polyl2 = ((c[2] - c[0]));
3697 d_y_dr_polyl2 = ((c[3] - c[1]));
3698 middle_x_dr_polyl2 = c[0] + (int) (d_x_dr_polyl2 / 6);
3699 middle_y_dr_polyl2 = c[1] + (int) (d_y_dr_polyl2 / 6);
3700 angle_dr_polyl2 = (int) (Math.toDegrees(Math.atan2(d_y_dr_polyl2, d_x_dr_polyl2)));
3701 // calc this in c-code !! will be much faster!!
3702 // calc this in c-code !! will be much faster!!
3703 // calc this in c-code !! will be much faster!!
3704
3705 // System.out.println("arrow angle=" + angle);
3706 matrix_oneway_arrows2.postTranslate(-Navit.oneway_arrow.getWidth() / 2, -Navit.oneway_arrow.getHeight() / 2);
3707
3708 //System.out.println("order=" + order);
3709 // resize the Bitmap
3710 if (order > 16)
3711 {
3712 matrix_oneway_arrows2.postScale(4.5f, 4.5f);
3713 }
3714 else if (order > 14)
3715 {
3716 matrix_oneway_arrows2.postScale(1.5f, 1.5f);
3717 }
3718
3719 if ((oneway & 1) == 1)
3720 {
3721 // rotate the Bitmap
3722 matrix_oneway_arrows2.postRotate(angle_dr_polyl2);
3723 }
3724 else if ((oneway & 2) == 2)
3725 {
3726 // rotate the Bitmap
3727 matrix_oneway_arrows2.postRotate(angle_dr_polyl2 + 180);
3728 }
3729
3730 if (oneway > 0)
3731 {
3732 if (c.length == 4)
3733 {
3734 matrix_oneway_arrows2.postTranslate(middle_x_dr_polyl2, middle_y_dr_polyl2);
3735 draw_canvas.drawBitmap(Navit.oneway_arrow, matrix_oneway_arrows2, null);
3736
3737 if ((oneway & 4) == 4) // bicycle can drive in both directions, so draw green arrow aswell
3738 {
3739 matrix_oneway_arrows2.reset();
3740 matrix_oneway_arrows2.postTranslate(-Navit.oneway_bicycle_arrow.getWidth() / 2, -Navit.oneway_bicycle_arrow.getHeight() / 2);
3741
3742 if (order > 16)
3743 {
3744 matrix_oneway_arrows2.postScale(4.5f, 4.5f);
3745 bow_scale_move = 4.5;
3746 }
3747 else if (order > 14)
3748 {
3749 matrix_oneway_arrows2.postScale(1.5f, 1.5f);
3750 bow_scale_move = 1.5;
3751 }
3752
3753 if ((oneway & 1) == 1)
3754 {
3755 // rotate the Bitmap
3756 matrix_oneway_arrows2.postRotate(angle_dr_polyl2 + 180);
3757 angle_dr_polyl2_move = angle_dr_polyl2 + 180;
3758 }
3759 else if ((oneway & 2) == 2)
3760 {
3761 // rotate the Bitmap
3762 matrix_oneway_arrows2.postRotate(angle_dr_polyl2);
3763 angle_dr_polyl2_move = angle_dr_polyl2;
3764 }
3765
3766 matrix_oneway_arrows2.postTranslate(middle_x_dr_polyl2, middle_y_dr_polyl2);
3767
3768 // move it a bit in arrow direction
3769 // calc this in c-code !! will be much faster!!
3770 // calc this in c-code !! will be much faster!!
3771 // calc this in c-code !! will be much faster!!
3772 bow_move_x = -(int) (Math.cos(Math.toRadians(angle_dr_polyl2_move)) * (double) (bow_scale_move * (3 + Navit.oneway_bicycle_arrow.getWidth())));
3773 bow_move_y = -(int) (Math.sin(Math.toRadians(angle_dr_polyl2_move)) * (double) (bow_scale_move * (3 + Navit.oneway_bicycle_arrow.getWidth())));
3774 // calc this in c-code !! will be much faster!!
3775 // calc this in c-code !! will be much faster!!
3776 // calc this in c-code !! will be much faster!!
3777 matrix_oneway_arrows2.postTranslate(bow_move_x, bow_move_y);
3778
3779 draw_canvas.drawBitmap(Navit.oneway_bicycle_arrow, matrix_oneway_arrows2, null);
3780 }
3781 }
3782
3783 // paint.setAntiAlias(b_paint_antialias);
3784
3785 }
3786 else
3787 {
3788 // normal = true;
3789 return;
3790 }
3791 }
3792 //}
3793 //else
3794 //{
3795 // // normal = true;
3796 // // draw nothing, just return!
3797 // return;
3798 //}
3799
3800 //paint.setPathEffect(dashed_map_lines__no_dash);
3801 }
3802
3803 public static class draw_object
3804 {
3805 int type;
3806 Paint paint;
3807
3808 // -- 99 - "ready" signal
3809 // -- 0 -- normal line
3810 int[] c;
3811 int order;
3812 int width;
3813 // -- 2 -- tunnel/bridge line
3814 int line_type;
3815
3816 // -- 1 -- text
3817 int x;
3818 int y;
3819 String text;
3820 int size;
3821 int dx;
3822 int dy;
3823 }
3824
3825 public static class DrawLinesThread extends Thread
3826 {
3827 private Boolean running;
3828 private Boolean start_drawing;
3829 private final LinkedBlockingQueue<draw_object> queue = new LinkedBlockingQueue<draw_object>();
3830
3831 int i = 0;
3832 private draw_object l2;
3833 int thread_num;
3834 int counter = 0;
3835
3836 int m_x;
3837 int m_y;
3838 int m_x2;
3839 int m_y2;
3840 Boolean m_c = false;
3841
3842 DrawLinesThread(int thread_num)
3843 {
3844 this.thread_num = thread_num;
3845 this.running = true;
3846 this.start_drawing = false;
3847 }
3848
3849 public void motion_callback(int x, int y, int x2, int y2)
3850 {
3851 m_x = x;
3852 m_y = y;
3853 m_x2 = x2;
3854 m_y2 = y2;
3855 m_c = true;
3856 }
3857
3858 public void add_text(Paint paint, int x, int y, String text, int size, int dx, int dy)
3859 {
3860 draw_object l = new draw_object();
3861 l.type = 1; // text
3862 l.x = x;
3863 l.y = y;
3864 l.text = text;
3865 l.size = size;
3866 l.dx = dx;
3867 l.dy = dy;
3868 // -- paint --
3869 l.paint = new Paint();
3870 l.paint.setColor(paint.getColor());
3871 l.paint.setAlpha(paint.getAlpha());
3872 l.paint.setTypeface(paint.getTypeface());
3873 // l.paint.setPathEffect(paint.getPathEffect());
3874 // -- paint --
3875 queue.offer(l);
3876 }
3877
3878 public void add_lines(Paint paint, int c[], int order, int width)
3879 {
3880 draw_object l = new draw_object();
3881 l.type = 0; // line
3882 l.c = c;
3883 // -- paint --
3884 l.paint = new Paint();
3885 l.paint.setColor(paint.getColor());
3886 l.paint.setAlpha(paint.getAlpha());
3887 l.paint.setPathEffect(paint.getPathEffect());
3888 // -- paint --
3889 l.order = order;
3890 l.width = width;
3891 queue.offer(l);
3892 }
3893
3894 public void add_lines3(Paint paint, int c[], int order, int oneway)
3895 {
3896 draw_object l = new draw_object();
3897 l.type = 3; // line (one way arrows)
3898 l.c = c;
3899 // -- paint --
3900 l.paint = new Paint();
3901 l.paint.setColor(paint.getColor());
3902 l.paint.setAlpha(paint.getAlpha());
3903 l.paint.setPathEffect(paint.getPathEffect());
3904 // -- paint --
3905 l.order = order;
3906 l.width = oneway; // misuse this field here!!
3907 queue.offer(l);
3908 }
3909
3910 public void add_lines2(Paint paint, int c[], int order, int width, int line_type)
3911 {
3912 draw_object l = new draw_object();
3913
3914 if (line_type == 98)
3915 {
3916 // clear queue
3917 queue.clear();
3918 // stop drawing
3919 start_drawing = false;
3920 // and wake up from sleeping
3921 this.interrupt();
3922 return;
3923 }
3924 if (line_type == 97)
3925 {
3926 // start drawing from queue
3927 //System.out.println("start drawing");
3928 start_drawing = true;
3929 // and wake up from sleeping
3930 this.interrupt();
3931 return;
3932 }
3933 else if (line_type > 90)
3934 {
3935 l.type = line_type; // "***" signal
3936 }
3937 else
3938 {
3939 l.type = 2; // bridge/tunnel line
3940 l.c = c;
3941 l.line_type = line_type;
3942 // -- paint --
3943 l.paint = new Paint();
3944 l.paint.setColor(paint.getColor());
3945 l.paint.setAlpha(paint.getAlpha());
3946 l.paint.setPathEffect(paint.getPathEffect());
3947 // -- paint --
3948 l.order = order;
3949 l.width = width;
3950 }
3951 queue.offer(l);
3952 }
3953
3954 public void stop_me()
3955 {
3956 this.running = false;
3957 }
3958
3959 public void run()
3960 {
3961 while (this.running)
3962 {
3963
3964 if (m_c)
3965 {
3966 NavitGraphics.MotionCallback(m_x, m_y, m_x2, m_y2);
3967 m_c = false;
3968 }
3969
3970 counter = 0;
3971 // while ((start_drawing) && (queue.size() > 0))
3972 while (queue.size() > 0)
3973 {
3974 // if (counter > 20000)
3975 // {
3976 // // give a breather
3977 // try
3978 // {
3979 // Thread.sleep(10);
3980 // }
3981 // catch (InterruptedException e)
3982 // {
3983 // // e.printStackTrace();
3984 // }
3985 // counter = 0;
3986 // }
3987
3988 try
3989 {
3990 // blocking call
3991 l2 = queue.take();
3992 // non-blocking call
3993 // l2 = queue.poll();
3994 if (l2 != null)
3995 {
3996 switch (l2.type)
3997 {
3998 case 0:
3999 draw_polyline3_threads(l2.paint, l2.c, l2.order, l2.width);
4000 counter++;
4001 break;
4002 case 1:
4003 draw_text_threads(l2.paint, l2.x, l2.y, l2.text, l2.size, l2.dx, l2.dy);
4004 counter++;
4005 break;
4006 case 2:
4007 draw_polyline4_threads(l2.paint, l2.c, l2.order, l2.width, l2.line_type);
4008 counter++;
4009 break;
4010 case 3:
4011 draw_polyline2_threads(l2.paint, l2.c, l2.order, l2.width);
4012 counter++;
4013 break;
4014 case 96:
4015 //System.out.println("refresh map (layers)");
4016 // draw_map_one_shot = true;
4017 //copy_map_buffer();
4018 //draw_reset_factors = true;
4019 //view_s.postInvalidate();
4020 break;
4021 case 99:
4022 //System.out.println("refresh map OLDOLD");
4023 // draw_map_one_shot = true;
4024 copy_map_buffer();
4025 draw_reset_factors = true;
4026 //System.out.println("invalidate 015");
4027 view_s.postInvalidate();
4028 //view_s.paint_me();
4029 // try
4030 // {
4031 // Thread.sleep(800);
4032 // }
4033 // catch (InterruptedException e)
4034 // {
4035 // // e.printStackTrace();
4036 // }
4037 break;
4038 }
4039 }
4040 }
4041 catch (Exception e)
4042 {
4043 // e.printStackTrace();
4044 // // System.out.println("" + this.thread_num + " *ERR*");
4045 }
4046 }
4047
4048 //if (counter > 0)
4049 //{
4050 // // System.out.println("" + this.thread_num + " counter=" + counter);
4051 // view_s.postInvalidate();
4052 //}
4053
4054 try
4055 {
4056 Thread.sleep(60);
4057 }
4058 catch (InterruptedException e)
4059 {
4060 // e.printStackTrace();
4061 }
4062 }
4063 }
4064 }
4065
4066 protected void draw_polyline3___NEW(Paint paint, int c[], int order, int width)
4067 {
4068 if (dl_thread[0] == null)
4069 {
4070 int ii = 0;
4071 for (ii = 0; ii < NavitGraphics.dl_thread_max; ii++)
4072 {
4073 NavitGraphics.dl_thread[ii] = new NavitGraphics.DrawLinesThread(ii);
4074 NavitGraphics.dl_thread[ii].start();
4075 }
4076 }
4077
4078 if (dl_thread_cur + 1 < dl_thread_max)
4079 {
4080 dl_thread_cur++;
4081 }
4082 else
4083 {
4084 dl_thread_cur = 0;
4085 }
4086 dl_thread[dl_thread_cur].add_lines(paint, c, order, width);
4087 }
4088
4089 static void draw_polyline3_threads(Paint paint, int c[], int order, int width)
4090 {
4091 // Log.e("NavitGraphics","draw_polyline3_threads");
4092 paint.setStyle(Paint.Style.STROKE);
4093 paint.setAntiAlias(Navit.p.PREF_use_anti_aliasing);
4094 paint.setStrokeWidth(width);
4095 // *******************
4096 // *******************
4097 // ****** paint.setColor(Color.RED);
4098 // *******************
4099 // *******************
4100
4101 if (order > DRAW_MORE_DETAILS_AT_ORDER)
4102 {
4103 paint.setStyle(Paint.Style.FILL);
4104 paint.setStrokeWidth(0);
4105 draw_canvas_s.drawCircle(c[0], c[1], (width / 2), paint);
4106 }
4107 for (int i = 2; i < c.length; i += 2)
4108 {
4109 if (order > DRAW_MORE_DETAILS_AT_ORDER)
4110 {
4111 paint.setStyle(Paint.Style.FILL);
4112 paint.setStrokeWidth(0);
4113 draw_canvas_s.drawCircle(c[i], c[i + 1], (width / 2), paint);
4114 paint.setStyle(Paint.Style.STROKE);
4115 paint.setStrokeWidth(width);
4116 }
4117 draw_canvas_s.drawLine(c[i - 2], c[i - 1], c[i], c[i + 1], paint);
4118 }
4119 }
4120
4121 // draw normal polylines -> this function gets called the most!! XX-thousand times
4122 // draw normal polylines -> this function gets called the most!! XX-thousand times
4123 // draw normal polylines -> this function gets called the most!! XX-thousand times
4124 Paint paint_dr_poly3 = new Paint();
4125 int i_dr_poly3;
4126
4127 Path path_polyline_3_arrow_head = new Path();
4128
4129 protected void draw_polyline3(int c[], int order, int width, int dashes, int r, int g, int b, int a, int with_end)
4130 {
4131
4132 paint_dr_poly3.setARGB(a, r, g, b);
4133 set_dashes(paint_dr_poly3, dashes, order);
4134
4135 //Log.e("NavitGraphics","draw_polyline3");
4136 paint_dr_poly3.setStyle(Paint.Style.STROKE);
4137 //b_paint_antialias = paint.isAntiAlias();
4138 paint_dr_poly3.setAntiAlias(Navit.p.PREF_use_anti_aliasing);
4139 //wsave_003 = paint.getStrokeWidth();
4140 paint_dr_poly3.setStrokeWidth(width);
4141
4142 // make lines nicer -----------
4143 paint_dr_poly3.setStrokeMiter(1);
4144 paint_dr_poly3.setStrokeJoin(Join.ROUND);
4145 paint_dr_poly3.setStrokeCap(Cap.BUTT);
4146 // make lines nicer -----------
4147
4148 if ((order > DRAW_MORE_DETAILS_AT_ORDER) && (with_end == 1))
4149 {
4150 paint_dr_poly3.setStyle(Paint.Style.FILL);
4151 paint_dr_poly3.setStrokeWidth(0);
4152 draw_canvas.drawCircle(c[0], c[1], (width / 2), paint_dr_poly3);
4153 }
4154
4155 for (i_dr_poly3 = 2; i_dr_poly3 < c.length; i_dr_poly3 += 2)
4156 {
4157 if ((order > DRAW_MORE_DETAILS_AT_ORDER) && (with_end == 1))
4158 {
4159 //if (i < (c.length - 2))
4160 //{
4161 paint_dr_poly3.setStyle(Paint.Style.FILL);
4162 paint_dr_poly3.setStrokeWidth(0);
4163 draw_canvas.drawCircle(c[i_dr_poly3], c[i_dr_poly3 + 1], (width / 2), paint_dr_poly3);
4164 //}
4165 paint_dr_poly3.setStyle(Paint.Style.STROKE);
4166 paint_dr_poly3.setStrokeWidth(width);
4167 }
4168 draw_canvas.drawLine(c[i_dr_poly3 - 2], c[i_dr_poly3 - 1], c[i_dr_poly3], c[i_dr_poly3 + 1], paint_dr_poly3);
4169 }
4170
4171 if (with_end == 4) // arrow head at the end
4172 {
4173 if (c.length > 3)
4174 {
4175 float x0 = c[c.length - 4];
4176 float y0 = c[c.length - 3];
4177
4178 float x1 = c[c.length - 2];
4179 float y1 = c[c.length - 1];
4180
4181 float dx = x1 - x0;
4182 float dy = y1 - y0;
4183
4184 float[] p = new float[8];
4185
4186 float l = (float) Math.sqrt(dx * dx + dy * dy);
4187
4188 // dx = pnt[i + 1].x - pnt[i].x;
4189 // dy = pnt[i + 1].y - pnt[i].y;
4190 // l = sqrt(dx * dx + dy * dy);
4191 // if (l)
4192 // {
4193 // dx = dx * 65536 / l;
4194 // dy = dy * 65536 / l;
4195 // p = pnt[i];
4196 // p.x += dx * 15 / 65536;
4197 // p.y += dy * 15 / 65536;
4198 // display_draw_arrow(&p, dx, dy, 10, gc, gra);
4199 // p = pnt[i + 1];
4200 // p.x -= dx * 15 / 65536;
4201 // p.y -= dy * 15 / 65536;
4202 // display_draw_arrow(&p, dx, dy, 10, gc, gra);
4203 // }
4204
4205 // struct point pnt[3];
4206 // pnt[0] = pnt[1] = pnt[2] = *p;
4207 // pnt[0].x += -dx * l / 65536 + dy * l / 65536;
4208 // pnt[0].y += -dy * l / 65536 - dx * l / 65536;
4209 // pnt[2].x += -dx * l / 65536 - dy * l / 65536;
4210 // pnt[2].y += -dy * l / 65536 + dx * l / 65536;
4211 // gra->meth.draw_lines(gra->priv, gc->priv, pnt, 3);
4212
4213 if (l != 0)
4214 {
4215 dx = dx / l;
4216 dy = dy / l;
4217
4218 final float f1 = 38f; // arrow length
4219 final float f1a = 38f;
4220 final float f1b = 19f;
4221 final float f2 = 32f; // arrow width
4222 final float f3 = 32f; // arrow width
4223
4224 x1 = x1 + (dx * f1);
4225 y1 = y1 + (dy * f1);
4226 p[2] = x1;
4227 p[3] = y1;
4228
4229 p[6] = x1 - (dx * (f1 + f1b));
4230 p[7] = y1 - (dy * (f1 + f1b));
4231
4232 x1 = x1 - (dx * f1a);
4233 y1 = y1 - (dy * f1a);
4234 p[0] = x1;
4235 p[1] = y1;
4236 p[4] = x1;
4237 p[5] = y1;
4238
4239 p[0] = p[0] + (-dx * f2 + dy * f3);
4240 p[1] = p[1] + (-dy * f3 - dx * f2);
4241 p[4] = p[4] + (-dx * f2 - dy * f3);
4242 p[5] = p[5] + (-dy * f3 + dx * f2);
4243
4244 paint_dr_poly3.setStyle(Paint.Style.FILL);
4245
4246 path_polyline_3_arrow_head.reset();
4247 path_polyline_3_arrow_head.setFillType(Path.FillType.EVEN_ODD);
4248
4249 path_polyline_3_arrow_head.moveTo(p[0], p[1]);
4250 path_polyline_3_arrow_head.lineTo(p[2], p[3]);
4251 path_polyline_3_arrow_head.lineTo(p[4], p[5]);
4252 path_polyline_3_arrow_head.lineTo(p[6], p[7]);
4253 path_polyline_3_arrow_head.close();
4254
4255 draw_canvas.drawPath(path_polyline_3_arrow_head, paint_dr_poly3);
4256
4257 paint_dr_poly3.setStyle(Paint.Style.STROKE);
4258 paint_dr_poly3.setStrokeMiter(1);
4259 paint_dr_poly3.setStrokeJoin(Join.ROUND);
4260 paint_dr_poly3.setStrokeCap(Cap.ROUND);
4261 paint_dr_poly3.setStrokeWidth(9);
4262 paint_dr_poly3.setColor(Color.WHITE);
4263
4264 draw_canvas.drawPath(path_polyline_3_arrow_head, paint_dr_poly3);
4265
4266 paint_dr_poly3.setStrokeWidth(3);
4267 // paint_dr_poly3.setARGB(255, 4, 0xb4, 0xae);
4268 paint_dr_poly3.setARGB(a, r, g, b);
4269
4270 draw_canvas.drawPath(path_polyline_3_arrow_head, paint_dr_poly3);
4271 }
4272 }
4273 }
4274 //paint.setAntiAlias(b_paint_antialias);
4275 //paint.setStrokeWidth(wsave_003);
4276 }
4277
4278 // draw normal polylines -> this function gets called the most!! XX-thousand times
4279 // draw normal polylines -> this function gets called the most!! XX-thousand times
4280 // draw normal polylines -> this function gets called the most!! XX-thousand times
4281 Paint paint_dr_poly4 = new Paint();
4282 int i_dr_poly4;
4283
4284 protected void draw_polyline4(int c[], int order, int width, int type, int dashes, int r, int g, int b, int a, int with_end)
4285 {
4286 // type:0 -> normal line
4287 // type:1 -> underground (tunnel)
4288 // type:2 -> bridge
4289
4290 if (type > 90)
4291 {
4292 if (type == 96)
4293 {
4294 //System.out.println("refresh map (layers)");
4295 // draw_map_one_shot = true;
4296 //copy_map_buffer();
4297 //draw_reset_factors = true;
4298 //view_s.postInvalidate();
4299 }
4300 else if (type == 99)
4301 {
4302 //System.out.println("refresh map");
4303 //// draw_map_one_shot = true;
4304 //copy_map_buffer();
4305 //draw_reset_factors = true;
4306 //view_s.postInvalidate();
4307 }
4308 else if (type == 95)
4309 {
4310 //System.out.println("cancel map");
4311 // draw_map_one_shot = true;
4312 //copy_backwards_map_buffer();
4313 //draw_reset_factors = true;
4314 //view_s.postInvalidate();
4315 }
4316 return;
4317 }
4318
4319 paint_dr_poly4.setARGB(a, r, g, b);
4320 set_dashes(paint_dr_poly4, dashes, order);
4321
4322 //b_paint_antialias = paint.isAntiAlias();
4323 paint_dr_poly4.setAntiAlias(Navit.p.PREF_use_anti_aliasing);
4324 //wsave_004 = paint.getStrokeWidth();
4325
4326 if (order <= DRAW_MORE_DETAILS_TUNNEL_BRIDGES_AT_ORDER)
4327 {
4328 type = 0;
4329 }
4330
4331 if (type == 2)
4332 {
4333 // bridge
4334 //
4335 //int csave = paint.getColor();
4336 paint_dr_poly4.setAlpha(120); // 0 .. 255 // 255 -> no seethru
4337 paint_dr_poly4.setStyle(Paint.Style.STROKE);
4338 paint_dr_poly4.setStrokeWidth(width + 2);
4339 // paint.setColor(Color.BLACK);
4340 if (order > DRAW_DETAIL_DASHES_AT_ORDER)
4341 {
4342 paint_dr_poly4.setStrokeWidth(width + 4);
4343 }
4344 for (i_dr_poly4 = 2; i_dr_poly4 < c.length; i_dr_poly4 += 2)
4345 {
4346 draw_canvas.drawLine(c[i_dr_poly4 - 2], c[i_dr_poly4 - 1], c[i_dr_poly4], c[i_dr_poly4 + 1], paint_dr_poly4);
4347 }
4348 //paint.setColor(csave);
4349
4350 // -- circles --
4351 /*
4352 * paint.setAlpha(120);
4353 * paint.setStyle(Paint.Style.FILL);
4354 * paint.setStrokeWidth(0);
4355 * draw_canvas.drawCircle(c[0], c[1], (width / 2), paint);
4356 * for (int i = 2; i < c.length; i += 2)
4357 * {
4358 * paint.setStyle(Paint.Style.FILL);
4359 * paint.setStrokeWidth(0);
4360 * draw_canvas.drawCircle(c[i], c[i + 1], (width / 2), paint);
4361 * }
4362 */
4363 // -- circles --
4364 }
4365
4366 // ---------------------------------------
4367 paint_dr_poly4.setStyle(Paint.Style.STROKE);
4368 paint_dr_poly4.setStrokeWidth(width);
4369
4370 if (type == 1)
4371 {
4372 // tunnel
4373 //paint2.setAlpha(70); // 0 .. 255 // 255 -> no seethru
4374 paint_dr_poly4.setAlpha(150); // 0 .. 255 // 255 -> no seethru
4375 if (order > DRAW_DETAIL_DASHES_AT_ORDER)
4376 {
4377 paint_dr_poly4.setPathEffect(dashed_map_lines__low);
4378 }
4379 else
4380 {
4381 paint_dr_poly4.setPathEffect(dashed_map_lines__high);
4382 }
4383 }
4384 else if (type == 2)
4385 {
4386 // bridge
4387 paint_dr_poly4.setAlpha(70); // 0 .. 255 // 255 -> no seethru
4388 }
4389
4390 paint_dr_poly4.setStyle(Paint.Style.STROKE);
4391 paint_dr_poly4.setStrokeWidth(width);
4392 for (i_dr_poly4 = 2; i_dr_poly4 < c.length; i_dr_poly4 += 2)
4393 {
4394 draw_canvas.drawLine(c[i_dr_poly4 - 2], c[i_dr_poly4 - 1], c[i_dr_poly4], c[i_dr_poly4 + 1], paint_dr_poly4);
4395 }
4396
4397 //paint.setPathEffect(dashed_map_lines__no_dash);
4398 //paint.setAntiAlias(b_paint_antialias);
4399 //paint.setStrokeWidth(wsave_004);
4400 }
4401
4402 protected void draw_polyline4__NEW(Paint paint, int c[], int order, int width, int type)
4403 {
4404 if (dl_thread[0] == null)
4405 {
4406 int ii = 0;
4407 for (ii = 0; ii < NavitGraphics.dl_thread_max; ii++)
4408 {
4409 NavitGraphics.dl_thread[ii] = new NavitGraphics.DrawLinesThread(ii);
4410 NavitGraphics.dl_thread[ii].start();
4411 }
4412 }
4413
4414 if (dl_thread_cur + 1 < dl_thread_max)
4415 {
4416 dl_thread_cur++;
4417 }
4418 else
4419 {
4420 dl_thread_cur = 0;
4421 }
4422 dl_thread[dl_thread_cur].add_lines2(paint, c, order, width, type);
4423 }
4424
4425 // for bridge or tunnel this function is used
4426 static void draw_polyline4_threads(Paint paint, int c[], int order, int width, int type)
4427 {
4428 // type:0 -> normal line
4429 // type:1 -> underground (tunnel)
4430 // type:2 -> bridge
4431
4432 paint.setAntiAlias(Navit.p.PREF_use_anti_aliasing);
4433
4434 if (order <= DRAW_MORE_DETAILS_TUNNEL_BRIDGES_AT_ORDER)
4435 {
4436 type = 0;
4437 }
4438
4439 if (type == 2)
4440 {
4441 // bridge
4442 //
4443 //int csave = paint.getColor();
4444 paint.setAlpha(120); // 0 .. 255 // 255 -> no seethru
4445 paint.setStyle(Paint.Style.STROKE);
4446 paint.setStrokeWidth(width + 2);
4447 // paint.setColor(Color.BLACK);
4448 if (order > DRAW_DETAIL_DASHES_AT_ORDER)
4449 {
4450 paint.setStrokeWidth(width + 4);
4451 }
4452 for (int i = 2; i < c.length; i += 2)
4453 {
4454 draw_canvas_s.drawLine(c[i - 2], c[i - 1], c[i], c[i + 1], paint);
4455 }
4456 //paint.setColor(csave);
4457
4458 // -- circles --
4459 /*
4460 * paint.setAlpha(120);
4461 * paint.setStyle(Paint.Style.FILL);
4462 * paint.setStrokeWidth(0);
4463 * draw_canvas.drawCircle(c[0], c[1], (width / 2), paint);
4464 * for (int i = 2; i < c.length; i += 2)
4465 * {
4466 * paint.setStyle(Paint.Style.FILL);
4467 * paint.setStrokeWidth(0);
4468 * draw_canvas.drawCircle(c[i], c[i + 1], (width / 2), paint);
4469 * }
4470 */
4471 // -- circles --
4472 }
4473
4474 // ---------------------------------------
4475 paint.setStyle(Paint.Style.STROKE);
4476 paint.setStrokeWidth(width);
4477
4478 if (type == 1)
4479 {
4480 // tunnel
4481 paint.setAlpha(70); // 0 .. 255 // 255 -> no seethru
4482 if (order > DRAW_DETAIL_DASHES_AT_ORDER)
4483 {
4484 paint.setPathEffect(dashed_map_lines__low);
4485 }
4486 else
4487 {
4488 paint.setPathEffect(dashed_map_lines__high);
4489 }
4490 }
4491 else if (type == 2)
4492 {
4493 // bridge
4494 paint.setAlpha(70); // 0 .. 255 // 255 -> no seethru
4495 }
4496
4497 paint.setStyle(Paint.Style.STROKE);
4498 paint.setStrokeWidth(width);
4499 for (int i = 2; i < c.length; i += 2)
4500 {
4501 draw_canvas_s.drawLine(c[i - 2], c[i - 1], c[i], c[i + 1], paint);
4502 }
4503 }
4504
4505 // for bridge or tunnel this function is used
4506
4507 protected void set_dashes(Paint paint, int variant, int order)
4508 {
4509 if (variant == 0)
4510 {
4511 paint.setPathEffect(dashed_map_lines__no_dash);
4512 return;
4513 }
4514
4515 if (order > DRAW_DETAIL_DASHES_AT_ORDER)
4516 {
4517 paint.setPathEffect(dashes__low[variant]);
4518 }
4519 else
4520 {
4521 paint.setPathEffect(dashes__high[variant]);
4522 }
4523 }
4524
4525 protected void draw_polyline_dashed(Paint paint, int c[], int order, int oneway)
4526 {
4527 // emtpy dummy for C-Code
4528 }
4529
4530 protected void draw_polyline_dashed______UNUSED(Paint paint, int c[], int order, int oneway)
4531 {
4532 //
4533 //
4534 // !! this function is unsed now !!
4535 //
4536 //
4537
4538 paint.setStyle(Paint.Style.STROKE);
4539 b_paint_antialias = paint.isAntiAlias();
4540 paint.setAntiAlias(Navit.p.PREF_use_anti_aliasing);
4541
4542 Boolean normal = false;
4543
4544 // create matrix for the manipulation
4545 Matrix matrix = new Matrix();
4546
4547 int middle_x = c[0] + (int) ((c[2] - c[0]) / 2);
4548 int middle_y = c[1] + (int) ((c[3] - c[1]) / 2);
4549 double d_x = ((c[2] - c[0]) / 6);
4550 double d_y = ((c[3] - c[1]) / 6);
4551 int angle = (int) (Math.toDegrees(Math.atan2(d_y, d_x)));
4552 matrix.postTranslate(-Navit.oneway_arrow.getWidth() / 2, -Navit.oneway_arrow.getHeight() / 2);
4553
4554 if (order > DRAW_ONEWAY_ARROWS_AT_ORDER)
4555 {
4556 if (oneway == 1)
4557 {
4558 if (!Navit.p.PREF_gui_oneway_arrows)
4559 {
4560 return;
4561 }
4562 // rotate the Bitmap
4563 matrix.postRotate(angle);
4564 }
4565 else if (oneway == 2)
4566 {
4567 if (!Navit.p.PREF_gui_oneway_arrows)
4568 {
4569 return;
4570 }
4571 // rotate the Bitmap
4572 matrix.postRotate(angle + 180);
4573 }
4574
4575 if (oneway > 0)
4576 {
4577 if (c.length == 4)
4578 {
4579 matrix.postTranslate(middle_x, middle_y);
4580 draw_canvas.drawBitmap(Navit.oneway_arrow, matrix, paint);
4581 }
4582 }
4583 else
4584 {
4585 normal = true;
4586 }
4587 }
4588 else
4589 {
4590 normal = true;
4591 }
4592
4593 if (normal)
4594 {
4595 // normal line
4596 if (order > DRAW_DETAIL_DASHES_AT_ORDER)
4597 {
4598 paint.setPathEffect(dashed_map_lines__low);
4599 }
4600 else
4601 {
4602 paint.setPathEffect(dashed_map_lines__high);
4603 }
4604 b_paint_path.reset();
4605 b_paint_path.moveTo(c[0], c[1]);
4606 for (int i = 2; i < c.length; i += 2)
4607 {
4608 b_paint_path.lineTo(c[i], c[i + 1]);
4609 }
4610
4611 draw_canvas.drawPath(b_paint_path, paint);
4612 paint.setPathEffect(dashed_map_lines__no_dash);
4613 }
4614 paint.setAntiAlias(b_paint_antialias);
4615 }
4616
4617 Paint paint_draw_polygon = new Paint();
4618 int dr_poly_i;
4619
4620 void ClearPreview_bitmap()
4621 {
4622 if (preview_bitmap != null)
4623 {
4624 preview_canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
4625 //System.out.println("CLEAR MAP:011:clear preview map");
4626 }
4627 }
4628
4629 static void DrawPreview_polyline(int type, int c[], String type2)
4630 {
4631 if (preview_bitmap != null)
4632 {
4633 path_preview.reset();
4634 path_preview.moveTo(c[0] * preview_coord_factor, c[1] * preview_coord_factor);
4635 for (int i = 2; i < c.length; i += 2)
4636 {
4637 path_preview.lineTo(c[i] * preview_coord_factor, c[i + 1] * preview_coord_factor);
4638 }
4639
4640 if ((type2.equals("street_0")) || (type2.equals("street_1_city")) || (type2.equals("street_1_land")))
4641 {
4642 //<itemgra item_types="street_0,street_1_city,street_1_land" order="{round(18-number($LAYOUT_001_ORDER_DELTA_1))}">
4643 //<polyline color="#d2d2d2" width="132"/>
4644 //<polyline color="#ffffff" width="126"/>
4645
4646 paint_preview.setColor(Color.parseColor("#FFD2D2D2"));
4647 paint_preview.setStyle(Paint.Style.STROKE);
4648 paint_preview.setStrokeWidth(dp_to_px(5));
4649 preview_canvas.drawPath(path_preview, paint_preview);
4650
4651 paint_preview.setColor(Color.parseColor("#FFFFFFFF"));
4652 paint_preview.setStrokeWidth(dp_to_px(3));
4653 preview_canvas.drawPath(path_preview, paint_preview);
4654 }
4655 else if ((type2.equals("street_pedestrian")) || (type2.equals("living_street")))
4656 {
4657 //<itemgra item_types="street_pedestrian,living_street" order="{round(18-number($LAYOUT_001_ORDER_DELTA_1))}">
4658 //<polyline color="#d2d2d2" width="40"/>
4659 //<polyline color="#dddddd" width="34"/>
4660
4661 paint_preview.setColor(Color.parseColor("#FFD2D2D2"));
4662 paint_preview.setStyle(Paint.Style.STROKE);
4663 paint_preview.setStrokeWidth(dp_to_px(5));
4664 preview_canvas.drawPath(path_preview, paint_preview);
4665
4666 paint_preview.setColor(Color.parseColor("#FFdddddd"));
4667 paint_preview.setStrokeWidth(dp_to_px(3));
4668 preview_canvas.drawPath(path_preview, paint_preview);
4669 }
4670 else if ((type2.equals("street_service")) || (type2.equals("street_parking_lane")))
4671 {
4672 //<itemgra item_types="street_service" order="13-{round(14-number($LAYOUT_001_ORDER_DELTA_1))}">
4673 //<polyline color="#d2d2d2" width="7"/>
4674 //<polyline color="#fefefe" width="5"/>
4675 paint_preview.setColor(Color.parseColor("#FFd2d2d2"));
4676 paint_preview.setStyle(Paint.Style.STROKE);
4677 paint_preview.setStrokeWidth(dp_to_px(5));
4678 preview_canvas.drawPath(path_preview, paint_preview);
4679
4680 paint_preview.setColor(Color.parseColor("#FFfefefe"));
4681 paint_preview.setStrokeWidth(dp_to_px(3));
4682 preview_canvas.drawPath(path_preview, paint_preview);
4683 }
4684 else if ((type2.equals("street_2_city")) || (type2.equals("ramp_street_2_city")) || (type2.equals("street_2_land")))
4685 {
4686 //<itemgra item_types="street_2_city,ramp_street_2_city,street_2_land,ramp" order="{round(15-number($LAYOUT_001_ORDER_DELTA_1))}">
4687 //<polyline color="#c0c0c0" width="19"/>
4688 //<polyline color="#fefc8c" width="15"/>
4689
4690 paint_preview.setColor(Color.parseColor("#FFC0C0C0"));
4691 paint_preview.setStyle(Paint.Style.STROKE);
4692 paint_preview.setStrokeWidth(dp_to_px(5));
4693 preview_canvas.drawPath(path_preview, paint_preview);
4694
4695 paint_preview.setColor(Color.parseColor("#FFFEFC8C"));
4696 paint_preview.setStrokeWidth(dp_to_px(3));
4697 preview_canvas.drawPath(path_preview, paint_preview);
4698 }
4699 else if ((type2.equals("street_3_city")) || (type2.equals("ramp_street_3_city")) || (type2.equals("street_3_land")) || (type2.equals("roundabout")))
4700 {
4701 // <itemgra item_types="street_3_city,ramp_street_3_city,street_3_land,roundabout" order="{round(16-number($LAYOUT_001_ORDER_DELTA_1))}">
4702 // <polyline color="#a0a0a0" width="40"/>
4703 // <polyline color="#fefc8c" width="34"/>
4704
4705 paint_preview.setColor(Color.parseColor("#FFa0a0a0"));
4706 paint_preview.setStyle(Paint.Style.STROKE);
4707 paint_preview.setStrokeWidth(dp_to_px(5));
4708 preview_canvas.drawPath(path_preview, paint_preview);
4709
4710 paint_preview.setColor(Color.parseColor("#FFfefc8c"));
4711 paint_preview.setStrokeWidth(dp_to_px(3));
4712 preview_canvas.drawPath(path_preview, paint_preview);
4713 }
4714 else if ((type2.equals("cycleway")))
4715 {
4716 // <itemgra item_types="cycleway" order="14-15">
4717 // <polyline color="#0000ff" width="2" dash="6"/>
4718
4719 paint_preview.setColor(Color.parseColor("#FF0000FF"));
4720 paint_preview.setStyle(Paint.Style.STROKE);
4721 paint_preview.setStrokeWidth(dp_to_px(3));
4722 preview_canvas.drawPath(path_preview, paint_preview);
4723 }
4724 else if ((type2.equals("street_4_city")) || (type2.equals("ramp_street_4_city")) || (type2.equals("street_4_land")) || (type2.equals("street_n_lanes")))
4725 {
4726 //<itemgra item_types="street_4_city,ramp_street_4_city,street_4_land,street_n_lanes" order="{round(15-number($LAYOUT_001_ORDER_DELTA_1))}">
4727 //<polyline color="#000000" width="24"/>
4728 //<polyline color="#f8dc79" width="20"/>
4729
4730 paint_preview.setColor(Color.parseColor("#FF000000"));
4731 paint_preview.setStyle(Paint.Style.STROKE);
4732 paint_preview.setStrokeWidth(dp_to_px(5));
4733 preview_canvas.drawPath(path_preview, paint_preview);
4734
4735 paint_preview.setColor(Color.parseColor("#FFf8dc79"));
4736 paint_preview.setStrokeWidth(dp_to_px(3));
4737 preview_canvas.drawPath(path_preview, paint_preview);
4738 }
4739 else if ((type2.equals("highway_city")) || (type2.equals("highway_land")) || (type2.equals("ramp_highway_land")))
4740 {
4741 // <itemgra item_types="highway_city,highway_land,ramp_highway_land" order="{round(13-number($LAYOUT_001_ORDER_DELTA_1))}">
4742 //<polyline color="#a8aab3" width="25"/>
4743 //<polyline color="#fc843b" width="17"/>
4744
4745 paint_preview.setColor(Color.parseColor("#FFa8aab3"));
4746 paint_preview.setStyle(Paint.Style.STROKE);
4747 paint_preview.setStrokeWidth(dp_to_px(5));
4748 preview_canvas.drawPath(path_preview, paint_preview);
4749
4750 paint_preview.setColor(Color.parseColor("#FFfc843b"));
4751 paint_preview.setStrokeWidth(dp_to_px(3));
4752 preview_canvas.drawPath(path_preview, paint_preview);
4753 }
4754 else if (type2.equals("poly_water_tiled") || (type2.equals("poly_water_from_triang")))
4755 {
4756 paint_preview.setColor(Color.parseColor("#FF82C8EA"));
4757 paint_preview.setStyle(Paint.Style.FILL);
4758 paint_preview.setStrokeWidth(dp_to_px(0));
4759 preview_canvas.drawPath(path_preview, paint_preview);
4760 }
4761 else if (type2.equals("poly_wood_from_triang") || (type2.equals("poly_wood")))
4762 {
4763 paint_preview.setColor(Color.parseColor("#FF8ec78d"));
4764 paint_preview.setStyle(Paint.Style.FILL);
4765 paint_preview.setStrokeWidth(dp_to_px(0));
4766 preview_canvas.drawPath(path_preview, paint_preview);
4767 }
4768 else if (type2.equals("wood_from_relations"))
4769 {
4770 paint_preview.setColor(Color.parseColor("#FF478f46"));
4771 paint_preview.setStyle(Paint.Style.FILL);
4772 paint_preview.setStrokeWidth(dp_to_px(0));
4773 preview_canvas.drawPath(path_preview, paint_preview);
4774 }
4775 else if (type2.equals("poly_park") || (type2.equals("poly_playground")))
4776 {
4777 //<itemgra item_types="poly_park,poly_playground" order="{round(12-number($LAYOUT_001_ORDER_DELTA_1))}-">
4778 //<polygon color="#7cc334"/>
4779 //<text text_size="8"/>
4780
4781 paint_preview.setColor(Color.parseColor("#FF7cc334"));
4782 paint_preview.setStyle(Paint.Style.FILL);
4783 paint_preview.setStrokeWidth(dp_to_px(0));
4784 preview_canvas.drawPath(path_preview, paint_preview);
4785 }
4786 else if ((type2.startsWith("poly")) && (Navit.GlobalScaleLevel > 10))
4787 {
4788 // !!!do nothing!!!
4789 }
4790 else
4791 {
4792 if (type2.startsWith("poly"))
4793 {
4794 // all the rest - polys
4795 paint_preview.setColor(Color.parseColor("#AA8E8E8E")); // semi-transparent gray
4796 paint_preview.setStyle(Paint.Style.FILL);
4797 paint_preview.setStrokeWidth(dp_to_px(0));
4798 preview_canvas.drawPath(path_preview, paint_preview);
4799 }
4800 else
4801 {
4802 // all the rest - lines
4803 paint_preview.setColor(Color.parseColor("#AA8E8E8E")); // semi-transparent gray
4804 paint_preview.setStyle(Paint.Style.STROKE);
4805 paint_preview.setStrokeWidth(dp_to_px(2));
4806 preview_canvas.drawPath(path_preview, paint_preview);
4807 }
4808 }
4809
4810 // System.out.println("DrawPreview_polyline:" + type2);
4811 }
4812 }
4813
4814 // this is used to draw filled polygons ---------------------------------------------
4815 // this is used to draw filled polygons ---------------------------------------------
4816 // this is used to draw filled polygons ---------------------------------------------
4817 // this is used to draw filled polygons ---------------------------------------------
4818 // this is used to draw filled polygons ---------------------------------------------
4819 protected void draw_polygon(int c[], int width, int r, int g, int b, int a)
4820 {
4821 paint_draw_polygon.setARGB(a, r, g, b);
4822 paint_draw_polygon.setStrokeWidth(width);
4823 paint_draw_polygon.setStyle(Paint.Style.FILL);
4824
4825 // Log.e("NavitGraphics", "polygon " + r + " " + g + " " + b + " " + a);
4826
4827 // paint_draw_polygon.setAntiAlias(Navit.p.PREF_use_anti_aliasing);
4828 paint_draw_polygon.setAntiAlias(false); // nicer without anti aliasing, strange but true
4829
4830 b_paint_path.reset();
4831 b_paint_path.moveTo(c[0], c[1]);
4832 for (dr_poly_i = 2; dr_poly_i < c.length; dr_poly_i += 2)
4833 {
4834 b_paint_path.lineTo(c[dr_poly_i], c[dr_poly_i + 1]);
4835 }
4836 draw_canvas.drawPath(b_paint_path, paint_draw_polygon);
4837 }
4838
4839 // this is used to draw filled polygons ---------------------------------------------
4840 // this is used to draw filled polygons ---------------------------------------------
4841 // this is used to draw filled polygons ---------------------------------------------
4842 // this is used to draw filled polygons ---------------------------------------------
4843 // this is used to draw filled polygons ---------------------------------------------
4844
4845 protected void draw_polygon2(Paint paint, int c[], int order, int oneway)
4846 {
4847 paint.setStyle(Paint.Style.FILL);
4848 b_paint_antialias = paint.isAntiAlias();
4849 paint.setAntiAlias(Navit.p.PREF_use_anti_aliasing);
4850 b_paint_path.reset();
4851 b_paint_path.moveTo(c[0], c[1]);
4852 for (int i = 2; i < c.length; i += 2)
4853 {
4854 b_paint_path.lineTo(c[i], c[i + 1]);
4855 }
4856
4857 if (order > DRAW_ONEWAY_ARROWS_AT_ORDER)
4858 {
4859 if (oneway == 1)
4860 {
4861 paint.setColor(Color.RED);
4862 if (!Navit.p.PREF_gui_oneway_arrows)
4863 {
4864 return;
4865 }
4866 }
4867 else if (oneway == 2)
4868 {
4869 paint.setColor(Color.BLUE);
4870 if (!Navit.p.PREF_gui_oneway_arrows)
4871 {
4872 return;
4873 }
4874 }
4875 }
4876
4877 draw_canvas.drawPath(b_paint_path, paint);
4878 paint.setAntiAlias(b_paint_antialias);
4879 }
4880
4881 protected void draw_rectangle(Paint paint, int x, int y, int w, int h)
4882 {
4883 //Log.e("NavitGraphics","draw_rectangle");
4884 Rect r = new Rect(x, y, x + w, y + h);
4885 paint.setStyle(Paint.Style.FILL);
4886 b_paint_antialias = paint.isAntiAlias();
4887 paint.setAntiAlias(Navit.p.PREF_use_anti_aliasing);
4888 //paint.setStrokeWidth(0);d
4889 draw_canvas.drawRect(r, paint);
4890 paint.setAntiAlias(b_paint_antialias);
4891 }
4892
4893 protected void draw_circle(Paint paint, int x, int y, int r)
4894 {
4895 // Log.e("NavitGraphics", "draw_circle " + x + " " + y + " " + r);
4896 // float fx = x;
4897 // float fy = y;
4898 // float fr = r / 2;
4899 paint.setStyle(Paint.Style.STROKE);
4900 b_paint_antialias = paint.isAntiAlias();
4901 paint.setAntiAlias(Navit.p.PREF_use_anti_aliasing);
4902 draw_canvas.drawCircle(x, y, r / 2, paint);
4903 paint.setAntiAlias(b_paint_antialias);
4904 }
4905
4906 protected void draw_text__NEW(Paint paint, int x, int y, String text, int size, int dx, int dy)
4907 {
4908 if (dl_thread[0] == null)
4909 {
4910 int ii = 0;
4911 for (ii = 0; ii < NavitGraphics.dl_thread_max; ii++)
4912 {
4913 NavitGraphics.dl_thread[ii] = new NavitGraphics.DrawLinesThread(ii);
4914 NavitGraphics.dl_thread[ii].start();
4915 }
4916 }
4917
4918 if (dl_thread_cur + 1 < dl_thread_max)
4919 {
4920 dl_thread_cur++;
4921 }
4922 else
4923 {
4924 dl_thread_cur = 0;
4925 }
4926
4927 // FONT ------------------
4928 // FONT ------------------
4929 if (Navit.p.PREF_use_custom_font == true)
4930 {
4931 if (paint.getTypeface() == null)
4932 {
4933 try
4934 {
4935 paint.setTypeface(Navit.NavitStreetnameFont);
4936 //System.out.println("Calling setTypeface");
4937 }
4938 catch (Exception e)
4939 {
4940 //e.printStackTrace();
4941 }
4942 }
4943 }
4944 else
4945 {
4946 if (paint.getTypeface() != null)
4947 {
4948 paint.setTypeface(null);
4949 }
4950 }
4951 // FONT ------------------
4952 // FONT ------------------
4953
4954 dl_thread[dl_thread_cur].add_text(paint, x, y, text, size, dx, dy);
4955 }
4956
4957 static void draw_text_threads(Paint paint, int x, int y, String text, int size, int dx, int dy)
4958 {
4959 // float fx = x;
4960 // float fy = y;
4961 //Log.e("NavitGraphics","Text size "+size + " vs " + paint.getTextSize());
4962 if (Navit.p.PREF_map_font_size != 2)
4963 {
4964 if (Navit.p.PREF_map_font_size == 3)
4965 {
4966 // large
4967 paint.setTextSize((int) ((size / 15) * 1.4));
4968 }
4969 else if (Navit.p.PREF_map_font_size == 4)
4970 {
4971 // extra large
4972 paint.setTextSize((int) ((size / 15) * 1.7));
4973 }
4974 else if (Navit.p.PREF_map_font_size == 5)
4975 {
4976 // extra large
4977 paint.setTextSize((int) ((size / 15) * 2.2));
4978 }
4979 else if (Navit.p.PREF_map_font_size == 1)
4980 {
4981 // small
4982 paint.setTextSize((int) ((size / 15) * 0.72));
4983 }
4984 else
4985 {
4986 // other? use normal size
4987 paint.setTextSize(size / 15);
4988 }
4989 }
4990 else
4991 {
4992 // normal size
4993 paint.setTextSize(size / 15);
4994 }
4995 paint.setStyle(Paint.Style.FILL);
4996 // FONT ------------------
4997 // FONT ------------------
4998 if (Navit.p.PREF_use_custom_font == true)
4999 {
5000 if (paint.getTypeface() == null)
5001 {
5002 try
5003 {
5004 paint.setTypeface(Navit.NavitStreetnameFont);
5005 //System.out.println("Calling setTypeface");
5006 }
5007 catch (Exception e)
5008 {
5009 //e.printStackTrace();
5010 }
5011 }
5012 }
5013 else
5014 {
5015 if (paint.getTypeface() != null)
5016 {
5017 paint.setTypeface(null);
5018 }
5019 }
5020 // FONT ------------------
5021 // FONT ------------------
5022 paint.setAntiAlias(Navit.p.PREF_use_anti_aliasing);
5023 if (dx == 0x10000 && dy == 0)
5024 {
5025 draw_canvas_s.drawText(text, x, y, paint);
5026 }
5027 else
5028 {
5029 Path b_paint_path_ = new Path();
5030 b_paint_path_.reset();
5031 b_paint_path_.moveTo(x, y);
5032 b_paint_path_.rLineTo(dx, dy);
5033 paint.setTextAlign(android.graphics.Paint.Align.LEFT);
5034 draw_canvas_s.drawTextOnPath(text, b_paint_path_, 0, 0, paint);
5035 }
5036 }
5037
5038 Paint paint_draw_text = new Paint();
5039
5040 protected void draw_text(int x, int y, String text, int size, int dx, int dy, int r, int g, int b, int a)
5041 {
5042
5043 paint_draw_text.setARGB(a, r, g, b);
5044
5045 // float fx = x;
5046 // float fy = y;
5047 // Log.e("NavitGraphics", "Text size " + size + " " + r + " " + g + " " + b + " " + a);
5048 if (Navit.p.PREF_map_font_size != 2)
5049 {
5050 if (Navit.p.PREF_map_font_size == 3)
5051 {
5052 // large
5053 paint_draw_text.setTextSize((int) ((size / 15) * 1.4));
5054 }
5055 else if (Navit.p.PREF_map_font_size == 4)
5056 {
5057 // extra large
5058 paint_draw_text.setTextSize((int) ((size / 15) * 1.7));
5059 }
5060 else if (Navit.p.PREF_map_font_size == 5)
5061 {
5062 // extra large
5063 paint_draw_text.setTextSize((int) ((size / 15) * 2.2));
5064 }
5065 else if (Navit.p.PREF_map_font_size == 1)
5066 {
5067 // small
5068 paint_draw_text.setTextSize((int) ((size / 15) * 0.72));
5069 }
5070 else
5071 {
5072 // other? use normal size
5073 paint_draw_text.setTextSize(size / 15);
5074 }
5075 }
5076 else
5077 {
5078 // normal size
5079 paint_draw_text.setTextSize(size / 15);
5080 }
5081 paint_draw_text.setStyle(Paint.Style.FILL);
5082 // FONT ------------------
5083 // FONT ------------------
5084 if (Navit.p.PREF_use_custom_font == true)
5085 {
5086 if (paint_draw_text.getTypeface() == null)
5087 {
5088 try
5089 {
5090 strokeTextPaint.setTypeface(Navit.NavitStreetnameFont);
5091 paint_draw_text.setTypeface(Navit.NavitStreetnameFont);
5092 // System.out.println("Calling setTypeface");
5093 }
5094 catch (Exception e)
5095 {
5096 //e.printStackTrace();
5097 }
5098 }
5099 }
5100 else
5101 {
5102 if (paint_draw_text.getTypeface() != null)
5103 {
5104 strokeTextPaint.setTypeface(null);
5105 paint_draw_text.setTypeface(null);
5106 }
5107 }
5108 // FONT ------------------
5109 // FONT ------------------
5110 // b_paint_antialias = paint_draw_text.isAntiAlias();
5111 paint_draw_text.setAntiAlias(Navit.p.PREF_use_anti_aliasing);
5112
5113 if (paint_draw_text.getTextSize() < 30)
5114 {
5115 strokeTextPaint.setStrokeWidth(s_strokTextSize_min);
5116 }
5117 else
5118 {
5119 strokeTextPaint.setStrokeWidth(s_strokTextSize);
5120 }
5121
5122 paint_draw_text.setTextAlign(android.graphics.Paint.Align.LEFT);
5123
5124 if (dx == 0x10000 && dy == 0)
5125 {
5126 strokeTextPaint.setTextSize(paint_draw_text.getTextSize());
5127 draw_canvas.drawText(text, x, y, strokeTextPaint);
5128 draw_canvas.drawText(text, x, y, paint_draw_text);
5129 }
5130 else
5131 {
5132 b_paint_path.reset();
5133 b_paint_path.moveTo(x, y);
5134 b_paint_path.rLineTo(dx, dy);
5135
5136 strokeTextPaint.setTextSize(paint_draw_text.getTextSize());
5137 // draw shadow ---
5138 draw_canvas.drawTextOnPath(text, b_paint_path, 0, 0, strokeTextPaint);
5139 // draw shadow ---
5140
5141 // draw normal text ---
5142 draw_canvas.drawTextOnPath(text, b_paint_path, 0, 0, paint_draw_text);
5143 // draw normal text ---
5144 }
5145 // paint.setAntiAlias(b_paint_antialias);
5146 }
5147
5148 protected void draw_image(int x, int y, Bitmap bitmap, int r, int g, int b, int a)
5149 {
5150 //Log.e("NavitGraphics","draw_image");
5151 // float fx = x;
5152 // float fy = y;
5153 //System.out.println("DO__DRAW:draw_image:drawBitmap start");
5154 draw_canvas.drawBitmap(bitmap, x, y, null);
5155 //System.out.println("DO__DRAW:draw_image:drawBitmap end");
5156 }
5157
5158 protected void draw_warp__YYY(String imagepath, int count, int p0x, int p0y, int p1x, int p1y, int p2x, int p2y)
5159 {
5160 // dummy -> do nothing!!
5161 }
5162
5163 float dw__new_len;
5164 float dw__scale_x_y;
5165 float dw__deltaY;
5166 float dw__deltaX;
5167 float dw__angle_deg;
5168 final int dw__map_tile_x = 256;
5169 final int dw__map_tile_y = 256;
5170 Bitmap dw__bitmap = null;
5171 InputStream dw__infile;
5172
5173 // ", "(Ljava/lang/String;IIIIIIIII)V
5174 protected void draw_warp(String imagepath, int count, int p0x, int p0y, int p1x, int p1y, int p2x, int p2y)
5175 {
5176 //System.out.println("draw_warp: image=" + imagepath + " count=" + count);
5177 //System.out.println("draw_warp: p0x=" + p0x + ", p0y=" + p0y + ", p1x=" + p1x + ", p1y=" + p1y + ", p2x=" + p2x + ", p2y=" + p2y);
5178
5179 // orig map tile size = 256px * 256px
5180 // p0(x,y)=position of left lower corner of image!!
5181
5182 /*
5183 * void imlib_render_image_on_drawable_skewed(int source_x, int source_y,
5184 * int source_width,
5185 * int source_height,
5186 * int destination_x,
5187 * int destination_y,
5188 * int h_angle_x, int h_angle_y,
5189 * int v_angle_x, int v_angle_y);
5190 */
5191
5192 try
5193 {
5194 dw__bitmap = null;
5195
5196 //if (imagepath.startsWith("6/"))
5197 //{
5198 // bitmap = BitmapFactory.decodeFile(Navit.MAP_FILENAME_PATH + "/" + imagepath);
5199 //}
5200 //else
5201 //{
5202 try
5203 {
5204 dw__infile = Navit.asset_mgr.open(imagepath);
5205 dw__bitmap = BitmapFactory.decodeStream(dw__infile);
5206 dw__infile.close();
5207 }
5208 catch (IOException e1)
5209 {
5210 e1.printStackTrace();
5211 }
5212 //}
5213
5214 if (count == 3)
5215 {
5216 // imlib_render_image_on_drawable_skewed(0, 0, w, h, p[0].x, p[0].y, p[1].x-p[0].x, p[1].y-p[0].y, p[2].x-p[0].x, p[2].y-p[0].y);
5217 //matrix.setRotate(90.0f); // Degrees
5218 dw__new_len = (float) (Math.sqrt(((p1x - p0x) * (p1x - p0x)) + ((p1y - p0y) * (p1y - p0y))));
5219 dw__scale_x_y = dw__new_len / dw__map_tile_y;
5220 dw__deltaY = -p1y + p0y;
5221 dw__deltaX = p1x - p0x;
5222 dw__angle_deg = -(float) (Math.atan2(dw__deltaY, dw__deltaX) * 180d / Math.PI);
5223 //System.out.println("_warp: angle=" + angle_deg);
5224 matrix_maptile.reset();
5225 matrix_maptile.postTranslate(p0x, p0y - (dw__map_tile_y * dw__scale_x_y));
5226 matrix_maptile.preScale(dw__scale_x_y, dw__scale_x_y);
5227 matrix_maptile.postRotate(dw__angle_deg, p0x, p0y);
5228 }
5229 else
5230 {
5231 dw__bitmap.recycle();
5232 dw__bitmap = null;
5233 return;
5234 }
5235
5236 draw_canvas.drawBitmap(dw__bitmap, matrix_maptile, paint_maptile);
5237 dw__bitmap.recycle();
5238 dw__bitmap = null;
5239 }
5240 catch (Exception e)
5241 {
5242
5243 }
5244 }
5245
5246 protected void draw_bigmap(int yaw, int order, float clng, float clat, int x_, int y_, int mcx, int mcy, int px_, int py_, int valid)
5247 {
5248 // not used, but references somewhere. so dont delete!!!
5249 }
5250
5251 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)
5252 {
5253 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
5254
5255 // System.out.println("NavitOSDJava:" + id + " " + text1 + " " + text2 + " " + text3 + " " + i1 + " " + i2 + " " + i3 + " " + i4 + " " + f1 + " " + f2 + " " + f3);
5256 // System.out.println("NavitOSDJava:" + last_paint_OSD);
5257 Boolean needed_value = false;
5258 try
5259 {
5260 if (id.equals("scale"))
5261 {
5262 if (text1 != null)
5263 {
5264 if (text1.equals("draw_rectangle1"))
5265 {
5266 Navit.OSD_scale.base = i1;
5267 }
5268 else if (text1.equals("draw_rectangle2"))
5269 {
5270 Navit.OSD_scale.scale_valid = true;
5271 Navit.OSD_scale.var = i1;
5272 }
5273 else if (text1.equals("draw_text"))
5274 {
5275 Navit.OSD_scale.scale_valid = true;
5276 Navit.OSD_scale.scale_text = text2;
5277 }
5278 }
5279 needed_value = true;
5280 }
5281 else if (id.equals("osd_text_draw"))
5282 {
5283 if ((text1 != null) && (text1.equals("draw_text")))
5284 {
5285 if ((text2 != null) && (text2.equals("navigation:nav_position:destination_time")))
5286 {
5287 // text3 = 20:38 --> ETA time (+1 means next day!)
5288 // System.out.println("destination_time:" + text3);
5289 Navit.OSD_route_001.arriving_time = text3;
5290 Navit.OSD_route_001.arriving_time_valid = true;
5291 needed_value = true;
5292
5293 if (Navit.OSD_route_001.arriving_time.compareTo("") == 0)
5294 {
5295 ZANaviLinearLayout.redraw_OSD(7);
5296 ZANaviOSDETA.last_ondraw = -1;
5297 }
5298 else if (ZANaviOSDETA.last_ondraw == -1)
5299 {
5300 ZANaviLinearLayout.redraw_OSD(7);
5301 ZANaviOSDETA.last_ondraw = System.currentTimeMillis();
5302 }
5303 else if ((ZANaviOSDETA.last_ondraw + 1400) < System.currentTimeMillis()) // only every 1.4 secs.
5304 {
5305 ZANaviLinearLayout.redraw_OSD(7);
5306 ZANaviOSDETA.last_ondraw = System.currentTimeMillis();
5307 }
5308 return;
5309 }
5310 else if ((text2 != null) && (text2.equals("navigation:nav_position:destination_secs_time")))
5311 {
5312 // text3 = 342 --> time to target in seconds
5313 // System.out.println("destination_secs_time:" + text3);
5314
5315 if ((text3 == null) || (text3.equals("")))
5316 {
5317 Navit.OSD_route_001.arriving_secs_to_dest = "";
5318 Navit.OSD_route_001.arriving_secs_to_dest_valid = false;
5319 }
5320 else
5321 {
5322 int secs = (Integer.parseInt(text3)) + 30; // add 30 secs to round up to next minute
5323 // System.out.println("SSS:secs=" + text3);
5324
5325 // int seconds = (int) (secs) % 60;
5326 int minutes = (int) ((secs / (60)) % 60);
5327 int hours = (int) ((secs / (60 * 60)) % 24);
5328 int days = (int) ((secs / (60 * 60)) / 24);
5329
5330 String days_ = "";
5331 if (days > 0)
5332 {
5333 days_ = "" + days + "d ";
5334 }
5335
5336 if ((hours > 0) || (days > 0))
5337 {
5338 Navit.OSD_route_001.arriving_secs_to_dest = days_ + hours + "h " + minutes + "m";
5339 }
5340 else
5341 {
5342 Navit.OSD_route_001.arriving_secs_to_dest = "" + minutes + " min";
5343 }
5344 Navit.OSD_route_001.arriving_secs_to_dest_valid = true;
5345 needed_value = true;
5346 }
5347
5348 ZANaviLinearLayout.redraw_OSD(5);
5349 return;
5350
5351 }
5352 else if ((text2 != null) && (text2.equals("navigation:nav_position:destination_length")))
5353 {
5354 // text3 = 575m -> driving distance to target
5355 // System.out.println("destination_length:" + text3);
5356 Navit.OSD_route_001.driving_distance_to_target = text3;
5357 Navit.OSD_route_001.driving_distance_to_target_valid = true;
5358 needed_value = true;
5359
5360 ZANaviLinearLayout.redraw_OSD(6);
5361 return;
5362 }
5363 else if ((text2 != null) && (text2.length() > 10) && (text2.substring(0, 11).equals("navigation:")))
5364 {
5365 String[] tmp_string = text2.split(":", 3);
5366 if (tmp_string.length == 3)
5367 {
5368 if (tmp_string[2].equals("length"))
5369 {
5370 // "navigation:******:length"
5371 // text3 = 250m --> when to do the next turn
5372 //System.out.println("nextturn_distance:" + text3);
5373 Navit.OSD_nextturn.nextturn_distance = text3;
5374 Navit.OSD_nextturn.nextturn_distance_valid = true;
5375 // we need to paint the OSD in any case
5376 last_paint_OSD = -1;
5377 needed_value = true;
5378
5379 ZANaviLinearLayout.redraw_OSD(4);
5380 return;
5381 }
5382 else if (tmp_string[2].equals("street_name_systematic"))
5383 {
5384 // "navigation:******:street_name_systematic"
5385 // System.out.println("nextturn_streetname_systematic:" + text3);
5386 Navit.OSD_nextturn.nextturn_streetname_systematic = text3;
5387 needed_value = true;
5388
5389 ZANaviLinearLayout.redraw_OSD(1);
5390 return;
5391 }
5392 else if (tmp_string[2].equals("street_name"))
5393 {
5394 // "navigation:******:street_name"
5395 // System.out.println("nextturn_streetname:" + text3);
5396 Navit.OSD_nextturn.nextturn_streetname = text3;
5397 needed_value = true;
5398 }
5399 }
5400 }
5401 else if ((text2 != null) && (text2.length() > 8) && (text2.substring(0, 9).equals("tracking:")))
5402 {
5403 if (NavitGraphics.navit_route_status == 0)
5404 {
5405 if (text2.equals("tracking:street_name:"))
5406 {
5407 // System.out.println("t2:" + text2 + text3);
5408 Navit.OSD_nextturn.nextturn_streetname = text3;
5409 last_paint_OSD = -1;
5410 needed_value = true;
5411
5412 ZANaviLinearLayout.redraw_OSD(1);
5413 return;
5414 }
5415 else if (text2.equals("tracking:street_name_systematic:"))
5416 {
5417 // System.out.println("t1:" + text2 + text3);
5418 Navit.OSD_nextturn.nextturn_streetname_systematic = text3;
5419 needed_value = true;
5420 }
5421 }
5422 }
5423 else
5424 {
5425 // Log.e("NavitOSDJava", "" + id + " " + text1 + " " + text2 + " " + text3 + " " + i1 + " " + i2 + " " + i3 + " " + i4 + " " + f1 + " " + f2 + " " + f3);
5426 }
5427 }
5428 }
5429 else if (id.equals("nav_next_turn"))
5430 {
5431 if ((text1 != null) && (text1.equals("draw_image1")))
5432 {
5433 // System.out.println("tttt222:" + text2);
5434 // text2 = res/drawable/xx.png
5435 if ((text2 == null) || (text2.equals("")))
5436 {
5437 Navit.OSD_nextturn.nextturn_image_valid = false;
5438 Navit.OSD_nextturn.nextturn_image.recycle();
5439 }
5440
5441 if (!Navit.OSD_nextturn.nextturn_image_filename.equals(text2))
5442 {
5443 // only if image is different from current image
5444 Navit.OSD_nextturn.nextturn_image_filename = text2;
5445 Navit.OSD_nextturn.nextturn_image_filename_valid = true;
5446 if (Navit.OSD_nextturn.nextturn_image != null)
5447 {
5448 try
5449 {
5450 Navit.OSD_nextturn.nextturn_image.recycle();
5451 }
5452 catch (Exception e)
5453 {
5454 }
5455 }
5456 // System.out.println("load image: " + Navit.OSD_nextturn.nextturn_image_filename);
5457 String x = Navit.OSD_nextturn.nextturn_image_filename.substring(13).replace(".png", "");
5458 // System.out.println("load image: " + x);
5459 int ResId = Navit.res_.getIdentifier("com.zoffcc.applications.zanavi:drawable/" + x, null, null);
5460 // System.out.println("ResId: " + ResId);
5461 Navit.OSD_nextturn.nextturn_image = BitmapFactory.decodeResource(Navit.res_, ResId);
5462 Navit.OSD_nextturn.nextturn_image_valid = true;
5463 }
5464
5465 ZANaviLinearLayout.redraw_OSD(3);
5466 return;
5467
5468 }
5469 needed_value = true;
5470 }
5471 else if (id.equals("compass"))
5472 {
5473 if ((text1 != null) && (text1.equals("text_and_dst_angle")))
5474 {
5475 if ((text2 == null) || (text2.equals("")))
5476 {
5477 Navit.OSD_compass.direct_distance_to_target = "";
5478 Navit.OSD_compass.direct_distance_to_target_valid = false;
5479 }
5480 else
5481 {
5482 Navit.OSD_compass.direct_distance_to_target = text2;
5483 Navit.OSD_compass.direct_distance_to_target_valid = true;
5484 }
5485 try
5486 {
5487 // Navit.OSD_compass.angle_target = Float.parseFloat(text3);
5488 Navit.OSD_compass.angle_target = i1;
5489 Navit.OSD_compass.angle_target_valid = true;
5490 }
5491 catch (Exception e)
5492 {
5493 //e.printStackTrace();
5494 }
5495 needed_value = true;
5496 }
5497 else if ((text1 != null) && (text1.equals("direction")))
5498 {
5499 try
5500 {
5501 // Navit.OSD_compass.angle_north = Float.parseFloat(text2);
5502 Navit.OSD_compass.angle_north = i1;
5503 Navit.OSD_compass.angle_north_valid = true;
5504 needed_value = true;
5505
5506 ZANaviLinearLayout.redraw_OSD(2);
5507 return;
5508 }
5509 catch (Exception e)
5510 {
5511 //e.printStackTrace();
5512
5513 }
5514 }
5515 }
5516 }
5517 catch (Exception x)
5518 {
5519 x.printStackTrace();
5520 }
5521
5522 if (!needed_value)
5523 {
5524 // we got values that we dont use
5525 //System.out.println("xx paint 0 xx");
5526 // if (Navit.METHOD_DEBUG) Navit.my_func_name(2);
5527 return;
5528 }
5529
5530 if (NavitGraphics.MAP_DISPLAY_OFF)
5531 {
5532 // paint only every 800ms
5533 if ((last_paint_OSD + 800) < System.currentTimeMillis())
5534 {
5535 try
5536 {
5537 last_paint_OSD = System.currentTimeMillis();
5538 //System.out.println("xx paint 1 xx");
5539 // **************NNNNNN*********** // NavitOSDJava.draw_real_wrapper(true, false);
5540 //++NavitAOSDJava_.postInvalidate();
5541 }
5542 catch (Exception r)
5543 {
5544 //r.printStackTrace();
5545 }
5546 }
5547 }
5548 else
5549 {
5550 // paint only every 600ms
5551 if ((last_paint_OSD + 750) < System.currentTimeMillis())
5552 {
5553 try
5554 {
5555 last_paint_OSD = System.currentTimeMillis();
5556 //System.out.println("xx paint 2 xx");
5557 // **************NNNNNN*********** // NavitOSDJava.draw_real_wrapper(true, false);
5558 // * works * // NavitOSDJava.draw_real_wrapper(true, true);
5559 }
5560 catch (Exception r)
5561 {
5562 //r.printStackTrace();
5563 }
5564 }
5565 }
5566 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
5567 }
5568
5569 static void copy_map_buffer()
5570 {
5571 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
5572
5573 // System.out.println("DO__DRAW:copy_map_buffer:drawBitmap enter");
5574 // SYN //
5575 synchronized (synch_drawing_for_map)
5576 {
5577 // stop any smooth drawing/moving first!
5578 Global_SmoothDrawing_stop = true;
5579 //System.out.println("copy_map_buffer: Enter ******");
5580
5581 //System.out.println("DO__DRAW:Java:reset GLOBAL factors");
5582 Global_Map_TransX = 0;
5583 Global_Map_TransY = 0;
5584 Global_Map_Rotationangle = 0f;
5585 Global_Map_Zoomfactor = 1.0f;
5586 try
5587 {
5588 //System.out.println("DO__DRAW:copy_map_buffer:drawBitmap start");
5589 draw_canvas_screen_s.drawBitmap(draw_bitmap_s, 0, 0, null);
5590 //System.out.println("DO__DRAW:copy_map_buffer:drawBitmap end");
5591
5592 // draw_canvas_screen_s.drawColor(Color.MAGENTA);
5593 //System.out.println("CLEAR MAP:004");
5594
5595 if (Navit.p.PREF_show_route_rects)
5596 {
5597 // System.out.println("route_rect::start");
5598
5599 // --- draw debug route rects ----
5600 Paint paint78 = new Paint();
5601 paint78.setStrokeWidth(15);
5602 paint78.setStyle(Style.STROKE);
5603
5604 int i3 = 0;
5605 for (i3 = 0; i3 < route_rects.size(); i3++)
5606 {
5607 route_rect rr = route_rects.get(i3);
5608 if (rr.order == -99)
5609 {
5610 // rectangle to just include all waypoints
5611 paint78.setColor(Color.RED);
5612 }
5613 else if (rr.order == 8)
5614 {
5615 // rectangle around every waypoint with low detail (order = 8) // larger roads
5616 paint78.setColor(Color.GREEN);
5617 }
5618 else if (rr.order == 18)
5619 {
5620 // rectangle around every waypoint with high detail (order = 18) // all small roads
5621 paint78.setColor(Color.MAGENTA);
5622 }
5623 else if (rr.order == 4)
5624 {
5625 // rectangles ??
5626 paint78.setColor(Color.BLUE);
5627 }
5628 else if (rr.order == 6)
5629 {
5630 // rectangles ??
5631 paint78.setColor(Color.CYAN);
5632 }
5633 else if (rr.order == 7)
5634 {
5635 // rectangles ??
5636 paint78.setColor(Color.YELLOW);
5637 }
5638
5639 String left_top_on_screen_string = CallbackGeoCalc(11, rr.x1, rr.y1);
5640 String tmp[] = left_top_on_screen_string.split(":", 2);
5641 int xx1 = Integer.parseInt(tmp[0]);
5642 int yy1 = Integer.parseInt(tmp[1]);
5643 // System.out.println("route_rect:: " + xx1 + "," + yy1);
5644
5645 left_top_on_screen_string = CallbackGeoCalc(11, rr.x2, rr.y2);
5646 tmp = left_top_on_screen_string.split(":", 2);
5647 int xx2 = Integer.parseInt(tmp[0]);
5648 int yy2 = Integer.parseInt(tmp[1]);
5649 // System.out.println("route_rect:: " + xx2 + "," + yy2);
5650
5651 // draw the route rectanlge
5652 draw_canvas_screen_s.drawRect(xx1 / Global_dpi_factor, yy1 / Global_dpi_factor, xx2 / Global_dpi_factor, yy2 / Global_dpi_factor, paint78);
5653 }
5654 // --- draw debug route rects ----
5655 }
5656 }
5657 catch (Exception e)
5658 {
5659 // if screen is rotated, bitmaps are not valid, and this would crash
5660 // find a better solution later!!
5661 }
5662 // System.out.println("DO__DRAW:copy_map_buffer:Ready ******");
5663
5664 }
5665 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
5666 }
5667
5668 static void copy_backwards_map_buffer()
5669 {
5670 }
5671
5672 protected void draw_mode(int mode)
5673 {
5674 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
5675
5676 //Log.e("NavitGraphics", "draw_mode mode=" + mode + " parent_graphics=" + String.valueOf(parent_graphics));
5677
5678 if (mode == 1 || (mode == 0 && parent_num != 0))
5679 {
5680 //System.out.println("DO__DRAW:draw_mode:erase start");
5681 draw_bitmap.eraseColor(0);
5682 //System.out.println("DO__DRAW:draw_mode:erase start");
5683 }
5684
5685 //if ((parent_num != 0) && ((mode == 2) || (mode == 4)))
5686 //{
5687 // vehicle graphics overlay
5688 // copy_map_buffer();
5689 // Paint paint43 = new Paint();
5690 // paint43.setStyle(Paint.Style.STROKE);
5691 // paint43.setAntiAlias(Navit.PREF_use_anti_aliasing);
5692 // paint43.setStrokeWidth(12);
5693 // paint43.setColor(Color.RED);
5694 // draw_canvas.drawLine(0, 0, 50, 50, paint43);
5695 //}
5696
5697 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
5698 }
5699
5700 protected void draw_drag(int x, int y)
5701 {
5702 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
5703
5704 // Log.e("NavitGraphics","draw_drag"+pos_x+" "+pos_y+" "+x+" "+y);
5705 pos_x = x;
5706 // System.out.println("px set:006");
5707 pos_y = y;
5708
5709 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
5710 }
5711
5712 protected void overlay_disable(int disable)
5713 {
5714 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
5715
5716 // UNUSED ------
5717
5718 //Log.e("NavitGraphics","overlay_disable");
5719 // assume we are NOT in map view mode!
5720 // -> always in map mode now !!!! # in_map = false;
5721
5722 // check if overlay has been initialized yet
5723 //if (NavitAOverlay != null)
5724 //{
5725 // NavitAOverlay.hide_bubble();
5726 //}
5727
5728 // overlay_disabled = disable;
5729 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
5730 }
5731
5732 protected void overlay_resize(int x, int y, int w, int h, int alpha, int wraparond)
5733 {
5734 // UNUSED ------
5735
5736 //Log.e("NavitGraphics", "overlay_resize: " + x + "" + y + "" + w + "" + h);
5737 //pos_x = x;
5738 //pos_y = y;
5739 }
5740
5741 public static String getLocalizedString(String text)
5742 {
5743 String ret = CallbackLocalizedString(text);
5744 //Log.e("NavitGraphics", "callback_handler -> lozalized string=" + ret);
5745 return ret;
5746 }
5747
5748 static String __n_distance(int i)
5749 {
5750 String ret = "";
5751 if ((i > 0) && (i < 10))
5752 {
5753 ret = __get_distance(i, 0);
5754 }
5755 else
5756 {
5757 switch (i)
5758 {
5759 case 10:
5760 ret = "";
5761 break;
5762 case 11:
5763 ret = "soon";
5764 break;
5765 case 12:
5766 ret = "after %i roads";
5767 break;
5768 case 13:
5769 ret = "now";
5770 break;
5771 default:
5772 ret = "";
5773 }
5774 }
5775 return ret;
5776 }
5777
5778 static String __get_distance(int i, int is_length)
5779 {
5780 String ret = "";
5781
5782 if (is_length == 0)
5783 {
5784 switch (i)
5785 {
5786 case 1:
5787 ret = "in %d m";
5788 break;
5789 case 2:
5790 ret = "in %d feet";
5791 break;
5792 case 3:
5793 ret = "in %d meters";
5794 break;
5795 case 4:
5796 ret = "in %d.%d miles";
5797 break;
5798 case 5:
5799 ret = "in %d.%d kilometers";
5800 break;
5801 case 6:
5802 ret = "in one mile";
5803 break;
5804 case 7:
5805 ret = "in %d miles";
5806 break;
5807 case 8:
5808 ret = "in one kilometer";
5809 break;
5810 case 9:
5811 ret = "in %d kilometer";
5812 break;
5813 default:
5814 ret = "";
5815 }
5816 }
5817 else
5818 {
5819 switch (i)
5820 {
5821 case 1:
5822 ret = "%d m";
5823 break;
5824 case 2:
5825 ret = "%d feet";
5826 break;
5827 case 3:
5828 ret = "%d meters";
5829 break;
5830 case 4:
5831 ret = "%d.%d miles";
5832 break;
5833 case 5:
5834 ret = "%d.%d kilometers";
5835 break;
5836 case 6:
5837 ret = "one mile";
5838 break;
5839 case 7:
5840 ret = "%d miles";
5841 break;
5842 case 8:
5843 ret = "one kilometer";
5844 break;
5845 case 9:
5846 ret = "%d kilometer";
5847 break;
5848 default:
5849 ret = "";
5850 }
5851 }
5852
5853 return ret;
5854 }
5855
5856 static String __direction(int i)
5857 {
5858 String ret = "";
5859
5860 switch (i)
5861 {
5862 case 1:
5863 ret = "left";
5864 break;
5865 case 2:
5866 ret = "right";
5867 break;
5868 default:
5869 ret = "";
5870 }
5871
5872 return ret;
5873 }
5874
5875 static String __strength(int i)
5876 {
5877 String ret = "";
5878
5879 switch (i)
5880 {
5881 case 1:
5882 ret = "";
5883 break;
5884 case 2:
5885 ret = "slight ";
5886 break;
5887 case 3:
5888 ret = "hard ";
5889 break;
5890 case 4:
5891 ret = "really hard ";
5892 break;
5893 default:
5894 ret = "";
5895 }
5896
5897 return ret;
5898 }
5899
5900 static String __navigation_item_destination(int i)
5901 {
5902 String ret = "";
5903
5904 switch (i)
5905 {
5906 case 1:
5907 ret = "";
5908 break;
5909 case 2:
5910 ret = "exit";
5911 break;
5912 case 3:
5913 ret = "into the ramp";
5914 break;
5915 case 4:
5916 ret = "%sinto the street %s%s%s";
5917 break;
5918 case 5:
5919 ret = "%sinto the %s%s%s|male form";
5920 break;
5921 case 6:
5922 ret = "%sinto the %s%s%s|female form";
5923 break;
5924 case 7:
5925 ret = "%sinto the %s%s%s|neutral form";
5926 break;
5927 case 8:
5928 ret = "%sinto the %s";
5929 break;
5930 default:
5931 ret = "";
5932 }
5933
5934 return ret;
5935 }
5936
5937 public static void generate_all_speech_commands()
5938 {
5939 try
5940 {
5941 NavitGraphics.NavitMsgTv2sc_.setVisibility(View.VISIBLE);
5942 NavitGraphics.NavitMsgTv2_.setVisibility(View.VISIBLE);
5943 NavitGraphics.NavitMsgTv2_.setEnabled(true);
5944 }
5945 catch (Exception e)
5946 {
5947 e.printStackTrace();
5948 }
5949
5950 String a = null;
5951 String b = null;
5952 String a1 = null;
5953 String b1 = null;
5954 String c = null;
5955 String c1 = null;
5956 String d = null;
5957 String d1 = null;
5958 int j;
5959 //
5960 //
5961 //
5962 a = "When possible, please turn around";
5963 a1 = CallbackLocalizedString(a);
5964 NavitGraphics.NavitMsgTv2_.append(a + "\n");
5965 NavitGraphics.NavitMsgTv2_.append(a1 + "\n");
5966 System.out.println(a);
5967 System.out.println(a1);
5968 //
5969 a = "Enter the roundabout soon";
5970 a1 = CallbackLocalizedString(a);
5971 NavitGraphics.NavitMsgTv2_.append(a + "\n");
5972 NavitGraphics.NavitMsgTv2_.append(a1 + "\n");
5973 System.out.println(a);
5974 System.out.println(a1);
5975 //
5976 a = "then you have reached your destination.";
5977 a1 = CallbackLocalizedString(a);
5978 NavitGraphics.NavitMsgTv2_.append(a + "\n");
5979 NavitGraphics.NavitMsgTv2_.append(a1 + "\n");
5980 System.out.println(a);
5981 System.out.println(a1);
5982 //
5983 a = "In %s, enter the roundabout";
5984 a1 = CallbackLocalizedString(a);
5985 for (j = 1; j < 10; j++)
5986 {
5987 if ((j == 4) || (j == 5))
5988 {
5989 b = __get_distance(j, 1);
5990 b1 = CallbackLocalizedString(b);
5991 c = String.format(b, 1, 4);
5992 c1 = String.format(b1, 1, 4);
5993 d = String.format(a, c);
5994 d1 = String.format(a1, c1);
5995 try
5996 {
5997 d = String.format(d, 3, 4, 5);
5998 }
5999 catch (Exception e)
6000 {
6001
6002 }
6003 try
6004 {
6005 d1 = String.format(d1, 3, 4, 5);
6006 }
6007 catch (Exception e)
6008 {
6009
6010 }
6011 NavitGraphics.NavitMsgTv2_.append(d + "\n");
6012 NavitGraphics.NavitMsgTv2_.append(d1 + "\n");
6013 System.out.println(d);
6014 System.out.println(d1);
6015 }
6016 else
6017 {
6018 b = __get_distance(j, 1);
6019 b1 = CallbackLocalizedString(b);
6020 c = String.format(b, 250);
6021 c1 = String.format(b1, 250);
6022 d = String.format(a, c);
6023 d1 = String.format(a1, c1);
6024 try
6025 {
6026 d = String.format(d, 3, 4, 5);
6027 }
6028 catch (Exception e)
6029 {
6030
6031 }
6032 try
6033 {
6034 d1 = String.format(d1, 3, 4, 5);
6035 }
6036 catch (Exception e)
6037 {
6038
6039 }
6040 NavitGraphics.NavitMsgTv2_.append(d + "\n");
6041 NavitGraphics.NavitMsgTv2_.append(d1 + "\n");
6042 System.out.println(d);
6043 System.out.println(d1);
6044 }
6045 }
6046 //
6047 a = "Follow the road for the next %s";
6048 a1 = CallbackLocalizedString(a);
6049 for (j = 1; j < 10; j++)
6050 {
6051 if ((j == 4) || (j == 5))
6052 {
6053 b = __get_distance(j, 1);
6054 b1 = CallbackLocalizedString(b);
6055 c = String.format(b, 1, 4);
6056 c1 = String.format(b1, 1, 4);
6057 d = String.format(a, c);
6058 d1 = String.format(a1, c1);
6059 try
6060 {
6061 d = String.format(d, 3, 4, 5);
6062 }
6063 catch (Exception e)
6064 {
6065
6066 }
6067 try
6068 {
6069 d1 = String.format(d1, 3, 4, 5);
6070 }
6071 catch (Exception e)
6072 {
6073
6074 }
6075 NavitGraphics.NavitMsgTv2_.append(d + "\n");
6076 NavitGraphics.NavitMsgTv2_.append(d1 + "\n");
6077 System.out.println(d);
6078 System.out.println(d1);
6079 }
6080 else
6081 {
6082 b = __get_distance(j, 1);
6083 b1 = CallbackLocalizedString(b);
6084 c = String.format(b, 250);
6085 c1 = String.format(b1, 250);
6086 d = String.format(a, c);
6087 d1 = String.format(a1, c1);
6088 try
6089 {
6090 d = String.format(d, 3, 4, 5);
6091 }
6092 catch (Exception e)
6093 {
6094
6095 }
6096 try
6097 {
6098 d1 = String.format(d1, 3, 4, 5);
6099 }
6100 catch (Exception e)
6101 {
6102
6103 }
6104 NavitGraphics.NavitMsgTv2_.append(d + "\n");
6105 NavitGraphics.NavitMsgTv2_.append(d1 + "\n");
6106 System.out.println(d);
6107 System.out.println(d1);
6108 }
6109 }
6110 //
6111 a = "Leave the roundabout at the %s";
6112 a1 = CallbackLocalizedString(a);
6113 b = String.format(a, "first exit");
6114 b1 = String.format(a1, CallbackLocalizedString("first exit"));
6115 NavitGraphics.NavitMsgTv2_.append(b + "\n");
6116 NavitGraphics.NavitMsgTv2_.append(b1 + "\n");
6117 System.out.println(b);
6118 System.out.println(b1);
6119 //
6120 a = "Leave the roundabout at the %s";
6121 a1 = CallbackLocalizedString(a);
6122 b = String.format(a, "third exit");
6123 b1 = String.format(a1, CallbackLocalizedString("third exit"));
6124 NavitGraphics.NavitMsgTv2_.append(b + "\n");
6125 NavitGraphics.NavitMsgTv2_.append(b1 + "\n");
6126 System.out.println(b);
6127 System.out.println(b1);
6128 //
6129 a = "then leave the roundabout at the %s";
6130 a1 = CallbackLocalizedString(a);
6131 b = String.format(a, "first exit");
6132 b1 = String.format(a1, CallbackLocalizedString("first exit"));
6133 NavitGraphics.NavitMsgTv2_.append(b + "\n");
6134 NavitGraphics.NavitMsgTv2_.append(b1 + "\n");
6135 System.out.println(b);
6136 System.out.println(b1);
6137 //
6138 a = "then leave the roundabout at the %s";
6139 a1 = CallbackLocalizedString(a);
6140 b = String.format(a, "third exit");
6141 b1 = String.format(a1, CallbackLocalizedString("third exit"));
6142 NavitGraphics.NavitMsgTv2_.append(b + "\n");
6143 NavitGraphics.NavitMsgTv2_.append(b1 + "\n");
6144 System.out.println(b);
6145 System.out.println(b1);
6146 //
6147 a = "Take the %1$s road to the %2$s";
6148 a1 = CallbackLocalizedString(a);
6149 b = String.format(a, "first", "left");
6150 b1 = String.format(a1, CallbackLocalizedString("first"), CallbackLocalizedString("left"));
6151 NavitGraphics.NavitMsgTv2_.append(b + "\n");
6152 NavitGraphics.NavitMsgTv2_.append(b1 + "\n");
6153 System.out.println(b);
6154 System.out.println(b1);
6155 //
6156 a = "Take the %1$s road to the %2$s";
6157 a1 = CallbackLocalizedString(a);
6158 b = String.format(a, "first", "right");
6159 b1 = String.format(a1, CallbackLocalizedString("first"), CallbackLocalizedString("right"));
6160 NavitGraphics.NavitMsgTv2_.append(b + "\n");
6161 NavitGraphics.NavitMsgTv2_.append(b1 + "\n");
6162 System.out.println(b);
6163 System.out.println(b1);
6164 //
6165 a = "Take the %1$s road to the %2$s";
6166 a1 = CallbackLocalizedString(a);
6167 b = String.format(a, "third", "left");
6168 b1 = String.format(a1, CallbackLocalizedString("third"), CallbackLocalizedString("left"));
6169 NavitGraphics.NavitMsgTv2_.append(b + "\n");
6170 NavitGraphics.NavitMsgTv2_.append(b1 + "\n");
6171 System.out.println(b);
6172 System.out.println(b1);
6173 //
6174 a = "Take the %1$s road to the %2$s";
6175 a1 = CallbackLocalizedString(a);
6176 b = String.format(a, "third", "right");
6177 b1 = String.format(a1, CallbackLocalizedString("third"), CallbackLocalizedString("right"));
6178 NavitGraphics.NavitMsgTv2_.append(b + "\n");
6179 NavitGraphics.NavitMsgTv2_.append(b1 + "\n");
6180 System.out.println(b);
6181 System.out.println(b1);
6182 //
6183 a = "You have reached your destination %s";
6184 a1 = CallbackLocalizedString(a);
6185 for (j = 1; j < 14; j++)
6186 {
6187 if (j == 10)
6188 {
6189 d = String.format(a, "");
6190 d1 = String.format(a1, "");
6191 try
6192 {
6193 d = String.format(d, 3, 4, 5);
6194 }
6195 catch (Exception e)
6196 {
6197
6198 }
6199 try
6200 {
6201 d1 = String.format(d1, 3, 4, 5);
6202 }
6203 catch (Exception e)
6204 {
6205
6206 }
6207 NavitGraphics.NavitMsgTv2_.append(d + "\n");
6208 NavitGraphics.NavitMsgTv2_.append(d1 + "\n");
6209 System.out.println(d + "\n");
6210 System.out.println(d1 + "\n");
6211 }
6212 else if (j == 12)
6213 {
6214 b = __n_distance(j);
6215 b1 = CallbackLocalizedString(b);
6216 c = b.replace("%i", "3");
6217 c1 = b1.replace("%i", "3");
6218 d = String.format(a, c);
6219 d1 = String.format(a1, c1);
6220 try
6221 {
6222 d = String.format(d, 3, 4, 5);
6223 }
6224 catch (Exception e)
6225 {
6226
6227 }
6228 try
6229 {
6230 d1 = String.format(d1, 3, 4, 5);
6231 }
6232 catch (Exception e)
6233 {
6234
6235 }
6236 NavitGraphics.NavitMsgTv2_.append(d + "\n");
6237 NavitGraphics.NavitMsgTv2_.append(d1 + "\n");
6238 System.out.println(d);
6239 System.out.println(d1);
6240 }
6241 else
6242 {
6243 b = __n_distance(j);
6244 b1 = CallbackLocalizedString(b);
6245 d = String.format(a, b);
6246 d1 = String.format(a1, b1);
6247 try
6248 {
6249 d = String.format(d, 3, 4, 5);
6250 }
6251 catch (Exception e)
6252 {
6253
6254 }
6255 try
6256 {
6257 d1 = String.format(d1, 3, 4, 5);
6258 }
6259 catch (Exception e)
6260 {
6261
6262 }
6263 NavitGraphics.NavitMsgTv2_.append(d + "\n");
6264 NavitGraphics.NavitMsgTv2_.append(d1 + "\n");
6265 System.out.println(d);
6266 System.out.println(d1);
6267 }
6268 }
6269 //
6270 a = "Turn %1$s%2$s %3$s%4$s";
6271 a1 = CallbackLocalizedString(a);
6272 String xx = null;
6273 String xx1 = null;
6274 String yy = null;
6275 String yy1 = null;
6276 for (j = 1; j < 5; j++)
6277 {
6278 if (j == 1)
6279 {
6280 b = __strength(j);
6281 b1 = "";
6282 }
6283 else
6284 {
6285 b = __strength(j);
6286 b1 = CallbackLocalizedString(b);
6287 }
6288
6289 for (int k = 1; k < 3; k++)
6290 {
6291 c = __direction(k);
6292 c1 = CallbackLocalizedString(c);
6293
6294 for (int m = 1; m < 14; m++)
6295 {
6296 if (m == 10)
6297 {
6298 xx = "";
6299 xx1 = "";
6300 }
6301 else if (m == 12)
6302 {
6303 String zz = __n_distance(m);
6304 String zz1 = CallbackLocalizedString(zz);
6305 xx = zz.replace("%i", "3");
6306 xx1 = zz1.replace("%i", "3");
6307 }
6308 else
6309 {
6310 xx = __n_distance(m);
6311 xx1 = CallbackLocalizedString(xx);
6312 }
6313
6314 for (int o = 1; o < 9; o++)
6315 {
6316 if (o == 2)
6317 {
6318 // leave out "exit"
6319 break;
6320 }
6321
6322 if (o == 1)
6323 {
6324 yy = __navigation_item_destination(o);
6325 yy1 = "";
6326 }
6327 else if (o == 4)
6328 {
6329 String zz;
6330 String zz1;
6331 zz = __navigation_item_destination(o);
6332 zz1 = CallbackLocalizedString(zz);
6333 yy = String.format(zz, " ", "somestreet", " ", "A23");
6334 yy1 = String.format(zz1, " ", "blablastrasse", " ", "A23");
6335 }
6336 else if ((o == 5) || (o == 6) || (o == 7))
6337 {
6338 String zz;
6339 String zz1;
6340 zz = __navigation_item_destination(o);
6341 zz1 = CallbackLocalizedString(zz);
6342 try
6343 {
6344 zz = zz.substring(0, zz.lastIndexOf("|"));
6345 }
6346 catch (Exception e)
6347 {
6348
6349 }
6350 try
6351 {
6352 zz1 = zz1.substring(0, zz1.lastIndexOf("|"));
6353 }
6354 catch (Exception e)
6355 {
6356
6357 }
6358 yy = String.format(zz, " ", "somestreet", " ", "A23");
6359 yy1 = String.format(zz1, " ", "blablastrasse", " ", "A23");
6360 }
6361 else if (o == 8)
6362 {
6363 String zz;
6364 String zz1;
6365 zz = __navigation_item_destination(o);
6366 zz1 = CallbackLocalizedString(zz);
6367 yy = String.format(zz, " ", "A23");
6368 yy1 = String.format(zz1, " ", "A23");
6369 }
6370 else
6371 {
6372 yy = __navigation_item_destination(o);
6373 yy1 = " " + CallbackLocalizedString(yy);
6374 yy = " " + yy;
6375 }
6376
6377 // apply parts
6378 d = String.format(a, b, c, xx, yy);
6379 d1 = String.format(a1, b1, c1, xx1, yy1);
6380 try
6381 {
6382 d = String.format(d, 3, 4, 5);
6383 }
6384 catch (Exception e)
6385 {
6386
6387 }
6388 try
6389 {
6390 d1 = String.format(d1, 3, 4, 5);
6391 }
6392 catch (Exception e)
6393 {
6394
6395 }
6396 NavitGraphics.NavitMsgTv2_.append(d + "\n");
6397 NavitGraphics.NavitMsgTv2_.append(d1 + "\n");
6398 System.out.println(d);
6399 System.out.println(d1);
6400 }
6401 }
6402 }
6403 }
6404 //
6405 a = "then turn %1$s%2$s %3$s%4$s";
6406 a1 = CallbackLocalizedString(a);
6407 xx = null;
6408 xx1 = null;
6409 yy = null;
6410 yy1 = null;
6411 for (j = 1; j < 5; j++)
6412 {
6413 if (j == 1)
6414 {
6415 b = __strength(j);
6416 b1 = "";
6417 }
6418 else
6419 {
6420 b = __strength(j);
6421 b1 = CallbackLocalizedString(b);
6422 }
6423
6424 for (int k = 1; k < 3; k++)
6425 {
6426 c = __direction(k);
6427 c1 = CallbackLocalizedString(c);
6428
6429 for (int m = 1; m < 14; m++)
6430 {
6431 if (m == 10)
6432 {
6433 xx = "";
6434 xx1 = "";
6435 }
6436 else if (m == 12)
6437 {
6438 String zz = __n_distance(m);
6439 String zz1 = CallbackLocalizedString(zz);
6440 xx = zz.replace("%i", "3");
6441 xx1 = zz1.replace("%i", "3");
6442 }
6443 else
6444 {
6445 xx = __n_distance(m);
6446 xx1 = CallbackLocalizedString(xx);
6447 }
6448
6449 for (int o = 1; o < 9; o++)
6450 {
6451 if (o == 2)
6452 {
6453 // leave out "exit"
6454 break;
6455 }
6456
6457 if (o == 1)
6458 {
6459 yy = __navigation_item_destination(o);
6460 yy1 = "";
6461 }
6462 else if (o == 4)
6463 {
6464 String zz;
6465 String zz1;
6466 zz = __navigation_item_destination(o);
6467 zz1 = CallbackLocalizedString(zz);
6468 yy = String.format(zz, " ", "somestreet", " ", "A23");
6469 yy1 = String.format(zz1, " ", "blablastrasse", " ", "A23");
6470 }
6471 else if ((o == 5) || (o == 6) || (o == 7))
6472 {
6473 String zz;
6474 String zz1;
6475 zz = __navigation_item_destination(o);
6476 zz1 = CallbackLocalizedString(zz);
6477 try
6478 {
6479 zz = zz.substring(0, zz.lastIndexOf("|"));
6480 }
6481 catch (Exception e)
6482 {
6483
6484 }
6485 try
6486 {
6487 zz1 = zz1.substring(0, zz1.lastIndexOf("|"));
6488 }
6489 catch (Exception e)
6490 {
6491
6492 }
6493 yy = String.format(zz, " ", "somestreet", " ", "A23");
6494 yy1 = String.format(zz1, " ", "blablastrasse", " ", "A23");
6495 }
6496 else if (o == 8)
6497 {
6498 String zz;
6499 String zz1;
6500 zz = __navigation_item_destination(o);
6501 zz1 = CallbackLocalizedString(zz);
6502 yy = String.format(zz, " ", "A23");
6503 yy1 = String.format(zz1, " ", "A23");
6504 }
6505 else
6506 {
6507 yy = __navigation_item_destination(o);
6508 yy1 = " " + CallbackLocalizedString(yy);
6509 yy = " " + yy;
6510 }
6511
6512 // apply parts
6513 d = String.format(a, b, c, xx, yy);
6514 d1 = String.format(a1, b1, c1, xx1, yy1);
6515 try
6516 {
6517 d = String.format(d, 3, 4, 5);
6518 }
6519 catch (Exception e)
6520 {
6521
6522 }
6523 try
6524 {
6525 d1 = String.format(d1, 3, 4, 5);
6526 }
6527 catch (Exception e)
6528 {
6529
6530 }
6531 NavitGraphics.NavitMsgTv2_.append(d + "\n");
6532 NavitGraphics.NavitMsgTv2_.append(d1 + "\n");
6533 System.out.println(d);
6534 System.out.println(d1);
6535 }
6536 }
6537 }
6538 }
6539 //
6540 //
6541 //
6542
6543 /*
6544 * speech commands:
6545 * ================
6546 *
6547 *
6548 * When possible, please turn around
6549 * Enter the roundabout soon
6550 * then you have reached your destination.
6551 *
6552 * In %s, enter the roundabout (get_distance(is_length=1))
6553 * Follow the road for the next %s (get_distance(is_length=1))
6554 *
6555 * Leave the roundabout at the %s (get_exit_count_str)
6556 * then leave the roundabout at the %s (get_exit_count_str)
6557 *
6558 * Take the %1$s road to the %2$s (get_count_str(),direction)
6559 * then take the %1$s road to the %2$s (get_count_str(),direction)
6560 *
6561 * Turn %1$s%2$s %3$s%4$s (strength,direction,distance,navigation_item_destination(" "))
6562 * then turn %1$s%2$s %3$s%4$s (strength,direction,distance,navigation_item_destination(" "))
6563 *
6564 * You have reached your destination %s (distance)
6565 *
6566 *
6567 *
6568 * distance:
6569 * ""
6570 * soon
6571 * get_distance(is_length=0)
6572 * after %i roads
6573 * now
6574 *
6575 *
6576 * direction:
6577 * left
6578 * right
6579 *
6580 * strength:
6581 * ""
6582 * slight
6583 * hard
6584 * really hard
6585 *
6586 * navigation_item_destination:
6587 * ============================
6588 * ""
6589 * (prefix)exit
6590 * (prefix)into the ramp
6591 * (prefix)into the street (streetname)(sep)(systematic streetname)
6592 * (prefix)into the (streetname)(sep)(systematic streetname) |male form %s%s%s
6593 * (prefix)into the (streetname)(sep)(systematic streetname) |female form %s%s%s
6594 * (prefix)into the (streetname)(sep)(systematic streetname) |neutral form %s%s%s
6595 * (prefix)into the (systematic streetname) %s
6596 *
6597 *
6598 *
6599 * get_count_str:
6600 * ==============
6601 * first
6602 * second
6603 * fifth
6604 *
6605 *
6606 * get_exit_count_str:
6607 * ===================
6608 * first exit
6609 * second exit
6610 * fifth exit
6611 *
6612 *
6613 *
6614 * get_distance:
6615 * =============
6616 * %d m (is_length 1)
6617 * in %d m
6618 * %d feet (is_length 1)
6619 * in %d feet
6620 * %d meters (is_length 1)
6621 * in %d meters
6622 * %d.%d miles (is_length 1)
6623 * in %d.%d miles
6624 * %d.%d kilometers (is_length 1)
6625 * in %d.%d kilometers
6626 * one mile,%d miles (is_length 1)
6627 * in one mile,in %d miles
6628 * one kilometer,%d kilometers (is_length 1)
6629 * in one kilometer,in %d kilometers
6630 */
6631
6632 }
6633
6634 /**
6635 * generic message channel to C-code
6636 */
6637 public static native void CallbackMessageChannelReal(int i, String s);
6638
6639 public static native int GetThreadId();
6640
6641 public static void CallbackMessageChannel(int i, String s)
6642 {
6643 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
6644
6645 Navit.cwthr.CallbackMessageChannel(i, s);
6646
6647 // if (Navit.METHOD_DEBUG) Navit.my_func_name(2);
6648 }
6649
6650 /**
6651 * return search result from C-code
6652 */
6653 public void fillStringArray(String s)
6654 {
6655
6656 if (Navit.index_search_realtime)
6657 {
6658 NavitAddressSearchActivity.fillStringArrayNew(s);
6659 return;
6660 }
6661
6662 //Log.e("NavitGraphics", "**** fillStringArray s=" + s);
6663 // deactivate the spinner
6664 // --> no we want to spin ** Navit.NavitAddressSearchSpinnerActive = false;
6665
6666 if (s.equals("D:D"))
6667 {
6668 // ok its a dummy, just move the percent bar
6669 // Log.e("NavitGraphics", "**** fillStringArray s=" + s);
6670 }
6671 else
6672 {
6673 try
6674 {
6675 // we hope its a real result value
6676 Navit.Navit_Address_Result_Struct tmp_addr = new Navit_Address_Result_Struct();
6677 String[] tmp_s = s.split(":");
6678 tmp_addr.result_type = tmp_s[0];
6679 tmp_addr.item_id = tmp_s[1];
6680
6681 if (Navit.use_index_search)
6682 {
6683 tmp_addr.lat = Integer.parseInt(tmp_s[2]);
6684 tmp_addr.lon = Integer.parseInt(tmp_s[3]);
6685 }
6686 else
6687 {
6688 tmp_addr.lat = Float.parseFloat(tmp_s[2]);
6689 tmp_addr.lon = Float.parseFloat(tmp_s[3]);
6690 }
6691 // the rest ist address
6692 tmp_addr.addr = s.substring(4 + tmp_s[0].length() + tmp_s[1].length() + tmp_s[2].length() + tmp_s[3].length(), s.length());
6693
6694 // String hash_id = tmp_addr.result_type + ":" + tmp_addr.lat + ":" + tmp_addr.lon + ":" + tmp_addr.addr;
6695 String hash_id = tmp_addr.result_type + ":" + tmp_addr.addr;
6696 //System.out.println("hash_id=" + hash_id);
6697 if ((!Navit.search_hide_duplicates) || (!Navit.Navit_Address_Result_double_index.contains(hash_id)))
6698 {
6699 Navit.NavitAddressResultList_foundItems.add(tmp_addr);
6700 Navit.Navit_Address_Result_double_index.add(hash_id);
6701 //System.out.println("*add*=" + hash_id);
6702
6703 // System.out.println("search_result:N:" + Navit.NavitAddressResultList_foundItems.size() + ":" + tmp_addr.result_type + ":" + tmp_addr.lat + ":" + tmp_addr.lon + ":" + tmp_addr.addr);
6704
6705 if (tmp_addr.result_type.equals("TWN"))
6706 {
6707 Navit.search_results_towns++;
6708 }
6709 else if (tmp_addr.result_type.equals("STR"))
6710 {
6711 Navit.search_results_streets++;
6712 }
6713 else if (tmp_addr.result_type.equals("SHN"))
6714 {
6715 Navit.search_results_streets_hn++;
6716 }
6717 else if (tmp_addr.result_type.equals("POI"))
6718 {
6719 Navit.search_results_poi++;
6720 }
6721
6722 Navit.NavitSearchresultBar_title = Navit.get_text("loading search results");
6723 Navit.NavitSearchresultBar_text = Navit.get_text("towns") + ":" + Navit.search_results_towns + " " + Navit.get_text("Streets") + ":" + Navit.search_results_streets + "/" + Navit.search_results_streets_hn + " " + Navit.get_text("POI") + ":" + Navit.search_results_poi;
6724
6725 // make the dialog move its bar ...
6726 // Bundle b = new Bundle();
6727 // b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
6728 // b.putInt("max", Navit.ADDRESS_RESULTS_DIALOG_MAX);
6729 // b.putInt("cur", Navit.NavitAddressResultList_foundItems.size() % (Navit.ADDRESS_RESULTS_DIALOG_MAX + 1));
6730 // b.putString("title", Navit.get_text("loading search results")); //TRANS
6731 // b.putString("text", Navit.get_text("towns") + ":" + Navit.search_results_towns + " " + Navit.get_text("Streets") + ":" + Navit.search_results_streets + "/" + Navit.search_results_streets_hn);
6732 // Navit.msg_to_msg_handler(b, 10);
6733 }
6734 //else
6735 //{
6736 // //System.out.println("double " + tmp_addr.addr);
6737 //}
6738 }
6739 catch (Exception e)
6740 {
6741
6742 }
6743 }
6744
6745 // always move the bar, so that the user knows app is still doing something (and has not crashed!)
6746 // Navit.NavitSearchresultBarIndex++;
6747 // if (Navit.NavitSearchresultBarIndex > Navit.ADDRESS_RESULTS_DIALOG_MAX)
6748 // {
6749 // Navit.NavitSearchresultBarIndex = 0;
6750 // }
6751 // make the dialog move its bar ...
6752 // Bundle b = new Bundle();
6753 // b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
6754 // b.putInt("max", Navit.ADDRESS_RESULTS_DIALOG_MAX);
6755 // b.putInt("cur", Navit.NavitSearchresultBarIndex);
6756 // b.putString("title", Navit.get_text("loading search results")); //TRANS
6757 // b.putString("text", Navit.get_text("towns") + ":" + Navit.search_results_towns + " " + Navit.get_text("Streets") + ":" + Navit.search_results_streets + "/" + Navit.search_results_streets_hn);
6758 // Navit.msg_to_msg_handler(b, 10);
6759 }
6760
6761 public void SearchResultList(int i, int partial_match, String text, String t_town, String t_hn, int flags, String country_iso2, String search_latlon, int search_radius)
6762 {
6763 CallbackSearchResultList(i, partial_match, text, t_town, t_hn, flags, country_iso2, search_latlon, search_radius);
6764 }
6765
6766 public native void CallbackSearchResultList(int i, int partial_match, String s, String s_town, String s_hn, int flags, String country_iso2, String search_latlon, int search_radius);
6767
6768 /**
6769 * get localized string
6770 */
6771 public static native String CallbackLocalizedString(String s);
6772
6773 //
6774 //
6775 //
6776 // get route_status value from C-lib
6777 /*
6778 *
6779 * 0 -> 1 -> 13 -> 5 -> 17 -> 5 ... 33 -> 5 -> 33 -> 5 ...
6780 *
6781 * route_status_no_destination=0, # 0 --> no dest. set
6782 * route_status_destination_set=1, # 1
6783 * route_status_not_found=1|2, # 3 --> no route to destination found / route blocked
6784 * route_status_building_path=1|4, # 5
6785 * route_status_building_graph=1|4|8, # 13
6786 * route_status_path_done_new=1|16, # 17 --> route found
6787 * route_status_path_done_incremental=1|32, # 33 --> route found
6788 */
6789 // now we get the value pushed from C automatically
6790 public static int CallbackDestinationValid2()
6791 {
6792 return NavitGraphics.navit_route_status;
6793 }
6794
6795 // call C-function to get value --> not used anymore now!!
6796 public static native int CallbackDestinationValid();
6797
6798 public static Handler callback_handler = Navit.callback_handler_55;
6799 public static Handler callback_handler_s = Navit.callback_handler_55;
6800
6801 //
6802 //
6803 //
6804
6805 // i=1 -> pixel a,b (x,y) -> geo string "lat(float)#lng(float)"
6806 // i=2 -> geo a,b (lat,lng) -> pixel string "x(int)#y(int)"
6807 public static native String CallbackGeoCalc(int i, float a, float b);
6808
6809 public static native String[] GetRoadBookItems(int result_id);
6810
6811 @SuppressLint("NewApi")
6812 public static void send_generic_text(int id, String text)
6813 {
6814 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
6815
6816 // System.out.println("NavitOSDJava:" + id + ":" + text);
6817
6818 if (id == 1)
6819 {
6820 // speech textblock
6821 if (NavitGraphics.NavitMsgTv2_.getVisibility() == View.VISIBLE)
6822 {
6823 NavitMsgTv2_.append("TEXT:" + text);
6824 }
6825 }
6826 else if (id == 3)
6827 {
6828 // destination:
6829
6830 //System.out.println("lane_destination=" + text);
6831
6832 Navit.lane_destination = text;
6833 // NavitOSDJava.draw_real_wrapper(false, true);
6834 }
6835 else if (id == 4) // next turn
6836 {
6837
6838 // example: "175|180|x250" // "x" mean this is the road we should drive on next, others are angles
6839 // 0 -> straight
6840 // less than 0 (minus) -> right
6841 // more than 0 (plus ) -> left
6842
6843 //System.out.println("lane_choices0=" + text);
6844
6845 Navit.lane_choices = text;
6846 }
6847 else if (id == 5) // next next turn
6848 {
6849 //System.out.println("lane_choices1=" + text);
6850 Navit.lane_choices1 = text;
6851 }
6852 else if (id == 6) // next next next turn
6853 {
6854 //System.out.println("lane_choices2=" + text);
6855 Navit.lane_choices2 = text;
6856 }
6857 else if (id == 8)
6858 {
6859 if (Navit.p.PREF_lane_assist)
6860 {
6861
6862 // lanes:
6863 //
6864 // none
6865 // through
6866 // left
6867 // right
6868 // slight_left
6869 // slight_right
6870 // sharp_left
6871 // sharp_right
6872 // mergeto_left
6873 // mergeto_right
6874 //
6875 // ... others are "unknown" for now
6876 //
6877
6878 // text = "street dir:num of lanes:forward lanes:values|values"
6879 // text = "1:3:2:none|through;left"
6880
6881 //System.out.println("LANES0=" + text);
6882
6883 try
6884 {
6885 Navit.lanes_num = Integer.parseInt(text.split(":", 4)[1]);
6886 }
6887 catch (Exception e)
6888 {
6889 Navit.lanes_num = 0;
6890 }
6891
6892 try
6893 {
6894 Navit.lanes_num_forward = Integer.parseInt(text.split(":", 4)[2]);
6895 }
6896 catch (Exception e)
6897 {
6898 Navit.lanes_num_forward = 0;
6899 }
6900
6901 try
6902 {
6903 Navit.lanes_text = text.split(":", 4)[3];
6904 }
6905 catch (Exception e)
6906 {
6907 Navit.lanes_text = "";
6908 }
6909 }
6910 }
6911 else if (id == 9)
6912 {
6913 if (Navit.p.PREF_lane_assist)
6914 {
6915
6916 // next lanes:
6917 //
6918 // none
6919 // through
6920 // left
6921 // right
6922 // slight_left
6923 // slight_right
6924 // sharp_left
6925 // sharp_right
6926 // mergeto_left
6927 // mergeto_right
6928 //
6929 // ... others are "unknown" for now
6930 //
6931
6932 // text = "street dir:num of lanes:forward lanes:values|values"
6933 // text = "1:3:2:none|through;left"
6934
6935 //System.out.println("LANES1=" + text);
6936
6937 try
6938 {
6939 Navit.lanes_num1 = Integer.parseInt(text.split(":", 4)[1]);
6940 }
6941 catch (Exception e)
6942 {
6943 Navit.lanes_num1 = 0;
6944 }
6945
6946 try
6947 {
6948 Navit.lanes_num_forward1 = Integer.parseInt(text.split(":", 4)[2]);
6949 }
6950 catch (Exception e)
6951 {
6952 Navit.lanes_num_forward1 = 0;
6953 }
6954
6955 try
6956 {
6957 Navit.lanes_text1 = text.split(":", 4)[3];
6958 }
6959 catch (Exception e)
6960 {
6961 Navit.lanes_text1 = "";
6962 }
6963
6964 // this is the last element -> so draw only HERE !!
6965 //System.out.println("xx paint 3 xx");
6966 // NavitOSDJava.draw_real_wrapper(true, false);
6967 ZANaviLinearLayout.redraw_OSD(9);
6968 }
6969 }
6970 else if (id == 13) // current segment length (in meters)
6971 {
6972 // System.out.println("seg_len=" + text);
6973
6974 Navit.seg_len = Integer.parseInt(text);
6975 }
6976 else if (id == 20) // speech commads debug info
6977 {
6978
6979 }
6980 else if (id == 21) // earth radius
6981 {
6982 Navit.__EARTH_RADIUS__ = Double.parseDouble(text);
6983 System.out.println("__EARTH_RADIUS__=" + Navit.__EARTH_RADIUS__);
6984 }
6985 else if (id == 22) // map accuarcy factor
6986 {
6987 Navit.__GEO_ACCURACY_FACTOR__ = Double.parseDouble(text);
6988 System.out.println("__GEO_ACCURACY_FACTOR__=" + Navit.__GEO_ACCURACY_FACTOR__);
6989 }
6990 else if (id == 31)
6991 {
6992 // we found a mapfile thats too old, need to update
6993 try
6994 {
6995 String text2 = text.replaceAll("[\n\r]", "");
6996 // System.out.println("MAPFILE TOO OLD:x:<map version>:<min.needed version>:<map filename>" + text2);
6997 String mapfilename = text2.split(":", 3)[2];
6998 File f = new File(mapfilename);
6999 String mapfilename_without_path = f.getName();
7000 int have_version = Integer.parseInt(text2.split(":", 3)[0]);
7001 int need_version = Integer.parseInt(text2.split(":", 3)[1]);
7002 System.out.println("MAPFILE TOO OLD:y:<map version>:<min.needed version>:<map filename>" + have_version + ":" + need_version + ":" + mapfilename_without_path);
7003 String cat_mapfilename = NavitMapDownloader.is_in_cat_file_disk_name(mapfilename_without_path);
7004 System.out.println("MAPFILE TOO OLD:y:<map version>:<min.needed version>:<map filename>" + have_version + ":" + need_version + ":" + cat_mapfilename);
7005
7006 Navit.Navit_maps_too_old = true;
7007
7008 if (Navit.have_maps_installed())
7009 {
7010 try
7011 {
7012 TextView no_maps_text = (TextView) Navit.Global_Navit_Object.findViewById(R.id.no_maps_text);
7013 no_maps_text.setText("\n\n\n" + Navit.get_text("Some Maps are too old!") + "\n" + Navit.get_text("Please update your maps") + "\n\n");
7014
7015 NavitGraphics.no_maps_container.setVisibility(View.VISIBLE);
7016 try
7017 {
7018 NavitGraphics.no_maps_container.setActivated(true);
7019 }
7020 catch (NoSuchMethodError e)
7021 {
7022 }
7023 NavitGraphics.no_maps_container.bringToFront();
7024 }
7025 catch (Exception e)
7026 {
7027 e.printStackTrace();
7028 }
7029 }
7030 }
7031 catch (Exception e)
7032 {
7033 }
7034 }
7035
7036 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7037 }
7038
7039 public static void return_generic_int(int id, int i)
7040 {
7041 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7042
7043 try
7044 {
7045 Message msg1 = new Message();
7046 Bundle b1 = new Bundle();
7047 b1.putInt("Callback", 98001);
7048 b1.putInt("id", id);
7049 b1.putInt("i", i);
7050 msg1.setData(b1);
7051 NavitGraphics.callback_handler_s.sendMessage(msg1);
7052 }
7053 catch (Exception e)
7054 {
7055 }
7056
7057 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7058 }
7059
7060 public static void set_vehicle_values(int x, int y, int angle, int speed)
7061 {
7062 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7063
7064 //System.out.println("DO__DRAW:set_vehicle_values:enter");
7065 // SYN // synchronized (synch_drawing_for_map)
7066 {
7067 // stop any smooth drawing/moving first!
7068 //System.out.println("set vehicle pos...");
7069 //System.out.println("DO__DRAW:set_vehicle_values:set");
7070 //--> don't set here // Global_SmoothDrawing_stop = true;
7071 last_vehicle_position_timestamp = System.currentTimeMillis();
7072
7073 //System.out.println("vehiclepos:1:x=" + x + " y=" + y + " Global_dpi_factor=" + NavitGraphics.Global_dpi_factor);
7074 Navit.NG__vehicle.vehicle_speed = speed;
7075 Navit.NG__vehicle.vehicle_pos_x = (int) ((float) x / NavitGraphics.Global_dpi_factor);
7076 Navit.NG__vehicle.vehicle_pos_y = (int) ((float) y / NavitGraphics.Global_dpi_factor);
7077 //System.out.println("vehiclepos:2:x=" + Navit.NG__vehicle.vehicle_pos_x + " y=" + Navit.NG__vehicle.vehicle_pos_y);
7078 Navit.NG__vehicle.vehicle_direction = angle;
7079 //System.out.println("DO__DRAW:set_vehicle_values:end");
7080 }
7081
7082 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7083 }
7084
7085 public static float ddx_last = 0;
7086 public static float ddy_last = 0;
7087 public static float dda_last = 0;
7088 public static float ddx = 0;
7089 public static float ddz = 0;
7090 public static float ddy = 0;
7091 public static float dda = 0f;
7092 public static long last_vehicle_position_timestamp = 0L;
7093 public static long Vehicle_updates_interval = 1000; // normal android phone gives position every 1000ms (=1 sec)
7094 public static int Vehicle_smooth_moves_count = 3; // how many intermediate moves do we want to draw
7095 public static int Vehicle_smooth_move_delay = 180;
7096 public static int Vehicle_smooth_move_delay_real_used = Vehicle_smooth_move_delay;
7097 public static int Vehicle_delay_real_gps_position = 650; // normal value for smooth delay = 450
7098 public static final int max_turn_angle = 190;
7099
7100 static class SmoothDriveThread_t_A extends Thread
7101 {
7102 int cur_count = 0;
7103 int xxx2 = 0;
7104
7105 public void run()
7106 {
7107 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:SmoothDriveThread_t_A:-- start --");
7108
7109 if (DEBUG_SMOOTH_DRIVING)
7110 {
7111 xxx2 = (int) (Math.random() * 1000f);
7112 }
7113
7114 smooth_driving_ts002a = System.currentTimeMillis();
7115
7116 //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);
7117 //draw_canvas_screen2.rotate(Global_Map_Rotationangle, Navit.NG__vehicle.vehicle_pos_x, Navit.NG__vehicle.vehicle_pos_y);
7118
7119 // ------ make vehicle smooth zoom with vehicle as center point --------------------
7120 // ------ because center point may be any point on screen from last finger movement!
7121 //System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:sszz:tnc x=" + Navit.NG__map_main.touch_now_center.x + " y=" + Navit.NG__map_main.touch_now_center.y);
7122 //System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:sszz:vhp x=" + Navit.NG__vehicle.vehicle_pos_x + " y=" + Navit.NG__vehicle.vehicle_pos_y);
7123 //System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:sszz:gmt x=" + Global_Map_TransX + " y=" + Global_Map_TransY);
7124
7125 if (Navit.GFX_OVERSPILL)
7126 {
7127 Navit.NG__map_main.touch_now_center.x = Navit.NG__vehicle.vehicle_pos_x - NavitGraphics.mCanvasWidth_overspill;
7128 Navit.NG__map_main.touch_now_center.y = Navit.NG__vehicle.vehicle_pos_y - NavitGraphics.mCanvasHeight_overspill;
7129 }
7130 else
7131 {
7132 Navit.NG__map_main.touch_now_center.x = Navit.NG__vehicle.vehicle_pos_x;
7133 Navit.NG__map_main.touch_now_center.y = Navit.NG__vehicle.vehicle_pos_y;
7134 }
7135
7136 // ------ make vehicle smooth zoom with vehicle as center point --------------------
7137
7138 float Global_Map_Zoomfactor_start = Global_Map_Zoomfactor;
7139
7140 for (cur_count = 0; cur_count < Vehicle_smooth_moves_count; cur_count++)
7141 {
7142 if (Global_SmoothDrawing_stop == false)
7143 {
7144 // dont delay the first smooth move!
7145 if (cur_count != 0)
7146 {
7147 try
7148 {
7149 Thread.sleep(Vehicle_smooth_move_delay_real_used);
7150 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:a=" + Vehicle_smooth_move_delay_real_used);
7151 }
7152 catch (InterruptedException e)
7153 {
7154 // e.printStackTrace();
7155 }
7156 }
7157
7158 }
7159
7160 if (Global_SmoothDrawing_stop == false)
7161 {
7162 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:smooth move #" + (cur_count + 1) + " delay=" + Vehicle_smooth_move_delay);
7163 //if (cur_count == (Vehicle_smooth_moves_count - 1))
7164 //{
7165 // Global_Map_TransX = Global_Map_TransX - ddx_last;
7166 // Global_Map_TransY = Global_Map_TransY - ddy_last;
7167 // Global_Map_Rotationangle = Global_Map_Rotationangle - dda_last;
7168 //}
7169 //else
7170 //{
7171 Global_Map_TransX = Global_Map_TransX - ddx;
7172 Global_Map_TransY = Global_Map_TransY - ddy;
7173 Global_Map_Rotationangle = Global_Map_Rotationangle - dda;
7174
7175 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:globalzoom factor o=" + Global_Map_Zoomfactor + " ddz=" + ddz);
7176 if (ddz != 0)
7177 {
7178 // ******OLD******* Global_Map_Zoomfactor = Global_Map_Zoomfactor * (1 + (cur_count + 1) * ddz) / (1 + cur_count * ddz);
7179 //System.out.println("DEBUG_SMOOTH_DRIVING:globalzoom factor 1=" + Global_Map_Zoomfactor + " ddz=" + ddz);
7180 //System.out.println("DEBUG_SMOOTH_DRIVING:globalzoom factor s=" + Global_Map_Zoomfactor_start);
7181 Global_Map_Zoomfactor = Global_Map_Zoomfactor + (ddz * Global_Map_Zoomfactor_start);
7182 //System.out.println("DEBUG_SMOOTH_DRIVING:globalzoom factor 2=" + Global_Map_Zoomfactor + " ddz=" + ddz);
7183 }
7184
7185 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:globalzoom factor n=" + Global_Map_Zoomfactor);
7186 //}
7187 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:this #" + (cur_count + 1) + ":ddx=" + Global_Map_TransX + " ddy=" + Global_Map_TransY + " dda=" + Global_Map_Rotationangle);
7188
7189 if (cur_count == 0)
7190 {
7191 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:c=" + (System.currentTimeMillis() - smooth_driving_ts003));
7192 if (Math.abs(System.currentTimeMillis() - smooth_driving_ts001 - Vehicle_updates_interval) < 100)
7193 {
7194 Vehicle_updates_interval = System.currentTimeMillis() - smooth_driving_ts001;
7195 }
7196 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:g=" + Vehicle_updates_interval);
7197 smooth_driving_ts001 = System.currentTimeMillis();
7198 Vehicle_smooth_move_delay_real_used = (int) (Vehicle_updates_interval / (Vehicle_smooth_moves_count + 1));
7199 }
7200 //else if (cur_count == (Vehicle_smooth_moves_count - 1))
7201 //{
7202 //}
7203 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:" + (cur_count + 1));
7204 // System.out.println("DO__DRAW:Java:postInvalidate 005");
7205 // SYN //
7206 Navit.NG__map_main.view.postInvalidate();
7207 // map_postInvalidate();
7208
7209 //SurfaceView2 vw = (SurfaceView2) Navit.NG__map_main.view;
7210 //vw.paint_me();
7211 }
7212 }
7213 smooth_driving_ts002 = System.currentTimeMillis();
7214 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:--set_vehicle_values_delta-- SLEEP - END");
7215 }
7216 }
7217
7218 static SmoothDriveThread_t_B STT_B = null;
7219
7220 static SmoothDriveThread_t_B[] STT_B_list = new SmoothDriveThread_t_B[10];
7221 static int STT_B_list_curr = 0;
7222 static boolean[] STT_B_list_valid = new boolean[10];
7223
7224 static SmoothDriveThread_t_A STT_A = null;
7225
7226 static Thread UNUSED__SmoothDriveThread_A = new Thread(new Runnable()
7227 {
7228 int cur_count = 0;
7229 int xxx2 = 0;
7230
7231 public void run()
7232 {
7233 if (DEBUG_SMOOTH_DRIVING)
7234 {
7235 xxx2 = (int) (Math.random() * 1000f);
7236 }
7237
7238 smooth_driving_ts002a = System.currentTimeMillis();
7239
7240 for (cur_count = 0; cur_count < Vehicle_smooth_moves_count; cur_count++)
7241 {
7242 if (Global_SmoothDrawing_stop == false)
7243 {
7244 // dont delay the first smooth move!
7245 if (cur_count != 0)
7246 {
7247 try
7248 {
7249 Thread.sleep(Vehicle_smooth_move_delay_real_used);
7250 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:a=" + Vehicle_smooth_move_delay_real_used);
7251 }
7252 catch (InterruptedException e)
7253 {
7254 // e.printStackTrace();
7255 }
7256 }
7257
7258 }
7259
7260 if (Global_SmoothDrawing_stop == false)
7261 {
7262 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:smooth move #" + (cur_count + 1) + " delay=" + Vehicle_smooth_move_delay);
7263 //if (cur_count == (Vehicle_smooth_moves_count - 1))
7264 //{
7265 // Global_Map_TransX = Global_Map_TransX - ddx_last;
7266 // Global_Map_TransY = Global_Map_TransY - ddy_last;
7267 // Global_Map_Rotationangle = Global_Map_Rotationangle - dda_last;
7268 //}
7269 //else
7270 //{
7271 Global_Map_TransX = Global_Map_TransX - ddx;
7272 Global_Map_TransY = Global_Map_TransY - ddy;
7273 Global_Map_Rotationangle = Global_Map_Rotationangle - dda;
7274 //}
7275 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:this #" + (cur_count + 1) + ":ddx=" + Global_Map_TransX + " ddy=" + Global_Map_TransY + " dda=" + Global_Map_Rotationangle);
7276
7277 if (cur_count == 0)
7278 {
7279 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:c=" + (System.currentTimeMillis() - smooth_driving_ts003));
7280 if (Math.abs(System.currentTimeMillis() - smooth_driving_ts001 - Vehicle_updates_interval) < 100)
7281 {
7282 Vehicle_updates_interval = System.currentTimeMillis() - smooth_driving_ts001;
7283 }
7284 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:g=" + Vehicle_updates_interval);
7285 smooth_driving_ts001 = System.currentTimeMillis();
7286 Vehicle_smooth_move_delay_real_used = (int) (Vehicle_updates_interval / (Vehicle_smooth_moves_count + 1));
7287 }
7288 //else if (cur_count == (Vehicle_smooth_moves_count - 1))
7289 //{
7290 //}
7291 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:" + (cur_count + 1));
7292 // System.out.println("DO__DRAW:Java:postInvalidate 006");
7293 // SYN // Navit.NG__map_main.view.postInvalidate();
7294 //SurfaceView2 vw = (SurfaceView2) Navit.NG__map_main.view;
7295 //vw.paint_me();
7296 }
7297 }
7298 smooth_driving_ts002 = System.currentTimeMillis();
7299 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:--set_vehicle_values_delta-- SLEEP - END");
7300 }
7301 });
7302
7303 static class SmoothDriveThread_t_B extends Thread
7304 {
7305 boolean is_thread_cancel = false;
7306
7307 public void cancel_previous()
7308 {
7309 is_thread_cancel = true;
7310 // System.out.println("DO__DRAW:Java:cancel_previous");
7311 }
7312
7313 public void reset_cancel_previous()
7314 {
7315 is_thread_cancel = false;
7316 // System.out.println("DO__DRAW:Java:reset_cancel_previous");
7317 }
7318
7319 public void run()
7320 {
7321 is_thread_cancel = false;
7322
7323 // System.out.println("DO__DRAW:Java:refresh map -> run");
7324 // try
7325 // {
7326 // Thread.sleep(Vehicle_delay_real_gps_position);
7327 // }
7328 // catch (InterruptedException e)
7329 // {
7330 // // e.printStackTrace();
7331 // }
7332 //System.out.println("DO__DRAW:Java:refresh map -> delay ready");
7333
7334 if (!Global_onTouch_fingerdown)
7335 {
7336 if (is_thread_cancel)
7337 {
7338 if (DEBUG_SMOOTH_DRIVING) System.out.println("DO__DRAW:Java:is_thread_cancel 000");
7339 return;
7340 }
7341
7342 smooth_driving_tmptmp = -(System.currentTimeMillis() - (smooth_driving_ts002a + (Vehicle_smooth_moves_count + 0) * Vehicle_smooth_move_delay_real_used));
7343 if (smooth_driving_tmptmp <= 0)
7344 {
7345 smooth_driving_tmptmp = 0;
7346 }
7347 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:b pre=" + smooth_driving_tmptmp);
7348 try
7349 {
7350 if (smooth_driving_tmptmp > 0)
7351 {
7352 // System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:b corr=" + (smooth_driving_tmptmp));
7353 Thread.sleep(smooth_driving_tmptmp);
7354
7355 if (is_thread_cancel)
7356 {
7357 // System.out.println("DO__DRAW:Java:is_thread_cancel 001");
7358 return;
7359 }
7360
7361 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:b corr=" + (smooth_driving_tmptmp));
7362 }
7363 else
7364 {
7365 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:b corr=NO DELAY");
7366 }
7367 }
7368 catch (InterruptedException e)
7369 {
7370 if (is_thread_cancel)
7371 {
7372 // System.out.println("DO__DRAW:Java:is_thread_cancel 002");
7373 return;
7374 }
7375 }
7376
7377 // if we are in onDraw right now, give some extra little delay
7378 // this is not 100% super good, but it will work :-)
7379 // do not make a while or for loop! keep it hardcoded for speed!!
7380 if (Global_Map_in_onDraw == true)
7381 {
7382 try
7383 {
7384 // System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> extra delay");
7385 Thread.sleep(8);
7386 }
7387 catch (InterruptedException e)
7388 {
7389 // e.printStackTrace();
7390 }
7391 }
7392 if (Global_Map_in_onDraw == true)
7393 {
7394 try
7395 {
7396 // System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> extra delay");
7397 Thread.sleep(8);
7398 }
7399 catch (InterruptedException e)
7400 {
7401 // e.printStackTrace();
7402 }
7403 }
7404 if (Global_Map_in_onDraw == true)
7405 {
7406 try
7407 {
7408 // System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> extra delay");
7409 Thread.sleep(8);
7410 }
7411 catch (InterruptedException e)
7412 {
7413 // e.printStackTrace();
7414 }
7415 }
7416 if (Global_Map_in_onDraw == true)
7417 {
7418 try
7419 {
7420 // System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> extra delay");
7421 Thread.sleep(28);
7422 }
7423 catch (InterruptedException e)
7424 {
7425 // e.printStackTrace();
7426 }
7427 }
7428 if (Global_Map_in_onDraw == true)
7429 {
7430 try
7431 {
7432 // System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> extra delay");
7433 Thread.sleep(28);
7434 }
7435 catch (InterruptedException e)
7436 {
7437 // e.printStackTrace();
7438 }
7439 }
7440 if (Global_Map_in_onDraw == true)
7441 {
7442 try
7443 {
7444 // System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> extra delay");
7445 Thread.sleep(28);
7446 }
7447 catch (InterruptedException e)
7448 {
7449 // e.printStackTrace();
7450 }
7451 }
7452 if (Global_Map_in_onDraw == true)
7453 {
7454 try
7455 {
7456 // System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> extra delay");
7457 Thread.sleep(28);
7458 }
7459 catch (InterruptedException e)
7460 {
7461 // e.printStackTrace();
7462 }
7463 }
7464 if (Global_Map_in_onDraw == true)
7465 {
7466 try
7467 {
7468 //System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> extra delay");
7469 Thread.sleep(28);
7470 }
7471 catch (InterruptedException e)
7472 {
7473 // e.printStackTrace();
7474 }
7475 }
7476 // do not make a while or for loop! keep it hardcoded for speed!!
7477
7478 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> draw!");
7479 if (DEBUG_SMOOTH_DRIVING)
7480 {
7481 System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:b=" + (System.currentTimeMillis() - smooth_driving_ts002));
7482 System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:RR");
7483 }
7484
7485 if (is_thread_cancel)
7486 {
7487 // System.out.println("DO__DRAW:Java:is_thread_cancel 003");
7488 return;
7489 }
7490
7491 // System.out.println("DO__DRAW:Java:postInvalidate 001:y");
7492 // SYN // view_s.postInvalidate();
7493 if ((System.currentTimeMillis() - last_map_postInvalidate) < 150)
7494 {
7495 // too fast -> dont update
7496 // System.out.println("DEBUG_SMOOTH_DRIVING:too fast");
7497
7498 // if (!map_c_drawing)
7499 // {
7500 // copy_map_buffer();
7501 // draw_reset_factors = true;
7502 // }
7503 // smooth_driving_ts003 = System.currentTimeMillis();
7504 //
7505 // last_map_postInvalidate = System.currentTimeMillis();
7506 // view_s.postInvalidate();
7507 }
7508 else
7509 {
7510 //if (!map_c_drawing)
7511 //{
7512 copy_map_buffer();
7513 draw_reset_factors = true;
7514 //}
7515 smooth_driving_ts003 = System.currentTimeMillis();
7516
7517 last_map_postInvalidate = System.currentTimeMillis();
7518 view_s.postInvalidate();
7519 }
7520 //view_s.paint_me();
7521 // System.out.println("DO__DRAW:Java:refresh map -> draw ready");
7522 }
7523 }
7524 }
7525
7526 static Thread SmoothDriveThread_SmoothDriveThread_B = new Thread(new Runnable()
7527 {
7528 public void run()
7529 {
7530 //System.out.println("DO__DRAW:Java:refresh map -> run");
7531 // try
7532 // {
7533 // Thread.sleep(Vehicle_delay_real_gps_position);
7534 // }
7535 // catch (InterruptedException e)
7536 // {
7537 // // e.printStackTrace();
7538 // }
7539 //System.out.println("DO__DRAW:Java:refresh map -> delay ready");
7540
7541 if (!Global_onTouch_fingerdown)
7542 {
7543 smooth_driving_tmptmp = -(System.currentTimeMillis() - (smooth_driving_ts002a + (Vehicle_smooth_moves_count + 0) * Vehicle_smooth_move_delay_real_used));
7544 if (smooth_driving_tmptmp <= 0)
7545 {
7546 smooth_driving_tmptmp = 0;
7547 }
7548 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:b pre=" + smooth_driving_tmptmp);
7549 try
7550 {
7551 if (smooth_driving_tmptmp > 0)
7552 {
7553 Thread.sleep(smooth_driving_tmptmp);
7554 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:b corr=" + (smooth_driving_tmptmp));
7555 }
7556 else
7557 {
7558 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:b corr=NO DELAY");
7559 }
7560 }
7561 catch (InterruptedException e)
7562 {
7563 }
7564
7565 // if we are in onDraw right now, give some extra little delay
7566 // this is not 100% super good, but it will work :-)
7567 // do not make a while or for loop! keep it hardcoded for speed!!
7568 if (Global_Map_in_onDraw == true)
7569 {
7570 try
7571 {
7572 //System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> extra delay");
7573 Thread.sleep(8);
7574 }
7575 catch (InterruptedException e)
7576 {
7577 // e.printStackTrace();
7578 }
7579 }
7580 if (Global_Map_in_onDraw == true)
7581 {
7582 try
7583 {
7584 //System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> extra delay");
7585 Thread.sleep(8);
7586 }
7587 catch (InterruptedException e)
7588 {
7589 // e.printStackTrace();
7590 }
7591 }
7592 if (Global_Map_in_onDraw == true)
7593 {
7594 try
7595 {
7596 //System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> extra delay");
7597 Thread.sleep(8);
7598 }
7599 catch (InterruptedException e)
7600 {
7601 // e.printStackTrace();
7602 }
7603 }
7604 if (Global_Map_in_onDraw == true)
7605 {
7606 try
7607 {
7608 //System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> extra delay");
7609 Thread.sleep(8);
7610 }
7611 catch (InterruptedException e)
7612 {
7613 // e.printStackTrace();
7614 }
7615 }
7616 if (Global_Map_in_onDraw == true)
7617 {
7618 try
7619 {
7620 //System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> extra delay");
7621 Thread.sleep(8);
7622 }
7623 catch (InterruptedException e)
7624 {
7625 // e.printStackTrace();
7626 }
7627 }
7628 if (Global_Map_in_onDraw == true)
7629 {
7630 try
7631 {
7632 //System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> extra delay");
7633 Thread.sleep(8);
7634 }
7635 catch (InterruptedException e)
7636 {
7637 // e.printStackTrace();
7638 }
7639 }
7640 if (Global_Map_in_onDraw == true)
7641 {
7642 try
7643 {
7644 //System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> extra delay");
7645 Thread.sleep(8);
7646 }
7647 catch (InterruptedException e)
7648 {
7649 // e.printStackTrace();
7650 }
7651 }
7652 if (Global_Map_in_onDraw == true)
7653 {
7654 try
7655 {
7656 //System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> extra delay");
7657 Thread.sleep(8);
7658 }
7659 catch (InterruptedException e)
7660 {
7661 // e.printStackTrace();
7662 }
7663 }
7664 if (Global_Map_in_onDraw == true)
7665 {
7666 try
7667 {
7668 //System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> extra delay");
7669 Thread.sleep(8);
7670 }
7671 catch (InterruptedException e)
7672 {
7673 // e.printStackTrace();
7674 }
7675 }
7676 if (Global_Map_in_onDraw == true)
7677 {
7678 try
7679 {
7680 //System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> extra delay");
7681 Thread.sleep(8);
7682 }
7683 catch (InterruptedException e)
7684 {
7685 // e.printStackTrace();
7686 }
7687 }
7688 if (Global_Map_in_onDraw == true)
7689 {
7690 try
7691 {
7692 //System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> extra delay");
7693 Thread.sleep(8);
7694 }
7695 catch (InterruptedException e)
7696 {
7697 // e.printStackTrace();
7698 }
7699 }
7700 if (Global_Map_in_onDraw == true)
7701 {
7702 try
7703 {
7704 //System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> extra delay");
7705 Thread.sleep(8);
7706 }
7707 catch (InterruptedException e)
7708 {
7709 // e.printStackTrace();
7710 }
7711 }
7712 // do not make a while or for loop! keep it hardcoded for speed!!
7713
7714 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:refresh map -> draw!");
7715 copy_map_buffer();
7716 draw_reset_factors = true;
7717 if (DEBUG_SMOOTH_DRIVING)
7718 {
7719 System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:b=" + (System.currentTimeMillis() - smooth_driving_ts002));
7720 System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:RR");
7721 }
7722 smooth_driving_ts003 = System.currentTimeMillis();
7723 // System.out.println("DO__DRAW:Java:postInvalidate 002");
7724 // SYN // view_s.postInvalidate();
7725 //view_s.paint_me();
7726 //System.out.println("DO__DRAW:Java:refresh map -> draw ready");
7727 }
7728 }
7729 });
7730
7731 public static void set_vehicle_values_delta(int dx, int dy, int dangle2, int dzoom, int l_old, int l_new)
7732 {
7733 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7734
7735 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:set_vehicle_values_delta:start");
7736
7737 // DPI
7738 dx = (int) ((float) dx / NavitGraphics.Global_dpi_factor);
7739 dy = (int) ((float) dy / NavitGraphics.Global_dpi_factor);
7740
7741 // zoom factor
7742 float current_horizontal_zoom_factor = 0;
7743 if ((l_new != 0) && (l_old != 0))
7744 {
7745 current_horizontal_zoom_factor = (float) l_new / (float) l_old;
7746 }
7747 // System.out.println("dzoom=" + dzoom + " l_old=" + l_old + " l_new=" + l_new + " f=" + current_horizontal_zoom_factor);
7748
7749 int xxx = 0;
7750 if (DEBUG_SMOOTH_DRIVING)
7751 {
7752 xxx = (int) (Math.random() * 1000f);
7753 }
7754 //System.out.println("" + xxx + "--set_vehicle_values_delta-- ENTER ++++++++++++");
7755
7756 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:00");
7757
7758 Navit.NG__vehicle.vehicle_pos_x_delta = dx;
7759 Navit.NG__vehicle.vehicle_pos_y_delta = dy;
7760 int dangle = dangle2;
7761 if (dangle2 > max_turn_angle)
7762 {
7763 // try to turn the correct way, sometimes there seems to be errors!
7764 dangle = dangle2 - 360;
7765 }
7766 else if (dangle2 < -max_turn_angle)
7767 {
7768 // try to turn the correct way, sometimes there seems to be errors!
7769 dangle = dangle2 + 360;
7770 }
7771
7772 Navit.NG__vehicle.vehicle_direction_delta = dangle;
7773 Navit.NG__vehicle.vehicle_zoom_delta = dzoom;
7774
7775 Global_SmoothDrawing_stop = false;
7776
7777 if (!Navit.p.PREF_use_smooth_drawing)
7778 {
7779 // disbaled via prefs
7780 // if (Navit.METHOD_DEBUG) Navit.my_func_name(2);
7781 return;
7782 }
7783
7784 //if (Navit.NG__vehicle.vehicle_speed < 3)
7785 //{
7786 // // too slow, dont use smooth moving
7787 // return;
7788 //}
7789
7790 //
7791 // Navit.NG__vehicle.vehicle_speed --> is in "km/h" !!
7792 // System.out.println("DEBUG_SMOOTH_DRIVING:v speed=" + Navit.NG__vehicle.vehicle_speed);
7793 //
7794 if ((Navit.NG__vehicle.vehicle_speed > 2) || (Navit.NG__vehicle.vehicle_direction_delta > 0))
7795 {
7796 if (Navit.p.PREF_use_more_smooth_drawing)
7797 {
7798 // really awesome smooth (80 steps / 80 fps) +1
7799 //Vehicle_smooth_moves_count = 79;
7800 //Vehicle_smooth_move_delay = 8;
7801 //
7802 // really awesome smooth (55 steps / 55 fps) +1
7803 //Vehicle_smooth_moves_count = 54;
7804 //Vehicle_smooth_move_delay = 17;
7805 //
7806 // really awesome smooth (30 steps / 30 fps) +1
7807 //Vehicle_smooth_moves_count = 29;
7808 //Vehicle_smooth_move_delay = 30;
7809 //
7810 // really awesome smooth (12 steps) +1
7811 //Vehicle_smooth_moves_count = 11;
7812 //Vehicle_smooth_move_delay = 81;
7813 //
7814 // really awesome smooth (11 steps) +1
7815 //Vehicle_smooth_moves_count = 10;
7816 //Vehicle_smooth_move_delay = 89;
7817 //
7818 // really awesome smooth (10 steps) +1
7819 //Vehicle_smooth_moves_count = 9;
7820 //Vehicle_smooth_move_delay = 96;
7821 //
7822 // really awesome smooth (9 steps) +1
7823 Vehicle_smooth_moves_count = 8;
7824 Vehicle_smooth_move_delay = 100;
7825 }
7826 else
7827 {
7828 // normal smooth (6 steps) +1
7829 // Vehicle_smooth_moves_count = 5;
7830 // Vehicle_smooth_move_delay = 190;
7831 // normal smooth (5 steps) +1
7832 Vehicle_smooth_moves_count = 4;
7833 Vehicle_smooth_move_delay = 205;
7834 // (4 steps) +1
7835 // Vehicle_smooth_moves_count = 3;
7836 // Vehicle_smooth_move_delay = 160;
7837 }
7838 }
7839 else if ((Navit.NG__vehicle.vehicle_speed >= 0) && (Navit.NG__vehicle.vehicle_direction_delta > 0))
7840 {
7841 // really awesome smooth (9 steps) +1
7842 // Vehicle_smooth_moves_count = 8;
7843 // Vehicle_smooth_move_delay = 100;
7844 // normal smooth (5 steps) +1
7845 Vehicle_smooth_moves_count = 4;
7846 Vehicle_smooth_move_delay = 205;
7847 // (4 steps) +1
7848 // Vehicle_smooth_moves_count = 3;
7849 // Vehicle_smooth_move_delay = 160;
7850 }
7851 else
7852 {
7853 // +++ (on slow speed and no turn) --> no smooth move! +++
7854 // if (Navit.METHOD_DEBUG) Navit.my_func_name(3);
7855 return;
7856 }
7857
7858 if (System.currentTimeMillis() > last_vehicle_position_timestamp + 1700L)
7859 {
7860 // last vehicle position was too long ago (1.7 secs ago, or longer)
7861 // if (Navit.METHOD_DEBUG) Navit.my_func_name(4);
7862 return;
7863 }
7864
7865 if (Global_onTouch_fingerdown)
7866 {
7867 // dont use smooth moving while user moves the map
7868 // if (Navit.METHOD_DEBUG) Navit.my_func_name(5);
7869 return;
7870 }
7871
7872 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:angle1:dx=" + dx + " dy=" + dy + " da=" + dangle2);
7873 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:angle2:dx=" + dx + " dy=" + dy + " da=" + dangle);
7874 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:globalzoom:dzoom=" + Navit.NG__vehicle.vehicle_zoom_delta);
7875 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:globalzoom:scale=" + Navit.GlobalScaleLevel);
7876
7877 if ((Math.abs(dangle) < 2) && (Math.abs(dx) < 1) && (Math.abs(dy) < 1))
7878 {
7879 // the move is very small only
7880 // if (Navit.METHOD_DEBUG) Navit.my_func_name(6);
7881 return;
7882 }
7883
7884 final int compensate = 1;
7885 dda = (float) dangle / (float) (Vehicle_smooth_moves_count + compensate);
7886 //dda_last = dangle - ((Vehicle_smooth_moves_count + compensate) * dda);
7887
7888 ddx = (float) dx / (float) (Vehicle_smooth_moves_count + compensate);
7889 ddy = (float) dy / (float) (Vehicle_smooth_moves_count + compensate);
7890 //ddx_last = (float) dx - (float) (Vehicle_smooth_moves_count + compensate) * ddx;
7891 //ddy_last = (float) dy - (float) (Vehicle_smooth_moves_count + compensate) * ddy;
7892
7893 if (Navit.NG__vehicle.vehicle_zoom_delta != 0)
7894 {
7895 //System.out.println("zoom:ddz old=" + ddz);
7896 ddz = (current_horizontal_zoom_factor - 1.0f) / (float) (Vehicle_smooth_moves_count + compensate);
7897 //System.out.println("zoom:ddz new=" + ddz);
7898 }
7899 else
7900 {
7901 ddz = 0;
7902 }
7903
7904 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:angle:ddx=" + ddx + " ddy=" + ddy + " dda=" + dda + " ddz=" + ddz);
7905 //if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:angle:ddx_l=" + ddx_last + " ddy_l=" + ddy_last + " dda_l=" + dda_last);
7906
7907 // now move the map (to have smooth driving)
7908 //System.out.println("" + xxx + "--set_vehicle_values_delta-- START");
7909 //System.out.println("" + xxx + "--set_vehicle_values_delta-- Thread start");
7910 STT_A = new SmoothDriveThread_t_A();
7911 STT_A.start();
7912 //System.out.println("translate, rotate");
7913 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:" + xxx + "--set_vehicle_values_delta-- END ++++++++++++");
7914
7915 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7916 }
7917
7918 static void deactivate_nav_wakelock()
7919 {
7920 try
7921 {
7922 Navit.is_navigating = false;
7923 // System.out.println("XXNAV: Navit.is_navigating = false 001");
7924
7925 Message msg = Navit.Navit_progress_h.obtainMessage();
7926 Bundle b = new Bundle();
7927 msg.what = 25;
7928 msg.setData(b);
7929 Navit.Navit_progress_h.sendMessage(msg);
7930 // System.out.println("XXNAV: Navit.is_navigating = false 002");
7931 }
7932 catch (Exception e)
7933 {
7934 e.printStackTrace();
7935 }
7936
7937 }
7938
7939 static void deactivate_nav_wakelock_real()
7940 {
7941 Log.e("Navit", "WakeLock Nav: release 2 deactivate_nav_wakelock_real - enter");
7942 try
7943 {
7944 Log.e("Navit", "WakeLock Nav: release 2 deactivate_nav_wakelock_real 001");
7945 if (Navit.wl_navigating != null)
7946 {
7947 Log.e("Navit", "WakeLock Nav: release 2 deactivate_nav_wakelock_real 002");
7948 if (Navit.wl_navigating.isHeld())
7949 {
7950 Navit.wl_navigating.release();
7951 Log.e("Navit", "WakeLock Nav: release 2");
7952 }
7953 }
7954 }
7955 catch (Exception e)
7956 {
7957 e.printStackTrace();
7958 }
7959
7960 if (Navit.is_paused == true)
7961 {
7962 try
7963 {
7964 // turn off GPS
7965 NavitVehicle.turn_off_all_providers();
7966 NavitVehicle.turn_off_sat_status();
7967
7968 // turn off speech
7969 try
7970 {
7971 Navit.Global_Navit_Object.mTts.stop();
7972 }
7973 catch (Exception e)
7974 {
7975 }
7976
7977 try
7978 {
7979 Navit.Global_Navit_Object.mTts.shutdown();
7980 }
7981 catch (Exception e)
7982 {
7983 }
7984 }
7985 catch (Exception e)
7986 {
7987 }
7988 }
7989 }
7990
7991 static void activate_nav_wakelock()
7992 {
7993 try
7994 {
7995 Navit.is_navigating = true;
7996 // System.out.println("XXNAV: Navit.is_navigating = TRUE");
7997
7998 Message msg = Navit.Navit_progress_h.obtainMessage();
7999 Bundle b = new Bundle();
8000 msg.what = 26;
8001 msg.setData(b);
8002 Navit.Navit_progress_h.sendMessage(msg);
8003 }
8004 catch (Exception e)
8005 {
8006 e.printStackTrace();
8007 }
8008 }
8009
8010 static void activate_nav_wakelock_real()
8011 {
8012 //System.out.println("XXNAV:001");
8013 try
8014 {
8015 if (Navit.wl_navigating != null)
8016 {
8017 //System.out.println("XXNAV:002");
8018 //if (Navit.wl_navigating.isHeld())
8019 //{
8020 //System.out.println("XXNAV:002.1 isHeld=true");
8021 //deactivate_nav_wakelock();
8022 //}
8023
8024 //if (!Navit.wl_navigating.isHeld())
8025 //{
8026 //System.out.println("XXNAV:005");
8027 Navit.wl_navigating.acquire();
8028 Log.e("Navit", "WakeLock Nav: aquire 2");
8029 //}
8030 }
8031 }
8032 catch (Exception e)
8033 {
8034 //System.out.println("XXNAV:006");
8035 e.printStackTrace();
8036 }
8037 }
8038
8039 @SuppressLint("NewApi")
8040 public static void return_generic_int_real(int id, int i)
8041 {
8042 // System.out.println("id=" + id + " i=" + i);
8043
8044 if (id == 1)
8045 {
8046 /*
8047 * 0 -> 1 -> 13 -> 5 -> 17 -> 5 ... 33 -> 5 -> 33 -> 5 ...
8048 *
8049 * route_status_no_destination=0, # 0 --> no dest. set
8050 * route_status_destination_set=1, # 1
8051 * route_status_not_found=1|2, # 3 --> no route to destination found / route blocked
8052 * route_status_building_path=1|4, # 5
8053 * route_status_building_graph=1|4|8, # 13
8054 * route_status_path_done_new=1|16, # 17 --> route found
8055 * route_status_path_done_incremental=1|32, # 33 --> route found
8056 */
8057 int old_status = NavitGraphics.navit_route_status;
8058
8059 // System.out.println("PRF:st:old=" + old_status + " new=" + i);
8060
8061 //System.out.println("XXNAV:a002");
8062 if ((old_status != 17) && (old_status != 33))
8063 {
8064 //System.out.println("XXNAV:a003");
8065 if ((i == 17) || (i == 33))
8066 {
8067 //System.out.println("XXNAV:a004");
8068 activate_nav_wakelock();
8069 }
8070 }
8071 else
8072 {
8073 //System.out.println("XXNAV:a005");
8074 if ((i != 17) && (i != 33))
8075 {
8076 //System.out.println("XXNAV:a006");
8077 deactivate_nav_wakelock();
8078
8079 if (i == 0)
8080 {
8081 NavitVehicle.pos_recording_add(2, 0, 0, 0, 0, 111); // CLR
8082 }
8083 }
8084 }
8085
8086 // id=1 -> route_status
8087 NavitGraphics.navit_route_status = i;
8088 try
8089 {
8090 if (i != 0)
8091 {
8092 // activate java line drawing
8093 Message msg = new Message();
8094 Bundle b = new Bundle();
8095 b.putInt("Callback", 85);
8096 b.putString("s", "0");
8097 msg.setData(b);
8098 try
8099 {
8100 Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
8101 }
8102 catch (Exception e)
8103 {
8104 e.printStackTrace();
8105 }
8106 }
8107 else
8108 {
8109 // activate line drawing from prefs setting
8110 if (Navit.p.PREF_c_linedrawing)
8111 {
8112 Message msg = new Message();
8113 Bundle b = new Bundle();
8114 b.putInt("Callback", 85);
8115 b.putString("s", "1");
8116 msg.setData(b);
8117 try
8118 {
8119 Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
8120 }
8121 catch (Exception e)
8122 {
8123 }
8124 }
8125 }
8126
8127 Navit.Global_Navit_Object.invalidateOptionsMenu();
8128 // create the options menu new
8129 }
8130 catch (Exception e)
8131 {
8132 }
8133
8134 if (i == 0)
8135 {
8136 ZANaviBusySpinner.active = false;
8137 ZANaviBusySpinner.cancelAnim();
8138 busyspinner_.setVisibility(View.INVISIBLE);
8139 busyspinnertext_.setVisibility(View.INVISIBLE);
8140 busyspinnertext_.setText("");
8141 Navit.set_debug_messages1("");
8142 // DEBUG: clear route rectangle list
8143 route_rects.clear();
8144 }
8145 else if (i == 1)
8146 {
8147 ZANaviBusySpinner.active = true;
8148 busyspinnertext_.setText(Navit.get_text("Destination set")); // TRANS
8149 busyspinner_.setVisibility(View.VISIBLE);
8150 busyspinnertext_.setVisibility(View.VISIBLE);
8151 //System.out.println("invalidate 017");
8152 busyspinner_.postInvalidate();
8153 Navit.set_debug_messages1("Destination set");
8154 }
8155 else if (i == 3)
8156 {
8157 ZANaviBusySpinner.active = true;
8158 ZANaviBusySpinner.cancelAnim();
8159 busyspinner_.setVisibility(View.VISIBLE);
8160 busyspinnertext_.setText(Navit.get_text("No route found / Route blocked")); // TRANS
8161 busyspinnertext_.setVisibility(View.VISIBLE);
8162 Navit.set_debug_messages1("No route found / Route blocked");
8163 }
8164 else if (i == 5)
8165 {
8166 // status "5" is now ignored in c-code!!!
8167 ZANaviBusySpinner.active = true;
8168 busyspinner_.setVisibility(View.VISIBLE);
8169 //System.out.println("invalidate 018");
8170 busyspinner_.postInvalidate();
8171 busyspinnertext_.setText(Navit.get_text("Building route path")); // TRANS
8172 busyspinnertext_.setVisibility(View.VISIBLE);
8173 Navit.set_debug_messages1("Building route path");
8174 }
8175 else if (i == 13)
8176 {
8177 ZANaviBusySpinner.active = true;
8178 busyspinner_.setVisibility(View.VISIBLE);
8179 //System.out.println("invalidate 019");
8180 busyspinner_.postInvalidate();
8181 busyspinnertext_.setText(Navit.get_text("Building route graph")); // TRANS
8182 busyspinnertext_.setVisibility(View.VISIBLE);
8183 Navit.set_debug_messages1("Building route graph");
8184 }
8185 else if (i == 17)
8186 {
8187 ZANaviBusySpinner.active = false;
8188 ZANaviBusySpinner.cancelAnim();
8189 busyspinner_.setVisibility(View.INVISIBLE);
8190 busyspinnertext_.setText("");
8191 busyspinnertext_.setVisibility(View.INVISIBLE);
8192 Navit.set_debug_messages1("Route found");
8193 }
8194 else if (i == 33)
8195 {
8196 ZANaviBusySpinner.active = false;
8197 ZANaviBusySpinner.cancelAnim();
8198 busyspinner_.setVisibility(View.INVISIBLE);
8199 busyspinnertext_.setText("");
8200 busyspinnertext_.setVisibility(View.INVISIBLE);
8201 Navit.set_debug_messages1("Route found");
8202 }
8203 }
8204 else if (id == 2)
8205 {
8206 if (i == 1)
8207 {
8208 // id=2,1 -> map draw finished
8209 if (DEBUG_TOUCH) System.out.println("wait_for_redraw_map=false xx1");
8210 NavitGraphics.wait_for_redraw_map = false;
8211 try
8212 {
8213 //NavitAndroidOverlay.overlay_draw_thread1.stop_redraw();
8214 //NavitAndroidOverlay.overlay_draw_thread1.stop_me();
8215 //NavitAndroidOverlay.overlay_draw_thread1 = null;
8216 }
8217 catch (Exception e)
8218 {
8219 // e.printStackTrace();
8220 }
8221 try
8222 {
8223 //System.out.println("DO__DRAW:Java:remove wait text");
8224 //System.out.println("invalidate 020");
8225 //System.out.println("xx paint 21 xx");
8226 NavitAOverlay_s.postInvalidate();
8227 }
8228 catch (Exception e)
8229 {
8230 e.printStackTrace();
8231 }
8232 }
8233 else if (i == 3)
8234 {
8235 // id=2,3 -> mapdraw cancel signal
8236 //System.out.println("DO__DRAW:Java:cancel map");
8237 map_c_drawing = false;
8238
8239 // draw_map_one_shot = true;
8240 //copy_backwards_map_buffer();
8241 //draw_reset_factors = true;
8242 //view_s.postInvalidate();
8243
8244 }
8245 else if (i == 2)
8246 {
8247 // id=2,2 -> mapdraw ready signal
8248 //System.out.println("DO__DRAW:Java:refresh map");
8249 // draw_map_one_shot = true;
8250 if (DEBUG_SMOOTH_DRIVING) System.out.println("DEBUG_SMOOTH_DRIVING:TMG-DEBUG:map draw ready");
8251
8252 map_c_drawing = false;
8253
8254 if ((Navit.p.PREF_use_smooth_drawing) && (Navit.NG__vehicle.vehicle_speed > 12))
8255 {
8256 // delay vehicle and map update just a tiny little bit here!! -- very experimental, also delays gps position !!!
8257
8258 //System.out.println("DEBUG_SMOOTH_DRIVING:map draw ready -> signal received");
8259 if (STT_B_list[0] != null)
8260 {
8261 STT_B_list[0].cancel_previous();
8262 }
8263 if (STT_B_list[1] != null)
8264 {
8265 STT_B_list[1].cancel_previous();
8266 }
8267 if (STT_B_list[2] != null)
8268 {
8269 STT_B_list[2].cancel_previous();
8270 }
8271 STT_B = new SmoothDriveThread_t_B();
8272 STT_B_list[2] = STT_B_list[1];
8273 STT_B_list[1] = STT_B_list[0];
8274 STT_B_list[0] = STT_B;
8275 STT_B.start();
8276 }
8277 else
8278 {
8279 copy_map_buffer();
8280 draw_reset_factors = true;
8281 // System.out.println("DO__DRAW:Java:postInvalidate 003");
8282 // SYN //
8283 view_s.postInvalidate();
8284 // map_postInvalidate();
8285 //view_s.paint_me();
8286 }
8287 }
8288 else if (i == 77)
8289 {
8290 //System.out.println("DEBUG_SMOOTH_DRIVING:map draw start -> signal received");
8291 map_c_drawing = true;
8292 }
8293 }
8294 else if (id == 3)
8295 {
8296 // id=3 -> new scale (zoom) number
8297 // 1 (=2^0) order: ~16 -> fully zoomed in
8298 // 1048576 (=2^20) order: -1 -> zoomed out to world
8299 if (DEBUG_TOUCH) System.out.println("scale=" + i);
8300 Navit.GlobalScaleLevel = i;
8301 }
8302 else if (id == 4)
8303 {
8304 Navit.set_debug_messages1("Destination reached");
8305 NavitGraphics.navit_route_status = 0;
8306
8307 //System.out.println("XXNAV:dd001");
8308 deactivate_nav_wakelock();
8309
8310 if (Navit.p.PREF_enable_debug_write_gpx)
8311 {
8312 NavitVehicle.speech_recording_end();
8313 }
8314 }
8315 else if (id == 5)
8316 {
8317 Navit.set_debug_messages1("Waypoint reached");
8318 }
8319 else if (id == 6)
8320 {
8321 // id=6 -> mean time for drawing map to screen (in 1/1000 of a second)
8322 Navit.set_debug_messages4("draw:" + (float) ((float) i / 1000f) + "s");
8323 }
8324 else if (id == 7)
8325 {
8326 // is underground
8327 Navit.pos_is_underground = i; // can be: 0 or 1
8328
8329 // System.out.println("pos_is_underground=" + Navit.pos_is_underground);
8330
8331 if (Navit.want_tunnel_extrapolation())
8332 {
8333 NavitVehicle.turn_on_tunnel_extrapolation();
8334 }
8335 else
8336 {
8337 NavitVehicle.turn_off_tunnel_extrapolation();
8338 }
8339 }
8340 else if (id == 8)
8341 {
8342 // max speed of current segment in km/h
8343 int old_speed = Navit.cur_max_speed;
8344 Navit.cur_max_speed = i;
8345 if (old_speed != Navit.cur_max_speed)
8346 {
8347 // reset "beep" flag
8348 Navit.toneG_heared = false;
8349
8350 // System.out.println("MAX SPEED=" + Navit.cur_max_speed);
8351 //System.out.println("xx paint 4 xx");
8352 // NavitOSDJava.draw_real_wrapper(true, false);
8353 ZANaviLinearLayout.redraw_OSD(8);
8354 }
8355 }
8356 }
8357
8358 public static Bitmap rotate_and_scale_bitmap(Bitmap in, int w, int h, int angle)
8359 {
8360 int width = in.getWidth();
8361 int height = in.getHeight();
8362
8363 if ((width == w) && (height == h) && (angle == 0))
8364 {
8365 return in;
8366 }
8367
8368 // System.out.println(" @@@@@@ w="+w+" h="+h);
8369
8370 // calculate the scale
8371 float scaleWidth = ((float) w) / width;
8372 float scaleHeight = ((float) h) / height;
8373
8374 // createa matrix for the manipulation
8375 Matrix matrix = new Matrix();
8376 // resize the bit map
8377 matrix.postScale(scaleWidth, scaleHeight);
8378 // rotate the Bitmap
8379 matrix.postRotate(angle);
8380
8381 // recreate the new Bitmap
8382 return (Bitmap.createBitmap(in, 0, 0, width, height, matrix, true));
8383 }
8384
8385 public static class route_rect
8386 {
8387 int x1;
8388 int y1;
8389 int x2;
8390 int y2;
8391 int order;
8392 };
8393
8394 public static ArrayList<route_rect> route_rects = new ArrayList<route_rect>();
8395
8396 // values are NOT in pixels!! they need to be converted to pixels before drawing
8397 public static void send_route_rect_to_java(int x1, int y1, int x2, int y2, int order)
8398 {
8399 //System.out.println("send_route_rect_to_java: " + x1 + "," + y1 + " " + x2 + "," + y2 + " o=" + order);
8400
8401 //String left_top_on_screen_string = CallbackGeoCalc(11, x1, y1);
8402 //String tmp[] = left_top_on_screen_string.split(":", 2);
8403 //int pixel_top_left_x = Integer.parseInt(tmp[0]);
8404 //int pixel_top_left_y = Integer.parseInt(tmp[1]);
8405 //System.out.println(" " + pixel_top_left_x + "," + pixel_top_left_y);
8406
8407 //left_top_on_screen_string = CallbackGeoCalc(11, x2, y2);
8408 //tmp = left_top_on_screen_string.split(":", 2);
8409 //pixel_top_left_x = Integer.parseInt(tmp[0]);
8410 //pixel_top_left_y = Integer.parseInt(tmp[1]);
8411 //System.out.println(" " + pixel_top_left_x + "," + pixel_top_left_y);
8412
8413 if (route_rects == null)
8414 {
8415 route_rects = new ArrayList<route_rect>();
8416 }
8417
8418 // System.out.println("route_rect::send:" + order + ":" + x1 + " " + y1 + " " + x2 + " " + y2);
8419
8420 route_rect rr = new route_rect();
8421 rr.x1 = x1;
8422 rr.y1 = y1;
8423 rr.x2 = x2;
8424 rr.y2 = y2;
8425 rr.order = order;
8426 route_rects.add(rr);
8427 }
8428
8429 public static int dp_to_px(int dp)
8430 {
8431 // System.out.println("FFF:dp=" + dp + " px1=" + (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, Navit.getBaseContext_.getResources().getDisplayMetrics()) + " ps2=" + (int) (((float) dp * Global_dpi_factor_better) + 0.5f));
8432
8433 // return (int) (((float) dp * Global_dpi_factor_better) + 0.5f);
8434 return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, Navit.getBaseContext_.getResources().getDisplayMetrics());
8435 }
8436
8437 public static int px_to_dp(int px)
8438 {
8439 // System.out.println("FFF:px=" + px + " dp1=" + (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, px, Navit.getBaseContext_.getResources().getDisplayMetrics()) + " ps2=" + (int) (((float) px / Global_dpi_factor_better) + 0.5f));
8440
8441 // return (int) (((float) px / Global_dpi_factor_better) + 0.5f);
8442 return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, px, Navit.getBaseContext_.getResources().getDisplayMetrics());
8443 }
8444
8445 public static void cancel_preview_map_drawing()
8446 {
8447 // System.out.println("cancel_preview_map_drawing:001");
8448
8449 try
8450 {
8451 NavitGraphics.CallbackMessageChannelReal(113, "");
8452 // System.out.println("cancel_preview_map_drawing:002");
8453 }
8454 catch (Exception e)
8455 {
8456 // System.out.println("cancel_preview_map_drawing:0EE");
8457 }
8458 }
8459
8460 static long last_map_postInvalidate = -1L;
8461 }

   
Visit the ZANavi Wiki