-1

这是我的代码,它被编译为 JAVA 应用程序。我要创建的是一个 Android 应用程序。我只想问我如何将这些代码转换为代码,以便当我将其编译为 ANDROID APPLICATION 时不会产生错误。

有人可以帮我怎么做吗?谢谢

这是我的代码:

public class DouglasMain extends PApplet{

 public static void main(String args[]) {
        PApplet.main(new String[] { "--present", "com.RDP.rdp.DouglasMain" });
      }

 Vector path = new Vector();

 public void setup(){

     size(550,550);
     smooth();

 }

 public void draw(){
     background(255);

     Tuple2f pt;
     noFill();
     strokeWeight(1);
     beginShape();

     for (int i=0; i < path.size(); i++)

     {
         pt = (Tuple2f)path.elementAt(i);vertex(pt.x,pt.y);

     }

     endShape();

     strokeWeight(5);

     beginShape(POINTS);

     for (int i=0; i < path.size(); i++)

     {
         pt = (Tuple2f)path.elementAt(i);vertex(pt.x,pt.y);      

     }

     endShape();

 }

 public void mousePressed(){

     path = new Vector();

 }

 public void mouseDragged(){

     path.add(new Tuple2f(mouseX, mouseY));

 }

 public void mousePressed1(){

     //to simplify, get our points into an array of Tuple2f

     if (path.size() > 1)

     {
         Tuple2f [] tmp = new Tuple2f[path.size()-1];

         for (int i =0; i < path.size()-1; i++)

         {
             tmp[i] = (Tuple2f)path.elementAt(i+1);

         }

         path = new Vector();
         path.addAll(Arrays.asList(DouglasPeuckerLineSimplifier.simplifyLine2D(5,tmp)));

     }

 } 
}
4

1 回答 1

2

这是一个好的开始:http: //developer.android.com/resources/tutorials/hello-world.html

于 2011-12-28T08:45:37.907 回答