/[projects]/android/FriendRadar/src/dk/thoerup/friendradar/RadarView.java
ViewVC logotype

Diff of /android/FriendRadar/src/dk/thoerup/friendradar/RadarView.java

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

revision 267 by torben, Sat Aug 15 10:05:48 2009 UTC revision 268 by torben, Mon Aug 17 07:49:49 2009 UTC
# Line 13  import android.view.SurfaceHolder; Line 13  import android.view.SurfaceHolder;
13  import android.view.SurfaceView;  import android.view.SurfaceView;
14    
15  //public class RadarView extends View {  //public class RadarView extends View {
16  public class RadarView extends SurfaceView implements SurfaceHolder.Callback, Runnable {          public class RadarView extends SurfaceView implements SurfaceHolder.Callback, Runnable {
17            
18            static final float VERT_CORECTION = 5;
19            
20          int angle = 0;          int angle = 0;
21          Paint p = new Paint();          Paint p = new Paint();
22          Paint p2 = new Paint();          Paint p2 = new Paint();
# Line 106  public class RadarView extends SurfaceVi Line 109  public class RadarView extends SurfaceVi
109                  canvas.drawText(distanceText3, (width-textWidth3)/2, vcenter+115+6, p3);                  canvas.drawText(distanceText3, (width-textWidth3)/2, vcenter+115+6, p3);
110                  canvas.drawText(distanceText4, (width-textWidth4)/2, vcenter+150+6, p3);                  canvas.drawText(distanceText4, (width-textWidth4)/2, vcenter+150+6, p3);
111    
112                  final float correction = 5;                  
113                  final float lineLength = 150;                  final float lineLength = 150;
114                  angle -= 6;                  angle -= 6;
115                                    
116                                    
117                  double base = (Math.sin(angle/360.0)*lineLength) + (float)hcenter;                  double base = (Math.sin(angle/360.0)*lineLength) + (float)hcenter;
118                  double height = (Math.cos(angle/360.0)*lineLength) + (float)vcenter;                  double height = (Math.cos(angle/360.0)*lineLength) + (float)vcenter;
119                  height += correction;                  height += VERT_CORECTION;
120                                    
121                                    
122                  canvas.drawLine(hcenter, vcenter, (float)base, (float)height, p2);                  canvas.drawLine(hcenter, vcenter, (float)base, (float)height, p2);
# Line 292  public class RadarView extends SurfaceVi Line 295  public class RadarView extends SurfaceVi
295                          double hypotenuse = (distance / (distanceBase*4.0)) * 150.0;                          double hypotenuse = (distance / (distanceBase*4.0)) * 150.0;
296                          double vertCathesis = Math.sin(bearingRad)*hypotenuse;                          double vertCathesis = Math.sin(bearingRad)*hypotenuse;
297                          double horzCathesis = Math.cos(bearingRad)*hypotenuse;                          double horzCathesis = Math.cos(bearingRad)*hypotenuse;
298                            
299    
300                          //vertCathesis *= -1.0;                          //vertCathesis *= -1.0;
301                                                    
302                          vertCathesis += vcenter;                          vertCathesis += vcenter;
303                          horzCathesis += hcenter;                          horzCathesis += hcenter;
304                                                    
305                            vertCathesis += VERT_CORECTION;
306                            
307                          canvas.drawCircle( (float)horzCathesis, (float)vertCathesis, 3, p3);                          canvas.drawCircle( (float)horzCathesis, (float)vertCathesis, 3, p3);
308                                                    
309                  }                  }

Legend:
Removed from v.267  
changed lines
  Added in v.268

  ViewVC Help
Powered by ViewVC 1.1.20