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

   
Visit the ZANavi Wiki