Utils.java :  » Location » friendtracker » atila » android » friendtracker » app » Android Open Source

Android Open Source » Location » friendtracker 
friendtracker » atila » android » friendtracker » app » Utils.java
package atila.android.friendtracker.app;

import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.RectF;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;

public class Utils
{
  /**
   * \brief Make hit testing to know if the user taps on the overlay passed by arg
   */
  public static boolean HitTest( Bitmap icon, Position iconPos, GeoPoint geopoint, MapView mapview )
  {
    boolean bRet = false;
    Point screenCoords = new Point();
    Point tapScreenCoords = new Point();
    RectF hitTestRect = new RectF();
    mapview.getProjection().toPixels(iconPos.GetMapPoint(), screenCoords);
    mapview.getProjection().toPixels(geopoint, tapScreenCoords);
    hitTestRect.set( 0, 0, icon.getWidth(), icon.getHeight());
    hitTestRect.offset(screenCoords.x - (icon.getWidth() >> 1), screenCoords.y - (icon.getHeight() >> 1));
    if(hitTestRect.contains( tapScreenCoords.x, tapScreenCoords.y) )
    {
      bRet = true;
    }
  
    return bRet;
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.