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

   
Visit the ZANavi Wiki