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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 30 - (show annotations) (download)
Wed Aug 22 17:01:27 2012 UTC (11 years, 7 months ago) by zoff99
File size: 29701 byte(s)
ZANavi 2.0, lots of changes, everything in its own thread, more performance
1 /**
2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2011 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 android.content.Context;
42 import android.content.DialogInterface;
43 import android.graphics.Canvas;
44 import android.graphics.Color;
45 import android.graphics.Paint;
46 import android.graphics.Paint.Style;
47 import android.graphics.RectF;
48 import android.os.Bundle;
49 import android.os.Message;
50 import android.view.MotionEvent;
51 import android.widget.ImageView;
52
53 public class NavitAndroidOverlay extends ImageView
54 {
55 public Boolean draw_bubble = false;
56 public static Boolean confirmed_bubble = false;
57 public static int confirmed_bubble_part = 0; // 0 -> left side, 1 -> right side
58 public long bubble_showing_since = 0L;
59 public static long bubble_max_showing_timespan = 8000L; // 8 secs.
60 public RectF follow_button_rect = new RectF(-100, 1, 1, 1);
61 public RectF zoomin_button_rect = new RectF(-100, 1, 1, 1);
62 public RectF zoomout_button_rect = new RectF(-100, 1, 1, 1);
63 public RectF mapdrawing_button_rect = new RectF(-100, 1, 1, 1);
64 public static int zoomin_ltx = 0;
65 public static int zoomin_lty = 0;
66 public static int zoomout_ltx = 0;
67 public static int zoomout_lty = 0;
68 public static int mapdrawing_ltx = 0;
69 public static int mapdrawing_lty = 0;
70 public int mCanvasHeight = 1;
71 public int mCanvasWidth = 1;
72 public static float draw_factor = 1.0f;
73
74 public static BubbleThread bubble_thread = null;
75
76 public static NavitGraphics.OverlayDrawThread overlay_draw_thread1;
77
78 private class BubbleThread extends Thread
79 {
80 private Boolean running;
81 private long bubble_showing_since = 0L;
82 private NavitAndroidOverlay a_overlay = null;
83
84 BubbleThread(NavitAndroidOverlay a_ov)
85 {
86 this.running = true;
87 this.a_overlay = a_ov;
88 this.bubble_showing_since = System.currentTimeMillis();
89 //Log.e("Navit", "BubbleThread created");
90 }
91
92 public void stop_me()
93 {
94 this.running = false;
95 }
96
97 public void run()
98 {
99 // Log.e("Navit", "BubbleThread started");
100 while (this.running)
101 {
102 if ((System.currentTimeMillis() - this.bubble_showing_since) > bubble_max_showing_timespan)
103 {
104 //Log.e("Navit", "BubbleThread: bubble displaying too long, hide it");
105 // with invalidate we call the onDraw() function, that will take care of it
106 //System.out.println("invalidate 001");
107 this.a_overlay.postInvalidate();
108 this.running = false;
109 }
110 else
111 {
112 try
113 {
114 Thread.sleep(280);
115 }
116 catch (InterruptedException e)
117 {
118 // e.printStackTrace();
119 }
120 }
121 }
122 //Log.e("Navit", "BubbleThread ended");
123 }
124 }
125
126 public static class NavitAndroidOverlayBubble
127 {
128 int x;
129 int y;
130 String text = null;
131 }
132
133 private NavitAndroidOverlayBubble bubble_001 = null;
134
135 public NavitAndroidOverlay(Context context)
136 {
137 super(context);
138 }
139
140 public void show_bubble()
141 {
142 //System.out.println("NavitAndroidOverlay -> show_bubble");
143 if (!this.draw_bubble)
144 {
145 confirmed_bubble = false;
146 this.draw_bubble = true;
147 this.bubble_showing_since = System.currentTimeMillis();
148 bubble_thread = new BubbleThread(this);
149 bubble_thread.start();
150
151 // test test DEBUG
152 /*
153 * Message msg = new Message();
154 * Bundle b = new Bundle();
155 * b.putInt("Callback", 4);
156 * b.putInt("x", this.bubble_001.x);
157 * b.putInt("y", this.bubble_001.y);
158 * msg.setData(b);
159 * Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
160 */
161 }
162 }
163
164 public Boolean get_show_bubble()
165 {
166 return this.draw_bubble;
167 }
168
169 public void hide_bubble()
170 {
171 // Log.e("NavitGraphics", "NavitAndroidOverlay -> hide_bubble");
172 confirmed_bubble = false;
173 this.draw_bubble = false;
174 this.bubble_showing_since = 0L;
175 try
176 {
177 bubble_thread.stop_me();
178 // bubble_thread.stop();
179 }
180 catch (Exception e)
181 {
182
183 }
184 //this.postInvalidate();
185 }
186
187 public void set_bubble(NavitAndroidOverlayBubble b)
188 {
189 this.bubble_001 = b;
190 }
191
192 @Override
193 public boolean onTouchEvent(MotionEvent event)
194 {
195 //if (NavitGraphics.wait_for_redraw_map == true)
196 //{
197 // Log.e("NavitGraphics", "GD NavitAndroidOverlay GD -> onTouchEvent");
198 // Message msg = new Message();
199 // Bundle b = new Bundle();
200 // b.putInt("Callback", 50);
201 // msg.setData(b);
202 // Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
203 //}
204 //else
205 //{
206 // // Log.e("NavitGraphics", "NavitAndroidOverlay -> onTouchEvent");
207 //}
208 super.onTouchEvent(event);
209
210 int action = event.getAction();
211 int x = (int) event.getX();
212 int y = (int) event.getY();
213
214 //Log.e("NavitGraphics", "NavitAndroidOverlay -> action=" + action);
215
216 //if (action == MotionEvent.ACTION_UP)
217 //{
218 // Log.e("NavitGraphics", "NavitAndroidOverlay -> onTouchEvent ACTION_UP");
219 // if (NavitGraphics.in_map)
220 // {
221 // return false;
222 // }
223 //}
224
225 if (action == MotionEvent.ACTION_DOWN)
226 {
227 if ((this.draw_bubble) && (!confirmed_bubble))
228 {
229 int dx = (int) ((20 / 1.5f) * draw_factor);
230 int dy = (int) ((-100 / 1.5f) * draw_factor);
231 int bubble_size_x = (int) ((150 / 1.5f) * draw_factor);
232 int bubble_size_y = (int) ((60 / 1.5f) * draw_factor);
233 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);
234 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);
235 if (box_rect_left.contains(x, y))
236 {
237 // bubble touched to confirm destination
238 confirmed_bubble = true;
239 confirmed_bubble_part = 0;
240 // draw confirmed bubble
241 //System.out.println("invalidate 002");
242 this.postInvalidate();
243 String dest_name = "Point on Screen";
244
245 // remeber recent dest.
246 try
247 {
248 dest_name = NavitGraphics.CallbackGeoCalc(8, this.bubble_001.x, this.bubble_001.y);
249 // System.out.println("x:"+dest_name+":y");
250 if ((dest_name.equals(" ")) || (dest_name == null))
251 {
252 dest_name = "Point on Screen";
253 }
254
255 Navit.remember_destination_xy(dest_name, this.bubble_001.x, this.bubble_001.y);
256 }
257 catch (Exception e)
258 {
259 e.printStackTrace();
260 }
261
262 if (NavitGraphics.navit_route_status == 0)
263 {
264 Navit.destination_set();
265
266 Message msg = new Message();
267 Bundle b = new Bundle();
268 b.putInt("Callback", 4);
269 b.putInt("x", this.bubble_001.x);
270 b.putInt("y", this.bubble_001.y);
271 msg.setData(b);
272 Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
273 }
274 else
275 {
276 Message msg = new Message();
277 Bundle b = new Bundle();
278 b.putInt("Callback", 49);
279 b.putInt("x", this.bubble_001.x);
280 b.putInt("y", this.bubble_001.y);
281 msg.setData(b);
282 Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
283 }
284
285 // try
286 // {
287 // Navit.follow_button_on();
288 // }
289 // catch (Exception e2)
290 // {
291 // e2.printStackTrace();
292 // }
293
294 // consume the event
295 return true;
296 }
297 else if (box_rect_right.contains(x, y))
298 {
299 // bubble touched to confirm destination
300 confirmed_bubble = true;
301 confirmed_bubble_part = 1;
302 // draw confirmed bubble
303 //System.out.println("invalidate 003");
304 this.postInvalidate();
305
306 // whats here?
307 String item_dump_pretty = NavitGraphics.CallbackGeoCalc(10, this.bubble_001.x, this.bubble_001.y);
308 try
309 {
310 String item_dump_pretty_parsed = "";
311 String[] item_dump_lines = item_dump_pretty.split("\n");
312 int jk = 0;
313 String sep = "";
314 for (jk = 0; jk < item_dump_lines.length; jk++)
315 {
316 if (item_dump_lines[jk].startsWith("+*TYPE*+:"))
317 {
318 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk].substring(9);
319 }
320 else if (item_dump_lines[jk].startsWith("flags="))
321 {
322
323 }
324 else if (item_dump_lines[jk].startsWith("maxspeed="))
325 {
326 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk];
327 }
328 else if (item_dump_lines[jk].startsWith("label="))
329 {
330 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk].substring(6);
331 }
332 else if (item_dump_lines[jk].startsWith("street_name="))
333 {
334 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk].substring(12);
335 }
336 else if (item_dump_lines[jk].startsWith("street_name_systematic="))
337 {
338 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk].substring(23);
339 }
340 else
341 {
342 item_dump_pretty_parsed = item_dump_pretty_parsed + sep + item_dump_lines[jk];
343 }
344
345 if (jk == 0)
346 {
347 sep = "\n";
348 }
349 }
350
351 Navit.generic_alert_box.setMessage(item_dump_pretty_parsed).setPositiveButton(Navit.get_text("Ok"), new DialogInterface.OnClickListener()
352 {
353 public void onClick(DialogInterface dialog, int id)
354 {
355 // Handle Ok
356 }
357 }).create();
358 Navit.generic_alert_box.setCancelable(true);
359 Navit.generic_alert_box.setTitle(Navit.get_text("What's here")); // TRANS
360 Navit.generic_alert_box.show();
361 }
362 catch (Exception e)
363 {
364 e.printStackTrace();
365 }
366
367 return true;
368 }
369
370 }
371 }
372
373 if (action == MotionEvent.ACTION_DOWN)
374 {
375 //Log.e("NavitGraphics", "NavitAndroidOverlay -> onTouchEvent ACTION_DOWN");
376 if (this.follow_button_rect.contains(x, y))
377 {
378 if (NavitGraphics.in_map)
379 {
380 // toggle follow mode
381 Navit.toggle_follow_button();
382 //System.out.println("invalidate 004");
383 this.postInvalidate();
384 // consume the event
385 return true;
386 }
387 }
388 else if (this.mapdrawing_button_rect.contains(x, y))
389 {
390 if (NavitGraphics.in_map)
391 {
392 try
393 {
394 Message msg = new Message();
395 Bundle b = new Bundle();
396 if (NavitGraphics.MAP_DISPLAY_OFF)
397 {
398 NavitGraphics.MAP_DISPLAY_OFF = false;
399 b.putInt("Callback", 63);
400 }
401 else
402 {
403 NavitGraphics.MAP_DISPLAY_OFF = true;
404 b.putInt("Callback", 62);
405 }
406 msg.setData(b);
407 Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
408 // redraw map
409 Message msg2 = new Message();
410 Bundle b2 = new Bundle();
411 b2.putInt("Callback", 64);
412 msg2.setData(b2);
413 Navit.N_NavitGraphics.callback_handler.sendMessage(msg2);
414
415 }
416 catch (Exception e)
417 {
418 e.printStackTrace();
419 }
420 // consume the event
421 return true;
422 }
423 }
424 else if (this.zoomin_button_rect.contains(x, y))
425 {
426 if (NavitGraphics.in_map)
427 {
428 try
429 {
430 if (overlay_draw_thread1 == null)
431 {
432 //overlay_draw_thread1 = new NavitGraphics.OverlayDrawThread();
433 //overlay_draw_thread1.start();
434 }
435 }
436 catch (Exception e)
437 {
438 //overlay_draw_thread1 = new NavitGraphics.OverlayDrawThread();
439 //overlay_draw_thread1.start();
440 }
441
442 // System.out.println("ZZZZZZZZ O.11");
443 // //if (NavitGraphics.wait_for_redraw_map == true)
444 // {
445 // System.out.println("ZZZZZZZZ O.11.A");
446 // // stop drawing the map
447 // try
448 // {
449 // NavitGraphics.CallbackMessageChannel(50, "");
450 // // Message msg = new Message();
451 // // Bundle b = new Bundle();
452 // // b.putInt("Callback", 50);
453 // // msg.setData(b);
454 // // Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
455 // }
456 // catch (Exception e)
457 // {
458 // e.printStackTrace();
459 // }
460 // }
461 NavitGraphics.wait_for_redraw_map = true;
462 //System.out.println("invalidate 005");
463 this.invalidate();
464 //System.out.println("wait_for_redraw_map=true o1");
465 //Log.e("NavitGraphics", "wait_for_redraw_map=true o1");
466 // zoom in
467 try
468 {
469 // NavitGraphics.CallbackMessageChannel(1, "");
470 Message msg = new Message();
471 Bundle b = new Bundle();
472 b.putInt("Callback", 1);
473 msg.setData(b);
474 Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
475 }
476 catch (Exception e)
477 {
478 e.printStackTrace();
479 }
480 // consume the event
481 return true;
482 }
483 }
484 else if (this.zoomout_button_rect.contains(x, y))
485 {
486 if (NavitGraphics.in_map)
487 {
488 try
489 {
490 if (overlay_draw_thread1 == null)
491 {
492 //overlay_draw_thread1 = new NavitGraphics.OverlayDrawThread();
493 //overlay_draw_thread1.start();
494 }
495 }
496 catch (Exception e)
497 {
498 //overlay_draw_thread1 = new NavitGraphics.OverlayDrawThread();
499 //overlay_draw_thread1.start();
500 }
501
502 // System.out.println("ZZZZZZZZ O.22");
503 // if (NavitGraphics.wait_for_redraw_map == true)
504 // {
505 // System.out.println("ZZZZZZZZ O.22.A");
506 // // stop drawing the map
507 // try
508 // {
509 // NavitGraphics.CallbackMessageChannel(50, "");
510 // // Message msg = new Message();
511 // // Bundle b = new Bundle();
512 // // b.putInt("Callback", 50);
513 // // msg.setData(b);
514 // // Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
515 // }
516 // catch (Exception e)
517 // {
518 // e.printStackTrace();
519 // }
520 // }
521
522 try
523 {
524 NavitGraphics.wait_for_redraw_map = true;
525 //System.out.println("invalidate 006");
526 this.invalidate();
527 //System.out.println("wait_for_redraw_map=true o2");
528 //Log.e("NavitGraphics", "wait_for_redraw_map=true o2");
529 // zoom out
530
531 // NavitGraphics.CallbackMessageChannel(2, "");
532 Message msg = new Message();
533 Bundle b = new Bundle();
534 b.putInt("Callback", 2);
535 msg.setData(b);
536 Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
537 }
538 catch (Exception e)
539 {
540 e.printStackTrace();
541 }
542 // consume the event
543 return true;
544 }
545 }
546 else
547 {
548 try
549 {
550 if (overlay_draw_thread1 == null)
551 {
552 //overlay_draw_thread1 = new NavitGraphics.OverlayDrawThread();
553 //overlay_draw_thread1.start();
554 }
555 }
556 catch (Exception e)
557 {
558 //overlay_draw_thread1 = new NavitGraphics.OverlayDrawThread();
559 //overlay_draw_thread1.start();
560 }
561 }
562 }
563
564 // test if we touched the grey rectangle
565 //
566 // if ((x < 300) && (x > 10) && (y < 200) && (y > 10))
567 // {
568 // Log.e("Navit", "NavitAndroidOverlay -> onTouchEvent -> touch Rect!!");
569 // return true;
570 // }
571 // else
572 // {
573 // return false;
574 // }
575
576 // false -> we dont use this event, give it to other layers
577 return false;
578 }
579
580 @Override
581 public void onSizeChanged(int w, int h, int oldw, int oldh)
582 {
583 // super.onSizeChanged(w, h, oldw, oldh);
584 this.mCanvasWidth = w;
585 this.mCanvasHeight = h;
586
587 draw_factor = 1.0f;
588 if (Navit.my_display_density.compareTo("mdpi") == 0)
589 {
590 draw_factor = 1.0f;
591 }
592 else if (Navit.my_display_density.compareTo("ldpi") == 0)
593 {
594 draw_factor = 0.7f;
595 }
596 else if (Navit.my_display_density.compareTo("hdpi") == 0)
597 {
598 draw_factor = 1.5f;
599 }
600
601 int w_1 = (int) ((10f / 1.5f) * draw_factor);
602 int h_1 = (int) ((200f / 1.5f) * draw_factor);
603 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);
604
605 /*
606 * int w_2 = (int) ((0 / 1.5f) * draw_factor) + 5;
607 * int h_2 = (int) ((0f / 1.5f) * draw_factor) + 5;
608 * int h_button_zoom = Navit.zoomin.getHeight();
609 * zoomin_ltx = w_2;
610 * zoomin_lty = h_2;
611 * this.zoomin_button_rect = new RectF(w_2, h_2, Navit.zoomin.getWidth() + w_2, h_button_zoom + h_2);
612 */
613
614 int w_2 = (int) ((0 / 1.5f) * draw_factor) + 5;
615 int h_2 = (int) ((70f / 1.5f) * draw_factor) + 5 + 25;
616 int h_button_zoom = Navit.zoomin.getHeight();
617 zoomin_ltx = w_2;
618 zoomin_lty = h_2;
619 this.zoomin_button_rect = new RectF(w_2, h_2, Navit.zoomin.getWidth() + w_2, h_button_zoom + h_2);
620
621 w_2 = (int) ((0 / 1.5f) * draw_factor) + 5;
622 h_2 = (int) ((2 * 70f / 1.5f) * draw_factor) + 5 + 25 + 25;
623 zoomout_ltx = w_2;
624 zoomout_lty = h_2;
625 this.zoomout_button_rect = new RectF(w_2, h_2, Navit.zoomout.getWidth() + w_2, h_button_zoom + h_2);
626
627 int mapdrawing_width = 75;
628 int mapdrawing_height = 75;
629 w_2 = (int) (((this.mCanvasWidth - mapdrawing_width) / 1.5f) * draw_factor) - 5;
630 h_2 = (int) ((70f / 1.5f) * draw_factor) + 5 + 25;
631 mapdrawing_ltx = w_2;
632 mapdrawing_lty = h_2;
633 this.mapdrawing_button_rect = new RectF(w_2, h_2, mapdrawing_width + w_2, mapdrawing_height + h_2);
634 }
635
636 public void onDraw(Canvas c)
637 {
638 // ************!!!!!!!!!!!!! optimze me !!!!!!!!!!!*************
639 // ************!!!!!!!!!!!!! optimze me !!!!!!!!!!!*************
640 // ************!!!!!!!!!!!!! optimze me !!!!!!!!!!!*************
641 // ************!!!!!!!!!!!!! optimze me !!!!!!!!!!!*************
642 // ************!!!!!!!!!!!!! optimze me !!!!!!!!!!!*************
643 // ************!!!!!!!!!!!!! optimze me !!!!!!!!!!!*************
644
645 //Log.e("NavitGraphics", "NavitAndroidOverlay -> onDraw");
646 //System.out.println("NavitAndroidOverlay -> onDraw");
647
648 if (this.draw_bubble)
649 {
650 if ((System.currentTimeMillis() - this.bubble_showing_since) > bubble_max_showing_timespan)
651 {
652 // bubble has been showing too log, hide it
653 this.hide_bubble();
654
655 // next lines are a hack, without it screen will not get updated anymore!
656 // next lines are a hack, without it screen will not get updated anymore!
657 // down
658 // Message msg = new Message();
659 // Bundle b = new Bundle();
660 // b.putInt("Callback", 21);
661 // b.putInt("x", 1);
662 // b.putInt("y", 1);
663 // msg.setData(b);
664 // Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
665 //
666 // // move
667 // msg = new Message();
668 // b = new Bundle();
669 // b.putInt("Callback", 23);
670 // b.putInt("x", 1 + 10);
671 // b.putInt("y", 1);
672 // msg.setData(b);
673 // Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
674 //
675 // // move
676 // msg = new Message();
677 // b = new Bundle();
678 // b.putInt("Callback", 23);
679 // b.putInt("x", 1 - 10);
680 // b.putInt("y", 1);
681 // msg.setData(b);
682 // Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
683 //
684 // // up
685 // msg = new Message();
686 // b = new Bundle();
687 // b.putInt("Callback", 22);
688 // b.putInt("x", 1);
689 // b.putInt("y", 1);
690 // msg.setData(b);
691 // Navit.N_NavitGraphics.callback_handler.sendMessage(msg);
692 // next lines are a hack, without it screen will not get updated anymore!
693 // next lines are a hack, without it screen will not get updated anymore!
694 }
695 }
696
697 if (this.draw_bubble)
698 {
699 //Log.e("Navit", "NavitAndroidOverlay -> onDraw -> bubble");
700
701 int dx = (int) ((20 / 1.5f) * draw_factor);
702 int dy = (int) ((-100 / 1.5f) * draw_factor);
703 Paint bubble_paint = new Paint(0);
704
705 int bubble_size_x = (int) ((150 / 1.5f) * draw_factor);
706 int bubble_size_y = (int) ((60 / 1.5f) * draw_factor);
707
708 // yellow-ish funny lines
709 int lx = (int) ((15 / 1.5f) * draw_factor);
710 int ly = (int) ((15 / 1.5f) * draw_factor);
711 bubble_paint.setStyle(Style.FILL);
712 bubble_paint.setAntiAlias(true);
713 bubble_paint.setStrokeWidth(8 / 1.5f * draw_factor);
714 bubble_paint.setColor(Color.parseColor("#FFF8C6"));
715 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);
716 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);
717
718 // draw black funny lines to target
719 bubble_paint.setStyle(Style.STROKE);
720 bubble_paint.setAntiAlias(true);
721 bubble_paint.setStrokeWidth(3);
722 bubble_paint.setColor(Color.parseColor("#000000"));
723 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);
724 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);
725
726 // filled rect yellow-ish (left side) (fill it all)
727 bubble_paint.setStyle(Style.FILL);
728 bubble_paint.setStrokeWidth(0);
729 bubble_paint.setAntiAlias(false);
730 bubble_paint.setColor(Color.parseColor("#FFF8C6"));
731 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);
732 int rx = (int) (20 / 1.5f * draw_factor);
733 int ry = (int) (20 / 1.5f * draw_factor);
734 c.drawRoundRect(box_rect, rx, ry, bubble_paint);
735
736 // filled rect green-ish (right side)
737 bubble_paint.setStyle(Style.FILL);
738 bubble_paint.setStrokeWidth(0);
739 bubble_paint.setAntiAlias(false);
740 bubble_paint.setColor(Color.parseColor("#74DF00"));
741 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);
742 c.drawRoundRect(box_rect_right_half, rx, ry, bubble_paint);
743
744 // correct the overlap
745 bubble_paint.setColor(Color.parseColor("#FFF8C6"));
746 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);
747 c.drawRect(box_rect_left_half_correction, bubble_paint);
748
749 // black outlined rect
750 bubble_paint.setStyle(Style.STROKE);
751 bubble_paint.setStrokeWidth(3);
752 bubble_paint.setAntiAlias(true);
753 bubble_paint.setColor(Color.parseColor("#000000"));
754 c.drawRoundRect(box_rect, rx, ry, bubble_paint);
755
756 // black separator lines (outer)
757 bubble_paint.setStyle(Style.STROKE);
758 bubble_paint.setStrokeWidth(8);
759 bubble_paint.setAntiAlias(true);
760 bubble_paint.setColor(Color.parseColor("#000000"));
761 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);
762
763 // black separator lines (inner)
764 bubble_paint.setStyle(Style.STROKE);
765 bubble_paint.setStrokeWidth(2);
766 bubble_paint.setAntiAlias(true);
767 bubble_paint.setColor(Color.parseColor("#D8D8D8"));
768 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);
769
770 if (NavitAndroidOverlay.confirmed_bubble)
771 {
772 // red outline (for confirmed bubble)
773 bubble_paint.setStyle(Style.STROKE);
774 bubble_paint.setStrokeWidth(5);
775 bubble_paint.setAntiAlias(true);
776 bubble_paint.setColor(Color.parseColor("#EC294D"));
777 c.drawRoundRect(box_rect, rx, ry, bubble_paint);
778 }
779
780 int inner_dx = (int) (30 / 1.5f * draw_factor);
781 int inner_dx_left = (int) (30 / 1.5f * draw_factor);
782 int inner_dx_right = (int) (30 / 1.5f * draw_factor) + (bubble_size_x / 2);
783 int inner_dy = (int) (36 / 1.5f * draw_factor);
784 bubble_paint.setAntiAlias(true);
785 bubble_paint.setStyle(Style.FILL);
786 bubble_paint.setTextSize((int) (20 / 1.5f * draw_factor));
787 bubble_paint.setStrokeWidth(3);
788 bubble_paint.setColor(Color.parseColor("#3b3131"));
789 // c.drawText(Navit.get_text("drive here"), this.bubble_001.x + dx + inner_dx, this.bubble_001.y + dy + inner_dy, bubble_paint);
790 c.drawText("X", this.bubble_001.x + dx + inner_dx_left, this.bubble_001.y + dy + inner_dy, bubble_paint);
791 c.drawText("?", this.bubble_001.x + dx + inner_dx_right, this.bubble_001.y + dy + inner_dy, bubble_paint);
792
793 }
794
795 if (NavitGraphics.in_map)
796 {
797 // draw follow
798 if (Navit.follow_current != null)
799 {
800 c.drawBitmap(Navit.follow_current, this.follow_button_rect.left, this.follow_button_rect.top, null);
801 }
802 }
803
804 if (NavitGraphics.in_map)
805 {
806 c.drawBitmap(Navit.zoomin, zoomin_ltx, zoomin_lty, null);
807 c.drawBitmap(Navit.zoomout, zoomout_ltx, zoomout_lty, null);
808 Paint paint = new Paint();
809 paint.setAntiAlias(true);
810 paint.setStyle(Style.STROKE);
811 paint.setColor(Color.GRAY);
812 paint.setAlpha(30);
813 paint.setStrokeWidth(2);
814 c.drawRoundRect(this.zoomin_button_rect, 10, 10, paint);
815 //paint.setStyle(Style.STROKE);
816 //paint.setColor(Color.GRAY);
817 //paint.setAlpha(30);
818 c.drawRoundRect(this.zoomout_button_rect, 10, 10, paint);
819 c.drawRoundRect(this.mapdrawing_button_rect, 10, 10, paint);
820 paint.setStrokeWidth(10);
821 paint.setAlpha(80);
822 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);
823 }
824
825 if (NavitGraphics.in_map)
826 {
827 //Log.e("NavitGraphics", "NavitAndroidOverlay -> draw2");
828 //if (NavitGraphics.wait_for_redraw_map)
829 //{
830 // //Log.e("NavitGraphics", "NavitAndroidOverlay -> draw wait rect");
831 // Paint paint = new Paint(0);
832 // paint.setAntiAlias(true);
833 // paint.setStyle(Style.FILL);
834 // paint.setColor(Color.LTGRAY);
835 // paint.setAlpha(70);
836 //
837 // RectF r1 = new RectF(20 * draw_factor, 20 * draw_factor, this.mCanvasWidth - 20 * draw_factor, this.mCanvasHeight - 20 * draw_factor);
838 // c.drawRoundRect(r1, 20, 20, paint);
839 // paint.setColor(Color.parseColor("#888888"));
840 // paint.setAlpha(230);
841 // paint.setTextAlign(Paint.Align.CENTER);
842 // paint.setStrokeWidth(2);
843 // paint.setTextSize(30);
844 // c.drawText(Navit.get_text("wait ..."), this.mCanvasWidth / 2, this.mCanvasHeight / 2, paint); //TRANS
845 //}
846 }
847
848 if (Navit.PREF_item_dump)
849 {
850 if (!Navit.debug_item_dump.equals(""))
851 {
852 Paint paint = new Paint(0);
853 paint.setAntiAlias(true);
854 paint.setColor(Color.BLUE);
855 // paint.setAlpha(240);
856 // paint.setColor(Color.parseColor("#888888"));
857 paint.setStrokeWidth(2);
858 paint.setTextSize(22);
859
860 String[] s = Navit.debug_item_dump.split("\n");
861 int i3;
862 int i4 = 0;
863 int max_char = 38;
864 for (i3 = 0; i3 < s.length; i3++)
865 {
866 if (s[i3].length() > max_char)
867 {
868 int j3;
869 int indent = 0;
870 for (j3 = 0; j3 < (int) (s[i3].length() / max_char); j3++)
871 {
872 if (j3 > 0)
873 {
874 indent = 8;
875 }
876 c.drawText(s[i3].substring(j3 * max_char, ((j3 + 1) * max_char) - 0), 20 + indent, 110 + (i4 * 32), paint);
877 i4++;
878 }
879 if ((((int) (s[i3].length() / max_char)) * max_char) < s[i3].length())
880 {
881 indent = 8;
882 c.drawText(s[i3].substring(j3 * max_char), 20 + indent, 110 + (i4 * 32), paint);
883 i4++;
884 }
885 }
886 else
887 {
888 c.drawText(s[i3], 20, 110 + (i4 * 32), paint);
889 i4++;
890 }
891 }
892 }
893 }
894
895 // // test, draw rectangles on top layer!
896 // Paint paint = new Paint(0);
897 // paint.setAntiAlias(false);
898 // paint.setStyle(Style.STROKE);
899 // paint.setColor(Color.GREEN);
900 // c.drawRect(0 * draw_factor, 0 * draw_factor, 64 * draw_factor, 64 * draw_factor, paint);
901 // paint.setColor(Color.RED);
902 // c.drawRect(0 * draw_factor, (0 + 70) * draw_factor, 64 * draw_factor,
903 // (64 + 70) * draw_factor, paint);
904 }
905 }

   
Visit the ZANavi Wiki