question: private static Point2D detectLine ( Point2D p1 , Point2D p2 , Point2D p , Line2D line , GeneralPath path ) { if ( line . ptLineDistSq ( p ) == 0 ) { p2 . setLocation ( p ) ; } else { p1 . setLocation ( p2 ) ; p2 . setLocation ( p ) ; line . setLine ( p1 , p2 ) ; path . lineTo ( ( float ) p1 . getX ( ) , ( float ) p1 . getY ( ) ) ; } return p2 ; }
target:  Checks to see if point p is on a line that passes thru points p1 and p2. If p is on the line, extend the line segment so that it is from p1 to the location of p. If the point p is not on the line, update my shape with a line extending to the old p2 location, make the old p2 the new p1, and make p2 the old p