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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 41 - (show annotations) (download)
Tue Aug 11 18:50:37 2015 UTC (8 years, 8 months ago) by zoff99
File size: 4495 byte(s)
many fixes, and new features
1 /**
2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2013 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.Paint;
26 import android.graphics.RectF;
27 import android.util.AttributeSet;
28 import android.view.View;
29
30 public class ZANaviOSDAirDist extends View
31 {
32
33 private Paint paint = new Paint();
34 private RectF f;
35 int end_x;
36 int end_y;
37 int nt_text_start_x = 0;
38 int nt_text_start_y = 0;
39 int nt_font_size = 10;
40 float draw_factor = 1;
41 int OSD_element_bg_001 = Navit.OSD_blueish_bg_color; // Color.argb(255, 190, 190, 190); // Color.argb(140, 136, 136, 136);
42 String my_text = "";
43 int w2;
44 int h2;
45 int w;
46 int h;
47
48 public ZANaviOSDAirDist(Context context)
49 {
50 super(context);
51 f = new RectF(0, 0, 1, 1);
52 paint.setTextAlign(Paint.Align.CENTER);
53 }
54
55 public ZANaviOSDAirDist(Context context, AttributeSet attrs)
56 {
57 super(context, attrs);
58 f = new RectF(0, 0, 1, 1);
59 paint.setTextAlign(Paint.Align.CENTER);
60 }
61
62 @Override
63 public void onSizeChanged(int w, int h, int oldw, int oldh)
64 {
65 super.onSizeChanged(w, h, oldw, oldh);
66 this.w2 = w / 2;
67 this.h2 = h / 2;
68 this.w = w;
69 this.h = h;
70
71 draw_factor = 1.0f;
72 if (Navit.my_display_density.compareTo("mdpi") == 0)
73 {
74 draw_factor = 1.0f;
75 }
76 else if (Navit.my_display_density.compareTo("ldpi") == 0)
77 {
78 draw_factor = 0.7f;
79 }
80 else if (Navit.my_display_density.compareTo("hdpi") == 0)
81 {
82 draw_factor = 1.5f;
83 }
84
85 // correct for ultra high DPI
86 if (Navit.metrics.densityDpi >= 320) //&& (Navit.PREF_shrink_on_high_dpi))
87 {
88 draw_factor = 1.8f * Navit.metrics.densityDpi / NavitGraphics.Global_want_dpi_other;
89 }
90
91 float real_factor = draw_factor / 1.5f;
92
93 f = new RectF(0 + 6, 0 + 6, w - 6, h - 6);
94
95 nt_text_start_x = (int) (20 * real_factor);
96 nt_text_start_y = (int) (30 * real_factor);
97 nt_font_size = (int) (24 * real_factor);
98 }
99
100 public void onDraw2222222(Canvas c)
101 {
102 if (1 == 2 + 2)
103 {
104 // System.out.println("xxxxxxxxxxxxx");
105 return;
106 }
107
108 // super.onDraw(c);
109 int dest_valid = NavitGraphics.CallbackDestinationValid2();
110
111 try
112 {
113 if ((Navit.OSD_compass.direct_distance_to_target_valid) && (dest_valid > 0))
114 {
115 my_text = Navit.OSD_compass.direct_distance_to_target;
116
117 if (NavitGraphics.MAP_DISPLAY_OFF)
118 {
119 paint.setColor(Color.argb(255, 20, 20, 230));
120 paint.setStyle(Paint.Style.FILL_AND_STROKE);
121 paint.setStrokeWidth(2);
122 paint.setAntiAlias(true);
123 c.drawRoundRect(f, 10, 10, paint);
124
125 paint.setColor(Color.WHITE);
126 paint.setStrokeWidth(3);
127 paint.setStyle(Paint.Style.FILL);
128 paint.setTextSize(nt_font_size);
129 paint.setAntiAlias(true);
130 c.drawText(my_text, nt_text_start_x, nt_text_start_y, paint);
131 }
132 else
133 {
134 paint.setColor(OSD_element_bg_001);
135 paint.setStyle(Paint.Style.FILL_AND_STROKE);
136 paint.setStrokeWidth(2);
137 paint.setAntiAlias(true);
138 c.drawRoundRect(f, 10, 10, paint);
139
140 paint.setColor(NavitOSDJava.OSD_element_text_shadow_001);
141 paint.setStrokeWidth(NavitOSDJava.OSD_element_text_shadow_width);
142 paint.setStyle(Paint.Style.STROKE);
143 paint.setTextSize(nt_font_size);
144 paint.setAntiAlias(true);
145 c.drawText(my_text, w2, h + (paint.ascent() / 2), paint);
146
147 paint.setColor(NavitOSDJava.OSD_element_text_001);
148 paint.setStrokeWidth(3);
149 paint.setStyle(Paint.Style.FILL);
150 paint.setTextSize(nt_font_size);
151 paint.setAntiAlias(true);
152 c.drawText(my_text, w2, h + (paint.ascent() / 2), paint);
153 }
154 }
155 }
156 catch (Exception e)
157 {
158 //e.printStackTrace();
159 }
160
161 }
162 }

   
Visit the ZANavi Wiki