anar+ in Eclipse


update http://code.google.com/p/proclipsing/wiki/GettingStarted is an alternative to the present tutorial. Note that you will need to install the ANAR+ library after that.


Here is a simple step by step tutorial explaining how to use anar+ within Eclipse. Eclipse is a programming platform for multiple programming languages. Mainly used for JAVA, you could integrate Processing within Eclipse. This is done by importing the core libraries inside Eclipse. This tutorial explain how to create a first sketch with anar+ and Processing v1.03.

ECLIPSE INSTALLATION

You first need Java on your machine. On most system, JRE is installed. The JRE is good to see a Java applet. To compile Java programs, you need more. You need to install JDK (JDK).

Eclipse could be downloaded at http://www.eclipse.org/downloads/. You might use Eclipse IDE for Java Developers version for your operation system. You also need a version of Processing P5. If you are on Windows, you might download the Processing (without Java version).

CREATE A NEW PROJECT

First, let's create a new Java Project:

You need to specify a name for your sketch. To be standard with Java structure, your name should be capitalized. But it doesn't kind if it is lowercase.

Click next at the bottom. You will get this dialog:

This is where you specify which external libraries you will use. Processing will be one of those. You might import other external Java libraries, but the minimum required to work with anar+ is the following libraries: anar.jar core.jar gluegen-rt.jar* jogl.jar* opengl.jar

You need to specify the path to each of these files on your operating system. These files could be found in the Processing installation directory in the lib/ folder. (*) note that you also need to specify the path to native libraries. When processing is using openGL, since some part of the libraries is written in different languages as Java, this part has to be compiled differently for your machine. All those different RT (runtime) version have been collected in one folder. All you need to specify is the path to the /processingInstall/opengl/library folder.

Press finish. You created a new Java Project and imported Processing and anar+.

CREATE A NEW SKETCH

Let's create a new sketch. In Eclipse, a sketch is the same as creating a new java class:

You will get this dialog:

You need to specify the superclass [processing.core.PApplet] and set the public static main(String[] args) to true. This step is not essential, you could do the same just by copying the code above.

You get a first Java class (our sketch).

We should add import anar.*; in the import lines.

In Java, the first called method at the very beginning is main(String[] args). This part is done for you in Processing. In fact, this line is added behind when you press the play button. In Eclipse, since we are writting in Java, you need to explicitely tell to Eclipse to call the first Processing method. Let's add a line inside the main method:

Now, everything should be ready to write our first sketch:

This part is similar as being inside the Processing IDE.

or you could simply use the code above (copy/paste):

import processing.core.PApplet;
import anar.*;
 
public class MyFirstSketch extends PApplet {
 
    public void setup(){
        size(800,400,OPENGL);
        Anar.init(this);
        Anar.drawAxis();
        Anar.add(new Circle(25)).translate(10,20,30);
    }
 
    public void draw(){
        background(255);
        Anar.draw();
    }
    
    public static void main(String[] args) {
        PApplet.main(new String[]{MyFirstSketch.class.getName()});
    }
 
}