Question: I have a program that implements a map GUI that is interactive. In this portion of the code, it creates 2 points that then slowly

I have a program that implements a map GUI that is interactive. In this portion of the code, it creates 2 points that then slowly connect to each other almost like an animation. However, what I want to do is edit it so that instead of the points being finite, I want the user to select the 2 points with mouse clicks and have those 2 points connect into a line similar to the animation I stated above. How should I approach this problem?

class Flash extends Thread { AcetateLayer acetLayer = new AcetateLayer(); double x1,y1,x2,y2; Flash(double x11,double y11,double x22, double y22) { x1 = x11;y1=y11;x2=x22;y2=y22; } public void run() { for (int i=0;i<21;i++) { try { Thread.sleep(300); final int j = i; if (acetLayer != null) QuickStart4f.map.remove(acetLayer); acetLayer = new AcetateLayer() { public void paintComponent(java.awt.Graphics g) { java.awt.Graphics2D g2d = (java.awt.Graphics2D) g; //Line2D.Double line = new Line2D.Double(startx,starty,endx,endy); Line2D.Double line = new Line2D.Double(x1,y1,x1+j*(x2-x1)/20.0,y1+j*(y2-y1)/20.0); g2d.setColor(new Color(0,0,250)); g2d.draw(line); g2d.setColor(new Color(250,0,0)); g2d.fillOval(298,198,5,5); g2d.fillOval(500,400,5,5); } }; acetLayer.setMap(QuickStart4f.map); QuickStart4f.map.add(acetLayer); } catch (Exception e) {} } } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!