class Dot{ float x,y,w,h, spx, tlength; int id = 0; int dnum; int selectid; int dotId; int dk; boolean selected; boolean isOver; boolean doDuplicate; boolean doCheck; boolean doReset; Bellipse[] duE; Bellipse sp; Brect cover; float[] dotPosX; float[] dotPosY; float cx, cy, cw, ch,ccx,ccy; // cover for the »ý½Ä±â ; float px, py; float[] temxA; float[] temyA; String dotX; String dotY; color dc; String title; Dot[] others; Dot(float x_, float y_, float w_, float h_, color dc_, String a, Dot[] aa, int dott){ x = x_; y = y_; w = w_; h = h_; title = a; others = aa; dotId = dott; float cc = textWidth(a); tlength = cc; spx = x+cc/2; sp = new Bellipse(spx, y+15, w, h, 1,1,0); duE = new Bellipse[id]; dotPosX = new float[id]; dotPosY = new float[id]; cx = sw/3+150; cy = 310; cw = 45; ch = 130; ccx = cx+cw/2; ccy = cy+ch/2; temxA = new float[0]; temyA = new float[0]; dc = dc_; } void renderTest(){ for(int i=0; i< duE.length; i++){ fill(255); ellipse(dotPosX[i]-100, dotPosY[i], 10, 10); } } void display(){ // renderTest(); fill(255); textFont(helv11); text(title, x, y); sp.display(); sp.setColor_r(dc); //drawAear(); // it is relate to apply the reset funtion try{ update(); locked(); } catch(Exception ex){ selectid = id; //reset selecteid duE = new Bellipse[0]; } for(int i=0; i sw/3+pannelW){ duE[id_].setPosition( sw/3+pannelW, mouseY); } if(temy < 50){ duE[id_].setPosition( mouseX, 60); } if(temy > 550){ duE[id_].setPosition( mouseX, 540); } } void checkCollideinside(int d){ float temx = mouseX+duE[d].w/2; float temy = mouseY+duE[d].w/2; float u = duE[d].w/2; float yu = duE[d].y; float xu = duE[d].x; if(temx >= cx && temx <= cx+cw+duE[d].w && temy >= cy && temy <= cy+ch+duE[d].w){ //doCheck = true; temxA = append(temxA, duE[d].x); temyA = append(temyA, duE[d].y); if(ccx-temxA[0] < 0 && (yu > cy && yu+u < cy+ch)){ float t = cx+cw-temxA[0]+u; temxA[0] = temxA[0]+t; temyA[0] = temyA[0];//mouseY; } if(ccx-temxA[0] > 0 && (yu > cy && yu+u < cy+ch)){ float t = cx-temxA[0]-u; temxA[0] = temxA[0]+t; temyA[0] = temyA[0];//mouseY; } if(ccy-temyA[0] >= 0 && (xu-u > cx && xu+u < cx+cw)){ float t = cy-temyA[0]-u; temyA[0] = temyA[0]+t; temxA[0] = mouseX; } if(ccy-temyA[0] < 0 && (xu-u > cx && xu+u < cx+cw)){ float t = cy+ch-temyA[0]+u; temyA[0] = temyA[0]+t; temxA[0] = mouseX; } duE[d].setPosition( temxA[0], temyA[0]); println(px); }else{ temxA = subset(temxA, 0,0); temyA = subset(temyA, 0,0); } } // check the dot for drag void locked(){ for(int i=0; i0){ dotX = dotX+","+str(dotPosX[i]); dotY = dotY+","+str(dotPosY[i]);} } } void reset(){ // make duE null duE = null; selected = false; id = 0; dotPosX = subset(dotPosX, 0, 0); dotPosY = subset(dotPosY, 0, 0); } // draw forbid area void drawAear(){ float temx = mouseX; float temy = mouseY; float u = 15; if(temx >= cx-u && temx <= cx+cw+u && temy >= cy && temy <= cy+ch+u){ stroke(113,8,8,60); fill(170,36,36,80); line(cx, cy, cx+cw, cy+ch); line(cx+cw, cy, cx, cy+ch); rect(cx, cy, cw, ch); noStroke(); } } }