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

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

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

Revision 30 Revision 31
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 java.util.ArrayList;
41import java.util.concurrent.LinkedBlockingQueue; 42import java.util.concurrent.LinkedBlockingQueue;
42 43
43import android.app.Activity; 44import android.app.Activity;
44import android.graphics.Bitmap; 45import android.graphics.Bitmap;
45import android.graphics.BitmapFactory; 46import android.graphics.BitmapFactory;
47import android.graphics.Canvas; 48import android.graphics.Canvas;
48import android.graphics.Color; 49import android.graphics.Color;
49import android.graphics.DashPathEffect; 50import android.graphics.DashPathEffect;
50import android.graphics.Matrix; 51import android.graphics.Matrix;
51import android.graphics.Paint; 52import android.graphics.Paint;
53import android.graphics.Paint.Style;
52import android.graphics.Path; 54import android.graphics.Path;
53import android.graphics.PointF; 55import android.graphics.PointF;
54import android.graphics.Rect; 56import android.graphics.Rect;
55import android.os.Bundle; 57import android.os.Bundle;
56import android.os.Debug; 58import android.os.Debug;
87 static Boolean draw_map_one_shot = false; 89 static Boolean draw_map_one_shot = false;
88 static Boolean draw_reset_factors = false; 90 static Boolean draw_reset_factors = false;
89 91
90 static Camera camera = new Camera(); 92 static Camera camera = new Camera();
91 static Matrix cam_m = new Matrix(); 93 static Matrix cam_m = new Matrix();
94 static float strech_factor_3d_map = 2.0f;
95 static int rotate_3d_map_angle = 61;
92 96
93 private Canvas draw_canvas; 97 private Canvas draw_canvas;
94 private Bitmap draw_bitmap; 98 private Bitmap draw_bitmap;
95 private Canvas draw_canvas_screen; 99 private Canvas draw_canvas_screen;
96 private Bitmap draw_bitmap_screen; 100 private Bitmap draw_bitmap_screen;
751 SizeChangedCallback(w, h); 755 SizeChangedCallback(w, h);
752 756
753 // 3D modus ----------------- 757 // 3D modus -----------------
754 NavitGraphics.camera.save(); 758 NavitGraphics.camera.save();
755 //NavitGraphics.camera.translate(0, 0, 40); 759 //NavitGraphics.camera.translate(0, 0, 40);
756 NavitGraphics.camera.rotateX(65); 760 NavitGraphics.camera.rotateX(rotate_3d_map_angle);
757 NavitGraphics.camera.getMatrix(NavitGraphics.cam_m); 761 NavitGraphics.camera.getMatrix(NavitGraphics.cam_m);
758 NavitGraphics.camera.restore(); 762 NavitGraphics.camera.restore();
759 // C-Code: (50 + offset) * height / 100 // offset = 30% 763 // C-Code: (50 + offset) * height / 100 // offset = 30%
760 //float y_point = (bitmap_h - (bitmap_h * 0.7f)); 764 //float y_point = (bitmap_h - (bitmap_h * 0.7f));
761 float y_offset = 0; // 20 765 float y_offset = 0; // 20
762 float y_point = bitmap_h * 0.7f; 766 float y_point = bitmap_h * 0.7f;
763 NavitGraphics.cam_m.preTranslate(-bitmap_w / 2, -y_offset - y_point); 767 NavitGraphics.cam_m.preTranslate(-bitmap_w / 2, -y_offset - y_point);
764 NavitGraphics.cam_m.postTranslate(bitmap_w / 2, y_offset + y_point); 768 NavitGraphics.cam_m.postTranslate(bitmap_w / 2, y_offset + y_point);
765 NavitGraphics.cam_m.postScale(2.5f, 2.5f, bitmap_w / 2, y_offset + y_point); 769 NavitGraphics.cam_m.postScale(strech_factor_3d_map, strech_factor_3d_map, bitmap_w / 2, y_offset + y_point);
766 //NavitGraphics.cam_m.postTranslate(0, 50); 770 //NavitGraphics.cam_m.postTranslate(0, 50);
767 // 3D modus ----------------- 771 // 3D modus -----------------
768 772
769 draw_factor = 1.0f; 773 draw_factor = 1.0f;
770 if (Navit.my_display_density.compareTo("mdpi") == 0) 774 if (Navit.my_display_density.compareTo("mdpi") == 0)
2144 // draw map async 2148 // draw map async
2145 CallbackMessageChannel(65, ""); 2149 CallbackMessageChannel(65, "");
2146 } 2150 }
2147 else if (msg.getData().getInt("Callback") == 66) 2151 else if (msg.getData().getInt("Callback") == 66)
2148 { 2152 {
2149 // enable "water from relations" 2153 // enable "multipolygons"
2150 CallbackMessageChannel(66, ""); 2154 CallbackMessageChannel(66, "");
2151 } 2155 }
2152 else if (msg.getData().getInt("Callback") == 67) 2156 else if (msg.getData().getInt("Callback") == 67)
2153 { 2157 {
2154 // disable "water from relations" 2158 // disable "multipolygons"
2155 CallbackMessageChannel(67, ""); 2159 CallbackMessageChannel(67, "");
2156 } 2160 }
2157 else if (msg.getData().getInt("Callback") == 68) 2161 else if (msg.getData().getInt("Callback") == 68)
2158 { 2162 {
2159 // shift "order" by this value (only for drawing objects) 2163 // shift "order" by this value (only for drawing objects)
2199 else if (msg.getData().getInt("Callback") == 75) 2203 else if (msg.getData().getInt("Callback") == 75)
2200 { 2204 {
2201 // stop demo vechile 2205 // stop demo vechile
2202 CallbackMessageChannel(75, ""); 2206 CallbackMessageChannel(75, "");
2203 } 2207 }
2204 2208 else if (msg.getData().getInt("Callback") == 76)
2209 {
2210 // show route rectangles
2211 CallbackMessageChannel(76, "");
2212 }
2213 else if (msg.getData().getInt("Callback") == 77)
2214 {
2215 // do not show route rectangles
2216 CallbackMessageChannel(77, "");
2217 }
2218 else if (msg.getData().getInt("Callback") == 78)
2219 {
2220 // shift layout "order" values
2221 String s = msg.getData().getString("s");
2222 CallbackMessageChannel(78, s);
2223 }
2224 else if (msg.getData().getInt("Callback") == 79)
2225 {
2226 // set traffic light delay/cost
2227 String s = msg.getData().getString("s");
2228 CallbackMessageChannel(79, s);
2229 }
2205 } 2230 }
2206 }; 2231 };
2207 2232
2208 public static native void TimeoutCallback(int del, int id); 2233 public static native void TimeoutCallback(int del, int id);
2209 2234
3892 Global_Map_Rotationangle = 0f; 3917 Global_Map_Rotationangle = 0f;
3893 Global_Map_Zoomfactor = 1.0f; 3918 Global_Map_Zoomfactor = 1.0f;
3894 try 3919 try
3895 { 3920 {
3896 draw_canvas_screen_s.drawBitmap(draw_bitmap_s, 0, 0, null); 3921 draw_canvas_screen_s.drawBitmap(draw_bitmap_s, 0, 0, null);
3922
3923 if (Navit.PREF_show_route_rects)
3924 {
3925 // --- draw debug route rects ----
3926 int i3 = 0;
3927 for (i3 = 0; i3 < route_rects.size(); i3++)
3928 {
3929 route_rect rr = route_rects.get(i3);
3930 Paint paint78 = new Paint();
3931 if (rr.order == -99)
3932 {
3933 // rectangle to just include all waypoints
3934 paint78.setColor(Color.RED);
3935 }
3936 else if (rr.order == 8)
3937 {
3938 // rectangle around every waypoint with low detail (order = 8)
3939 paint78.setColor(Color.GREEN);
3940 }
3941 else if (rr.order == 18)
3942 {
3943 // rectangle around every waypoint with high detail (order = 18)
3944 paint78.setColor(Color.MAGENTA);
3945 }
3946 else if (rr.order == 4)
3947 {
3948 // rectangles ??
3949 paint78.setColor(Color.BLUE);
3950 }
3951 else if (rr.order == 6)
3952 {
3953 // rectangles ??
3954 paint78.setColor(Color.CYAN);
3955 }
3956 else if (rr.order == 7)
3957 {
3958 // rectangles ??
3959 paint78.setColor(Color.YELLOW);
3960 }
3961
3962 paint78.setStrokeWidth(15);
3963 paint78.setStyle(Style.STROKE);
3964
3965 String left_top_on_screen_string = CallbackGeoCalc(11, rr.x1, rr.y1);
3966 String tmp[] = left_top_on_screen_string.split(":", 2);
3967 int xx1 = Integer.parseInt(tmp[0]);
3968 int yy1 = Integer.parseInt(tmp[1]);
3969 //System.out.println(" " + xx1 + "," + yy1);
3970
3971 left_top_on_screen_string = CallbackGeoCalc(11, rr.x2, rr.y2);
3972 tmp = left_top_on_screen_string.split(":", 2);
3973 int xx2 = Integer.parseInt(tmp[0]);
3974 int yy2 = Integer.parseInt(tmp[1]);
3975 //System.out.println(" " + xx2 + "," + yy2);
3976
3977 // draw the route rectanlge
3978 draw_canvas_screen_s.drawRect(xx1, yy1, xx2, yy2, paint78);
3979 }
3980 // --- draw debug route rects ----
3981 }
3897 } 3982 }
3898 catch (Exception e) 3983 catch (Exception e)
3899 { 3984 {
3900 // if screen is rotated, bitmaps are not valid, and this would crash 3985 // if screen is rotated, bitmaps are not valid, and this would crash
3901 // find a better solution later!! 3986 // find a better solution later!!
4900 // we hope its a real result value 4985 // we hope its a real result value
4901 Navit.Navit_Address_Result_Struct tmp_addr = new Navit_Address_Result_Struct(); 4986 Navit.Navit_Address_Result_Struct tmp_addr = new Navit_Address_Result_Struct();
4902 String[] tmp_s = s.split(":"); 4987 String[] tmp_s = s.split(":");
4903 tmp_addr.result_type = tmp_s[0]; 4988 tmp_addr.result_type = tmp_s[0];
4904 tmp_addr.item_id = tmp_s[1]; 4989 tmp_addr.item_id = tmp_s[1];
4990
4991 if (Navit.use_index_search)
4992 {
4993 tmp_addr.lat = Integer.parseInt(tmp_s[2]);
4994 tmp_addr.lon = Integer.parseInt(tmp_s[3]);
4995 }
4996 else
4997 {
4905 tmp_addr.lat = Float.parseFloat(tmp_s[2]); 4998 tmp_addr.lat = Float.parseFloat(tmp_s[2]);
4906 tmp_addr.lon = Float.parseFloat(tmp_s[3]); 4999 tmp_addr.lon = Float.parseFloat(tmp_s[3]);
5000 }
4907 // the rest ist address 5001 // the rest ist address
4908 tmp_addr.addr = s.substring(4 + tmp_s[0].length() + tmp_s[1].length() + tmp_s[2].length() + tmp_s[3].length(), s.length()); 5002 tmp_addr.addr = s.substring(4 + tmp_s[0].length() + tmp_s[1].length() + tmp_s[2].length() + tmp_s[3].length(), s.length());
4909 5003
4910 // if "type" and "H id" and "text" is the same, treat it as a double entry!
4911 // this is just a crude estimate now
4912 // *OLD* String hash_id = tmp_addr.result_type + ":" + tmp_addr.item_id.split("L")[0] + ":" + tmp_addr.addr;
4913 // String hash_id = tmp_addr.result_type + ":" + tmp_addr.item_id + ":" + tmp_addr.addr;
4914 String hash_id = tmp_addr.result_type + ":" + tmp_addr.lat + ":" + tmp_addr.lon + ":" + tmp_addr.addr; 5004 // String hash_id = tmp_addr.result_type + ":" + tmp_addr.lat + ":" + tmp_addr.lon + ":" + tmp_addr.addr;
5005 String hash_id = tmp_addr.result_type + ":" + tmp_addr.addr;
4915 //System.out.println("hash_id=" + hash_id); 5006 //System.out.println("hash_id=" + hash_id);
4916 if (!Navit.Navit_Address_Result_double_index.contains(hash_id)) 5007 if ((!Navit.search_hide_duplicates) || (!Navit.Navit_Address_Result_double_index.contains(hash_id)))
4917 { 5008 {
4918 Navit.NavitAddressResultList_foundItems.add(tmp_addr); 5009 Navit.NavitAddressResultList_foundItems.add(tmp_addr);
4919 Navit.Navit_Address_Result_double_index.add(hash_id); 5010 Navit.Navit_Address_Result_double_index.add(hash_id);
4920 //System.out.println("*add*=" + hash_id); 5011 //System.out.println("*add*=" + hash_id);
4921 5012
4969 // b.putString("title", Navit.get_text("loading search results")); //TRANS 5060 // b.putString("title", Navit.get_text("loading search results")); //TRANS
4970 // b.putString("text", Navit.get_text("towns") + ":" + Navit.search_results_towns + " " + Navit.get_text("Streets") + ":" + Navit.search_results_streets + "/" + Navit.search_results_streets_hn); 5061 // b.putString("text", Navit.get_text("towns") + ":" + Navit.search_results_towns + " " + Navit.get_text("Streets") + ":" + Navit.search_results_streets + "/" + Navit.search_results_streets_hn);
4971 // Navit.msg_to_msg_handler(b, 10); 5062 // Navit.msg_to_msg_handler(b, 10);
4972 } 5063 }
4973 5064
4974 public void SearchResultList(int i, int partial_match, String text, int flags, String country_iso2, String search_latlon, int search_radius) 5065 public void SearchResultList(int i, int partial_match, String text, String t_town, String t_hn, int flags, String country_iso2, String search_latlon, int search_radius)
4975 { 5066 {
4976 CallbackSearchResultList(i, partial_match, text, flags, country_iso2, search_latlon, search_radius); 5067 CallbackSearchResultList(i, partial_match, text, t_town, t_hn, flags, country_iso2, search_latlon, search_radius);
4977 } 5068 }
4978 5069
4979 public native void CallbackSearchResultList(int i, int partial_match, String s, int flags, String country_iso2, String search_latlon, int search_radius); 5070 public native void CallbackSearchResultList(int i, int partial_match, String s, String s_town, String s_hn, int flags, String country_iso2, String search_latlon, int search_radius);
4980 5071
4981 /** 5072 /**
4982 * get localized string 5073 * get localized string
4983 */ 5074 */
4984 public static native String CallbackLocalizedString(String s); 5075 public static native String CallbackLocalizedString(String s);
5027 { 5118 {
5028 // set cache size for (map-)files 5119 // set cache size for (map-)files
5029 String s = msg.getData().getString("s"); 5120 String s = msg.getData().getString("s");
5030 CallbackMessageChannel(55, s); 5121 CallbackMessageChannel(55, s);
5031 } 5122 }
5123 else if (msg.getData().getInt("Callback") == 78)
5124 {
5125 // shift layout "order" values
5126 String s = msg.getData().getString("s");
5127 CallbackMessageChannel(78, s);
5128 }
5129 else if (msg.getData().getInt("Callback") == 79)
5130 {
5131 // set traffic light delay
5132 String s = msg.getData().getString("s");
5133 CallbackMessageChannel(79, s);
5134 }
5032 else if (msg.getData().getInt("Callback") == 9901) 5135 else if (msg.getData().getInt("Callback") == 9901)
5033 { 5136 {
5034 // if follow mode is on, then dont show freeview streetname 5137 // if follow mode is on, then dont show freeview streetname
5035 //if (!Navit.PREF_follow_gps) 5138 //if (!Navit.PREF_follow_gps)
5036 //{ 5139 //{
5262 ZANaviBusySpinner.cancelAnim(); 5365 ZANaviBusySpinner.cancelAnim();
5263 busyspinner_.setVisibility(View.INVISIBLE); 5366 busyspinner_.setVisibility(View.INVISIBLE);
5264 busyspinnertext_.setVisibility(View.INVISIBLE); 5367 busyspinnertext_.setVisibility(View.INVISIBLE);
5265 busyspinnertext_.setText(""); 5368 busyspinnertext_.setText("");
5266 Navit.set_debug_messages1(""); 5369 Navit.set_debug_messages1("");
5370 // DEBUG: clear route rectangle list
5371 route_rects.clear();
5267 } 5372 }
5268 else if (i == 1) 5373 else if (i == 1)
5269 { 5374 {
5270 ZANaviBusySpinner.active = true; 5375 ZANaviBusySpinner.active = true;
5271 busyspinnertext_.setText(Navit.get_text("Destination set")); // TRANS 5376 busyspinnertext_.setText(Navit.get_text("Destination set")); // TRANS
5451 5556
5452 // recreate the new Bitmap 5557 // recreate the new Bitmap
5453 return (Bitmap.createBitmap(in, 0, 0, width, height, matrix, true)); 5558 return (Bitmap.createBitmap(in, 0, 0, width, height, matrix, true));
5454 } 5559 }
5455 5560
5561 public static class route_rect
5562 {
5563 int x1;
5564 int y1;
5565 int x2;
5566 int y2;
5567 int order;
5568 };
5569
5570 public static ArrayList<route_rect> route_rects = new ArrayList<route_rect>();
5571
5572 // value are NOT in pixels!! they need to be converted to pixels before drawing
5573 public static void send_route_rect_to_java(int x1, int y1, int x2, int y2, int order)
5574 {
5575 //System.out.println("send_route_rect_to_java: " + x1 + "," + y1 + " " + x2 + "," + y2 + " o=" + order);
5576
5577 //String left_top_on_screen_string = CallbackGeoCalc(11, x1, y1);
5578 //String tmp[] = left_top_on_screen_string.split(":", 2);
5579 //int pixel_top_left_x = Integer.parseInt(tmp[0]);
5580 //int pixel_top_left_y = Integer.parseInt(tmp[1]);
5581 //System.out.println(" " + pixel_top_left_x + "," + pixel_top_left_y);
5582
5583 //left_top_on_screen_string = CallbackGeoCalc(11, x2, y2);
5584 //tmp = left_top_on_screen_string.split(":", 2);
5585 //pixel_top_left_x = Integer.parseInt(tmp[0]);
5586 //pixel_top_left_y = Integer.parseInt(tmp[1]);
5587 //System.out.println(" " + pixel_top_left_x + "," + pixel_top_left_y);
5588
5589 if (route_rects == null)
5590 {
5591 route_rects = new ArrayList<route_rect>();
5592 }
5593
5594 route_rect rr = new route_rect();
5595 rr.x1 = x1;
5596 rr.y1 = y1;
5597 rr.x2 = x2;
5598 rr.y2 = y2;
5599 rr.order = order;
5600 route_rects.add(rr);
5601 }
5602
5456} 5603}

Legend:
Removed from v.30  
changed lines
  Added in v.31

   
Visit the ZANavi Wiki