diff --git a/drawing/drawing.pde b/drawing/drawing.pde index aa773dd..bdca3b8 100644 --- a/drawing/drawing.pde +++ b/drawing/drawing.pde @@ -1,8 +1,10 @@ + final int DRAW_NORMAL=1; final int DRAW_DRAG=2; final int Vertex_Rad=8; // define parameters for rectangular button - int rectX=500, rectY=500; + int rectX1=500, rectY1=500; + int rectX2=500, rectY2=550; int rectwidth=80; int rectheight=40; color rectColor; @@ -16,8 +18,8 @@ void setup() { background(255); rectColor=(150); rectHighlight=color(255,0,0); - rectX=500; - rectY=500; + rectX1=500; + rectY1=500; noStroke(); } Graph G=new Graph(); @@ -70,9 +72,10 @@ void mouseDragged(){ } void mousePressed(){ - if(vertex_under_mouse==null && !check_mouse_over_button(rectX,rectY,rectheight,rectwidth)){ + if(vertex_under_mouse==null && !check_mouse_over_button(rectX1,rectY1,rectheight,rectwidth) &&!check_mouse_over_button(rectX2,rectY2,rectheight,rectwidth)){ G.V.add(new Vertex(mouseX, mouseY,true)); } + } void mouseReleased(){ @@ -92,46 +95,63 @@ void mouseReleased(){ void mouse_over_BUTTON(){ - if(check_mouse_over_button(rectX,rectY,rectheight,rectwidth)){ + if(check_mouse_over_button(rectX1,rectY1,rectheight,rectwidth)){ fill(255,0,0); }else { fill(rectColor); } noStroke(); - rect(rectX,rectY,rectwidth,rectheight); + rect(rectX1,rectY1,rectwidth,rectheight); + textSize(10); + fill(0, 0, 0); + text("Initial Graph",rectX1+rectwidth/8,rectY1+rectheight/2); + + if(check_mouse_over_button(rectX2,rectY2,rectheight,rectwidth)) + fill(255,0,0); + else + fill(rectColor); + + rect(rectX2,rectY2,rectwidth,rectheight); textSize(10); fill(0, 0, 0); - text("Initial Graph",rectX+rectwidth/8,rectY+rectheight/2); - + text("Reset",rectX2+rectwidth/8,rectY2+rectheight/2); } void mouseClicked(){ - if(check_mouse_over_button(rectX,rectY,rectheight,rectwidth)) - //draw edges should be implemented by pressing button. + if(check_mouse_over_button(rectX1,rectY1,rectheight,rectwidth)){ + //draw edges should be implemented by pressing button. + if (G.V.size()<=3) throw new RuntimeException("Requires at least 5 points"); + ArrayList index=new ArrayList (); for(int i=0;i