Java Code Examples for android.graphics.Point

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project android-xbmcremote, under directory /src/org/xbmc/android/widget/gestureremote/.

Source file: GestureRemoteAnimation.java

  24 
vote

@Override protected void applyTransformation(float interpolatedTime,Transformation t){
  final Point to=new Point(mFrom.x - (int)((mFrom.x - mOrigin.x) * interpolatedTime),mFrom.y - (int)((mFrom.y - mOrigin.y) * interpolatedTime));
  mCursor.setPosition(to);
  if (mGestureZoneFadeOut) {
    mCursor.backgroundFadePos=(int)(interpolatedTime * 255.0);
  }
  if (mGestureZoneFadeIn) {
    mCursor.backgroundFadePos=(int)((1 - interpolatedTime) * 255.0);
  }
}
 

Example 2

From project AirCastingAndroidClient, under directory /src/main/java/pl/llp/aircasting/view/.

Source file: NoisePlot.java

  22 
vote

private void drawNote(Canvas canvas,Note note){
  if (!inRange(note))   return;
  Point place=place(note);
  Drawable noteArrow=resourceHelper.getNoteArrow();
  centerBottomAt(noteArrow,place);
  noteArrow.draw(canvas);
}
 

Example 3

From project Android, under directory /app/src/main/java/com/github/mobile/util/.

Source file: ImageUtils.java

  22 
vote

/** 
 * Get bitmap with maximum height or width
 * @param imagePath
 * @param width
 * @param height
 * @return image
 */
public static Bitmap getBitmap(final String imagePath,int width,int height){
  Point size=getSize(imagePath);
  int currWidth=size.x;
  int currHeight=size.y;
  int scale=1;
  while (currWidth >= width || currHeight >= height) {
    currWidth/=2;
    currHeight/=2;
    scale*=2;
  }
  return getBitmap(imagePath,scale);
}
 

Example 4

From project android-bankdroid, under directory /src/net/margaritov/preference/colorpicker/.

Source file: ColorPickerView.java

  22 
vote

private Point hueToPoint(float hue){
  final RectF rect=mHueRect;
  final float height=rect.height();
  Point p=new Point();
  p.y=(int)(height - (hue * height / 360f) + rect.top);
  p.x=(int)rect.left;
  return p;
}
 

Example 5

From project android-joedayz, under directory /Proyectos/androidMDWCompleto/src/com/android/mdw/demo/.

Source file: Main.java

  22 
vote

@Override public boolean draw(Canvas canvas,MapView mapView,boolean shadow,long when){
  super.draw(canvas,mapView,shadow);
  Point scrnPoint=new Point();
  mapView.getProjection().toPixels(this.point,scrnPoint);
  Bitmap marker=BitmapFactory.decodeResource(getResources(),R.drawable.icon);
  canvas.drawBitmap(marker,scrnPoint.x - marker.getWidth() / 2,scrnPoint.y - marker.getHeight() / 2,null);
  return true;
}
 

Example 6

From project android-ocr, under directory /android/src/edu/sfsu/cs/orange/ocr/camera/.

Source file: PreviewCallback.java

  22 
vote

@Override public void onPreviewFrame(byte[] data,Camera camera){
  Point cameraResolution=configManager.getCameraResolution();
  Handler thePreviewHandler=previewHandler;
  if (cameraResolution != null && thePreviewHandler != null) {
    Message message=thePreviewHandler.obtainMessage(previewMessage,cameraResolution.x,cameraResolution.y,data);
    message.sendToTarget();
    previewHandler=null;
  }
 else {
    Log.d(TAG,"Got preview callback, but no handler or resolution available");
  }
}
 

Example 7

From project androidtracks, under directory /src/org/sfcta/cycletracks/.

Source file: ShowMap.java

  22 
vote

@Override public boolean draw(Canvas canvas,MapView mapView,boolean shadow,long when){
  super.draw(canvas,mapView,shadow);
  Point screenPoint=new Point();
  mapView.getProjection().toPixels(p,screenPoint);
  Bitmap bmp=BitmapFactory.decodeResource(getResources(),d);
  int height=bmp.getScaledHeight(canvas);
  int width=(int)(0.133333 * bmp.getScaledWidth(canvas));
  canvas.drawBitmap(bmp,screenPoint.x - width,screenPoint.y - height,null);
  return true;
}
 

Example 8

From project apps-for-android, under directory /BTClickLinkCompete/src/net/clc/bt/.

Source file: AirHockey.java

  22 
vote

public Point getPaddleCenter(){
  if (mPaddleTimes.size() > 0) {
    Point p=mPaddlePoints.get(mPaddlePoints.size() - 1);
    int x=p.x + 10;
    int y=p.y - 130;
    return new Point(x,y);
  }
 else {
    return new Point(-1,-1);
  }
}
 

Example 9

From project BibleQuote-for-Android, under directory /src/com/BibleQuote/controls/ColorPicker/.

Source file: ColorPickerView.java

  22 
vote

private Point hueToPoint(float hue){
  final RectF rect=mHueRect;
  final float height=rect.height();
  Point p=new Point();
  p.y=(int)(height - (hue * height / 360f) + rect.top);
  p.x=(int)rect.left;
  return p;
}
 

Example 10

From project CHMI, under directory /src/org/kaldax/app/chmi/.

Source file: GMapsLayoutProvider.java

  22 
vote

@Override public void draw(Canvas canvas,MapView mapView,boolean shadow){
  if ((posDrawable == null) || (positionPoint == null)) {
    return;
  }
  if (!shadow) {
    super.draw(canvas,mapView,shadow);
    Point point=new Point();
    Projection p=mapView.getProjection();
    p.toPixels(positionPoint,point);
    posDrawable.setBounds(point.x - 20,point.y - 20,point.x + 20,point.y + 20);
    posDrawable.draw(canvas);
  }
}
 

Example 11

From project creamed_glacier_app_settings, under directory /src/net/margaritov/preference/colorpicker/.

Source file: ColorPickerView.java

  22 
vote

private Point hueToPoint(float hue){
  final RectF rect=mHueRect;
  final float height=rect.height();
  Point p=new Point();
  p.y=(int)(height - (hue * height / 360f) + rect.top);
  p.x=(int)rect.left;
  return p;
}
 

Example 12

From project cw-advandroid, under directory /Maps/EvenNooerYawk/src/com/commonsware/android/nooer/.

Source file: NooYawk.java

  22 
vote

@Override protected boolean onTap(int i){
  OverlayItem item=getItem(i);
  GeoPoint geo=item.getPoint();
  Point pt=map.getProjection().toPixels(geo,null);
  View view=panel.getView();
  ((TextView)view.findViewById(R.id.latitude)).setText(String.valueOf(geo.getLatitudeE6() / 1000000.0));
  ((TextView)view.findViewById(R.id.longitude)).setText(String.valueOf(geo.getLongitudeE6() / 1000000.0));
  ((TextView)view.findViewById(R.id.x)).setText(String.valueOf(pt.x));
  ((TextView)view.findViewById(R.id.y)).setText(String.valueOf(pt.y));
  panel.show(pt.y * 2 > map.getHeight());
  return (true);
}
 

Example 13

From project cw-omnibus, under directory /Maps/EvenNooerYawk/src/com/commonsware/android/nooer/.

Source file: NooYawk.java

  22 
vote

@Override protected boolean onTap(int i){
  OverlayItem item=getItem(i);
  GeoPoint geo=item.getPoint();
  Point pt=map.getProjection().toPixels(geo,null);
  View view=panel.getView();
  ((TextView)view.findViewById(R.id.latitude)).setText(String.valueOf(geo.getLatitudeE6() / 1000000.0));
  ((TextView)view.findViewById(R.id.longitude)).setText(String.valueOf(geo.getLongitudeE6() / 1000000.0));
  ((TextView)view.findViewById(R.id.x)).setText(String.valueOf(pt.x));
  ((TextView)view.findViewById(R.id.y)).setText(String.valueOf(pt.y));
  panel.show(pt.y * 2 > map.getHeight());
  return (true);
}
 

Example 14

From project droid-comic-viewer, under directory /src/net/robotmedia/acv/ui/.

Source file: ComicViewerActivity.java

  22 
vote

public boolean onDoubleTap(MotionEvent e){
  String action=preferences.getString(Constants.INPUT_DOUBLE_TAP,Constants.ACTION_VALUE_ZOOM_IN);
  Point p=new Point(Math.round(e.getX()),Math.round(e.getY()));
  if (Constants.ACTION_VALUE_ZOOM_IN.equals(action) && isComicLoaded() && mScreen.isMaxZoom()) {
    return mScreen.zoom(-1,p);
  }
 else {
    return action(Constants.INPUT_DOUBLE_TAP,Constants.ACTION_VALUE_ZOOM_IN,p);
  }
}
 

Example 15

From project droidgiro-android, under directory /src/com/google/zxing/client/android/camera/.

Source file: PreviewCallback.java

  22 
vote

public void onPreviewFrame(byte[] data,Camera camera){
  Point cameraResolution=configManager.getCameraResolution();
  if (!useOneShotPreviewCallback) {
    camera.setPreviewCallback(null);
  }
  if (previewHandler != null) {
    Message message=previewHandler.obtainMessage(previewMessage,cameraResolution.x,cameraResolution.y,data);
    message.sendToTarget();
    previewHandler=null;
  }
 else {
    Log.d(TAG,"Got preview callback, but no handler for it");
  }
}
 

Example 16

From project gh4a, under directory /src/com/github/mobile/util/.

Source file: ImageUtils.java

  22 
vote

/** 
 * Get bitmap with maximum height or width
 * @param imagePath
 * @param width
 * @param height
 * @return image
 */
public static Bitmap getBitmap(final String imagePath,int width,int height){
  Point size=getSize(imagePath);
  int currWidth=size.x;
  int currHeight=size.y;
  int scale=1;
  while (currWidth >= width || currHeight >= height) {
    currWidth/=2;
    currHeight/=2;
    scale*=2;
  }
  return getBitmap(imagePath,scale);
}
 

Example 17

From project gobandroid, under directory /src/org/ligi/gobandroid_hd/ui/.

Source file: GoBoardViewHD.java

  22 
vote

public PointF getZoomTranslate(){
  if (zoom <= 1.0f)   return new PointF(0,0);
  int act_zoom_poi=0;
  if (zoom_poi >= 0) {
    act_zoom_poi=zoom_poi;
  }
 else   if (getApp().getInteractionScope().getTouchPosition() >= 0) {
    act_zoom_poi=getApp().getInteractionScope().getTouchPosition();
  }
 else   Log.w("zoom requested but no POI to center around");
  Point act_zoom_point=getGame().linear_coordinate2Point(act_zoom_poi);
  PointF res=new PointF(-stone_size * (act_zoom_point.x - getGame().getSize() / 2.0f / zoom),-stone_size * (act_zoom_point.y - getGame().getSize() / 2.0f / zoom));
  return res;
}
 

Example 18

From project Hawksword, under directory /src/com/bw/hawksword/ocr/camera/.

Source file: CameraManager.java

  22 
vote

/** 
 * Like  {@link #getFramingRect} but coordinates are in terms of the preview frame,not UI / screen.
 */
public Rect getFramingRectInPreview(){
  Point cameraResolution=configManager.getCameraResolution();
  Point screenResolution=configManager.getScreenResolution();
  if (framingRectInPreview == null) {
    Rect rect=new Rect(getFramingRect());
    rect.left=rect.left * cameraResolution.x / screenResolution.x;
    rect.right=rect.right * cameraResolution.x / screenResolution.x;
    rect.top=rect.top * cameraResolution.y / screenResolution.y;
    rect.bottom=rect.bottom * cameraResolution.y / screenResolution.y;
    framingRectInPreview=rect;
  }
  return framingRectInPreview;
}
 

Example 19

From project huiswerk, under directory /print/zxing-1.6/android/src/com/google/zxing/client/android/camera/.

Source file: CameraManager.java

  22 
vote

/** 
 * Like  {@link #getFramingRect} but coordinates are in terms of the preview frame,not UI / screen.
 */
public Rect getFramingRectInPreview(){
  if (framingRectInPreview == null) {
    Rect rect=new Rect(getFramingRect());
    Point cameraResolution=configManager.getCameraResolution();
    Point screenResolution=configManager.getScreenResolution();
    rect.left=rect.left * cameraResolution.x / screenResolution.x;
    rect.right=rect.right * cameraResolution.x / screenResolution.x;
    rect.top=rect.top * cameraResolution.y / screenResolution.y;
    rect.bottom=rect.bottom * cameraResolution.y / screenResolution.y;
    framingRectInPreview=rect;
  }
  return framingRectInPreview;
}
 

Example 20

From project kevoree-library, under directory /android/org.kevoree.library.android.osmdroid/src/main/java/microsoft/mappoint/.

Source file: TileSystem.java

  22 
vote

/** 
 * Converts a point from latitude/longitude WGS-84 coordinates (in degrees) into pixel XY coordinates at a specified level of detail.
 * @param latitude Latitude of the point, in degrees
 * @param longitude Longitude of the point, in degrees
 * @param levelOfDetail Level of detail, from 1 (lowest detail) to 23 (highest detail)
 * @param reuse An optional Point to be recycled, or null to create a new one automatically
 * @return Output parameter receiving the X and Y coordinates in pixels
 */
public static Point LatLongToPixelXY(double latitude,double longitude,final int levelOfDetail,final Point reuse){
  final Point out=(reuse == null ? new Point() : reuse);
  latitude=Clip(latitude,MinLatitude,MaxLatitude);
  longitude=Clip(longitude,MinLongitude,MaxLongitude);
  final double x=(longitude + 180) / 360;
  final double sinLatitude=Math.sin(latitude * Math.PI / 180);
  final double y=0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI);
  final int mapSize=MapSize(levelOfDetail);
  out.x=(int)Clip(x * mapSize + 0.5,0,mapSize - 1);
  out.y=(int)Clip(y * mapSize + 0.5,0,mapSize - 1);
  return out;
}
 

Example 21

From project MIT-Mobile-for-Android, under directory /src/com/google/zxing/client/android/camera/.

Source file: CameraManager.java

  22 
vote

/** 
 * Like  {@link #getFramingRect} but coordinates are in terms of the preview frame,not UI / screen.
 */
public Rect getFramingRectInPreview(){
  if (framingRectInPreview == null) {
    Rect rect=new Rect(getFramingRect());
    Point cameraResolution=configManager.getCameraResolution();
    Point screenResolution=configManager.getScreenResolution();
    rect.left=rect.left * cameraResolution.x / screenResolution.x;
    rect.right=rect.right * cameraResolution.x / screenResolution.x;
    rect.top=rect.top * cameraResolution.y / screenResolution.y;
    rect.bottom=rect.bottom * cameraResolution.y / screenResolution.y;
    framingRectInPreview=rect;
  }
  return framingRectInPreview;
}
 

Example 22

From project Mobile-Tour-Guide, under directory /zxing-2.0/android/src/com/google/zxing/client/android/camera/.

Source file: PreviewCallback.java

  22 
vote

@Override public void onPreviewFrame(byte[] data,Camera camera){
  Point cameraResolution=configManager.getCameraResolution();
  Handler thePreviewHandler=previewHandler;
  if (thePreviewHandler != null) {
    Message message=thePreviewHandler.obtainMessage(previewMessage,cameraResolution.x,cameraResolution.y,data);
    message.sendToTarget();
    previewHandler=null;
  }
 else {
    Log.d(TAG,"Got preview callback, but no handler for it");
  }
}
 

Example 23

From project NFCShopping, under directory /nfc updater client/NFCUpdater/src/scut/bgooo/updater/camera/.

Source file: CameraManager.java

  22 
vote

/** 
 * Like  {@link #getFramingRect} but coordinates are in terms of the previewframe, not UI / screen.
 */
public Rect getFramingRectInPreview(){
  if (framingRectInPreview == null) {
    Rect rect=new Rect(getFramingRect());
    Point cameraResolution=configManager.getCameraResolution();
    Point screenResolution=configManager.getScreenResolution();
    rect.left=rect.left * cameraResolution.x / screenResolution.x;
    rect.right=rect.right * cameraResolution.x / screenResolution.x;
    rect.top=rect.top * cameraResolution.y / screenResolution.y;
    rect.bottom=rect.bottom * cameraResolution.y / screenResolution.y;
    framingRectInPreview=rect;
  }
  return framingRectInPreview;
}
 

Example 24

From project ohmagePhone, under directory /src/org/ohmage/triggers/types/location/.

Source file: LocTrigMapsActivity.java

  22 
vote

private MapsOverlayItem hitTestOverlayCircle(Point p){
  MapsOverlayItem item=mOverlayItems.getFocus();
  if (item == null || item.locationId == CURR_LOC_ID) {
    return null;
  }
  Point markerP=mMapView.getProjection().toPixels(item.getPoint(),null);
  float rInPixels=mMapView.getProjection().metersToEquatorPixels(item.radius);
  if (euclidDist(p,markerP) > rInPixels) {
    return null;
  }
  return item;
}
 

Example 25

From project Ohmage_Phone, under directory /src/org/ohmage/triggers/types/location/.

Source file: LocTrigMapsActivity.java

  22 
vote

private MapsOverlayItem hitTestOverlayCircle(Point p){
  MapsOverlayItem item=mOverlayItems.getFocus();
  if (item == null || item.locationId == CURR_LOC_ID) {
    return null;
  }
  Point markerP=mMapView.getProjection().toPixels(item.getPoint(),null);
  float rInPixels=mMapView.getProjection().metersToEquatorPixels(item.radius);
  if (euclidDist(p,markerP) > rInPixels) {
    return null;
  }
  return item;
}
 

Example 26

From project Android-MapForgeFragment, under directory /library-common/src/com/jakewharton/android/mapsforge_fragment/.

Source file: CircleOverlay.java

  21 
vote

/** 
 * Constructs a new CircleOverlay with the given default paints. The drawing quality can be improved by enabling  {@link Paint#setAntiAlias(boolean) anti-aliasing}.
 * @param defaultPaintFill the default paint which will be used to fill the circles (may be null).
 * @param defaultPaintOutline the default paint which will be used to draw the circle outlines (may be null).
 */
public CircleOverlay(Paint defaultPaintFill,Paint defaultPaintOutline){
  super();
  this.defaultPaintFill=defaultPaintFill;
  this.defaultPaintOutline=defaultPaintOutline;
  this.hasDefaultPaint=defaultPaintFill != null || defaultPaintOutline != null;
  this.circlePosition=new Point();
  this.visibleCircles=new ArrayList<Integer>(ARRAY_LIST_INITIAL_CAPACITY);
  this.visibleCirclesRedraw=new ArrayList<Integer>(ARRAY_LIST_INITIAL_CAPACITY);
  this.path=new Path();
}
 

Example 27

From project android_7, under directory /src/org/immopoly/android/widget/.

Source file: ImmoscoutPlacesOverlay.java

  21 
vote

public void draw(Canvas canvas,MapView mapView,boolean shadow){
  if (bubble != null && bubble.animationDone) {
    Point ntp=bubble.mapIconPos;
    Point p=new Point();
    mMapView.getProjection().toPixels(bubble.mapIconGeoPoint,p);
    if (Math.abs(ntp.x - p.x) > 20 || Math.abs(ntp.y - p.y) > 20) {
      hideBubble();
    }
  }
  int latProjection=(mapView.getProjection().fromPixels(200,200).getLatitudeE6() - mapView.getProjection().fromPixels(0,0).getLatitudeE6());
  if (Math.abs(latProjection - prevLatProjection) > 10) {
    prevLatProjection=latProjection;
    clusterize();
  }
  super.draw(canvas,mapView,shadow);
}
 

Example 28

From project android_packages_apps_Gallery2, under directory /src/com/android/gallery3d/app/.

Source file: Wallpaper.java

  21 
vote

@SuppressWarnings("fallthrough") @Override protected void onResume(){
  super.onResume();
  Intent intent=getIntent();
switch (mState) {
case STATE_INIT:
{
      mPickedItem=intent.getData();
      if (mPickedItem == null) {
        Intent request=new Intent(Intent.ACTION_GET_CONTENT).setClass(this,DialogPicker.class).setType(IMAGE_TYPE);
        startActivityForResult(request,STATE_PHOTO_PICKED);
        return;
      }
      mState=STATE_PHOTO_PICKED;
    }
case STATE_PHOTO_PICKED:
{
    int width=getWallpaperDesiredMinimumWidth();
    int height=getWallpaperDesiredMinimumHeight();
    Point size=new Point();
    getWindowManager().getDefaultDisplay().getSize(size);
    float spotlightX=(float)size.x / width;
    float spotlightY=(float)size.y / height;
    Intent request=new Intent(CropImage.ACTION_CROP).setDataAndType(mPickedItem,IMAGE_TYPE).addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT).putExtra(CropImage.KEY_OUTPUT_X,width).putExtra(CropImage.KEY_OUTPUT_Y,height).putExtra(CropImage.KEY_ASPECT_X,width).putExtra(CropImage.KEY_ASPECT_Y,height).putExtra(CropImage.KEY_SPOTLIGHT_X,spotlightX).putExtra(CropImage.KEY_SPOTLIGHT_Y,spotlightY).putExtra(CropImage.KEY_SCALE,true).putExtra(CropImage.KEY_SCALE_UP_IF_NEEDED,true).putExtra(CropImage.KEY_NO_FACE_DETECTION,true).putExtra(CropImage.KEY_SET_AS_WALLPAPER,true);
    startActivity(request);
    finish();
  }
}
}
 

Example 29

From project CityBikes, under directory /src/net/homelinux/penecoptero/android/citybikes/app/.

Source file: StationOverlay.java

  21 
vote

@Override public void draw(Canvas canvas,MapView mapView,boolean shadow){
  calculatePixelRadius(mapView);
  Projection astral=mapView.getProjection();
  Point screenPixels=astral.toPixels(this.getCenter(),null);
  RectF oval=new RectF(screenPixels.x - this.radiusInPixels,screenPixels.y - this.radiusInPixels,screenPixels.x + this.radiusInPixels,screenPixels.y + this.radiusInPixels);
  if (this.station.isBookmarked()) {
    canvas.drawPath(createStar(5,screenPixels,(float)(this.radiusInPixels * 1.5),(float)(this.radiusInPixels * 1.5 / 2)),this.currentPaint);
    if (this.selected)     canvas.drawPath(createStar(5,screenPixels,(float)(this.radiusInPixels * 1.5),(float)(this.radiusInPixels * 1.5 / 2)),this.selectedPaint);
  }
 else {
    canvas.drawOval(oval,this.currentPaint);
    if (this.selected) {
      canvas.drawCircle(screenPixels.x,screenPixels.y,this.radiusInPixels,this.selectedPaint);
    }
  }
}
 

Example 30

From project GSM-Signal-Tracking-, under directory /gpstracker/src/nl/sogeti/android/gpstracker/viewer/.

Source file: LoggerMap.java

  21 
vote

private void moveActiveViewWindow(){
  GeoPoint lastPoint=getLastTrackPoint();
  if (lastPoint != null && mLoggerServiceManager.getLoggingState() == Constants.LOGGING) {
    Point out=new Point();
    this.mMapView.getProjection().toPixels(lastPoint,out);
    int height=this.mMapView.getHeight();
    int width=this.mMapView.getWidth();
    if (out.x < 0 || out.y < 0 || out.y > height || out.x > width) {
      this.mMapView.clearAnimation();
      this.mMapView.getController().setCenter(lastPoint);
    }
 else     if (out.x < width / 4 || out.y < height / 4 || out.x > (width / 4) * 3 || out.y > (height / 4) * 3) {
      this.mMapView.clearAnimation();
      this.mMapView.getController().animateTo(lastPoint);
    }
  }
}
 

Example 31

From project Hax-Launcher, under directory /src/com/t3hh4xx0r/haxlauncher/.

Source file: Workspace.java

  21 
vote

protected void setWallpaperDimension(){
  Point size=new Point();
  mLauncher.getWindowManager().getDefaultDisplay().getSize(size);
  final int maxDim=Math.max(size.x,size.y);
  final int minDim=Math.min(size.x,size.y);
  if (LauncherApplication.isScreenLarge()) {
    mWallpaperWidth=(int)(maxDim * wallpaperTravelToScreenWidthRatio(maxDim,minDim));
    mWallpaperHeight=maxDim;
  }
 else {
    mWallpaperWidth=Math.max((int)(minDim * WALLPAPER_SCREENS_SPAN),maxDim);
    mWallpaperHeight=maxDim;
  }
  new Thread("setWallpaperDimension"){
    public void run(){
      mWallpaperManager.suggestDesiredDimensions(mWallpaperWidth,mWallpaperHeight);
    }
  }
.start();
}
 

Example 32

From project ignition, under directory /ignition-location/ignition-location-samples/src/com/github/ignition/samples/location/overlays/.

Source file: AccuracyCircleOverlay.java

  21 
vote

@Override public void draw(Canvas canvas,MapView mapView,boolean shadow){
  Projection projection=mapView.getProjection();
  if (shadow && projection == null) {
    Log.v(LOG_TAG,"drawing not done because shadow and projection are null");
    return;
  }
  Point pt=new Point();
  projection.toPixels(geoPoint,pt);
  float circleRadius=metersToRadius(accuracy,projection,geoPoint.getLatitudeE6());
  Paint paint=new Paint(Paint.ANTI_ALIAS_FLAG);
  paint.setColor(0x186666ff);
  paint.setStyle(Style.FILL_AND_STROKE);
  canvas.drawCircle(pt.x,pt.y,circleRadius,paint);
  paint.setColor(0xff6666ff);
  paint.setStyle(Style.STROKE);
  canvas.drawCircle(pt.x,pt.y,circleRadius,paint);
  paint.setColor(Color.RED);
  paint.setStyle(Style.FILL_AND_STROKE);
  canvas.drawCircle(pt.x,pt.y,3,paint);
  super.draw(canvas,mapView,shadow);
}
 

Example 33

From project Locast-Android, under directory /src/edu/mit/mobile/android/maps/.

Source file: PathOverlay.java

  21 
vote

private void updatePath(Projection projection){
  mPath=new Path();
  final Point p=new Point();
  boolean first=true;
  for (  final GeoPoint gp : mPathGeo) {
    projection.toPixels(gp,p);
    if (first) {
      mPath.moveTo(p.x,p.y);
      first=false;
    }
 else {
      mPath.lineTo(p.x,p.y);
    }
  }
}
 

Example 34

From project LunaTerm, under directory /src/tw/loli/lunaTerm/.

Source file: GestureView.java

  21 
vote

@Override public boolean onTouchEvent(MotionEvent ev){
  Log.v(TAG,"onTouchEvent...action=" + ev.getAction());
  Point evPoint=new Point((int)ev.getX(),(int)ev.getY());
  if (magnifierOn) {
    if (ev.getAction() == MotionEvent.ACTION_UP) {
      if ((TerminalActivity.termActFlags & TerminalActivity.FLLAG_LONG_PRESS_SHOW) != 0) {
        magnifierOn=false;
        Log.v(TAG,"magnifier off");
      }
    }
    invalidate();
  }
 else {
    if (mOnGestureListener == null)     Log.e(TAG,"there is no gesture listener");
    mGestureDetector.onTouchEvent(ev);
    if (ev.getAction() != MotionEvent.ACTION_DOWN)     drawLine(lastTouchedPoint,evPoint);
    if (ev.getAction() == MotionEvent.ACTION_UP)     clear();
  }
  if (ev.getAction() == MotionEvent.ACTION_DOWN) {
    startPoint=evPoint;
    fingerOnScreen=true;
  }
 else   if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL)   fingerOnScreen=false;
  lastTouchedPoint=evPoint;
  super.onTouchEvent(ev);
  return true;
}
 

Example 35

From project mapdroid, under directory /src/au/id/tedp/mapdroid/.

Source file: OSMMapView.java

  21 
vote

protected Point getCenterTileOrigin(Canvas c){
  Rect clipBounds=c.getClipBounds();
  int x, y;
  x=(clipBounds.right - clipBounds.left) / 2 + clipBounds.left;
  y=(clipBounds.bottom - clipBounds.top) / 2 + clipBounds.top;
  x-=TileSet.getXPixel(zoom,mLong,tileServer.getTileSize());
  y-=TileSet.getYPixel(zoom,mLat,tileServer.getTileSize());
  return new Point(x,y);
}
 

Example 36

From project mixare, under directory /src/org/mixare/.

Source file: MixMap.java

  21 
vote

public void draw(Canvas canvas,MapView mapv,boolean shadow){
  super.draw(canvas,mapv,shadow);
  if (geoPoints.size() <= 0) {
    return;
  }
  Projection projection=mapv.getProjection();
  Paint mPaint=new Paint();
  mPaint.setDither(true);
  mPaint.setColor(Color.BLUE);
  mPaint.setStyle(Paint.Style.STROKE);
  mPaint.setStrokeJoin(Paint.Join.ROUND);
  mPaint.setStrokeCap(Paint.Cap.ROUND);
  mPaint.setStrokeWidth(3);
  Path path=new Path();
  Point start=new Point();
  projection.toPixels(geoPoints.get(0),start);
  path.moveTo(start.x,start.y);
  for (  GeoPoint gp : geoPoints) {
    Point p=new Point();
    projection.toPixels(gp,p);
    path.lineTo(p.x,p.y);
  }
  canvas.drawPath(path,mPaint);
}
 

Example 37

From project mobilis, under directory /MobilisXHunt/MobilisXHunt_Android/src/de/tudresden/inf/rn/mobilis/android/xhunt/ui/overlay/.

Source file: PlayerIconOverlay.java

  21 
vote

@Override public void draw(Canvas canvas,MapView mapView,boolean shadow){
  super.draw(canvas,mapView,shadow);
  int fontSize=12;
  int titleMargin=3;
  XHuntPlayer player=mXhuntService.getCurrentGame().getPlayerByJID(mMapActivity.getMxaProxy().getXmppJid());
  Drawable sourceIcon=mMapActivity.getResources().getDrawable(player.getPlayerIconID());
  int iconHeight=((BitmapDrawable)sourceIcon).getBitmap().getHeight();
  for (  OverlayItem item : overlayIcons) {
    if (!item.getTitle().contains("ghost")) {
      GeoPoint point=item.getPoint();
      Point markerBottomCenterCoords=new Point();
      mapView.getProjection().toPixels(point,markerBottomCenterCoords);
      TextPaint textPaint=new TextPaint();
      Paint paintRect=new Paint();
      Rect rect=new Rect();
      textPaint.setTextSize(fontSize);
      textPaint.getTextBounds(item.getSnippet(),0,item.getSnippet().length(),rect);
      rect.inset(-titleMargin,-titleMargin);
      rect.offsetTo(markerBottomCenterCoords.x - rect.width() / 2,markerBottomCenterCoords.y - iconHeight - rect.height());
      textPaint.setTextAlign(Paint.Align.CENTER);
      textPaint.setTextSize(fontSize);
      textPaint.setARGB(255,255,255,255);
      paintRect.setARGB(130,0,0,0);
      canvas.drawRoundRect(new RectF(rect),2,2,paintRect);
      canvas.drawText(item.getSnippet(),rect.left + rect.width() / 2,rect.bottom - titleMargin,textPaint);
    }
  }
}
 

Example 38

From project Novocation, under directory /demo/src/com/novoda/locationdemo/activity/location/.

Source file: AccuracyCircleOverlay.java

  21 
vote

@Override public void draw(Canvas canvas,MapView mapView,boolean shadow){
  Projection projection=mapView.getProjection();
  if (shadow && projection == null) {
    Log.v(LOG_TAG,"drawing not done because shadow and projection are null");
    return;
  }
  Point pt=new Point();
  projection.toPixels(geoPoint,pt);
  float circleRadius=metersToRadius(accuracy,projection,geoPoint.getLatitudeE6());
  Log.v(LOG_TAG,"Circle Radius : " + circleRadius);
  Paint paint=new Paint(Paint.ANTI_ALIAS_FLAG);
  paint.setColor(0x186666ff);
  paint.setStyle(Style.FILL_AND_STROKE);
  canvas.drawCircle((float)pt.x,(float)pt.y,circleRadius,paint);
  paint.setColor(0xff6666ff);
  paint.setStyle(Style.STROKE);
  canvas.drawCircle((float)pt.x,(float)pt.y,circleRadius,paint);
  paint.setColor(Color.RED);
  paint.setStyle(Style.FILL_AND_STROKE);
  canvas.drawCircle((float)pt.x,(float)pt.y,3,paint);
  super.draw(canvas,mapView,shadow);
}
 

Example 39

From project onebusaway-android, under directory /src/com/joulespersecond/seattlebusbot/map/.

Source file: RouteMapController.java

  21 
vote

@Override public void draw(Canvas canvas,MapView mapView,boolean shadow){
  if (shadow) {
    super.draw(canvas,mapView,shadow);
    return;
  }
  final Projection projection=mapView.getProjection();
  Point pt=new Point();
  final int len=mLines.size();
  Path path=new Path();
  for (int i=0; i < len; ++i) {
    final Line line=mLines.get(i);
    final List<GeoPoint> geoPoints=line.getPoints();
    int numPts=geoPoints.size();
    projection.toPixels(geoPoints.get(0),pt);
    path.moveTo(pt.x,pt.y);
    int j=1;
    for (; j < numPts; ++j) {
      projection.toPixels(geoPoints.get(j),pt);
      path.lineTo(pt.x,pt.y);
    }
    canvas.drawPath(path,line.getPaint());
    path.rewind();
  }
}
 

Example 40

From project ImageFilterForAndroid, under directory /src/HaoRan/ImageFilter/.

Source file: TileReflectionFilter.java

  20 
vote

/** 
 * Constructor \n param -45 <= nAngle <= 45 \n param 2 <= nSquareSize <= 200 \n param -20 <= nCurvature <= 20
 */
public TileReflectionFilter(int nSquareSize,int nCurvature,int nAngle,byte focusType){
  nAngle=Function.FClamp(nAngle,-45,45);
  m_sin=Math.sin(AngleToRadian(nAngle));
  m_cos=Math.cos(AngleToRadian(nAngle));
  nSquareSize=Function.FClamp(nSquareSize,2,200);
  m_scale=IImageFilter.LIB_PI / nSquareSize;
  m_focusType=focusType;
  nCurvature=Function.FClamp(nCurvature,-20,20);
  if (nCurvature == 0)   nCurvature=1;
  m_curvature=nCurvature * nCurvature / 10.0 * (Math.abs(nCurvature) / nCurvature);
  for (int i=0; i < aasamples; i++) {
    double x=(i * 4) / (double)aasamples, y=i / (double)aasamples;
    x=x - (int)x;
    m_aapt[i]=new Point((int)(m_cos * x + m_sin * y),(int)(m_cos * y - m_sin * x));
  }
}
 

Example 41

From project cornerstone, under directory /frameworks/base/core/java/android/view/.

Source file: ViewRootImpl.java

  19 
vote

public boolean getChildVisibleRect(View child,Rect r,android.graphics.Point offset){
  if (child != mView) {
    throw new RuntimeException("child is not mine, honest!");
  }
  return r.intersect(0,0,mWidth,mHeight);
}
 

Example 42

From project KeyboardTerm, under directory /src/tw/kenshinn/keyboardTerm/.

Source file: GestureView.java

  19 
vote

private void drawLine(Point p1,Point p2){
  if (footprintBitmap == null)   return;
  footprintCanvas.drawLine(p1.x,p1.y,p2.x,p2.y,footprintPaint);
  int x1=Math.min(p1.x,p2.x) - 10;
  int y1=Math.min(p1.y,p2.y) - 10;
  int x2=Math.max(p1.x,p2.x) + 10;
  int y2=Math.max(p1.y,p2.y) + 10;
  mRect.set(x1,y1,x2,y2);
  invalidate(mRect);
}