views:

44

answers:

1

Hi,

I'm trying to make an interactive GUI but I need to move a certain object whenever that rectangle is clicked + dragged. Basically I wanna know whether a rectangle, that has been affine transformed, contains a specific point (x, y). Is there a way to do this? I have tried using contains() method but it doesn't work for a rectangle that has been affine transformed. I checked the Java tutorials but the user interactive GUIs don't use affine transformation. Can someone point me to a tutorial that allows the user to affine transform a certain shape as well as move the shape ONLY when the shape itself is clicked + dragged. If not, how can I approach this?

Thanks.

+1  A: 

This example shows that contains() works as expected on a transformed Shape. The example uses Polygon, but Rectangle also implements Shape.

If instead the graphics context itself is transformed, you'll have to create an inverse "to capture the changes you make to the transform", as shown this example.

trashgod