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

Diff of /navit/navit/android/src/com/zoffcc/applications/zanavi/NavitAndroidOverlay.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 40 Revision 41
36 * Boston, MA 02110-1301, USA. 36 * Boston, MA 02110-1301, USA.
37 */ 37 */
38 38
39package com.zoffcc.applications.zanavi; 39package com.zoffcc.applications.zanavi;
40 40
41import android.annotation.SuppressLint;
41import android.content.Context; 42import android.content.Context;
42import android.content.DialogInterface; 43import android.content.DialogInterface;
43import android.graphics.Canvas; 44import android.graphics.Canvas;
44import android.graphics.Color; 45import android.graphics.Color;
45import android.graphics.Matrix; 46import android.graphics.Matrix;
46import android.graphics.Paint; 47import android.graphics.Paint;
47import android.graphics.Paint.Align;
48import android.graphics.Paint.Style;
49import android.graphics.Path; 48import android.graphics.Path;
49import android.graphics.Rect;
50import android.graphics.RectF; 50import android.graphics.RectF;
51import android.os.Bundle; 51import android.os.Bundle;
52import android.os.Message; 52import android.os.Message;
53import android.util.AttributeSet; 53import android.util.AttributeSet;
54import android.view.MotionEvent; 54import android.view.MotionEvent;
55import android.view.View; 55import android.view.View;
56 56
57import com.zoffcc.applications.zanavi.Navit.geo_coord;
58
57public class NavitAndroidOverlay extends View 59public class NavitAndroidOverlay extends View
58{ 60{
59 public Boolean draw_bubble = false; 61 public Boolean draw_bubble = false;
62 public Boolean draw_bubble_first = false;
60 public static Boolean confirmed_bubble = false; 63 public static Boolean confirmed_bubble = false;
61 public static int confirmed_bubble_part = 0; // 0 -> left side, 1 -> right side 64 public static int confirmed_bubble_part = 0; // 0 -> left side, 1 -> right side
62 public long bubble_showing_since = 0L; 65 public long bubble_showing_since = 0L;
63 public static long bubble_max_showing_timespan = 5000L; // 5 secs. 66 public static long bubble_max_showing_timespan = 5000L; // 5 secs.
64 public RectF follow_button_rect = new RectF(-100, 1, 1, 1); 67 // public RectF follow_button_rect = new RectF(-100, 1, 1, 1);
65 public RectF voice_recog_rect = new RectF(-100, 1, 1, 1); 68 //public RectF voice_recog_rect = new RectF(-100, 1, 1, 1);
66 public RectF zoomin_button_rect = new RectF(-100, 1, 1, 1); 69 //public RectF zoomin_button_rect = new RectF(-100, 1, 1, 1);
67 public RectF zoomout_button_rect = new RectF(-100, 1, 1, 1); 70 //public RectF zoomout_button_rect = new RectF(-100, 1, 1, 1);
68 public RectF mapdrawing_button_rect = new RectF(-100, 1, 1, 1); 71 //public RectF mapdrawing_button_rect = new RectF(-100, 1, 1, 1);
69 public static int zoomin_ltx = 0; 72 public static int zoomin_ltx = 0;
70 public static int zoomin_lty = 0; 73 public static int zoomin_lty = 0;
71 public static int zoomout_ltx = 0; 74 public static int zoomout_ltx = 0;
72 public static int zoomout_lty = 0; 75 public static int zoomout_lty = 0;
73 public static int mapdrawing_ltx = 0; 76 public static int mapdrawing_ltx = 0;
82 public static int voice_rec_bar_limit = 10; 85 public static int voice_rec_bar_limit = 10;
83 Matrix lanes_scaleMatrix = new Matrix(); 86 Matrix lanes_scaleMatrix = new Matrix();
84 Matrix lanes_transMatrix = new Matrix(); 87 Matrix lanes_transMatrix = new Matrix();
85 RectF lanes_rectF = new RectF(); 88 RectF lanes_rectF = new RectF();
86 89
90 public static boolean measure_mode = false;
91 public static int measure_result_meters = -1;
92 static int measure_1_x = 0;
93 static int measure_1_y = 0;
94 static int measure_2_x = 0;
95 static int measure_2_y = 0;
96 static boolean measure_first = true;
97 static boolean measure_valid = false;
98 static Paint paint_measure = new Paint();
99 static int measure_point_radius = 3;
100
101 private Paint paint_replay = new Paint();
102 private Paint paint_rewind_small = new Paint();
103
104 Message msg_dd = null;
105 Bundle b_dd = new Bundle();
106
87 RectF bounds_speedwarning = new RectF(120, 800, 120 + 200, 800 + 200); 107 RectF bounds_speedwarning = new RectF(120, 800, 120 + 200, 800 + 200);
88 Paint paint_speedwarning = new Paint(0); 108 Paint paint_speedwarning = new Paint(0);
89 109
90 static boolean no_draw = false; 110 static boolean no_draw = false;
91 111
150 int x; 170 int x;
151 int y; 171 int y;
152 String text = null; 172 String text = null;
153 } 173 }
154 174
155 private NavitAndroidOverlayBubble bubble_001 = null; 175 NavitAndroidOverlayBubble bubble_001 = null;
156 176
157 public NavitAndroidOverlay(Context context) 177 public NavitAndroidOverlay(Context context)
158 { 178 {
159 super(context); 179 super(context);
180
181 paint_measure.setColor(Color.RED);
182 paint_measure.setStyle(Paint.Style.STROKE);
183 paint_measure.setStrokeWidth(NavitGraphics.dp_to_px(6));
184 measure_point_radius = NavitGraphics.dp_to_px(10);
185
186 paint_replay.setColor(0xaa444444); // grey
187 paint_replay.setStyle(Paint.Style.FILL_AND_STROKE);
188
189 paint_rewind_small.setColor(0xaa440202); // red
190 paint_rewind_small.setStyle(Paint.Style.FILL_AND_STROKE);
160 } 191 }
161 192
162 public NavitAndroidOverlay(Context context, AttributeSet attrs) 193 public NavitAndroidOverlay(Context context, AttributeSet attrs)
163 { 194 {
164 super(context, attrs); 195 super(context, attrs);
196
197 paint_measure.setColor(Color.RED);
198 paint_measure.setStyle(Paint.Style.STROKE);
199 paint_measure.setStrokeWidth(NavitGraphics.dp_to_px(6));
200 measure_point_radius = NavitGraphics.dp_to_px(10);
201
202 paint_replay.setColor(0xaa444444);
203 paint_replay.setStyle(Paint.Style.FILL_AND_STROKE);
204
205 paint_rewind_small.setColor(0xaa440202); // red
206 paint_rewind_small.setStyle(Paint.Style.FILL_AND_STROKE);
165 } 207 }
166 208
167 public void show_bubble() 209 public void show_bubble()
168 { 210 {
169 //System.out.println("NavitAndroidOverlay -> show_bubble"); 211 //System.out.println("NavitAndroidOverlay -> show_bubble");
170 if (!this.draw_bubble) 212 if (!this.draw_bubble)
171 { 213 {
214 try
215 {
216 Message msg = Navit.Navit_progress_h.obtainMessage();
217 Bundle b = new Bundle();
218 msg.what = 34;
219 msg.setData(b);
220 Navit.Navit_progress_h.sendMessage(msg);
221 }
222 catch (Exception e)
223 {
224 e.printStackTrace();
225 }
226
172 confirmed_bubble = false; 227 confirmed_bubble = false;
173 this.draw_bubble = true; 228 this.draw_bubble = true;
229 this.draw_bubble_first = true;
174 this.bubble_showing_since = System.currentTimeMillis(); 230 this.bubble_showing_since = System.currentTimeMillis();
175 bubble_thread = new BubbleThread(this); 231 bubble_thread = new BubbleThread(this);
176 bubble_thread.start(); 232 bubble_thread.start();
177 233
178 // test test DEBUG 234 // test test DEBUG
196 public void hide_bubble() 252 public void hide_bubble()
197 { 253 {
198 // Log.e("NavitGraphics", "NavitAndroidOverlay -> hide_bubble"); 254 // Log.e("NavitGraphics", "NavitAndroidOverlay -> hide_bubble");
199 confirmed_bubble = false; 255 confirmed_bubble = false;
200 this.draw_bubble = false; 256 this.draw_bubble = false;
257 this.draw_bubble_first = false;
258
259 try
260 {
261 Message msg = Navit.Navit_progress_h.obtainMessage();
262 Bundle b = new Bundle();
263 msg.what = 35;
264 msg.setData(b);
265 Navit.Navit_progress_h.sendMessage(msg);
266 }
267 catch (Exception e)
268 {
269 e.printStackTrace();
270 }
271
201 this.bubble_showing_since = 0L; 272 this.bubble_showing_since = 0L;
202 try 273 try
203 { 274 {
204 bubble_thread.stop_me(); 275 bubble_thread.stop_me();
205 // bubble_thread.stop(); 276 // bubble_thread.stop();
214 public void set_bubble(NavitAndroidOverlayBubble b) 285 public void set_bubble(NavitAndroidOverlayBubble b)
215 { 286 {
216 this.bubble_001 = b; 287 this.bubble_001 = b;
217 } 288 }
218 289
290 public void whats_button_clicked()
291 {
292 // bubble touched to confirm destination
293 confirmed_bubble = true;
294 confirmed_bubble_part = 1;
295 // draw confirmed bubble
296 //System.out.println("invalidate 003");
297 this.postInvalidate();
298
299 // whats here?
300 String item_dump_pretty = "";
301 if (Navit.GFX_OVERSPILL)
302 {
303 item_dump_pretty = NavitGraphics.CallbackGeoCalc(10, (this.bubble_001.x + NavitGraphics.mCanvasWidth_overspill) * NavitGraphics.Global_dpi_factor, (this.bubble_001.y + NavitGraphics.mCanvasHeight_overspill) * NavitGraphics.Global_dpi_factor);
304 }
305 else
306 {
307 item_dump_pretty = NavitGraphics.CallbackGeoCalc(10, this.bubble_001.x * NavitGraphics.Global_dpi_factor, this.bubble_001.y * NavitGraphics.Global_dpi_factor);
308 }
309
310 try
311 {
312 String item_dump_pretty_parsed = "";
313 String[] item_dump_lines = item_dump_pretty.split("\n");
314 int jk = 0;
315 String sep = "";
316 for (jk = 0; jk < item_dump_lines.length; jk++)
317 {
318 if (item_dump_lines[jk].startsWith("+*TYPE*+:"))
319 {
320 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk].substring(9);
321 }
322 else if (item_dump_lines[jk].startsWith("flags="))
323 {
324
325 }
326 else if (item_dump_lines[jk].startsWith("maxspeed="))
327 {
328 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk];
329 }
330 else if (item_dump_lines[jk].startsWith("label="))
331 {
332 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk].substring(6);
333 }
334 else if (item_dump_lines[jk].startsWith("street_name="))
335 {
336 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk].substring(12);
337 }
338 else if (item_dump_lines[jk].startsWith("street_name_systematic="))
339 {
340 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk].substring(23);
341 }
342 else
343 {
344 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk];
345 }
346
347 if (jk == 0)
348 {
349 sep = "\n";
350 }
351 }
352
353 Navit.generic_alert_box.setMessage(item_dump_pretty_parsed).setPositiveButton(Navit.get_text("Ok"), new DialogInterface.OnClickListener()
354 {
355 public void onClick(DialogInterface dialog, int id)
356 {
357 // Handle Ok
358 }
359 }).create();
360 Navit.generic_alert_box.setCancelable(true);
361 Navit.generic_alert_box.setTitle(Navit.get_text("What's here")); // TRANS
362 Navit.generic_alert_box.show();
363 }
364 catch (Exception e)
365 {
366 e.printStackTrace();
367 }
368
369 this.hide_bubble();
370 this.postInvalidate();
371 }
372
373 public void drive_button_clicked()
374 {
375 // bubble touched to confirm destination
376 confirmed_bubble = true;
377 confirmed_bubble_part = 0;
378 // draw confirmed bubble
379 //System.out.println("invalidate 002");
380 this.postInvalidate();
381 String dest_name = "Point on Screen";
382
383 // remeber recent dest.
384 try
385 {
386 if (Navit.GFX_OVERSPILL)
387 {
388 dest_name = NavitGraphics.CallbackGeoCalc(8, (this.bubble_001.x + NavitGraphics.mCanvasWidth_overspill) * NavitGraphics.Global_dpi_factor, (this.bubble_001.y + NavitGraphics.mCanvasHeight_overspill) * NavitGraphics.Global_dpi_factor);
389 }
390 else
391 {
392 dest_name = NavitGraphics.CallbackGeoCalc(8, this.bubble_001.x * NavitGraphics.Global_dpi_factor, this.bubble_001.y * NavitGraphics.Global_dpi_factor);
393 }
394
395 // System.out.println("x:"+dest_name+":y");
396 if ((dest_name.equals(" ")) || (dest_name == null))
397 {
398 dest_name = "Point on Screen";
399 }
400
401 // Navit.remember_destination_xy(dest_name, this.bubble_001.x, this.bubble_001.y);
402 }
403 catch (Exception e)
404 {
405 e.printStackTrace();
406 }
407
408 Navit.geo_coord gc1 = null;
409 if (Navit.GFX_OVERSPILL)
410 {
411 gc1 = Navit.px_to_geo((int) ((float) (this.bubble_001.x + NavitGraphics.mCanvasWidth_overspill) * NavitGraphics.Global_dpi_factor), (int) ((float) (this.bubble_001.y + NavitGraphics.mCanvasHeight_overspill) * NavitGraphics.Global_dpi_factor));
412 }
413 else
414 {
415 gc1 = Navit.px_to_geo((int) ((float) this.bubble_001.x * NavitGraphics.Global_dpi_factor), (int) ((float) this.bubble_001.y * NavitGraphics.Global_dpi_factor));
416 }
417
418 Navit.route_wrapper(dest_name, 0, 0, false, gc1.Latitude, gc1.Longitude, true);
419
420 final Thread zoom_to_route_008 = new Thread()
421 {
422 @Override
423 public void run()
424 {
425 try
426 {
427 Thread.sleep(1000);
428 // --------- zoom to route ---------
429 Message msg = new Message();
430 Bundle b = new Bundle();
431 b.putInt("Callback", 17);
432 msg.setData(b);
433 NavitGraphics.callback_handler.sendMessage(msg);
434 // --------- zoom to route ---------
435 }
436 catch (Exception e)
437 {
438 }
439 }
440 };
441 zoom_to_route_008.start();
442
443 this.hide_bubble();
444 this.postInvalidate();
445 }
446
219 @Override 447 @Override
220 public boolean onTouchEvent(MotionEvent event) 448 public boolean onTouchEvent(MotionEvent event)
221 { 449 {
222 //if (NavitGraphics.wait_for_redraw_map == true)
223 //{
224 // Log.e("NavitGraphics", "GD NavitAndroidOverlay GD -> onTouchEvent");
225 // Message msg = new Message();
226 // Bundle b = new Bundle();
227 // b.putInt("Callback", 50);
228 // msg.setData(b);
229 // Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
230 //}
231 //else
232 //{
233 // // Log.e("NavitGraphics", "NavitAndroidOverlay -> onTouchEvent");
234 //}
235 super.onTouchEvent(event); 450 super.onTouchEvent(event);
236 451
237 int action = event.getAction(); 452 int action = event.getAction();
238 int x = (int) event.getX(); 453 int x = (int) event.getX();
239 int y = (int) event.getY(); 454 int y = (int) event.getY();
247 // { 462 // {
248 // return false; 463 // return false;
249 // } 464 // }
250 //} 465 //}
251 466
467 if (NavitAndroidOverlay.measure_mode)
468 {
469
470 if (action == MotionEvent.ACTION_UP)
471 {
472 if (measure_first)
473 {
474 measure_first = false;
475 measure_1_x = x;
476 measure_1_y = y;
477
478 measure_valid = false;
479 }
480 else
481 {
482 measure_first = true;
483 measure_2_x = x;
484 measure_2_y = y;
485
486 geo_coord gc1 = Navit.px_to_geo(measure_1_x, measure_1_y);
487 geo_coord gc2 = Navit.px_to_geo(measure_2_x, measure_2_y);
488
489 // System.out.println("XXXXXXXXXXXXXX:3a " + gc1.Latitude + " " + gc1.Longitude + " " + gc2.Latitude + " " + gc2.Longitude);
490
491 int m = NavitVehicle.distanceBetween(gc1.Latitude, gc1.Longitude, gc2.Latitude, gc2.Longitude);
492
493 measure_valid = true;
494
495 measure_result_meters = m;
496 ZANaviLinearLayout.redraw_OSD(1);
497 NavitGraphics.NavitAOverlay_s.postInvalidate();
498 }
499 }
500
501 return true;
502 }
503
504 if (ZANaviDebugReceiver.is_replaying)
505 {
506 if (action == MotionEvent.ACTION_DOWN)
507 {
508 Rect r = new Rect(40, mCanvasHeight / 5, 40 + NavitGraphics.dp_to_px(50), (mCanvasHeight / 5) + NavitGraphics.dp_to_px(50));
509 if (r.contains(x, y))
510 {
511 ZANaviDebugReceiver.DR_skip();
512 }
513
514 r = new Rect(40 + NavitGraphics.dp_to_px(80), mCanvasHeight / 5, 40 + NavitGraphics.dp_to_px(50) + NavitGraphics.dp_to_px(80), (mCanvasHeight / 5) + NavitGraphics.dp_to_px(50));
515 if (r.contains(x, y))
516 {
517 ZANaviDebugReceiver.DR_rewind_small();
518 }
519
520 }
521 }
522
252 if (action == MotionEvent.ACTION_DOWN) 523 if (action == MotionEvent.ACTION_DOWN)
253 { 524 {
254 if ((this.draw_bubble) && (!confirmed_bubble)) 525 if ((this.draw_bubble) && (!confirmed_bubble))
255 { 526 {
256 int dx = (int) ((20 / 1.5f) * draw_factor); 527 int dx = (int) ((20 / 1.5f) * draw_factor);
260 RectF box_rect_left = new RectF(this.bubble_001.x + dx, this.bubble_001.y + dy, this.bubble_001.x + bubble_size_x / 2 + dx, this.bubble_001.y + bubble_size_y + dy); 531 RectF box_rect_left = new RectF(this.bubble_001.x + dx, this.bubble_001.y + dy, this.bubble_001.x + bubble_size_x / 2 + dx, this.bubble_001.y + bubble_size_y + dy);
261 RectF box_rect_right = new RectF(this.bubble_001.x + bubble_size_x / 2 + dx, this.bubble_001.y + dy, this.bubble_001.x + bubble_size_x + dx, this.bubble_001.y + bubble_size_y + dy); 532 RectF box_rect_right = new RectF(this.bubble_001.x + bubble_size_x / 2 + dx, this.bubble_001.y + dy, this.bubble_001.x + bubble_size_x + dx, this.bubble_001.y + bubble_size_y + dy);
262 533
263 if (box_rect_left.contains(x, y)) 534 if (box_rect_left.contains(x, y))
264 { 535 {
265 // bubble touched to confirm destination
266 confirmed_bubble = true;
267 confirmed_bubble_part = 0;
268 // draw confirmed bubble
269 //System.out.println("invalidate 002");
270 this.postInvalidate();
271 String dest_name = "Point on Screen";
272
273 // remeber recent dest.
274 try
275 {
276 dest_name = NavitGraphics.CallbackGeoCalc(8, this.bubble_001.x * NavitGraphics.Global_dpi_factor, this.bubble_001.y * NavitGraphics.Global_dpi_factor);
277 // System.out.println("x:"+dest_name+":y");
278 if ((dest_name.equals(" ")) || (dest_name == null))
279 {
280 dest_name = "Point on Screen";
281 }
282
283 Navit.remember_destination_xy(dest_name, this.bubble_001.x, this.bubble_001.y);
284 }
285 catch (Exception e)
286 {
287 e.printStackTrace();
288 }
289
290 // DEBUG: clear route rectangle list
291 NavitGraphics.route_rects.clear();
292
293 if (NavitGraphics.navit_route_status == 0)
294 {
295 Navit.destination_set();
296
297 Message msg = new Message();
298 Bundle b = new Bundle();
299 b.putInt("Callback", 4);
300 b.putInt("x", (int) ((float) this.bubble_001.x * NavitGraphics.Global_dpi_factor));
301 b.putInt("y", (int) ((float) this.bubble_001.y * NavitGraphics.Global_dpi_factor));
302 msg.setData(b);
303 Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
304 }
305 else
306 {
307 Message msg = new Message();
308 Bundle b = new Bundle();
309 b.putInt("Callback", 49);
310 b.putInt("x", (int) ((float) this.bubble_001.x * NavitGraphics.Global_dpi_factor));
311 b.putInt("y", (int) ((float) this.bubble_001.y * NavitGraphics.Global_dpi_factor));
312 msg.setData(b);
313 Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
314 }
315
316 final Thread zoom_to_route_008 = new Thread()
317 {
318 @Override
319 public void run()
320 {
321 try
322 {
323 Thread.sleep(1000);
324 // --------- zoom to route ---------
325 Message msg = new Message();
326 Bundle b = new Bundle();
327 b.putInt("Callback", 17);
328 msg.setData(b);
329 Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
330 // --------- zoom to route ---------
331 }
332 catch (Exception e)
333 {
334 }
335 }
336 };
337 zoom_to_route_008.start();
338
339 // try
340 // {
341 // Navit.follow_button_on();
342 // }
343 // catch (Exception e2)
344 // {
345 // e2.printStackTrace();
346 // }
347
348 this.hide_bubble();
349 this.postInvalidate();
350
351 // consume the event
352 return true;
353 } 536 }
354 // else if (2 == 1) 537 // else if (2 == 1)
355 // { 538 // {
356 // // share the current location with your friends 539 // // share the current location with your friends
357 // share_location("48.422", "16.34", "Meeting Point"); 540 // share_location("48.422", "16.34", "Meeting Point");
358 // } 541 // }
359 else if (box_rect_right.contains(x, y)) 542 else if (box_rect_right.contains(x, y))
360 { 543 {
361 // bubble touched to confirm destination
362 confirmed_bubble = true;
363 confirmed_bubble_part = 1;
364 // draw confirmed bubble
365 //System.out.println("invalidate 003");
366 this.postInvalidate();
367
368 // whats here?
369 String item_dump_pretty = NavitGraphics.CallbackGeoCalc(10, this.bubble_001.x * NavitGraphics.Global_dpi_factor, this.bubble_001.y * NavitGraphics.Global_dpi_factor);
370 try
371 {
372 String item_dump_pretty_parsed = "";
373 String[] item_dump_lines = item_dump_pretty.split("\n");
374 int jk = 0;
375 String sep = "";
376 for (jk = 0; jk < item_dump_lines.length; jk++)
377 {
378 if (item_dump_lines[jk].startsWith("+*TYPE*+:"))
379 {
380 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk].substring(9);
381 }
382 else if (item_dump_lines[jk].startsWith("flags="))
383 {
384
385 }
386 else if (item_dump_lines[jk].startsWith("maxspeed="))
387 {
388 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk];
389 }
390 else if (item_dump_lines[jk].startsWith("label="))
391 {
392 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk].substring(6);
393 }
394 else if (item_dump_lines[jk].startsWith("street_name="))
395 {
396 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk].substring(12);
397 }
398 else if (item_dump_lines[jk].startsWith("street_name_systematic="))
399 {
400 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk].substring(23);
401 }
402 else
403 {
404 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk];
405 }
406
407 if (jk == 0)
408 {
409 sep = "\n";
410 }
411 }
412
413 Navit.generic_alert_box.setMessage(item_dump_pretty_parsed).setPositiveButton(Navit.get_text("Ok"), new DialogInterface.OnClickListener()
414 {
415 public void onClick(DialogInterface dialog, int id)
416 {
417 // Handle Ok
418 }
419 }).create();
420 Navit.generic_alert_box.setCancelable(true);
421 Navit.generic_alert_box.setTitle(Navit.get_text("What's here")); // TRANS
422 Navit.generic_alert_box.show();
423 } 544 }
424 catch (Exception e)
425 {
426 e.printStackTrace();
427 }
428
429 this.hide_bubble();
430 this.postInvalidate();
431
432 return true;
433 } 545 }
434
435 } 546 }
436 }
437
438 if (action == MotionEvent.ACTION_DOWN)
439 {
440 //Log.e("NavitGraphics", "NavitAndroidOverlay -> onTouchEvent ACTION_DOWN");
441 if (this.follow_button_rect.contains(x, y))
442 {
443 if (NavitGraphics.in_map)
444 {
445 // toggle follow mode
446 Navit.toggle_follow_button();
447 //System.out.println("invalidate 004");
448 this.postInvalidate();
449 //NavitGraphics.NavitAOSDJava_.postInvalidate();
450 // consume the event
451 return true;
452 }
453 }
454 // else if ((!Navit.has_hw_menu_button) && (Navit.menu_button_rect_touch.contains(x, y)))
455 // {
456 // // open the options menu
457 // try
458 // {
459 // Message msg = Navit.Navit_progress_h.obtainMessage();
460 // Bundle b = new Bundle();
461 // msg.what = 18;
462 // msg.setData(b);
463 // Navit.Navit_progress_h.sendMessage(msg);
464 // }
465 // catch (Exception e)
466 // {
467 // e.printStackTrace();
468 // }
469 // }
470 else if (this.mapdrawing_button_rect.contains(x, y))
471 {
472 if (NavitGraphics.in_map)
473 {
474 try
475 {
476
477 if (Navit.PREF_show_2d3d_toggle)
478 {
479 // toggle "2d/3d"
480 if (Navit.PREF_show_3d_map)
481 {
482 // swtich to 2d mode
483 Navit.PREF_show_3d_map = false;
484 Navit.set_2d3d_mode_in_settings();
485 // redraw map
486 NavitGraphics.view_s.postInvalidate();
487 }
488 else
489 {
490 // swtich to 3d mode
491 Navit.PREF_show_3d_map = true;
492 Navit.set_2d3d_mode_in_settings();
493 // redraw map
494 NavitGraphics.view_s.postInvalidate();
495 }
496 }
497 else
498 {
499 // toggle "map on/off"
500
501 Message msg = new Message();
502 Bundle b = new Bundle();
503 if (NavitGraphics.MAP_DISPLAY_OFF)
504 {
505 NavitGraphics.MAP_DISPLAY_OFF = false;
506 b.putInt("Callback", 63);
507 }
508 else
509 {
510 NavitGraphics.MAP_DISPLAY_OFF = true;
511 b.putInt("Callback", 62);
512 }
513 msg.setData(b);
514 Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
515 // redraw map
516 Message msg2 = new Message();
517 Bundle b2 = new Bundle();
518 b2.putInt("Callback", 64);
519 msg2.setData(b2);
520 Navit.N_NavitGraphics.callback_handler.sendMessage(msg2);
521 // redraw map
522 NavitGraphics.view_s.postInvalidate();
523 //NavitGraphics.NavitAOSDJava_.postInvalidate();
524 }
525 }
526 catch (Exception e)
527 {
528 e.printStackTrace();
529 }
530 // consume the event
531 return true;
532 }
533 }
534 else if (this.zoomin_button_rect.contains(x, y))
535 {
536 if (NavitGraphics.in_map)
537 {
538 if (Navit.PREF_show_3d_map)
539 {
540 // if in 3d map -> toggle 3d angle
541 NavitGraphics.rotate_3d_map_angle++;
542 NavitGraphics.init_3d_mode();
543 // redraw map
544 NavitGraphics.view_s.postInvalidate();
545 }
546 else
547 {
548 // if in 2d map -> zoom in
549 NavitGraphics.wait_for_redraw_map = true;
550 //System.out.println("invalidate 005");
551 this.invalidate();
552 //System.out.println("wait_for_redraw_map=true o1");
553 //Log.e("NavitGraphics", "wait_for_redraw_map=true o1");
554 // zoom in
555 try
556 {
557 // NavitGraphics.CallbackMessageChannel(1, "");
558 Message msg = new Message();
559 Bundle b = new Bundle();
560 b.putInt("Callback", 1);
561 msg.setData(b);
562 Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
563 }
564 catch (Exception e)
565 {
566 e.printStackTrace();
567 }
568 }
569 // consume the event
570 return true;
571 }
572 }
573 else if (this.zoomout_button_rect.contains(x, y))
574 {
575 if (NavitGraphics.in_map)
576 {
577 if (Navit.PREF_show_3d_map)
578 {
579 // if in 3d map -> toggle 3d angle
580 NavitGraphics.rotate_3d_map_angle--;
581 NavitGraphics.init_3d_mode();
582 // redraw map
583 NavitGraphics.view_s.postInvalidate();
584 }
585 else
586 {
587 // if in 2d map -> zoom out
588 try
589 {
590 NavitGraphics.wait_for_redraw_map = true;
591 //System.out.println("invalidate 006");
592 this.invalidate();
593 //System.out.println("wait_for_redraw_map=true o2");
594 //Log.e("NavitGraphics", "wait_for_redraw_map=true o2");
595 // zoom out
596
597 // NavitGraphics.CallbackMessageChannel(2, "");
598 Message msg = new Message();
599 Bundle b = new Bundle();
600 b.putInt("Callback", 2);
601 msg.setData(b);
602 Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
603 }
604 catch (Exception e)
605 {
606 e.printStackTrace();
607 }
608 }
609 // consume the event
610 return true;
611 }
612 }
613 else if (this.voice_recog_rect.contains(x, y))
614 {
615 System.out.println("VOICE REC rect touched");
616 voice_rec_bar_visible = true;
617 voice_rec_bar_x = x;
618 voice_rec_bar_y = y;
619 this.postInvalidate();
620 }
621 else
622 {
623 try
624 {
625 if (overlay_draw_thread1 == null)
626 {
627 //overlay_draw_thread1 = new NavitGraphics.OverlayDrawThread();
628 //overlay_draw_thread1.start();
629 }
630 }
631 catch (Exception e)
632 {
633 //overlay_draw_thread1 = new NavitGraphics.OverlayDrawThread();
634 //overlay_draw_thread1.start();
635 }
636 }
637 }
638
639 // test if we touched the grey rectangle
640 //
641 // if ((x < 300) && (x > 10) && (y < 200) && (y > 10))
642 // {
643 // Log.e("Navit", "NavitAndroidOverlay -> onTouchEvent -> touch Rect!!");
644 // return true;
645 // }
646 // else
647 // {
648 // return false;
649 // }
650 547
651 // false -> we dont use this event, give it to other layers 548 // false -> we dont use this event, give it to other layers
652 return false; 549 return false;
653 } 550 }
654 551
679 draw_factor = 1.8f * Navit.metrics.densityDpi / NavitGraphics.Global_want_dpi_other; 576 draw_factor = 1.8f * Navit.metrics.densityDpi / NavitGraphics.Global_want_dpi_other;
680 } 577 }
681 578
682 int w_1 = (int) ((10f / 1.5f) * draw_factor); 579 int w_1 = (int) ((10f / 1.5f) * draw_factor);
683 int h_1 = (int) ((200f / 1.5f) * draw_factor); 580 int h_1 = (int) ((200f / 1.5f) * draw_factor);
684 this.follow_button_rect = new RectF(this.mCanvasWidth - Navit.follow_current.getWidth() - w_1, this.mCanvasHeight - Navit.follow_current.getHeight() - h_1, this.mCanvasWidth - w_1, this.mCanvasHeight - h_1); 581 // this.follow_button_rect = new RectF(this.mCanvasWidth - Navit.follow_current.getWidth() - w_1, this.mCanvasHeight - Navit.follow_current.getHeight() - h_1, this.mCanvasWidth - w_1, this.mCanvasHeight - h_1);
685 582
686 // rect to slide open voice recognition 583 // rect to slide open voice recognition
687 this.voice_recog_rect = new RectF(0, (this.mCanvasHeight / 2f) - 100 * draw_factor, 16 * draw_factor, (this.mCanvasHeight / 2f) + 100 * draw_factor); 584 // this.voice_recog_rect = new RectF(0, (this.mCanvasHeight / 2f) - 100 * draw_factor, 16 * draw_factor, (this.mCanvasHeight / 2f) + 100 * draw_factor);
688 this.voice_rec_bar_limit = this.mCanvasWidth / 2; 585 NavitAndroidOverlay.voice_rec_bar_limit = this.mCanvasWidth / 2;
689 586
690 /* 587 /*
691 * int w_2 = (int) ((0 / 1.5f) * draw_factor) + 5; 588 * int w_2 = (int) ((0 / 1.5f) * draw_factor) + 5;
692 * int h_2 = (int) ((0f / 1.5f) * draw_factor) + 5; 589 * int h_2 = (int) ((0f / 1.5f) * draw_factor) + 5;
693 * int h_button_zoom = Navit.zoomin.getHeight(); 590 * int h_button_zoom = Navit.zoomin.getHeight();
699 int w_2 = (int) ((0 / 1.5f) * draw_factor) + 5; 596 int w_2 = (int) ((0 / 1.5f) * draw_factor) + 5;
700 int h_2 = (int) ((70f / 1.5f) * draw_factor) + 5 + 25; 597 int h_2 = (int) ((70f / 1.5f) * draw_factor) + 5 + 25;
701 int h_button_zoom = Navit.zoomin.getHeight(); 598 int h_button_zoom = Navit.zoomin.getHeight();
702 zoomin_ltx = w_2; 599 zoomin_ltx = w_2;
703 zoomin_lty = h_2; 600 zoomin_lty = h_2;
704 this.zoomin_button_rect = new RectF(w_2, h_2, Navit.zoomin.getWidth() + w_2, h_button_zoom + h_2); 601 // this.zoomin_button_rect = new RectF(w_2, h_2, Navit.zoomin.getWidth() + w_2, h_button_zoom + h_2);
705 602
706 w_2 = (int) ((0 / 1.5f) * draw_factor) + 5; 603 w_2 = (int) ((0 / 1.5f) * draw_factor) + 5;
707 h_2 = (int) ((2 * 70f / 1.5f) * draw_factor) + 5 + 25 + 25; 604 h_2 = (int) ((2 * 70f / 1.5f) * draw_factor) + 5 + 25 + 25;
708 zoomout_ltx = w_2; 605 zoomout_ltx = w_2;
709 zoomout_lty = h_2; 606 zoomout_lty = h_2;
710 this.zoomout_button_rect = new RectF(w_2, h_2, Navit.zoomout.getWidth() + w_2, h_button_zoom + h_2); 607 // this.zoomout_button_rect = new RectF(w_2, h_2, Navit.zoomout.getWidth() + w_2, h_button_zoom + h_2);
711 608
712 int mapdrawing_width = (int) ((75f / 1.5f) * draw_factor); 609 int mapdrawing_width = (int) ((75f / 1.5f) * draw_factor);
713 int mapdrawing_height = (int) ((75f / 1.5f) * draw_factor); 610 int mapdrawing_height = (int) ((75f / 1.5f) * draw_factor);
714 w_2 = (int) ((this.mCanvasWidth - mapdrawing_width) - 5); 611 w_2 = (int) ((this.mCanvasWidth - mapdrawing_width) - 5);
715 h_2 = (int) ((70f / 1.5f) * draw_factor) + 5 + 25; 612 h_2 = (int) ((70f / 1.5f) * draw_factor) + 5 + 25;
716 mapdrawing_ltx = w_2; 613 mapdrawing_ltx = w_2;
717 mapdrawing_lty = h_2; 614 mapdrawing_lty = h_2;
718 this.mapdrawing_button_rect = new RectF(w_2, h_2, mapdrawing_width + w_2, mapdrawing_height + h_2); 615 // this.mapdrawing_button_rect = new RectF(w_2, h_2, mapdrawing_width + w_2, mapdrawing_height + h_2);
719 616
720 // on small screens (like the blackberry Q10) the follow button overlaps the 2d/3d button (mapdrawing button) 617 // on small screens (like the blackberry Q10) the follow button overlaps the 2d/3d button (mapdrawing button)
721 // check and then move 2d/3d button to the left 618 // check and then move 2d/3d button to the left
722 boolean must_move_2d3d_button = false; 619 // boolean must_move_2d3d_button = false;
723 if (mapdrawing_button_rect.contains(follow_button_rect.left, follow_button_rect.top)) 620 // if (mapdrawing_button_rect.contains(follow_button_rect.left, follow_button_rect.top))
724 { 621 // {
725 must_move_2d3d_button = true; 622 // must_move_2d3d_button = true;
726 } 623 // }
727 else if (mapdrawing_button_rect.contains(follow_button_rect.right, follow_button_rect.top)) 624 // else if (mapdrawing_button_rect.contains(follow_button_rect.right, follow_button_rect.top))
728 { 625 // {
729 must_move_2d3d_button = true; 626 // must_move_2d3d_button = true;
730 } 627 // }
731 else if (mapdrawing_button_rect.contains(follow_button_rect.left, follow_button_rect.bottom)) 628 // else if (mapdrawing_button_rect.contains(follow_button_rect.left, follow_button_rect.bottom))
732 { 629 // {
733 must_move_2d3d_button = true; 630 // must_move_2d3d_button = true;
734 } 631 // }
735 else if (mapdrawing_button_rect.contains(follow_button_rect.left, follow_button_rect.bottom)) 632 // else if (mapdrawing_button_rect.contains(follow_button_rect.left, follow_button_rect.bottom))
736 { 633 // {
737 must_move_2d3d_button = true; 634 // must_move_2d3d_button = true;
738 } 635 // }
739 636 //
740 if (must_move_2d3d_button) 637 // if (must_move_2d3d_button)
741 { 638 // {
742 // move to left of follow button 639 // // move to left of follow button
743 this.mapdrawing_button_rect = new RectF(w_2 - (this.mCanvasWidth - follow_button_rect.left), h_2, mapdrawing_width + w_2 - (this.mCanvasWidth - follow_button_rect.left), mapdrawing_height + h_2); 640 // this.mapdrawing_button_rect = new RectF(w_2 - (this.mCanvasWidth - follow_button_rect.left), h_2, mapdrawing_width + w_2 - (this.mCanvasWidth - follow_button_rect.left), mapdrawing_height + h_2);
744 } 641 // }
745 642
746 // put menu button below "2D/3D" button 643 // put menu button below "2D/3D" button
747 if (Navit.metrics.densityDpi >= 320) // && (Navit.PREF_shrink_on_high_dpi)) 644 if (Navit.metrics.densityDpi >= 320) // && (Navit.PREF_shrink_on_high_dpi))
748 { 645 {
749 Navit.menu_button_rect = new RectF(this.mCanvasWidth - 10 - Navit.menu_button.getWidth(), 10 + mapdrawing_height + h_2 + 5, this.mCanvasWidth - 10, Navit.menu_button.getHeight() + 10 + mapdrawing_height + h_2 + 5); 646 Navit.menu_button_rect = new RectF(this.mCanvasWidth - 10 - Navit.menu_button.getWidth(), 10 + mapdrawing_height + h_2 + 5, this.mCanvasWidth - 10, Navit.menu_button.getHeight() + 10 + mapdrawing_height + h_2 + 5);
841 } 738 }
842 739
843 return lanes_kind_count; 740 return lanes_kind_count;
844 } 741 }
845 742
743 @SuppressLint("NewApi")
846 public void onDraw(Canvas c) 744 public void onDraw(Canvas c)
847 { 745 {
848 // ************!!!!!!!!!!!!! optimze me !!!!!!!!!!!*************
849 // ************!!!!!!!!!!!!! optimze me !!!!!!!!!!!*************
850 // ************!!!!!!!!!!!!! optimze me !!!!!!!!!!!*************
851 // ************!!!!!!!!!!!!! optimze me !!!!!!!!!!!*************
852 // ************!!!!!!!!!!!!! optimze me !!!!!!!!!!!*************
853 // ************!!!!!!!!!!!!! optimze me !!!!!!!!!!!*************
854 746
855 // System.out.println("XYZ:NavitAndroidOverlay -> onDraw"); 747 if (measure_mode)
856
857 // if (2 == 1 + 1)
858 // {
859 // return;
860 // }
861
862 //Log.e("NavitGraphics", "NavitAndroidOverlay -> onDraw");
863 //System.out.println("VOICE REC:NavitAndroidOverlay -> onDraw");
864
865 try
866 {
867 if (NavitAndroidOverlay.voice_rec_bar_visible)
868 { 748 {
869 // System.out.println("VOICE REC:NavitAndroidOverlay -> onDraw"); 749 if (measure_valid)
870 // System.out.println("XYZ:NavitAndroidOverlay -> onDraw");
871 c.drawBitmap(Navit.long_green_arrow, voice_rec_bar_x - Navit.long_green_arrow.getWidth() + (30 * draw_factor), (mCanvasHeight / 2), null);
872 }
873 else if (NavitAndroidOverlay.voice_rec_bar_visible2)
874 {
875 // System.out.println("VOICE REC:NavitAndroidOverlay -> onDraw");
876 // System.out.println("XYZ:NavitAndroidOverlay -> onDraw");
877 c.drawBitmap(Navit.long_green_arrow, voice_rec_bar_x - Navit.long_green_arrow.getWidth() + (30 * draw_factor), (mCanvasHeight / 2), null);
878 }
879
880 }
881 catch (Exception e)
882 { 750 {
883 e.printStackTrace(); 751 // draw the line
752 c.drawLine(measure_1_x, measure_1_y, measure_2_x, measure_2_y, paint_measure);
753 c.drawCircle(measure_1_x, measure_1_y, measure_point_radius, paint_measure);
754 c.drawCircle(measure_2_x, measure_2_y, measure_point_radius, paint_measure);
884 } 755 }
885 756
886 //Paint pp = new Paint(); 757 return;
887 //pp.setColor(Color.RED); 758 }
888 //pp.setStrokeWidth(10); 759
889 //c.drawRect(voice_recog_rect, pp); 760 if (ZANaviDebugReceiver.is_replaying)
761 {
762 c.drawRect(40, mCanvasHeight / 5, 40 + NavitGraphics.dp_to_px(50), (mCanvasHeight / 5) + NavitGraphics.dp_to_px(50), paint_replay);
763 c.drawRect(40 + NavitGraphics.dp_to_px(80), mCanvasHeight / 5, 40 + NavitGraphics.dp_to_px(50) + NavitGraphics.dp_to_px(80), (mCanvasHeight / 5) + NavitGraphics.dp_to_px(50), paint_rewind_small);
764 }
890 765
891 if (this.draw_bubble) 766 if (this.draw_bubble)
892 { 767 {
893 if ((System.currentTimeMillis() - this.bubble_showing_since) > bubble_max_showing_timespan) 768 if ((System.currentTimeMillis() - this.bubble_showing_since) > bubble_max_showing_timespan)
894 { 769 {
895 // bubble has been showing too log, hide it 770 // bubble has been showing too log, hide it
896 this.hide_bubble(); 771 this.hide_bubble();
897
898 // next lines are a hack, without it screen will not get updated anymore!
899 // next lines are a hack, without it screen will not get updated anymore!
900 // down
901 // Message msg = new Message();
902 // Bundle b = new Bundle();
903 // b.putInt("Callback", 21);
904 // b.putInt("x", 1);
905 // b.putInt("y", 1);
906 // msg.setData(b);
907 // Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
908 //
909 // // move
910 // msg = new Message();
911 // b = new Bundle();
912 // b.putInt("Callback", 23);
913 // b.putInt("x", 1 + 10);
914 // b.putInt("y", 1);
915 // msg.setData(b);
916 // Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
917 //
918 // // move
919 // msg = new Message();
920 // b = new Bundle();
921 // b.putInt("Callback", 23);
922 // b.putInt("x", 1 - 10);
923 // b.putInt("y", 1);
924 // msg.setData(b);
925 // Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
926 //
927 // // up
928 // msg = new Message();
929 // b = new Bundle();
930 // b.putInt("Callback", 22);
931 // b.putInt("x", 1);
932 // b.putInt("y", 1);
933 // msg.setData(b);
934 // Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
935 // next lines are a hack, without it screen will not get updated anymore!
936 // next lines are a hack, without it screen will not get updated anymore!
937 } 772 }
938 } 773 }
939 774
940 if (this.draw_bubble) 775 if (this.draw_bubble)
941 { 776 {
942 //Log.e("Navit", "NavitAndroidOverlay -> onDraw -> bubble"); 777 if (draw_bubble_first)
943
944 int dx = (int) ((20 / 1.5f) * draw_factor);
945 int dy = (int) ((-100 / 1.5f) * draw_factor);
946 Paint bubble_paint = new Paint(0);
947
948 int bubble_size_x = (int) ((150 / 1.5f) * draw_factor);
949 int bubble_size_y = (int) ((60 / 1.5f) * draw_factor);
950
951 // yellow-ish funny lines
952 int lx = (int) ((15 / 1.5f) * draw_factor);
953 int ly = (int) ((15 / 1.5f) * draw_factor);
954 bubble_paint.setStyle(Style.FILL);
955 bubble_paint.setAntiAlias(true);
956 bubble_paint.setStrokeWidth(8 / 1.5f * draw_factor);
957 bubble_paint.setColor(Color.parseColor("#FFF8C6"));
958 c.drawLine(this.bubble_001.x + dx, this.bubble_001.y + dy + bubble_size_y - ly, this.bubble_001.x, this.bubble_001.y, bubble_paint);
959 c.drawLine(this.bubble_001.x + dx + lx, this.bubble_001.y + dy + bubble_size_y, this.bubble_001.x, this.bubble_001.y, bubble_paint);
960
961 // draw black funny lines to target
962 bubble_paint.setStyle(Style.STROKE);
963 bubble_paint.setAntiAlias(true);
964 bubble_paint.setStrokeWidth(3);
965 bubble_paint.setColor(Color.parseColor("#000000"));
966 c.drawLine(this.bubble_001.x + dx, this.bubble_001.y + dy + bubble_size_y - ly, this.bubble_001.x, this.bubble_001.y, bubble_paint);
967 c.drawLine(this.bubble_001.x + dx + lx, this.bubble_001.y + dy + bubble_size_y, this.bubble_001.x, this.bubble_001.y, bubble_paint);
968
969 // filled rect yellow-ish (left side) (fill it all)
970 bubble_paint.setStyle(Style.FILL);
971 bubble_paint.setStrokeWidth(0);
972 bubble_paint.setAntiAlias(false);
973 bubble_paint.setColor(Color.parseColor("#FFF8C6"));
974 RectF box_rect = new RectF(this.bubble_001.x + dx, this.bubble_001.y + dy, this.bubble_001.x + bubble_size_x + dx, this.bubble_001.y + bubble_size_y + dy);
975 int rx = (int) (20 / 1.5f * draw_factor);
976 int ry = (int) (20 / 1.5f * draw_factor);
977 c.drawRoundRect(box_rect, rx, ry, bubble_paint);
978
979 // filled rect green-ish (right side)
980 bubble_paint.setStyle(Style.FILL);
981 bubble_paint.setStrokeWidth(0);
982 bubble_paint.setAntiAlias(false);
983 bubble_paint.setColor(Color.parseColor("#74DF00"));
984 RectF box_rect_right_half = new RectF(this.bubble_001.x + dx + (bubble_size_x / 2) - rx, this.bubble_001.y + dy, this.bubble_001.x + bubble_size_x + dx, this.bubble_001.y + bubble_size_y + dy);
985 c.drawRoundRect(box_rect_right_half, rx, ry, bubble_paint);
986
987 // correct the overlap
988 bubble_paint.setColor(Color.parseColor("#FFF8C6"));
989 RectF box_rect_left_half_correction = new RectF(this.bubble_001.x + dx + (bubble_size_x / 2) - rx - 1, this.bubble_001.y + dy, this.bubble_001.x + dx + (bubble_size_x / 2), this.bubble_001.y + bubble_size_y + dy);
990 c.drawRect(box_rect_left_half_correction, bubble_paint);
991
992 // black outlined rect
993 bubble_paint.setStyle(Style.STROKE);
994 bubble_paint.setStrokeWidth(3);
995 bubble_paint.setAntiAlias(true);
996 bubble_paint.setColor(Color.parseColor("#000000"));
997 c.drawRoundRect(box_rect, rx, ry, bubble_paint);
998
999 // black separator lines (outer)
1000 bubble_paint.setStyle(Style.STROKE);
1001 bubble_paint.setStrokeWidth(8);
1002 bubble_paint.setAntiAlias(true);
1003 bubble_paint.setColor(Color.parseColor("#000000"));
1004 c.drawLine(box_rect.left + (box_rect.right - box_rect.left) / 2, box_rect.top, box_rect.left + (box_rect.right - box_rect.left) / 2, box_rect.bottom, bubble_paint);
1005
1006 // black separator lines (inner)
1007 bubble_paint.setStyle(Style.STROKE);
1008 bubble_paint.setStrokeWidth(2);
1009 bubble_paint.setAntiAlias(true);
1010 bubble_paint.setColor(Color.parseColor("#D8D8D8"));
1011 c.drawLine(box_rect.left + (box_rect.right - box_rect.left) / 2, box_rect.top, box_rect.left + (box_rect.right - box_rect.left) / 2, box_rect.bottom, bubble_paint);
1012
1013 if (NavitAndroidOverlay.confirmed_bubble)
1014 {
1015 // red outline (for confirmed bubble)
1016 bubble_paint.setStyle(Style.STROKE);
1017 bubble_paint.setStrokeWidth(5);
1018 bubble_paint.setAntiAlias(true);
1019 bubble_paint.setColor(Color.parseColor("#EC294D"));
1020 c.drawRoundRect(box_rect, rx, ry, bubble_paint);
1021 }
1022
1023 int inner_dx = (int) (30 / 1.5f * draw_factor);
1024 int inner_dx_left = (int) (30 / 1.5f * draw_factor);
1025 int inner_dx_right = (int) (30 / 1.5f * draw_factor) + (bubble_size_x / 2);
1026 int inner_dy = (int) (36 / 1.5f * draw_factor);
1027 bubble_paint.setAntiAlias(true);
1028 bubble_paint.setStyle(Style.FILL);
1029 bubble_paint.setTextSize((int) (20 / 1.5f * draw_factor));
1030 bubble_paint.setStrokeWidth(3);
1031 bubble_paint.setColor(Color.parseColor("#3b3131"));
1032 // c.drawText(Navit.get_text("drive here"), this.bubble_001.x + dx + inner_dx, this.bubble_001.y + dy + inner_dy, bubble_paint);
1033 c.drawText("X", this.bubble_001.x + dx + inner_dx_left, this.bubble_001.y + dy + inner_dy, bubble_paint);
1034 c.drawText("?", this.bubble_001.x + dx + inner_dx_right, this.bubble_001.y + dy + inner_dy, bubble_paint);
1035
1036 }
1037
1038 if (NavitGraphics.in_map)
1039 {
1040 // draw follow
1041 if (Navit.follow_current != null)
1042 {
1043 c.drawBitmap(Navit.follow_current, this.follow_button_rect.left, this.follow_button_rect.top, null);
1044 }
1045 }
1046
1047 if (NavitGraphics.in_map)
1048 {
1049 c.drawBitmap(Navit.zoomin, zoomin_ltx, zoomin_lty, null);
1050 c.drawBitmap(Navit.zoomout, zoomout_ltx, zoomout_lty, null);
1051 Paint paint = new Paint();
1052 paint.setAntiAlias(true);
1053 paint.setStyle(Style.STROKE);
1054 paint.setColor(Color.GRAY);
1055 paint.setAlpha(30);
1056 paint.setStrokeWidth(2);
1057 c.drawRoundRect(this.zoomin_button_rect, 10, 10, paint);
1058 //paint.setStyle(Style.STROKE);
1059 //paint.setColor(Color.GRAY);
1060 //paint.setAlpha(30);
1061 c.drawRoundRect(this.zoomout_button_rect, 10, 10, paint);
1062
1063 // draw rectanlge around "2d/3d" or "map on/off" toggle button
1064 c.drawRoundRect(this.mapdrawing_button_rect, 10, 10, paint);
1065
1066 if (Navit.PREF_show_2d3d_toggle)
1067 {
1068 // draw "2d/3d" toggle button
1069 if (draw_factor == 0.7f) // ldpi
1070 { 778 {
1071 paint.setStrokeWidth(1); 779 try
1072 paint.setTextSize(12);
1073 paint.setAlpha(80);
1074 c.drawText("2D", this.mapdrawing_button_rect.left + 15, this.mapdrawing_button_rect.top + 15, paint);
1075 c.drawText("3D", this.mapdrawing_button_rect.left + 8, this.mapdrawing_button_rect.bottom - 6, paint);
1076 }
1077 else if (draw_factor == 1.0f) // mdpi
1078 {
1079 paint.setStrokeWidth(1);
1080 paint.setTextSize(18);
1081 paint.setAlpha(80);
1082 c.drawText("2D", this.mapdrawing_button_rect.left + 20, this.mapdrawing_button_rect.top + 20, paint);
1083 c.drawText("3D", this.mapdrawing_button_rect.left + 8, this.mapdrawing_button_rect.bottom - 8, paint);
1084 }
1085 else
1086 // draw_factor == 1.5f // hdpi
1087 {
1088 paint.setStrokeWidth(1);
1089 paint.setStyle(Style.FILL_AND_STROKE);
1090 paint.setTextSize(28 * draw_factor / 1.5f);
1091 paint.setAlpha(80);
1092 c.drawText("2D", this.mapdrawing_button_rect.left + (30 * draw_factor / 1.5f), this.mapdrawing_button_rect.top + (30 * draw_factor / 1.5f), paint);
1093 c.drawText("3D", this.mapdrawing_button_rect.left + 10, this.mapdrawing_button_rect.bottom - 10, paint);
1094 }
1095 }
1096 else
1097 { 780 {
1098 // draw "map on/off" toggle button 781 System.out.println("BB:09");
1099 if ((draw_factor == 0.7f) || (draw_factor == 1.0f)) 782 msg_dd = Navit.Navit_progress_h.obtainMessage();
1100 { 783 msg_dd.what = 36;
1101 paint.setStrokeWidth(6); 784 msg_dd.setData(b_dd);
1102 } 785 Navit.Navit_progress_h.sendMessage(msg_dd);
1103 else
1104 {
1105 paint.setStrokeWidth(10);
1106 }
1107 paint.setAlpha(80);
1108 c.drawLine(this.mapdrawing_button_rect.left + 10, this.mapdrawing_button_rect.bottom - 10, this.mapdrawing_button_rect.right - 10, this.mapdrawing_button_rect.top + 10, paint);
1109 } 786 }
1110 787 catch (Exception e)
1111 // if (!Navit.has_hw_menu_button)
1112 // { 788 {
1113 // // draw emulated menu button 789 e.printStackTrace();
1114 // c.drawBitmap(Navit.menu_button, Navit.menu_button_rect.left, Navit.menu_button_rect.top, null);
1115 // // Paint px = new Paint();
1116 // // px.setColor(Color.RED);
1117 // // px.setStyle(Style.STROKE);
1118 // // c.drawRect(Navit.menu_button_rect_touch, px);
1119 // } 790 }
791
792 try
793 {
794 System.out.println("BB:10");
795 msg_dd = Navit.Navit_progress_h.obtainMessage();
796 msg_dd.what = 37;
797 msg_dd.setData(b_dd);
798 Navit.Navit_progress_h.sendMessage(msg_dd);
799 }
800 catch (Exception e)
801 {
802 e.printStackTrace();
803 }
804
805 draw_bubble_first = false;
1120 } 806 }
1121
1122 //if (NavitGraphics.in_map)
1123 //{
1124 //Log.e("NavitGraphics", "NavitAndroidOverlay -> draw2");
1125 //if (NavitGraphics.wait_for_redraw_map)
1126 //{
1127 // //Log.e("NavitGraphics", "NavitAndroidOverlay -> draw wait rect");
1128 // Paint paint = new Paint(0);
1129 // paint.setAntiAlias(true);
1130 // paint.setStyle(Style.FILL);
1131 // paint.setColor(Color.LTGRAY);
1132 // paint.setAlpha(70);
1133 //
1134 // RectF r1 = new RectF(20 * draw_factor, 20 * draw_factor, this.mCanvasWidth - 20 * draw_factor, this.mCanvasHeight - 20 * draw_factor);
1135 // c.drawRoundRect(r1, 20, 20, paint);
1136 // paint.setColor(Color.parseColor("#888888"));
1137 // paint.setAlpha(230);
1138 // paint.setTextAlign(Paint.Align.CENTER);
1139 // paint.setStrokeWidth(2);
1140 // paint.setTextSize(30);
1141 // c.drawText(Navit.get_text("wait ..."), this.mCanvasWidth / 2, this.mCanvasHeight / 2, paint); //TRANS
1142 //} 807 }
1143 //}
1144 808
1145 if (Navit.PREF_item_dump) 809 if (Navit.p.PREF_item_dump)
1146 { 810 {
1147 if (!Navit.debug_item_dump.equals("")) 811 if (!Navit.debug_item_dump.equals(""))
1148 { 812 {
1149 Paint paint = new Paint(0); 813 Paint paint = new Paint(0);
1150 paint.setAntiAlias(true); 814 paint.setAntiAlias(true);
1196 } 860 }
1197 } 861 }
1198 } 862 }
1199 } 863 }
1200 864
1201 // quick dirty lanes and destination display hack ! -----------------------------------
1202 // quick dirty lanes and destination display hack ! -----------------------------------
1203 // quick dirty lanes and destination display hack ! -----------------------------------
1204 if ((Navit.lanes_text == null) || (Navit.lanes_text.equals("")))
1205 {
1206 if (Navit.seg_len < 200)
1207 {
1208 // if we dont have lane information now, use the lane information of the next segment
1209 // but only if the current segment is not too long (in meters) !!
1210 Navit.lanes_num = Navit.lanes_num1;
1211 Navit.lanes_num_forward = Navit.lanes_num_forward1;
1212 Navit.lanes_text = Navit.lanes_text1;
1213 }
1214 } 865 }
1215 866
1216 if (Navit.PREF_lane_assist) 867 public static void cleanup_measure_mode()
1217 { 868 {
1218 if (Navit.lanes_text != null) 869 measure_valid = false;
1219 { 870 measure_result_meters = -1;
1220 if (!Navit.lanes_text.equals("")) 871 NavitGraphics.NavitAOverlay_s.postInvalidate();
1221 {
1222
1223 Paint paint = new Paint(0);
1224 // paint.setAntiAlias(true);
1225 // paint.setColor(Color.BLUE);
1226 // paint.setStyle(Style.FILL);
1227 // c.drawRect(100, 340, 1000, 440, paint);
1228 // paint.setColor(Color.WHITE);
1229 // paint.setStyle(Style.FILL_AND_STROKE);
1230 // paint.setStrokeWidth(2);
1231 // paint.setTextSize(50);
1232 // c.drawText(Navit.lanes_num + ":" + Navit.lanes_num_forward + ":" + Navit.lanes_text, 120, 400, paint);
1233
1234 String lanes_split[] = Navit.lanes_text.split("\\|");
1235 int parsed_num_lanes = lanes_split.length;
1236
1237 int lanes_choices_count = 0;
1238 int lanes_choices_route = -1;
1239 int[] lanes_choices_split_int = null;
1240 String[] lanes_choices_split = null;
1241 int highlight_kind = -1;
1242
1243 int[] lanes_kind = new int[10];
1244 int lanes_kind_count = 0;
1245
1246 // only 1 choice ---------------------
1247 if (Navit.lane_choices != null)
1248 {
1249 if (!Navit.lane_choices.equals(""))
1250 {
1251 lanes_choices_split = Navit.lane_choices.split("\\|");
1252 lanes_choices_count = lanes_choices_split.length;
1253 int tmp_lanes_kind_count = get_lanes_kind_count(parsed_num_lanes, lanes_split);
1254
1255 if ((lanes_choices_count == 1) && (tmp_lanes_kind_count > 1))
1256 {
1257 // we only have 1 choice to drive to (means: no turns here)
1258 // so use info from next segment
1259 Navit.lane_choices = Navit.lane_choices1;
1260 }
1261 }
1262 }
1263 // only 1 choice ---------------------
1264
1265 // only 1 choice (again) ---------------------
1266 if (Navit.lane_choices != null)
1267 {
1268 if (!Navit.lane_choices.equals(""))
1269 {
1270 lanes_choices_split = Navit.lane_choices.split("\\|");
1271 lanes_choices_count = lanes_choices_split.length;
1272 int tmp_lanes_kind_count = get_lanes_kind_count(parsed_num_lanes, lanes_split);
1273
1274 if ((lanes_choices_count == 1) && (tmp_lanes_kind_count > 1))
1275 {
1276 // we only have 1 choice to drive to (means: no turns here)
1277 // so use info from next next segment
1278 Navit.lane_choices = Navit.lane_choices2;
1279 }
1280 }
1281 }
1282 // only 1 choice (again) ---------------------
1283
1284 // sort and check lane choice -------------------------------------
1285 if (Navit.lane_choices != null)
1286 {
1287 if (!Navit.lane_choices.equals(""))
1288 {
1289
1290 lanes_choices_split = Navit.lane_choices.split("\\|");
1291 lanes_choices_count = lanes_choices_split.length;
1292 lanes_choices_route = -1;
1293 lanes_choices_split_int = new int[lanes_choices_split.length];
1294
1295 //System.out.println("SORTED:---orig---=" + Navit.lane_choices);
1296
1297 if (lanes_choices_count > 1)
1298 {
1299 // find route lane
1300 int kk = 0;
1301 for (kk = 0; kk < lanes_choices_count; kk++)
1302 {
1303 // System.out.println("SORTED:kk=" + kk + " lcs length=" + lanes_choices_split.length);
1304
1305 if (lanes_choices_split[kk].startsWith("x"))
1306 {
1307 lanes_choices_route = kk;
1308 //System.out.println("SORTED:route lane=" + lanes_choices_route);
1309 lanes_choices_split_int[kk] = Integer.parseInt(lanes_choices_split[kk].substring(1));
1310 //System.out.println("SORTED:res1=" + lanes_choices_split_int[kk] + " " + lanes_choices_split[kk].substring(1) + " " + lanes_choices_split[kk]);
1311 }
1312 else
1313 {
1314 lanes_choices_split_int[kk] = Integer.parseInt(lanes_choices_split[kk]);
1315 //System.out.println("SORTED:res2=" + lanes_choices_split_int[kk]);
1316 }
1317 }
1318
1319 // sort entries (remember to also move the found "route" lane!!)
1320 kk = 0;
1321 int ll = 0;
1322 int temp;
1323 int max;
1324 for (kk = 1; kk < lanes_choices_count; kk++)
1325 {
1326 //System.out.println("SORTED:loop1=" + kk);
1327
1328 temp = lanes_choices_split_int[kk - 1];
1329 max = lanes_choices_split_int[kk - 1];
1330 for (ll = kk; ll < lanes_choices_count; ll++)
1331 {
1332 //System.out.println("SORTED:loop2=" + ll + " temp=" + temp + " max=" + max);
1333
1334 if (lanes_choices_split_int[ll] > max)
1335 {
1336 if (lanes_choices_route == ll)
1337 {
1338 // move the found "route" lane
1339 lanes_choices_route = kk - 1;
1340 //System.out.println("SORTED:move route lane1=" + ll + " -> " + (kk - 1));
1341 }
1342 else if (lanes_choices_route == kk - 1)
1343 {
1344 // move the found "route" lane
1345 lanes_choices_route = ll;
1346 //System.out.println("SORTED:move route lane2=" + (kk - 1) + " -> " + ll);
1347 }
1348
1349 temp = lanes_choices_split_int[ll];
1350 lanes_choices_split_int[ll] = max;
1351 lanes_choices_split_int[kk - 1] = temp;
1352 }
1353 }
1354 }
1355
1356 // sorted:
1357 //for (kk = 0; kk < lanes_choices_count; kk++)
1358 //{
1359 // System.out.println("SORTED:k=" + kk + " v=" + lanes_choices_split_int[kk]);
1360 //}
1361 //System.out.println("SORTED:Route=" + lanes_choices_route);
1362
1363 }
1364 else if (lanes_choices_count == 1)
1365 {
1366 if (lanes_choices_split[0].startsWith("x"))
1367 {
1368 lanes_choices_route = 0;
1369 lanes_choices_split_int[0] = Integer.parseInt(lanes_choices_split[0].substring(1));
1370 }
1371 else
1372 {
1373 lanes_choices_split_int[0] = Integer.parseInt(lanes_choices_split[0]);
1374 }
1375 }
1376
1377 Paint paint2 = new Paint(0);
1378 // paint2.setAntiAlias(true);
1379 // paint2.setColor(Color.BLUE);
1380 // paint2.setStyle(Style.FILL);
1381 // c.drawRect(100, 340, 1000, 440, paint2);
1382 // paint2.setColor(Color.WHITE);
1383 // paint2.setStyle(Style.FILL_AND_STROKE);
1384 // paint2.setStrokeWidth(2);
1385 // paint2.setTextSize(50);
1386 // c.drawText(Navit.lane_choices, 120, 400, paint2);
1387
1388 final int num_of_kinds = 6;
1389 lanes_kind = new int[num_of_kinds];
1390 lanes_kind_count = 0;
1391
1392 int k = 0;
1393 for (k = 0; k < num_of_kinds; k++)
1394 {
1395 lanes_kind[k] = 0; // reset all
1396 }
1397
1398 int j = 0;
1399 for (j = 0; j < parsed_num_lanes; j++)
1400 {
1401 String lanes_split_sub[] = lanes_split[j].split(";");
1402 int parsed_num_lanes_sub = lanes_split_sub.length;
1403
1404 k = 0;
1405 String single_arrow = "";
1406 for (k = 0; k < parsed_num_lanes_sub; k++)
1407 {
1408 single_arrow = lanes_split_sub[k].replaceAll("\\s", "");
1409
1410 // none 3
1411 // through 3
1412 // left 1
1413 // right 5
1414 // slight_left 2
1415 // slight_right 4
1416 // sharp_left 1
1417 // sharp_right 5
1418 // mergeto_left -
1419 // mergeto_right -
1420 // merge_to_left -
1421 // merge_to_right -
1422
1423 if (single_arrow.equalsIgnoreCase("sharp_left"))
1424 {
1425 lanes_kind[1] = 1;
1426 }
1427 else if (single_arrow.equalsIgnoreCase("sharp_right"))
1428 {
1429 lanes_kind[5] = 1;
1430 }
1431 else if (single_arrow.equalsIgnoreCase("none"))
1432 {
1433 lanes_kind[3] = 1;
1434 }
1435 else if (single_arrow.equalsIgnoreCase("through"))
1436 {
1437 lanes_kind[3] = 1;
1438 }
1439 else if (single_arrow.equalsIgnoreCase("left"))
1440 {
1441 lanes_kind[1] = 1;
1442 }
1443 else if (single_arrow.equalsIgnoreCase("right"))
1444 {
1445 lanes_kind[5] = 1;
1446 }
1447 else if (single_arrow.equalsIgnoreCase("slight_left"))
1448 {
1449 lanes_kind[2] = 1;
1450 }
1451 else if (single_arrow.equalsIgnoreCase("slight_right"))
1452 {
1453 lanes_kind[4] = 1;
1454 }
1455
1456 }
1457 }
1458
1459 lanes_kind_count = 0;
1460 for (k = 0; k < num_of_kinds; k++)
1461 {
1462 if (lanes_kind[k] == 1)
1463 {
1464 //System.out.println("SORTED:lanes_kind_count=" + lanes_kind_count + " lanes_choices_route=" + lanes_choices_route);
1465 if (lanes_kind_count == lanes_choices_route)
1466 {
1467 highlight_kind = k;
1468 //System.out.println("SORTED:highlight_kind=" + highlight_kind);
1469 }
1470 lanes_kind_count++;
1471 //System.out.println("SORTED:lanes_kind:" + k + "=" + lanes_kind[k]);
1472 }
1473 }
1474 //System.out.println("SORTED:lanes_kind_count=" + lanes_kind_count);
1475
1476 }
1477
1478 }
1479 // sort and check lane choice -------------------------------------
1480
1481 // -------- START POINT ----------
1482 // -------- START POINT ----------
1483 int xx1 = 0;
1484 int yy1 = 750;
1485 int xx1_start = xx1;
1486 int yy1_start = yy1;
1487 float fx_factor = 1080;
1488 float fy_factor = 1701;
1489
1490 // calc resize factor:
1491 float fx_ = fx_factor / (float) NavitGraphics.mCanvasWidth;
1492 float fy_ = fy_factor / (float) NavitGraphics.mCanvasHeight;
1493 float final_factor = 1.0f / fx_;
1494 if (fy_ > fx_)
1495 {
1496 final_factor = 1.0f / fy_;
1497 }
1498 float final_translator = (float) yy1_start * final_factor;
1499 float final_translator_x = 170.0f * ((float) NavitGraphics.mCanvasWidth / fx_factor);
1500
1501 //System.out.println("SORTED:tran: " + fx_factor + " " + NavitGraphics.mCanvasWidth + " " + final_translator_x);
1502
1503 lanes_transMatrix.reset();
1504 if (NavitGraphics.mCanvasWidth > fx_factor)
1505 {
1506 lanes_transMatrix.setTranslate((final_translator_x) - 170.0f, final_translator - (float) yy1_start);
1507 }
1508 else
1509 {
1510 lanes_transMatrix.setTranslate(0.0f, final_translator - (float) yy1_start);
1511 }
1512 //System.out.println("SORTED:tran: x=" + NavitGraphics.mCanvasWidth + " y=" + NavitGraphics.mCanvasHeight + " " + (final_translator - (float) yy1_start) + " f=" + final_factor);
1513 // -------- START POINT ----------
1514 // -------- START POINT ----------
1515
1516 boolean highlight_lane = false;
1517 if (lanes_kind_count == lanes_choices_count)
1518 {
1519 highlight_lane = true;
1520 //System.out.println("SORTED:highlight_lane=" + highlight_lane);
1521 }
1522
1523 if (parsed_num_lanes == 3)
1524 {
1525 xx1 = xx1 + (170 / 2) * 2;
1526 }
1527 else if (parsed_num_lanes == 2)
1528 {
1529 xx1 = xx1 + (170 / 2) * 3;
1530 }
1531 else if (parsed_num_lanes == 1)
1532 {
1533 xx1 = xx1 + (170 / 2) * 4;
1534 }
1535
1536 int j = 0;
1537 for (j = 0; j < parsed_num_lanes; j++)
1538 {
1539
1540 // move to next lane (move to right)
1541 xx1 = xx1 + 170;
1542
1543 String lanes_split_sub[] = lanes_split[j].split(";");
1544 int parsed_num_lanes_sub = lanes_split_sub.length;
1545
1546 int k = 0;
1547 String single_arrow = "";
1548 for (k = 0; k < parsed_num_lanes_sub; k++)
1549 {
1550
1551 single_arrow = lanes_split_sub[k].replaceAll("\\s", "");
1552
1553 // dirty correction hack !! ------------------
1554 // dirty correction hack !! ------------------
1555 // if (single_arrow.equalsIgnoreCase("sharp_right"))
1556 // {
1557 // single_arrow = "right";
1558 // }
1559 // else if (single_arrow.equalsIgnoreCase("sharp_left"))
1560 // {
1561 // single_arrow = "left";
1562 // }
1563 if (single_arrow.equalsIgnoreCase("merge_to_left"))
1564 {
1565 single_arrow = "mergeto_left";
1566 }
1567 else if (single_arrow.equalsIgnoreCase("merge_to_right"))
1568 {
1569 single_arrow = "mergeto_right";
1570 }
1571 // dirty correction hack !! ------------------
1572 // dirty correction hack !! ------------------
1573
1574 // ---------===================---------------
1575 // ---------===================---------------
1576 // ---------===================---------------
1577
1578 pathForTurn.reset();
1579 int ha = 72;
1580 int wa = 72;
1581
1582 int th = 12 * 3; // (12) thickness
1583 // pathForTurn.moveTo(wa / 2, ha - 1);
1584
1585 pathForTurn.moveTo(xx1, yy1);
1586
1587 float sarrowL = 22 * 4; // (22) side of arrow ?
1588 float harrowL = (float) (Math.sqrt(2) * sarrowL); // (float) (Math.sqrt(2) * sarrowL)
1589 float spartArrowL = (float) ((sarrowL - th / Math.sqrt(2)) / 2); // (float) ((sarrowL - th / Math.sqrt(2)) / 2)
1590 float hpartArrowL = ((float) (harrowL - th) / 2); // ((float) (harrowL - th) / 2)
1591
1592 // none
1593 // through
1594 // left
1595 // right
1596 // slight_left
1597 // slight_right
1598 // sharp_left
1599 // sharp_right
1600 // mergeto_left
1601 // mergeto_right
1602 // merge_to_left
1603 // merge_to_right
1604
1605 no_draw = false;
1606
1607 paint.setColor(Color.LTGRAY);
1608
1609 if ((single_arrow.equalsIgnoreCase("slight_left")) || (single_arrow.equalsIgnoreCase("slight_right")))
1610 {
1611 // -----------------------------------------------------
1612 // turn slighty left or right
1613 // -----------------------------------------------------
1614 int b = 1; // right = 1 or left = -1
1615 if (single_arrow.equalsIgnoreCase("slight_left"))
1616 {
1617 b = -1;
1618 pathForTurn.moveTo(xx1 - 4, yy1);
1619 if ((highlight_lane) && (highlight_kind == 2))
1620 {
1621 //System.out.println("SORTED: XXXXXXXXXXXXXXXX");
1622 paint.setColor(Color.GREEN);
1623 }
1624
1625 }
1626 else
1627 {
1628 pathForTurn.moveTo(xx1 + 40, yy1);
1629
1630 if ((highlight_lane) && (highlight_kind == 4))
1631 {
1632 paint.setColor(Color.GREEN);
1633 }
1634 }
1635
1636 int h = (int) (24.0f * 3.0f); // (24)
1637 int quadShiftY = 22 * 4; // (22)
1638 float quadShiftX = ((float) (quadShiftY / (1 + Math.sqrt(2)))) * 1.5f; // (float) (quadShiftY / (1 + Math.sqrt(2)))
1639 float nQuadShiftX = ((sarrowL - 2 * spartArrowL) - quadShiftX - th); // (sarrowL - 2 * spartArrowL) - quadShiftX - th
1640 float nQuadShifty = quadShiftY + (sarrowL - 2 * spartArrowL); // quadShiftY + (sarrowL - 2 * spartArrowL)
1641 pathForTurn.rMoveTo(-b * 4, 0);
1642 pathForTurn.rLineTo(0, -h /* + partArrowL */);
1643 pathForTurn.rQuadTo(0, -quadShiftY + quadShiftX /*- partArrowL*/, b * quadShiftX, -quadShiftY /*- partArrowL*/);
1644 pathForTurn.rLineTo(b * spartArrowL, spartArrowL);
1645 pathForTurn.rLineTo(0, -sarrowL); // center
1646 pathForTurn.rLineTo(-b * sarrowL, 0);
1647 pathForTurn.rLineTo(b * spartArrowL, spartArrowL);
1648 pathForTurn.rQuadTo(b * nQuadShiftX, -nQuadShiftX, b * nQuadShiftX, nQuadShifty);
1649 pathForTurn.rLineTo(0, h);
1650 // -----------------------------------------------------
1651 // -----------------------------------------------------
1652 }
1653 else if ((single_arrow.equalsIgnoreCase("left")) || (single_arrow.equalsIgnoreCase("right")))
1654 {
1655 int b = 1; // right = 1 or left = -1
1656 if (single_arrow.equalsIgnoreCase("left"))
1657 {
1658 b = -1;
1659 pathForTurn.moveTo(xx1 - 4, yy1);
1660
1661 if ((highlight_lane) && (highlight_kind == 1))
1662 {
1663 paint.setColor(Color.GREEN);
1664 }
1665 }
1666 else
1667 {
1668 pathForTurn.moveTo(xx1 + 40, yy1);
1669
1670 if ((highlight_lane) && (highlight_kind == 5))
1671 {
1672 paint.setColor(Color.GREEN);
1673 }
1674 }
1675
1676 float quadShiftX = 18;
1677 float quadShiftY = 18;
1678 int wl = 10; // width
1679 int h = (int) (ha - quadShiftY - harrowL + hpartArrowL - 5);
1680
1681 // --
1682 h = -2 * h;
1683 // --
1684
1685 int sl = wl + th / 2;
1686
1687 // --
1688 sl = 2;
1689 // --
1690
1691 pathForTurn.rMoveTo(-b * sl, 0);
1692 pathForTurn.rLineTo(0, -h);
1693 pathForTurn.rQuadTo(0, -quadShiftY, b * quadShiftX, -quadShiftY);
1694 pathForTurn.rLineTo(b * wl, 0);
1695
1696 pathForTurn.rLineTo(0, hpartArrowL);
1697 pathForTurn.rLineTo(b * harrowL / 2, -harrowL / 2); // center
1698 pathForTurn.rLineTo(-b * harrowL / 2, -harrowL / 2);
1699 pathForTurn.rLineTo(0, hpartArrowL);
1700
1701 pathForTurn.rLineTo(-b * wl, 0);
1702 pathForTurn.rQuadTo(-b * (quadShiftX + th), 0, -b * (quadShiftX + th), quadShiftY + th);
1703 pathForTurn.rLineTo(0, h);
1704 }
1705 else if ((single_arrow.equalsIgnoreCase("sharp_left")) || (single_arrow.equalsIgnoreCase("sharp_right")))
1706 {
1707 int b = 1; // right = 1 or left = -1
1708 if (single_arrow.equalsIgnoreCase("sharp_left"))
1709 {
1710 b = -1;
1711 pathForTurn.moveTo(xx1 - 4, yy1);
1712
1713 if ((highlight_lane) && (highlight_kind == 1))
1714 {
1715 paint.setColor(Color.GREEN);
1716 }
1717 }
1718 else
1719 {
1720 pathForTurn.moveTo(xx1 + 40, yy1);
1721
1722 if ((highlight_lane) && (highlight_kind == 5))
1723 {
1724 paint.setColor(Color.GREEN);
1725 }
1726 }
1727
1728 float quadShiftX = 18;
1729 float quadShiftY = 18;
1730 int wl = 10; // width
1731 int h = (int) (ha - quadShiftY - harrowL + hpartArrowL - 5);
1732
1733 // --
1734 h = -2 * h;
1735 // --
1736
1737 int sl = wl + th / 2;
1738
1739 // --
1740 sl = 2;
1741 // --
1742
1743 pathForTurn.rMoveTo(-b * sl, 0);
1744 pathForTurn.rLineTo(0, -h);
1745 pathForTurn.rQuadTo(0, -quadShiftY, b * quadShiftX, -quadShiftY);
1746 pathForTurn.rLineTo(b * wl, 0);
1747
1748 pathForTurn.rLineTo(0, hpartArrowL);
1749 pathForTurn.rLineTo(b * harrowL / 2, -harrowL / 2); // center
1750 pathForTurn.rLineTo(-b * harrowL / 2, -harrowL / 2);
1751 pathForTurn.rLineTo(0, hpartArrowL);
1752
1753 pathForTurn.rLineTo(-b * wl, 0);
1754 pathForTurn.rQuadTo(-b * (quadShiftX + th), 0, -b * (quadShiftX + th), quadShiftY + th);
1755 pathForTurn.rLineTo(0, h);
1756 }
1757 else if ((single_arrow.equalsIgnoreCase("mergeto_left")) || (single_arrow.equalsIgnoreCase("mergeto_right")))
1758 {
1759 int b = 1; // right = 1 or left = -1
1760 if (single_arrow.equalsIgnoreCase("mergeto_left"))
1761 {
1762 b = -1;
1763 pathForTurn.moveTo(xx1 - 4, yy1);
1764
1765 if ((highlight_lane) && (highlight_kind == -99))
1766 {
1767 paint.setColor(Color.GREEN);
1768 }
1769 }
1770 else
1771 {
1772 pathForTurn.moveTo(xx1 + 40, yy1);
1773
1774 if ((highlight_lane) && (highlight_kind == -99))
1775 {
1776 paint.setColor(Color.GREEN);
1777 }
1778 }
1779
1780 int h = (int) (24.0f * 3.0f); // (24)
1781
1782 // --
1783 h = (int) ((float) h * 0.9f);
1784 // --
1785
1786 int quadShiftY = 22 * 4; // (22)
1787 float quadShiftX = ((float) (quadShiftY / (1 + Math.sqrt(2)))) * 1.2f; // (float) (quadShiftY / (1 + Math.sqrt(2)))
1788 float nQuadShiftX = ((sarrowL - 2 * spartArrowL) - quadShiftX - th); // (sarrowL - 2 * spartArrowL) - quadShiftX - th
1789 float nQuadShifty = quadShiftY + (sarrowL - 2 * spartArrowL); // quadShiftY + (sarrowL - 2 * spartArrowL)
1790 pathForTurn.rMoveTo(-b * 4, 0);
1791 pathForTurn.rLineTo(0, -h /* + partArrowL */);
1792 pathForTurn.rQuadTo(0, -quadShiftY + quadShiftX /*- partArrowL*/, b * quadShiftX, -quadShiftY /*- partArrowL*/);
1793 pathForTurn.rLineTo(b * spartArrowL, spartArrowL);
1794 pathForTurn.rLineTo(0, -sarrowL); // center
1795 pathForTurn.rLineTo(-b * sarrowL, 0);
1796 pathForTurn.rLineTo(b * spartArrowL, spartArrowL);
1797 pathForTurn.rQuadTo(b * nQuadShiftX, -nQuadShiftX, b * nQuadShiftX, nQuadShifty);
1798 pathForTurn.rLineTo(0, h);
1799 }
1800 else if ((single_arrow.equalsIgnoreCase("none")) || (single_arrow.equalsIgnoreCase("through")))
1801 {
1802 int h = ((int) (ha - hpartArrowL - 16)); // (int) (ha - hpartArrowL - 16)
1803
1804 if ((highlight_lane) && (highlight_kind == 3))
1805 {
1806 paint.setColor(Color.GREEN);
1807 //System.out.println("SORTED:highlight straight");
1808 }
1809
1810 h = 18 * h;
1811
1812 pathForTurn.rMoveTo(th, 0);
1813 pathForTurn.rLineTo(0, -h);
1814 pathForTurn.rLineTo(hpartArrowL, 0);
1815 pathForTurn.rLineTo(-harrowL / 2, -harrowL / 2); // center
1816 pathForTurn.rLineTo(-harrowL / 2, harrowL / 2);
1817 pathForTurn.rLineTo(hpartArrowL, 0);
1818 pathForTurn.rLineTo(0, h);
1819 }
1820 else
1821 {
1822 no_draw = true;
1823 }
1824
1825 if (!no_draw)
1826 {
1827 pathForTurn.close();
1828
1829 // now scale path to correct size ---------------
1830 // now scale path to correct size ---------------
1831 // now scale path to correct size ---------------
1832 lanes_scaleMatrix.reset();
1833 // pathForTurn.computeBounds(lanes_rectF, true);
1834 // lanes_scaleMatrix.setScale(0.25f, 0.25f, lanes_rectF.centerX(), lanes_rectF.centerY());
1835 lanes_scaleMatrix.setScale(final_factor, final_factor, xx1_start, yy1_start);
1836 pathForTurn.transform(lanes_scaleMatrix);
1837 pathForTurn.transform(lanes_transMatrix);
1838 // now scale path to correct size ---------------
1839 // now scale path to correct size ---------------
1840 // now scale path to correct size ---------------
1841
1842 paint.setAntiAlias(true);
1843 paint.setDither(true);
1844
1845 paint.setStyle(Style.FILL);
1846 paint.setStrokeWidth(0);
1847
1848 c.drawPath(pathForTurn, paint);
1849
1850 paint.setColor(Color.BLACK);
1851 paint.setStyle(Style.STROKE);
1852 paint.setStrokeWidth(4);
1853
1854 c.drawPath(pathForTurn, paint);
1855 }
1856 }
1857
1858 }
1859 // ---------===================---------------
1860 // ---------===================---------------
1861 }
1862 }
1863 }
1864
1865 // max speed -------------------
1866 if (Navit.PREF_roadspeed_warning)
1867 {
1868 if ((Navit.cur_max_speed != -1) && (Navit.your_are_speeding))
1869 {
1870 paint_speedwarning.setAntiAlias(true);
1871 paint_speedwarning.setColor(Color.WHITE);
1872 paint_speedwarning.setStyle(Style.FILL);
1873 c.drawOval(bounds_speedwarning, paint_speedwarning);
1874
1875 paint_speedwarning.setColor(Color.RED);
1876 paint_speedwarning.setStyle(Style.STROKE);
1877 paint_speedwarning.setStrokeWidth(30);
1878 c.drawOval(bounds_speedwarning, paint_speedwarning);
1879
1880 paint_speedwarning.setColor(Color.BLACK);
1881 paint_speedwarning.setStyle(Style.FILL_AND_STROKE);
1882 paint_speedwarning.setStrokeWidth(2);
1883 if (Navit.PREF_use_imperial)
1884 {
1885 Navit.cur_max_speed_corr = (int) ((((float) Navit.cur_max_speed) / 1.6f) + 0.5f);
1886 }
1887 else
1888 {
1889 Navit.cur_max_speed_corr = Navit.cur_max_speed;
1890 }
1891
1892 if (Navit.cur_max_speed_corr > 99)
1893 {
1894 paint_speedwarning.setTextSize(60);
1895 }
1896 else
1897 {
1898 paint_speedwarning.setTextSize(68);
1899 }
1900 paint_speedwarning.setTextAlign(Align.CENTER);
1901 float textHeight = paint_speedwarning.descent() - paint_speedwarning.ascent();
1902 float textOffset = (textHeight / 2) - paint_speedwarning.descent();
1903 c.drawText("" + Navit.cur_max_speed_corr, bounds_speedwarning.centerX(), bounds_speedwarning.centerY() + textOffset, paint_speedwarning);
1904 }
1905 }
1906 // else // -- draw circle with grey border
1907 // {
1908 // RectF bounds = new RectF(120, 800, 120 + 200, 800 + 200);
1909 //
1910 // Paint paint = new Paint(0);
1911 // paint.setAntiAlias(true);
1912 // paint.setColor(Color.WHITE);
1913 // paint.setStyle(Style.FILL);
1914 // c.drawOval(bounds, paint);
1915 //
1916 // paint.setColor(Color.LTGRAY);
1917 // paint.setStyle(Style.STROKE);
1918 // paint.setStrokeWidth(30);
1919 // c.drawOval(bounds, paint);
1920 // }
1921 // max speed -------------------
1922
1923 // if (Navit.lane_destination != null)
1924 // {
1925 // if (!Navit.lane_destination.equals(""))
1926 // {
1927 // Paint paint = new Paint(0);
1928 // paint.setAntiAlias(true);
1929 // paint.setColor(Color.BLUE);
1930 // paint.setStyle(Style.FILL);
1931 // c.drawRect(100, 200, 1000, 300, paint);
1932 // paint.setColor(Color.WHITE);
1933 // paint.setStyle(Style.FILL_AND_STROKE);
1934 // paint.setStrokeWidth(2);
1935 // paint.setTextSize(50);
1936 // c.drawText(Navit.lane_destination, 120, 260, paint);
1937 // }
1938 // }
1939
1940 // if (Navit.lane_choices != null)
1941 // {
1942 // if (!Navit.lane_choices.equals(""))
1943 // {
1944 // Paint paint = new Paint(0);
1945 // paint.setAntiAlias(true);
1946 // paint.setColor(Color.BLUE);
1947 // paint.setStyle(Style.FILL);
1948 // c.drawRect(100, 340, 1000, 440, paint);
1949 // paint.setColor(Color.WHITE);
1950 // paint.setStyle(Style.FILL_AND_STROKE);
1951 // paint.setStrokeWidth(2);
1952 // paint.setTextSize(46);
1953 // c.drawText(Navit.lane_choices, 120, 380, paint);
1954 // }
1955 // }
1956 // if (Navit.lane_choices1 != null)
1957 // {
1958 // if (!Navit.lane_choices1.equals(""))
1959 // {
1960 // Paint paint = new Paint(0);
1961 // paint.setAntiAlias(true);
1962 // paint.setColor(Color.BLUE);
1963 // paint.setStyle(Style.FILL);
1964 // // c.drawRect(100, 340, 1000, 440, paint);
1965 // paint.setColor(Color.WHITE);
1966 // paint.setStyle(Style.FILL_AND_STROKE);
1967 // paint.setStrokeWidth(2);
1968 // paint.setTextSize(46);
1969 // c.drawText(Navit.lane_choices1, 120, 437, paint);
1970 // }
1971 // }
1972
1973 // quick dirty lanes and destiantion display hack ! -----------------------------------
1974 // quick dirty lanes and destiantion display hack ! -----------------------------------
1975 // quick dirty lanes and destiantion display hack ! -----------------------------------
1976
1977 // // test, draw rectangles on top layer!
1978 // Paint paint = new Paint(0);
1979 // paint.setAntiAlias(false);
1980 // paint.setStyle(Style.STROKE);
1981 // paint.setColor(Color.GREEN);
1982 // c.drawRect(0 * draw_factor, 0 * draw_factor, 64 * draw_factor, 64 * draw_factor, paint);
1983 // paint.setColor(Color.RED);
1984 // c.drawRect(0 * draw_factor, (0 + 70) * draw_factor, 64 * draw_factor,
1985 // (64 + 70) * draw_factor, paint);
1986 } 872 }
1987} 873}

Legend:
Removed from v.40  
changed lines
  Added in v.41

   
Visit the ZANavi Wiki