I fear I don't get the final goal. I see the circles to snap on the box, which works well, but I am not sure how other circles must "connect", to what?
I will comment on some portions of code, at least.
It looks like you do too much pushMatrix/popMatrix. They are OK around the scale/translate operations, but they are useless around the method calls. They don't really hurt, except adding "noise" to code reading...
The lines:
Code: for(int i = 0; i<boxes.size(); i++)
{
pushMatrix();
for(int ii = 0; ii<tempboxes.size(); ii++) {
tempbox = (Box)tempboxes.get(boxes_quant); //This is temporary list for getting data you need out of it's
// objects for further using for other lists in runtime adding
tempbox.xxx = (tempbox.xxx)*0; // In my case I need "0" pisition so I discard changes with "*0"
tempbox.yyy = (tempbox.yyy)*0;
xxxx = tempbox.xxx; // Get data out of it
yyyy = tempbox.yyy;
}
boxx = new Box(xxxx,yyyy); // Use data for Arraylist I work with
boxx = (Box)boxes.get(i);
fill (250,250,250);
((Box)boxes.get(i)).display(); //class' Box function
popMatrix();
}
... do nothing! (almost...)
You put nothing in tempboxes, so the loop will never be executed. Beside,
tempbox.xxx = (tempbox.xxx)*0; is the same as
tempbox.xxx = 0; and
xxxx = tempbox.xxx; is thus always 0 too...
You set boxx to a new object then discard it immediately (next line, new assignment of the variable).
So the loop actually only display the boxes.
Idem for circles.
I don't get why in the constructors you set the variables to themselves, and redo that in the display() routine.
It is late, I will come back later.
I played a bit with the code, it acts the same, but it is shorter...
Code:Box boxx;
Circle circle;
ArrayList boxes;
ArrayList circles;
void setup() {
//strokeWeight(0.5);
noStroke();
size(800, 800);
fill(230,230,250);
frameRate(60);
rectMode(CENTER);
boxes = new ArrayList();
circles = new ArrayList();
}
void draw(){
background(100,100,100);
fill (250,250,250);
// Boxes
for(int i = 0; i<boxes.size(); i++)
{
((Box)boxes.get(i)).display(); //class' Box function
}
// Pick latest box
if (boxes.size() > 0)
boxx = (Box) boxes.get(boxes.size() - 1);
// Circles that same
for(int i = 0; i<circles.size(); i++)
{
((Circle)circles.get(i)).display();
}
if (circles.size() > 0)
circle = (Circle) circles.get(circles.size() - 1);
}
void mousePressed() {
for(int i = 0; i<boxes.size(); i++)
{
((Box)boxes.get(i)).mousePressed();
}
for(int i = 0; i<circles.size(); i++)
{
((Circle)circles.get(i)).mousePressed();
}
}
void mouseDragged() {
for(int i = 0; i<boxes.size(); i++)
{
((Box)boxes.get(i)).mouseDragged();
}
for(int i = 0; i<circles.size(); i++)
{
((Circle)circles.get(i)).mouseDragged();
}
}
void mouseReleased() {
for(int i = 0; i<boxes.size(); i++)
{
((Box)boxes.get(i)).mouseReleased();
}
for(int i = 0; i<circles.size(); i++)
{
((Circle)circles.get(i)).mouseReleased();
}
}
void keyReleased() {
if (keyCode == 'B') {
boxes.add(new Box(100,100));
}
if (keyCode == 'C') {
circles.add( new Circle(100,100));
}
}