Hi all. So, this is a GUI I have made using Processing 3.5.3 in Windows7 (64 bit). I have an issue with having a continuously moving marker along with the mouse in the rectangle where I see the data. Currently, I have written the code such that I get a static black vertical line only at the places I click (as shown in the attached image) and otherwise I don’t see any vertical line as I move the mouse.
In order to achieve this target, I am trying the following: On clicking “marker” button, I call for a thread in which the data plotting rectangle refreshes itself (Let’s ignore plotting of data for now) and as I move the mouse, the vertical line moves. It does refresh & the vertical line moves with mouse. But there are rectangles created randomly in the vicinity. I don’t know why is this happening. Probably, moving mouse interrupts… But, how do I handle them efficiently. I tried looking for any marker facility in G4P library. Couldn’t find any. Any suggestions?? Following is the thread code (being called after I click “Marker” buttton). Also the image is provided to show the problem:
void marker()
{
while(true) {
if((mouseX<950) && (mouseX>150) && (mouseY<600) && (mouseY>50))
{
//background(255);
//redraw();
displayframe();
println(mouseY);
stroke(0);
strokeWeight(1.2);
//fill(0);
line(mouseX,50,mouseX,600);
//line(150,mouseY,950,mouseY);
}
}
void displayframe()
{
fill(255);
rect(150,50,800,550);
//println("ho, hotay");
}
}