rkshukla
YaBB Newbies
Offline
Posts: 39
Re: keyboard and mouse : not working coherent
Reply #5 - Jul 21st , 2008, 2:30pm
Code: for (i = 0; i <= feeds_f.length-1; i++) { String [] elements_f=split(feeds_f[i], "RAM_BREAK"); if(elements_f.length!=1){ box[num2] = new Box(float (elements_f[8]) ,float (elements_f[9]), float(elements_f[10]) ,float(elements_f[11]),0,1,0,elements_f[5], elements_f[3],"FEED"); num2++; } } ////////////////////////////////////////////////////////////////////////////////////////////////// //num2=0; for (i = 0; i <= feeds_b.length-1; i++) { String [] elements_b=split(feeds_b[i], "RAM_BREAK"); if(elements_b.length!=1){ box[num2] = new Box(float (elements_b[5]) ,float (elements_b[6]), float(elements_b[7]) ,float(elements_b[8]),0,1,0,elements_b[2], elements_b[1],"BM"); num2++; } } /////////////////////////////////////////////////////////////////////////////////////////////////// for (i = 0; i <= feeds_i.length-1; i++) { String [] elements_i=split(feeds_i[i], "RAM_BREAK"); if(elements_i.length!=1){ box[num2] = new Box(float (elements_i[4]) ,float (elements_i[5]), float(elements_i[6]) ,float(elements_i[7]),0,1,0,elements_i[0], elements_i[1],"IM"); num2++; } } /////////////////////////////////////////////////////////////////////////////////////////////////// for(i=0;i<=num_i-1;i++) { int offset=num_f+num_b; img[i]=loadImage(box[i+offset].txt,"png"); println("Loading IMAGES"); } /////////////////////////////////////////////////////////////////////////////////////////////////// for(i=0;i<=num_o-1;i++) { String [] elements_o=split(feeds_o[i], "RAM_BREAK"); box[num2] = new Box(float (elements_o[2]) ,float (elements_o[3]), float(elements_o[4]) ,float(elements_o[5]),0,1,0,elements_o[0], "http://www.w3.org/2001/sw/WebOnt/#Current" ,elements_o[1]); println("Loading Ontologies"); num2++; } ////////////////////////////////////////////////////////////////////////////////////////////////////// /* lines[0]= new Line(0,0); link_number++;*/ } class Box { float x, y, ln, ht,cx,cy,r,rd; int over,moving,resized; String txt,plink,type; Box( float px, float py, float pln,float pht,int pover,int pmoving,int presized,String ptxt,String pplink,String ptype ) { x = px; y = py; ln = pln/2; // adjusted according to mode RADIUS ht = pht/2; r=sqrt(ln*ln+ht*ht); cx=x+ln; cy=y+ht; over=pover; // not used this field in the code resized=presized; //resized =1 means that it is being resized , resized =0 means it is not being resized moving=pmoving; // moving means whether this is allowed to move or not...if 1 then allowed to move i.e. to be dragged txt=ptxt; plink=pplink; type=ptype; } void dragcheck() { if(mousePressed) // update function for boxes { float D=(this.x-pmouseX)*(this.x-pmouseX)+(this.y-pmouseY)*(this.y-pmouseY); // calculate the distance of mouse position from the center of object who called the dragcheck D=sqrt(D); float D1=(this.cx-pmouseX)*(this.cx-pmouseX)+(this.cy-pmouseY)*(this.cy-pmouseY); // calculate the distance of mouse position from the center of object who called the dragcheck D1=sqrt(D1); if (D<=this.r ) { if(D1<=this.rd) this.resized=1; /////////////////////////////////////////////////////// if(this.moving==1 && this.resized==1 && anyresize==1) // if the box is being dragged but is over resize zone then this part works { for(i=0;i<=num-1;i++) { box[i].resized=0; //locking all others from being dragged box[i].moving=0; } this.resized=1; //resize acts like a flag ...if it is one then the object can be resized lest no this.moving=1; // here we just stopped odrag=1; //tells that this resize is for objects so no panning needed this.ln=this.ln+(mouseX-pmouseX)*2; // *2 has made sensitivity good this.ht=this.ht+(mouseY-pmouseY)*2; if(this.ln <=0)this.ln=2; if(this.ht<=0)this.ht=2; this.r=sqrt(this.ln*this.ln+this.ht*this.ht); this.cx=this.x+this.ln; this.cy=this.y+this.ht; //counter++; } /////////////////////////////////////////////////// if(this.moving==1 && this.resized==0) // this is the move and drag loop { for(i=0;i<=num-1;i++) // { box[i].moving=0; //locking all others from being dragged box[i].resized=0; } this.moving=1; //moving acts like a flag ...if it is one then the object can move lest no odrag=1; //tells that this drag is for objects so no panning needed anyresize=0; this.x=mouseX; this.y=mouseY; this.cx=this.x+this.ln; this.cy=this.y+this.ht; } ///////////////////////////////////////////////////////////////// } } // till here for boxs being dragged or resized }