ContactOverlay.java :  » Location » friendtracker » atila » android » friendtracker » Android Open Source

Android Open Source » Location » friendtracker 
friendtracker » atila » android » friendtracker » ContactOverlay.java
/*
 * FriendTracker
 * Copyright (c) 2009 Juan Gomez Mosquera
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 * for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Or you can get a 
 * copy here: <http://www.gnu.org/licenses/>.
 */

package atila.android.friendtracker;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.drawable.BitmapDrawable;
import atila.android.friendtracker.app.G;

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

public class ContactOverlay extends Overlay 
{
  private Bitmap m_Icon;
  
  public ContactOverlay()
  {
    super();
  }
  
  public boolean Init()
  {
    BitmapDrawable bd = (BitmapDrawable)G.g_Control.m_Parent.getResources().getDrawable(R.drawable.contact1);  
    m_Icon = bd.getBitmap();
    return true;
  }
  
  @Override
  public void draw(Canvas canvas, MapView mapView, boolean shadow) 
  { 
    super.draw(canvas, mapView, shadow); 

        Paint paint = new Paint();    
        Point screenCoords = new Point(); 

        mapView.getProjection().toPixels( G.g_Control.m_User.m_Position.GetMapPoint(), screenCoords); 

        paint.setStrokeWidth(1); 
        paint.setARGB(100, 255, 255, 255); 
        paint.setStyle(Paint.Style.FILL); 
        
        canvas.drawBitmap(m_Icon, screenCoords.x - (m_Icon.getWidth() >> 1), screenCoords.y - (m_Icon.getHeight() >> 1), paint); 
    
  }

}
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.