/** * Node Map. * * Left-click and drag to move nodes. Right-click on * empty space to make a new node. Right-click and * drag between nodes to make new connections. * Middle-click on a node to delete it and its * connections. * * (You can hold down the 'n' key to simulate a right-click or 'd' to simulate a middle click.) * */ int num = 2; Node thisNode = null; Node currentNode = null; Node selectedNode = null; Node startNode = null; Node deleteNode = null; ArrayList nodes; ArrayList connections; void setup() { size(400,400); smooth(); strokeWeight(1.5); strokeCap(ROUND); nodes = new ArrayList(); for(int i=0; i width) {x = width;} if (y > height) {y = height;} update(); } void update() { boxx = x - size/2; boxy = y - size/2; for (int i=0; i < connections.size(); i++) { ((Connection)connections.get(i)).update(); } } boolean over() { if(overRect(boxx, boxy, size, size)) { return true; } else { return false; } } void display(int redVal, int greenVal, int blueVal) { fill(redVal,greenVal,blueVal, 127); stroke(255, 127); rect(boxx, boxy, size, size); } void delete() { while (connections.size() != 0) { ((Connection)connections.get(0)).delete(); } others.remove(this); } } boolean overRect(int x, int y, int width, int height) { if (mouseX >= x && mouseX <= x+width && mouseY >= y && mouseY <= y+height) { return true; } else { return false; } }