Hi,

I have a canvas that displays Shapes (described in application specific
world coords)
by converting them from world space to screen space
(by using the appropirate coord. converter).

I need to implement an efficient hit testing method to select
the Shape that is under the mouse click. The shapes can include open
ended
cubic and quadratic curves and in general any shape that can be
described
by a GeneralPath.

I thought of two ways to approach this problem:

1st approach:

1. Convert the mouse pos(x,y) to world coords.(wx, wy)

2.  Create a little rectangle(epsRect) around the mouse click position
and convert
into world coords.

3. Now, I try to narrow the possible candidates first by testing the
intersection of epsRect
with the bounding boxes of the list of shapes.

4. Now, I test intersection with the list of shapes that passed the
check in step 3. I still
could have multiple shapes that pass this test.

Second approach:

The other approach seems to be to use Graphics2D.hit(..) in device
space.

One thing that came to mind was the use of fancy strokes. In the first
approach, I think
I could still use createStrokedShape() reconverted to world coords. to
use for hit testing
against the shape of the stroke but a Stroke of any width greater than
the
infinitely thin outline does not have a parallel in the world
coordinates..
The second approach works better in this regard.

I am interested in hearing your opinions about the advantages
and disadvantages of doing it one way or the other.

Thanks,
Satish.

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to