// class Radio class Radio { float x,y, size, dotsize, gap; color baseGray, dotGray; int me; boolean checked = false; Radio[] others; Bellipse bg; Radio(float x_, float y_, float s, color b, color d, int m, Radio[] o){ x = x_; y = y_; size = s; baseGray = b; dotGray = d; me = m; others = o; bg = new Bellipse(x, y, size, size, 2); } boolean press(float mx, float my){ if(dist(x,y,mx,my) < size/2){ checked = true; for(int i=0; i < others.length; i++){ if(i != me){ others[i].bg.isLocked = false; } } return true; } else{ return false; } } void display(){ bg.display(); } }//// end of class Radio //class checkbox class checkBox{ float x, y; float size; color baseGray; boolean checked = false; Brect bg; checkBox(float x_, float y_, float s, color b){ x = x_; y = y_; size = s; baseGray = b; bg = new Brect(x, y, size, size, 1); } void press(float mx, float my){ if((mx >=x) && (mx <= x+size) && (my >= y) && (my <= y+size) ){ checked = !checked; } } void display(){ bg.display(); fill(0,0); rect(x, y, size, size); if(checked == true){ line(x, y, x+size, y+size); line(x+size, y, x, y+size); } } }//end of class checkbox //class NewScrollBar class NewScrollBar{ float bw; //barWidth; float hw; //handleWidth; float bh; //barHeight; float hh; //handleHeight; float bx; //barX; float by; //barY; float hx; //handleX; float hy; //handleY; float maxVal; float minVal; float posRatio; float ratioValue; color bgColor = color(255); int dn; //the numebr of portion of bar width ; Rectangle hd; NewScrollBar(float bx_, float by_, float bw_, float bh_, int n_){ bw = bw_; bh = bh_; bx = bx_; by = by_; dn = n_; hw = bw/dn; hh = bh_; hx = bx_; hy = by_; maxVal = bx + bw - hw; minVal = bx; hd = new Rectangle( hx, hy, hw, hh, 1); hd.r = color(40); } void display(){ update(); fill(bgColor); rect(bx, by, bw, bh); ratioValue = getVal(); //text(percent, bx, by-30); hd.display(); }// end od display void update(){ checkLock(); if(hd.isLocked){ hd.x = constrain(mouseX, minVal, maxVal); } }// end of update void checkLock(){ //lock if( hd.isPressed){ hd.isLocked = true; } //release if(!mousePressed) { hd.isLocked = false; } }//end of checkLock void setX(float x){ hx = x; } float getVal(){ float increase = hd.x - bx; float lengthValue = maxVal - bx; float temPercentage = (increase/lengthValue)*100; posRatio = temPercentage; return posRatio; } } //class INputTextfield begin //------------------------------------------// class INputTextfield { float x, y, w, h, tfw, tfh, ntl; int l; //leading int tlength; String textContents; String labeltext; String samet; float margin; PFont pf; Brect fieldArea; Textbox textField, textField2; boolean isTyping; boolean reset; INputTextfield(String a_, float x_, float y_, float w_, float h_,int l_,PFont ts_){ labeltext = a_; textContents = labeltext; samet = labeltext; x = x_; y = y_; w = w_; h = h_; l = l_; pf = ts_; margin = 6; tfw = w-margin*2; tfh = h-margin*2; //textfield textField = new Textbox(textContents, x+margin, y+margin, tfw, tfh, l, pf ); textField2 = new Textbox(textContents, x+margin, y+margin, tfw, tfh, l, pf ); tlength = 1; reset = false; // backgroud of box fieldArea = new Brect(x, y, w, h, 1); fieldArea.n = color(255); fieldArea.r = color(255); fieldArea.o = color(255); fieldArea.p = color(255); fieldArea.b = color(0,60); } void display(){ update(); fieldArea.display(); fill(0,100); textField.textBox(); fill(0,160); textField2.textBox(); } void update(){ // check activate it or not if(fieldArea.isPressed){ fieldArea.isLocked = true; fieldArea.b = color(234,82,21); } if(!fieldArea.isOver && mousePressed){ fieldArea.isLocked = false; fieldArea.b = color(0,60); } // reset intro-text if(reset){ //labeltext = textContents ; textField2.textContent = textField.textContent = labeltext; } } void write(){ // start-clean up if(fieldArea.isLocked){ if(labeltext.length() > 0){ textContents = ""; labeltext = ""; reset = false; } // add character char k = char(key); textContents = textContents + str(k); textField.textContent = textContents; // light color textField2.textContent = textContents.substring(0, textContents.length()-1); // dark color } } void delete(){ if(fieldArea.isLocked){ if(textContents.length() >0){ int temm = textContents.length()-1; textContents = textContents.substring(0, temm); textField.textContent = textContents; // light color // check null- zero point of length() of dark color type if(textField2.textContent.length() > 0){ textField2.textContent = textContents.substring(0, textContents.length()-1);// dark color } // temporary reset if(textContents.length() == 0){ textField.textContent = "Rewrite"; } } } } float getTextLegnth(String xx){ float teml = textWidth(xx); ntl = teml; return ntl; } int getLineNums(float teml){ return ceil(teml/tfw); } int getStringL(){ return textContents.length(); } } //class INputTextfield end /////////////////////////////////////////////////////////////// // class Textbox start -----------------------------// class Textbox{ float x, y, w, h, tl, fonth ; float th, ted, tea; String textContent; PFont px; int leading; Textbox(){ } Textbox(String a_, float x_, float y_, float w_, float h_,int l_,PFont ts_){ textContent = a_; px = ts_; textFont(px); tl = textWidth(textContent); fonth = textDescent()+textAscent(); ted = textDescent(); tea = textAscent(); x = x_; y = y_; w = w_; h = h_; leading = l_; } void textBox(){ textFont(px); textLeading(leading); text(textContent,int(x), int(y), int(w),int(h)); //getTh(); //rect(x, y,10, th); } void textBox_R(){ pushMatrix(); translate(x,y); rotate(radians(90)); textFont(px); textLeading(leading); text(textContent,-textWidth(textContent)/2, 0); popMatrix(); } void setPosition(float x_, float y_){ x = x_; y = y_; } void setString(String dd){ textContent = dd; } float getTh(){ int lineNum = ceil(tl/w); if(lineNum > 1){ float hh =leading*lineNum-ted; // println(tea); return th = hh; } else { float hh =leading*lineNum; return th = hh; } } float getLength(){ return tl; //=textWidth(textContent); } } // class Textbox end -----------------------------// ////class Choise start////////////////////////////////////////////// class Choise { String[] item; String selectItem; float x,y, w, sellh; int num; int caseID; int selectId; Button[] sellB; BArrow baB; boolean isFirst; boolean isSpread; PFont pff; Choise(String[] a, float x_, float y_,float w_, PFont pff_){ item = a; num = item.length; //println(num); pff = pff_; x = x_; y = y_; w = w_; isFirst = true; isSpread = false; caseID = 1; selectId = 0; selectItem = item[0]; sellB = new Button[num]; for(int i=0; ix+sellB[0].w+baB.w && mousePressed) || (mouseY < y && mousePressed) || (mouseY > y+(sellB[0].h*num) && mousePressed) ){ caseID = 2; } } } void showHide(int xx){ switch(xx){ case 1: selectId =0; for(int i=0; i= x_ && mouseX <= x_+w_ && mouseY >= y_ && mouseY <= y_+h_){ return true; } else{ return false; } } void setColor_o(color x){ o = x; } void setColor_p(color x){ p = x; } void setColor_n(color x){ n = x; } void setColor_r(color x){ r = x; } void setColor_b(color x){ b = x; } float getX(){ return x; } float getY(){ return y; } float getW(){ return w; } float getH(){ return h; } } ///class Rectangle end///////////////////////////////////// ///class Brect start///////////////////////////////////// class Brect{ // position and size float x,y,w,h,m; // case of use 1: button 2: other- change color as it pressed and remain color changed int ca; int con; int on; // boolean over and pressed boolean isOver; boolean isPressed; boolean isLocked; //style of rect color n= color(211,211,211); color r= color(211,211,211); color o= color(245, 59, 12); color p= color(100, 21, 1); color c= color(33, 9, 3); color b= color(255, 255, 255); Brect(float x_, float y_, float w_, float h_, float m_, int f){ x = x_; y = y_; m = m_; w = w_; h = h_; ca = f; con =0; isOver = false; isPressed = false; isLocked = false; } Brect(float x_, float y_, float w_, float h_, int f){ x = x_; y = y_; w = w_; h = h_; ca = f; con =0; isOver = false; isPressed = false; isLocked = false; } void update(){ over(); press(); switch(ca){ case 1: if(isOver && isPressed){ n = p; on = 1; } else if(isOver && isPressed==false){ n = o; } else{ n = r; on = 0; } break; case 2: if(isOver && isPressed && isLocked){ n = p; } else if(isOver){ n = o; } else if(!isLocked){ n = r; } break; } } void over(){ if(overShape(x, y, w, h)){ isOver = true; } else{ isOver = false; } } void press(){ switch(ca){ case 1: if(isOver && mousePressed ){ isPressed = true; } else{ isPressed = false; } break; case 2: if( isOver && mousePressed || isLocked){ isPressed = true; isLocked = true; } else if(isOver && isLocked && mousePressed){ isLocked = false; } else{ isPressed = false; } break; } } void release(){ isLocked = false; } void display(){ update(); noStroke(); switch(ca){ case 1: fill(b); rect(x-1, y-1, w+2, h+2); fill(n); rect(x, y, w, h); break; case 2: if(isOver){ fill(b); rect(x-1, y-1, w+2, h+2); fill(n); rect(x, y, w, h); stroke(b); line(x+2,y+2,x+w-2,y+h-2); line(x+2,y+h-2,x+w-2,y+2); } else if(isLocked){ fill(b); rect(x-1, y-1, w+2, h+2); fill(n); rect(x, y, w, h); stroke(b); line(x+2,y+2,x+w-2,y+h-2); line(x+2,y+h-2,x+w-2,y+2); } else{ rect(x, y, w, h); } break; } } void setPosition(float xx, float yy){ x = xx; y = yy; } void setSize(float ww, float hh){ w = ww; h = hh; } boolean overShape(float x_, float y_, float w_, float h_){ if(mouseX >= x_ && mouseX <= x_+w_ && mouseY >= y_ && mouseY <= y_+h_){ return true; } else{ return false; } } void setColor_o(color x){ o = x; } void setColor_p(color x){ p = x; } void setColor_n(color x){ n = x; } void setColor_r(color x){ r = x; } void setColor_b(color x){ b = x; } float getX(){ return x; } float getY(){ return y; } float getW(){ return w; } float getH(){ return h; } } ///class Brect end/////////////////////////////////////