b0039561_4c5b6ff551fbc  

import java.util.*;

import android.app.Activity;
import android.content.*;
import android.graphics.*;
import android.os.Bundle;
import android.util.*;
import android.view.*;
import android.view.View.OnTouchListener;
import android.view.GestureDetector.*;

public class main extends Activity {
 
 ArrayList<PointF> arPTs; 
 
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        MyView vw = new MyView(this);
        
        setContentView(vw);
       

        
        arPTs = new ArrayList<PointF>();
    }
    
    /*
    @Override
    public boolean onTouch(View v, MotionEvent event) { 
        for (int i=0; i<event.getPointerCount(); i++) { 
            Log.d("Pointer", "Pointer "+(i+1)+": x="+event.getX(i)+", 
    y="+event.getY(i)); 
        }
    } 
    */
    
    protected class MyView extends View //implements OnGestureListener
    {
     
     //private GestureDetector gestureScanner;
             
     
     public MyView(Context context)
     {
      super(context);
      //gestureScanner = new GestureDetector(this);
     }
     
        @Override
        protected void onSizeChanged(int w, int h, int oldw, int oldh) {
            super.onSizeChanged(w, h, oldw, oldh);
        }     
    
        @Override
        protected void onDraw(Canvas canvas)
     {
      Paint pnt = new Paint();
      pnt.setColor(Color.BLUE);
      
      canvas.drawColor(Color.WHITE);
            
      canvas.drawCircle(111,111, 110, pnt);
      
      int i = 0;
      
      
      pnt.setTextSize(64.0f);
      
      for (PointF pt : arPTs) {
       
       i++;
       pnt.setColor(Color.MAGENTA);
       canvas.drawCircle(pt.x,pt.y, 40, pnt);
       
       pnt.setColor(Color.BLACK);
       canvas.drawText(String.valueOf(i),pt.x,pt.y-64,pnt);
   }
      
      
     }  
     
     //@Override    
     //public boolean onTouch(View v, MotionEvent me)
     public boolean onTouchEvent (MotionEvent me)
     {
      arPTs.clear();
      
      for (int i=0; i<me.getPointerCount(); i++) { 
             Log.d("Pointer", "Pointer "+(i+1)+": x="+me.getX(i)+",y="+me.getY(i));
             PointF ptf = new PointF();
             ptf.x = me.getX(i);
             ptf.y = me.getY(i);            
             arPTs.add(ptf);
         }     
      
      invalidate();
      
      
      
      
      return !false;//true;
      
         //return gestureScanner.onTouchEvent(me);
     }

     public boolean onDown(MotionEvent e)
     {
         return true;
     }
  
     // 빠르게 긋기
     public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
     {
      return true;
     }
  
     public void onLongPress(MotionEvent e)
     {
  
     }
     public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
     {
         return true;
     }
     public void onShowPress(MotionEvent e)
     {
     }    
  
     public boolean onSingleTapUp(MotionEvent e)    
     {
         return true;
     } 
     
    
    
    }
    
    
 
 
   

}

創作者介紹
創作者 shadow 的頭像
shadow

資訊園

shadow 發表在 痞客邦 留言(0) 人氣()