In my program, I've got a set of chess squares drawn on panel by a Graphics object (with each Square object having a Rectangle object that defines its bounds). I recently, added a method for drawing lines across some of the squares for emphasis. The problem is: I need to be able to "erase" these lines and it seems the only way of erasing a line it is redrawing the squares "affected" by the line.
I want to ask, assuming a line starts from PointA(x, y) and stops at PointB(x, y), how do I determine the squares on the panel to redraw? Is it best to resolve each line into a series of Points and then, check which Square.Rectangle contains any of the points? If so, how do I do that?