I did it like this now. So the nodes are in the ArrayList. Probably not right but a beginning. But i didnt create the ArrayList inside the class Node, as you can see. Is it right?
In mouseClicked the Nodes will be added to the List.
import java.util.ArrayList;
void setup() {
size(600,600);
}
void draw() {
}
void mouseClicked(){
// loop over Array of nodes to check if there is another node
Node knoten = new Node(mouseX,mouseY);
// Adding node
NodeList.add(knoten);
// println(NodeList.size());
// println(NodeList.indexOf(knoten));
}
ArrayList<Node> NodeList = new ArrayList<Node>();
// class Node
public class Node extends Zaehler {
private float x;
private float y;
int knotennummer;
void draw(){
// display();
}
public Node(float x, float y){
hochzaehler();
this.x = x;
this.y = y;
display();
}
public void display(){
strokeWeight(2);
stroke(0); // black
fill(0);
ellipse(x, y, 60, 60);
fill(255);
textSize(20);
text(knotennummer,x,y); //number inside the node
}
void hochzaehler(){
knotennummerzaehler ++;
knotennummer = knotennummerzaehler;
}
}
static class Zaehler{
static int knotennummerzaehler = -1;
}
class Edge {
void display(){
//line();
}
Edge(){
fill(0);
line(mouseX, mouseY,0,0);
}
}