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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 41 - (show annotations) (download)
Tue Aug 11 18:50:37 2015 UTC (8 years, 7 months ago) by zoff99
File size: 27150 byte(s)
many fixes, and new features
1 /**
2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2015 Zoff <zoff@zoff.cc>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 package com.zoffcc.applications.zanavi;
21
22 import android.content.Context;
23 import android.graphics.Canvas;
24 import android.graphics.Color;
25 import android.graphics.Matrix;
26 import android.graphics.Paint;
27 import android.graphics.Paint.Style;
28 import android.graphics.Path;
29 import android.graphics.RectF;
30 import android.util.AttributeSet;
31 import android.view.View;
32
33 public class ZANaviOSDLaneAssist extends View
34 {
35 int w = 10;
36 int h = 10;
37 // RectF bounds_speedwarning = new RectF(120, 800, 120 + 200, 800 + 200);
38 // Paint paint_speedwarning = new Paint(0);
39 Paint paint = new Paint(0);
40 Paint paint2 = new Paint(0);
41 float textHeight = 10;
42 float textOffset = 10;
43 Matrix lanes_scaleMatrix = new Matrix();
44 Matrix lanes_transMatrix = new Matrix();
45 RectF lanes_rectF = new RectF();
46 boolean no_draw = false;
47 Path pathForTurn = new Path();
48
49 public ZANaviOSDLaneAssist(Context context)
50 {
51 super(context);
52 }
53
54 public ZANaviOSDLaneAssist(Context context, AttributeSet attrs)
55 {
56 super(context, attrs);
57 }
58
59 @Override
60 public void onSizeChanged(int w1, int h1, int oldw, int oldh)
61 {
62 super.onSizeChanged(w1, h1, oldw, oldh);
63 this.w = w1;
64 this.h = h1;
65 lanes_transMatrix.reset();
66 lanes_transMatrix.setTranslate(0.0f, NavitGraphics.dp_to_px(40)); // works: 0.0f, 120.0f
67 }
68
69 int get_lanes_kind_count(int parsed_num_lanes, String[] lanes_split)
70 {
71 final int num_of_kinds = 6;
72 int[] lanes_kind = new int[num_of_kinds];
73 int lanes_kind_count = 0;
74
75 int k = 0;
76 for (k = 0; k < num_of_kinds; k++)
77 {
78 lanes_kind[k] = 0; // reset all
79 }
80
81 int j = 0;
82 for (j = 0; j < parsed_num_lanes; j++)
83 {
84 String lanes_split_sub[] = lanes_split[j].split(";");
85 int parsed_num_lanes_sub = lanes_split_sub.length;
86
87 k = 0;
88 String single_arrow = "";
89 for (k = 0; k < parsed_num_lanes_sub; k++)
90 {
91 single_arrow = lanes_split_sub[k].replaceAll("\\s", "");
92
93 // none 3
94 // through 3
95 // left 1
96 // right 5
97 // slight_left 2
98 // slight_right 4
99 // sharp_left 1
100 // sharp_right 5
101 // mergeto_left -
102 // mergeto_right -
103 // merge_to_left -
104 // merge_to_right -
105
106 if (single_arrow.equalsIgnoreCase("sharp_left"))
107 {
108 lanes_kind[1] = 1;
109 }
110 else if (single_arrow.equalsIgnoreCase("sharp_right"))
111 {
112 lanes_kind[5] = 1;
113 }
114 else if (single_arrow.equalsIgnoreCase("none"))
115 {
116 lanes_kind[3] = 1;
117 }
118 else if (single_arrow.equalsIgnoreCase("through"))
119 {
120 lanes_kind[3] = 1;
121 }
122 else if (single_arrow.equalsIgnoreCase("left"))
123 {
124 lanes_kind[1] = 1;
125 }
126 else if (single_arrow.equalsIgnoreCase("right"))
127 {
128 lanes_kind[5] = 1;
129 }
130 else if (single_arrow.equalsIgnoreCase("slight_left"))
131 {
132 lanes_kind[2] = 1;
133 }
134 else if (single_arrow.equalsIgnoreCase("slight_right"))
135 {
136 lanes_kind[4] = 1;
137 }
138
139 }
140 }
141
142 lanes_kind_count = 0;
143 for (k = 0; k < num_of_kinds; k++)
144 {
145 if (lanes_kind[k] == 1)
146 {
147 lanes_kind_count++;
148 }
149 }
150
151 return lanes_kind_count;
152 }
153
154 public void onDraw(Canvas c)
155 {
156 super.onDraw(c);
157
158 if (Navit.p.PREF_lane_assist)
159 {
160 if ((Navit.lanes_text == null) || (Navit.lanes_text.equals("")))
161 {
162 if (Navit.seg_len < 200)
163 {
164 // if we dont have lane information now, use the lane information of the next segment
165 // but only if the current segment is not too long (in meters) !!
166 Navit.lanes_num = Navit.lanes_num1;
167 Navit.lanes_num_forward = Navit.lanes_num_forward1;
168 Navit.lanes_text = Navit.lanes_text1;
169 }
170 }
171
172 if (Navit.lanes_text != null)
173 {
174 if (!Navit.lanes_text.equals(""))
175 {
176 // paint.setAntiAlias(true);
177 // paint.setColor(Color.BLUE);
178 // paint.setStyle(Style.FILL);
179 // c.drawRect(100, 340, 1000, 440, paint);
180 // paint.setColor(Color.WHITE);
181 // paint.setStyle(Style.FILL_AND_STROKE);
182 // paint.setStrokeWidth(2);
183 // paint.setTextSize(50);
184 // c.drawText(Navit.lanes_num + ":" + Navit.lanes_num_forward + ":" + Navit.lanes_text, 120, 400, paint);
185
186 String lanes_split[] = Navit.lanes_text.split("\\|");
187 int parsed_num_lanes = lanes_split.length;
188
189 int lanes_choices_count = 0;
190 int lanes_choices_route = -1;
191 int[] lanes_choices_split_int = null;
192 String[] lanes_choices_split = null;
193 int highlight_kind = -1;
194
195 int[] lanes_kind = new int[10];
196 int lanes_kind_count = 0;
197
198 // only 1 choice ---------------------
199 if (Navit.lane_choices != null)
200 {
201 if (!Navit.lane_choices.equals(""))
202 {
203 lanes_choices_split = Navit.lane_choices.split("\\|");
204 lanes_choices_count = lanes_choices_split.length;
205 int tmp_lanes_kind_count = get_lanes_kind_count(parsed_num_lanes, lanes_split);
206
207 if ((lanes_choices_count == 1) && (tmp_lanes_kind_count > 1))
208 {
209 // we only have 1 choice to drive to (means: no turns here)
210 // so use info from next segment
211 Navit.lane_choices = Navit.lane_choices1;
212 }
213 }
214 }
215 // only 1 choice ---------------------
216
217 // only 1 choice (again) ---------------------
218 if (Navit.lane_choices != null)
219 {
220 if (!Navit.lane_choices.equals(""))
221 {
222 lanes_choices_split = Navit.lane_choices.split("\\|");
223 lanes_choices_count = lanes_choices_split.length;
224 int tmp_lanes_kind_count = get_lanes_kind_count(parsed_num_lanes, lanes_split);
225
226 if ((lanes_choices_count == 1) && (tmp_lanes_kind_count > 1))
227 {
228 // we only have 1 choice to drive to (means: no turns here)
229 // so use info from next next segment
230 Navit.lane_choices = Navit.lane_choices2;
231 }
232 }
233 }
234 // only 1 choice (again) ---------------------
235
236 // sort and check lane choice -------------------------------------
237 if (Navit.lane_choices != null)
238 {
239 if (!Navit.lane_choices.equals(""))
240 {
241 lanes_choices_split = Navit.lane_choices.split("\\|");
242 lanes_choices_count = lanes_choices_split.length;
243 lanes_choices_route = -1;
244 lanes_choices_split_int = new int[lanes_choices_split.length];
245
246 //System.out.println("SORTED:---orig---=" + Navit.lane_choices);
247
248 if (lanes_choices_count > 1)
249 {
250 // find route lane
251 int kk = 0;
252 for (kk = 0; kk < lanes_choices_count; kk++)
253 {
254 // System.out.println("SORTED:kk=" + kk + " lcs length=" + lanes_choices_split.length);
255
256 if (lanes_choices_split[kk].startsWith("x"))
257 {
258 lanes_choices_route = kk;
259 //System.out.println("SORTED:route lane=" + lanes_choices_route);
260 lanes_choices_split_int[kk] = Integer.parseInt(lanes_choices_split[kk].substring(1));
261 //System.out.println("SORTED:res1=" + lanes_choices_split_int[kk] + " " + lanes_choices_split[kk].substring(1) + " " + lanes_choices_split[kk]);
262 }
263 else
264 {
265 lanes_choices_split_int[kk] = Integer.parseInt(lanes_choices_split[kk]);
266 //System.out.println("SORTED:res2=" + lanes_choices_split_int[kk]);
267 }
268 }
269
270 // sort entries (remember to also move the found "route" lane!!)
271 kk = 0;
272 int ll = 0;
273 int temp;
274 int max;
275 for (kk = 1; kk < lanes_choices_count; kk++)
276 {
277 //System.out.println("SORTED:loop1=" + kk);
278
279 temp = lanes_choices_split_int[kk - 1];
280 max = lanes_choices_split_int[kk - 1];
281 for (ll = kk; ll < lanes_choices_count; ll++)
282 {
283 //System.out.println("SORTED:loop2=" + ll + " temp=" + temp + " max=" + max);
284
285 if (lanes_choices_split_int[ll] > max)
286 {
287 if (lanes_choices_route == ll)
288 {
289 // move the found "route" lane
290 lanes_choices_route = kk - 1;
291 //System.out.println("SORTED:move route lane1=" + ll + " -> " + (kk - 1));
292 }
293 else if (lanes_choices_route == kk - 1)
294 {
295 // move the found "route" lane
296 lanes_choices_route = ll;
297 //System.out.println("SORTED:move route lane2=" + (kk - 1) + " -> " + ll);
298 }
299
300 temp = lanes_choices_split_int[ll];
301 lanes_choices_split_int[ll] = max;
302 lanes_choices_split_int[kk - 1] = temp;
303 }
304 }
305 }
306
307 // sorted:
308 //for (kk = 0; kk < lanes_choices_count; kk++)
309 //{
310 // System.out.println("SORTED:k=" + kk + " v=" + lanes_choices_split_int[kk]);
311 //}
312 //System.out.println("SORTED:Route=" + lanes_choices_route);
313
314 }
315 else if (lanes_choices_count == 1)
316 {
317 if (lanes_choices_split[0].startsWith("x"))
318 {
319 lanes_choices_route = 0;
320 lanes_choices_split_int[0] = Integer.parseInt(lanes_choices_split[0].substring(1));
321 }
322 else
323 {
324 lanes_choices_split_int[0] = Integer.parseInt(lanes_choices_split[0]);
325 }
326 }
327
328 // paint2.setAntiAlias(true);
329 // paint2.setColor(Color.BLUE);
330 // paint2.setStyle(Style.FILL);
331 // c.drawRect(100, 340, 1000, 440, paint2);
332 // paint2.setColor(Color.WHITE);
333 // paint2.setStyle(Style.FILL_AND_STROKE);
334 // paint2.setStrokeWidth(2);
335 // paint2.setTextSize(50);
336 // c.drawText(Navit.lane_choices, 120, 400, paint2);
337
338 final int num_of_kinds = 6;
339 lanes_kind = new int[num_of_kinds];
340 lanes_kind_count = 0;
341
342 int k = 0;
343 for (k = 0; k < num_of_kinds; k++)
344 {
345 lanes_kind[k] = 0; // reset all
346 }
347
348 int j = 0;
349 for (j = 0; j < parsed_num_lanes; j++)
350 {
351 String lanes_split_sub[] = lanes_split[j].split(";");
352 int parsed_num_lanes_sub = lanes_split_sub.length;
353
354 k = 0;
355 String single_arrow = "";
356 for (k = 0; k < parsed_num_lanes_sub; k++)
357 {
358 single_arrow = lanes_split_sub[k].replaceAll("\\s", "");
359
360 // none 3
361 // through 3
362 // left 1
363 // right 5
364 // slight_left 2
365 // slight_right 4
366 // sharp_left 1
367 // sharp_right 5
368 // mergeto_left -
369 // mergeto_right -
370 // merge_to_left -
371 // merge_to_right -
372
373 if (single_arrow.equalsIgnoreCase("sharp_left"))
374 {
375 lanes_kind[1] = 1;
376 }
377 else if (single_arrow.equalsIgnoreCase("sharp_right"))
378 {
379 lanes_kind[5] = 1;
380 }
381 else if (single_arrow.equalsIgnoreCase("none"))
382 {
383 lanes_kind[3] = 1;
384 }
385 else if (single_arrow.equalsIgnoreCase("through"))
386 {
387 lanes_kind[3] = 1;
388 }
389 else if (single_arrow.equalsIgnoreCase("left"))
390 {
391 lanes_kind[1] = 1;
392 }
393 else if (single_arrow.equalsIgnoreCase("right"))
394 {
395 lanes_kind[5] = 1;
396 }
397 else if (single_arrow.equalsIgnoreCase("slight_left"))
398 {
399 lanes_kind[2] = 1;
400 }
401 else if (single_arrow.equalsIgnoreCase("slight_right"))
402 {
403 lanes_kind[4] = 1;
404 }
405
406 }
407 }
408
409 lanes_kind_count = 0;
410 for (k = 0; k < num_of_kinds; k++)
411 {
412 if (lanes_kind[k] == 1)
413 {
414 //System.out.println("SORTED:lanes_kind_count=" + lanes_kind_count + " lanes_choices_route=" + lanes_choices_route);
415 if (lanes_kind_count == lanes_choices_route)
416 {
417 highlight_kind = k;
418 //System.out.println("SORTED:highlight_kind=" + highlight_kind);
419 }
420 lanes_kind_count++;
421 //System.out.println("SORTED:lanes_kind:" + k + "=" + lanes_kind[k]);
422 }
423 }
424 //System.out.println("SORTED:lanes_kind_count=" + lanes_kind_count);
425
426 }
427
428 }
429 // sort and check lane choice -------------------------------------
430
431 // -------- START POINT ----------
432 // -------- START POINT ----------
433 float scale_x = ((float) NavitGraphics.dp_to_px(100)) / 100.0f * 0.5f / 3.0f; // works: 0.5f
434 float scale_y = ((float) NavitGraphics.dp_to_px(100)) / 100.0f * 0.5f / 3.0f; // works: 0.5f
435 int lane_symbol_width = 152; // works: 140
436 int xx1 = 0; // works: 0
437 int yy1 = NavitGraphics.dp_to_px(10); // works: 30
438 int xx1_start = xx1;
439 int yy1_start = yy1;
440
441 // fill with grey ----------------------
442 c.drawColor(0xbbcccccc); // grey
443 // fill with grey ----------------------
444
445 // float fx_factor = this.w;
446 // float fy_factor = this.h;
447 // calc resize factor:
448 // float fx_ = fx_factor / 1;
449 // float fy_ = fy_factor / 1;
450 // float final_factor = 1.0f / fx_;
451 // if (fy_ > fx_)
452 // {
453 // final_factor = 1.0f / fy_;
454 // }
455 // float final_translator = (float) yy1_start * final_factor;
456 // float final_translator_x = 170.0f * ((float) NavitGraphics.mCanvasWidth / fx_factor);
457
458 //System.out.println("SORTED:tran: " + fx_factor + " " + NavitGraphics.mCanvasWidth + " " + final_translator_x);
459
460 // if (NavitGraphics.mCanvasWidth > fx_factor)
461 // {
462 // lanes_transMatrix.setTranslate((final_translator_x) - 170.0f, final_translator - (float) yy1_start);
463 // }
464 // else
465 // {
466 // lanes_transMatrix.setTranslate(0.0f, final_translator - (float) yy1_start);
467 // }
468
469 //System.out.println("SORTED:tran: x=" + NavitGraphics.mCanvasWidth + " y=" + NavitGraphics.mCanvasHeight + " " + (final_translator - (float) yy1_start) + " f=" + final_factor);
470 // -------- START POINT ----------
471 // -------- START POINT ----------
472
473 boolean highlight_lane = false;
474 if (lanes_kind_count == lanes_choices_count)
475 {
476 highlight_lane = true;
477 //System.out.println("SORTED:highlight_lane=" + highlight_lane);
478 }
479
480 if (parsed_num_lanes == 3)
481 {
482 xx1 = xx1 + (lane_symbol_width) * 1;
483 }
484 else if (parsed_num_lanes == 2)
485 {
486 xx1 = xx1 + (lane_symbol_width) * 2;
487 }
488 else if (parsed_num_lanes == 1)
489 {
490 xx1 = xx1 + (lane_symbol_width) * 3;
491 }
492
493 int j = 0;
494 for (j = 0; j < parsed_num_lanes; j++)
495 {
496
497 // move to next lane (move to right)
498 xx1 = xx1 + lane_symbol_width;
499
500 String lanes_split_sub[] = lanes_split[j].split(";");
501 int parsed_num_lanes_sub = lanes_split_sub.length;
502
503 int k = 0;
504 String single_arrow = "";
505 for (k = 0; k < parsed_num_lanes_sub; k++)
506 {
507
508 single_arrow = lanes_split_sub[k].replaceAll("\\s", "");
509
510 // dirty correction hack !! ------------------
511 // dirty correction hack !! ------------------
512 // if (single_arrow.equalsIgnoreCase("sharp_right"))
513 // {
514 // single_arrow = "right";
515 // }
516 // else if (single_arrow.equalsIgnoreCase("sharp_left"))
517 // {
518 // single_arrow = "left";
519 // }
520 if (single_arrow.equalsIgnoreCase("merge_to_left"))
521 {
522 single_arrow = "mergeto_left";
523 }
524 else if (single_arrow.equalsIgnoreCase("merge_to_right"))
525 {
526 single_arrow = "mergeto_right";
527 }
528 // dirty correction hack !! ------------------
529 // dirty correction hack !! ------------------
530
531 // ---------===================---------------
532 // ---------===================---------------
533 // ---------===================---------------
534
535 pathForTurn.reset();
536 int ha = 72;
537 int wa = 72;
538
539 int th = 12 * 3; // (12) thickness
540 // pathForTurn.moveTo(wa / 2, ha - 1);
541
542 pathForTurn.moveTo(xx1, yy1);
543
544 float sarrowL = 22 * 4; // (22) side of arrow ?
545 float harrowL = (float) (Math.sqrt(2) * sarrowL); // (float) (Math.sqrt(2) * sarrowL)
546 float spartArrowL = (float) ((sarrowL - th / Math.sqrt(2)) / 2); // (float) ((sarrowL - th / Math.sqrt(2)) / 2)
547 float hpartArrowL = ((float) (harrowL - th) / 2); // ((float) (harrowL - th) / 2)
548
549 // none
550 // through
551 // left
552 // right
553 // slight_left
554 // slight_right
555 // sharp_left
556 // sharp_right
557 // mergeto_left
558 // mergeto_right
559 // merge_to_left
560 // merge_to_right
561
562 no_draw = false;
563
564 paint.setColor(Color.LTGRAY);
565
566 if ((single_arrow.equalsIgnoreCase("slight_left")) || (single_arrow.equalsIgnoreCase("slight_right")))
567 {
568 // -----------------------------------------------------
569 // turn slighty left or right
570 // -----------------------------------------------------
571 int b = 1; // right = 1 or left = -1
572 if (single_arrow.equalsIgnoreCase("slight_left"))
573 {
574 b = -1;
575 pathForTurn.moveTo(xx1 - 4, yy1);
576 if ((highlight_lane) && (highlight_kind == 2))
577 {
578 //System.out.println("SORTED: XXXXXXXXXXXXXXXX");
579 paint.setColor(Color.GREEN);
580 }
581
582 }
583 else
584 {
585 pathForTurn.moveTo(xx1 + 40, yy1);
586
587 if ((highlight_lane) && (highlight_kind == 4))
588 {
589 paint.setColor(Color.GREEN);
590 }
591 }
592
593 int h = (int) (24.0f * 3.0f); // (24)
594 int quadShiftY = 22 * 4; // (22)
595 float quadShiftX = ((float) (quadShiftY / (1 + Math.sqrt(2)))) * 1.5f; // (float) (quadShiftY / (1 + Math.sqrt(2)))
596 float nQuadShiftX = ((sarrowL - 2 * spartArrowL) - quadShiftX - th); // (sarrowL - 2 * spartArrowL) - quadShiftX - th
597 float nQuadShifty = quadShiftY + (sarrowL - 2 * spartArrowL); // quadShiftY + (sarrowL - 2 * spartArrowL)
598 pathForTurn.rMoveTo(-b * 4, 0);
599 pathForTurn.rLineTo(0, -h /* + partArrowL */);
600 pathForTurn.rQuadTo(0, -quadShiftY + quadShiftX /*- partArrowL*/, b * quadShiftX, -quadShiftY /*- partArrowL*/);
601 pathForTurn.rLineTo(b * spartArrowL, spartArrowL);
602 pathForTurn.rLineTo(0, -sarrowL); // center
603 pathForTurn.rLineTo(-b * sarrowL, 0);
604 pathForTurn.rLineTo(b * spartArrowL, spartArrowL);
605 pathForTurn.rQuadTo(b * nQuadShiftX, -nQuadShiftX, b * nQuadShiftX, nQuadShifty);
606 pathForTurn.rLineTo(0, h);
607 // -----------------------------------------------------
608 // -----------------------------------------------------
609 }
610 else if ((single_arrow.equalsIgnoreCase("left")) || (single_arrow.equalsIgnoreCase("right")))
611 {
612 int b = 1; // right = 1 or left = -1
613 if (single_arrow.equalsIgnoreCase("left"))
614 {
615 b = -1;
616 pathForTurn.moveTo(xx1 - 4, yy1);
617
618 if ((highlight_lane) && (highlight_kind == 1))
619 {
620 paint.setColor(Color.GREEN);
621 }
622 }
623 else
624 {
625 pathForTurn.moveTo(xx1 + 40, yy1);
626
627 if ((highlight_lane) && (highlight_kind == 5))
628 {
629 paint.setColor(Color.GREEN);
630 }
631 }
632
633 float quadShiftX = 18;
634 float quadShiftY = 18;
635 int wl = 10; // width
636 int h = (int) (ha - quadShiftY - harrowL + hpartArrowL - 5);
637
638 // --
639 h = -2 * h;
640 // --
641
642 int sl = wl + th / 2;
643
644 // --
645 sl = 2;
646 // --
647
648 pathForTurn.rMoveTo(-b * sl, 0);
649 pathForTurn.rLineTo(0, -h);
650 pathForTurn.rQuadTo(0, -quadShiftY, b * quadShiftX, -quadShiftY);
651 pathForTurn.rLineTo(b * wl, 0);
652
653 pathForTurn.rLineTo(0, hpartArrowL);
654 pathForTurn.rLineTo(b * harrowL / 2, -harrowL / 2); // center
655 pathForTurn.rLineTo(-b * harrowL / 2, -harrowL / 2);
656 pathForTurn.rLineTo(0, hpartArrowL);
657
658 pathForTurn.rLineTo(-b * wl, 0);
659 pathForTurn.rQuadTo(-b * (quadShiftX + th), 0, -b * (quadShiftX + th), quadShiftY + th);
660 pathForTurn.rLineTo(0, h);
661 }
662 else if ((single_arrow.equalsIgnoreCase("sharp_left")) || (single_arrow.equalsIgnoreCase("sharp_right")))
663 {
664 int b = 1; // right = 1 or left = -1
665 if (single_arrow.equalsIgnoreCase("sharp_left"))
666 {
667 b = -1;
668 pathForTurn.moveTo(xx1 - 4, yy1);
669
670 if ((highlight_lane) && (highlight_kind == 1))
671 {
672 paint.setColor(Color.GREEN);
673 }
674 }
675 else
676 {
677 pathForTurn.moveTo(xx1 + 40, yy1);
678
679 if ((highlight_lane) && (highlight_kind == 5))
680 {
681 paint.setColor(Color.GREEN);
682 }
683 }
684
685 float quadShiftX = 18;
686 float quadShiftY = 18;
687 int wl = 10; // width
688 int h = (int) (ha - quadShiftY - harrowL + hpartArrowL - 5);
689
690 // --
691 h = -2 * h;
692 // --
693
694 int sl = wl + th / 2;
695
696 // --
697 sl = 2;
698 // --
699
700 pathForTurn.rMoveTo(-b * sl, 0);
701 pathForTurn.rLineTo(0, -h);
702 pathForTurn.rQuadTo(0, -quadShiftY, b * quadShiftX, -quadShiftY);
703 pathForTurn.rLineTo(b * wl, 0);
704
705 pathForTurn.rLineTo(0, hpartArrowL);
706 pathForTurn.rLineTo(b * harrowL / 2, -harrowL / 2); // center
707 pathForTurn.rLineTo(-b * harrowL / 2, -harrowL / 2);
708 pathForTurn.rLineTo(0, hpartArrowL);
709
710 pathForTurn.rLineTo(-b * wl, 0);
711 pathForTurn.rQuadTo(-b * (quadShiftX + th), 0, -b * (quadShiftX + th), quadShiftY + th);
712 pathForTurn.rLineTo(0, h);
713 }
714 else if ((single_arrow.equalsIgnoreCase("mergeto_left")) || (single_arrow.equalsIgnoreCase("mergeto_right")))
715 {
716 int b = 1; // right = 1 or left = -1
717 if (single_arrow.equalsIgnoreCase("mergeto_left"))
718 {
719 b = -1;
720 pathForTurn.moveTo(xx1 - 4, yy1);
721
722 if ((highlight_lane) && (highlight_kind == -99))
723 {
724 paint.setColor(Color.GREEN);
725 }
726 }
727 else
728 {
729 pathForTurn.moveTo(xx1 + 40, yy1);
730
731 if ((highlight_lane) && (highlight_kind == -99))
732 {
733 paint.setColor(Color.GREEN);
734 }
735 }
736
737 int h = (int) (24.0f * 3.0f); // (24)
738
739 // --
740 h = (int) ((float) h * 0.9f);
741 // --
742
743 int quadShiftY = 22 * 4; // (22)
744 float quadShiftX = ((float) (quadShiftY / (1 + Math.sqrt(2)))) * 1.2f; // (float) (quadShiftY / (1 + Math.sqrt(2)))
745 float nQuadShiftX = ((sarrowL - 2 * spartArrowL) - quadShiftX - th); // (sarrowL - 2 * spartArrowL) - quadShiftX - th
746 float nQuadShifty = quadShiftY + (sarrowL - 2 * spartArrowL); // quadShiftY + (sarrowL - 2 * spartArrowL)
747 pathForTurn.rMoveTo(-b * 4, 0);
748 pathForTurn.rLineTo(0, -h /* + partArrowL */);
749 pathForTurn.rQuadTo(0, -quadShiftY + quadShiftX /*- partArrowL*/, b * quadShiftX, -quadShiftY /*- partArrowL*/);
750 pathForTurn.rLineTo(b * spartArrowL, spartArrowL);
751 pathForTurn.rLineTo(0, -sarrowL); // center
752 pathForTurn.rLineTo(-b * sarrowL, 0);
753 pathForTurn.rLineTo(b * spartArrowL, spartArrowL);
754 pathForTurn.rQuadTo(b * nQuadShiftX, -nQuadShiftX, b * nQuadShiftX, nQuadShifty);
755 pathForTurn.rLineTo(0, h);
756 }
757 else if ((single_arrow.equalsIgnoreCase("none")) || (single_arrow.equalsIgnoreCase("through")))
758 {
759 int h = ((int) (ha - hpartArrowL - 16)); // (int) (ha - hpartArrowL - 16)
760
761 if ((highlight_lane) && (highlight_kind == 3))
762 {
763 paint.setColor(Color.GREEN);
764 //System.out.println("SORTED:highlight straight");
765 }
766
767 h = 18 * h;
768
769 pathForTurn.rMoveTo(th, 0);
770 pathForTurn.rLineTo(0, -h);
771 pathForTurn.rLineTo(hpartArrowL, 0);
772 pathForTurn.rLineTo(-harrowL / 2, -harrowL / 2); // center
773 pathForTurn.rLineTo(-harrowL / 2, harrowL / 2);
774 pathForTurn.rLineTo(hpartArrowL, 0);
775 pathForTurn.rLineTo(0, h);
776 }
777 else
778 {
779 no_draw = true;
780 }
781
782 if (!no_draw)
783 {
784 pathForTurn.close();
785
786 // now scale path to correct size ---------------
787 // now scale path to correct size ---------------
788 // now scale path to correct size ---------------
789 lanes_scaleMatrix.reset();
790 // pathForTurn.computeBounds(lanes_rectF, true);
791 // lanes_scaleMatrix.setScale(0.25f, 0.25f, lanes_rectF.centerX(), lanes_rectF.centerY());
792 lanes_scaleMatrix.setScale(scale_x, scale_y, xx1_start, yy1_start);
793 pathForTurn.transform(lanes_scaleMatrix);
794 pathForTurn.transform(lanes_transMatrix);
795 // now scale path to correct size ---------------
796 // now scale path to correct size ---------------
797 // now scale path to correct size ---------------
798
799 paint.setAntiAlias(true);
800 paint.setDither(true);
801
802 paint.setStyle(Style.FILL);
803 paint.setStrokeWidth(0);
804
805 c.drawPath(pathForTurn, paint);
806
807 paint.setColor(Color.BLACK);
808 paint.setStyle(Style.STROKE);
809 paint.setStrokeWidth((float) NavitGraphics.dp_to_px(100) * (float) 4.0f / (float) 3.0f / (float) 100.0f); // works: 4
810
811 c.drawPath(pathForTurn, paint);
812 }
813 }
814
815 }
816 // ---------===================---------------
817 // ---------===================---------------
818 }
819 else
820 {
821 c.drawColor(Color.TRANSPARENT);
822 // c.drawColor(Color.RED);
823 }
824 }
825 else
826 {
827 c.drawColor(Color.TRANSPARENT);
828 // c.drawColor(Color.GREEN);
829 }
830 }
831 else
832 {
833 c.drawColor(Color.TRANSPARENT);
834 // c.drawColor(Color.BLUE);
835 }
836
837 // System.out.println("onDraw:OSDLaneAssist");
838 }
839 }

   
Visit the ZANavi Wiki