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

   
Visit the ZANavi Wiki