title: Swing paint program - How to handle selection?
body: <p>I'm trying to make a paint program using swing. I have several shapes that the user can draw, including ellipses, lines, and rectangles. The shapes can drawn (using graphics2d) with various strokes (line thicknesses) and can be filled or unfilled.</p>
  
  <p>I'm trying to implement a feature such that the user can click a shape with the right mouse button and drag it to move it.</p>
  
  <p>My current strategy is to poll the array of shapes is reverse order (meaning in case of multiple shapes the most recently added one is selected).</p>
  
  <p>Each shape implementation has a method called <code>isSelected(int x, int y)</code>. I need to figure out how to determine whether a point falls on the shape. One challenge is that an unfilled shape such as an oval should not be selected when clicked inside, but should be selected if it is filled. Also, selection should respond to the thickness of a stroke. That is, a line should be selectable by clicking out the outer area if it uses a thicker stroke, not just the exact center of the line.</p>
  
  <p>How on earth can I go about implementing this?</p>