You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by ju...@hiro.sk on 2006/06/01 18:40:32 UTC

Transforming GraphicsNode

Hi,

I have one problem. I am painting GraphicsNode instance into a JFrame
calling it's paint method. This drawing works great.

Then I need to determine if a particular point is contained in
GraphicsNode instance (for example a mouse position after mouse click). So
I use the contain method of my GraphicsNode instance. And this is the
problem. First time I use contains method it works correctly. But then I
translate the GraphicsNode instance using
AffineTransform.getTranslateInstance(tx, ty) and node's setTransform
method. After the translation the node is painted into new position but
the contains method returns true only for the points in original position.
I don't understand why.

Can any one help me? I need to transform the GraphicsNode instances in a
way that the contains method will return true for points in new positions.

If my email is too complicated I can write down little example.

Thanks a lot
  Julo Chrobak


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: Transforming GraphicsNode

Posted by André Ávila <as...@nextech.com.br>.
Hi Julo,

I think you could either translate the Point2D you pass to the contains()
method using the same transform that you applied to the GraphicsNode or
translate your node back to the original coordinate system using the inverse
AffineTransform before calling contains(). Both solutions should work the
same way.

Hope that helps,

André

----- Original Message ----- 
From: <ju...@hiro.sk>
To: <ba...@xmlgraphics.apache.org>
Sent: Thursday, June 01, 2006 1:40 PM
Subject: Transforming GraphicsNode


> Hi,
>
> I have one problem. I am painting GraphicsNode instance into a JFrame
> calling it's paint method. This drawing works great.
>
> Then I need to determine if a particular point is contained in
> GraphicsNode instance (for example a mouse position after mouse click). So
> I use the contain method of my GraphicsNode instance. And this is the
> problem. First time I use contains method it works correctly. But then I
> translate the GraphicsNode instance using
> AffineTransform.getTranslateInstance(tx, ty) and node's setTransform
> method. After the translation the node is painted into new position but
> the contains method returns true only for the points in original position.
> I don't understand why.
>
> Can any one help me? I need to transform the GraphicsNode instances in a
> way that the contains method will return true for points in new positions.
>
> If my email is too complicated I can write down little example.
>
> Thanks a lot
>   Julo Chrobak
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org