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 th...@kodak.com on 2007/04/03 12:01:39 UTC

Re: Finding ZoomedIn/ZoomedOut element?s ?x? and ?y? attribute

Hi Selva,

Selva <se...@yahoo.co.in> wrote on 04/02/2007 09:55:49 PM:

> I am trying to find the ZoomedIn/ZoomedOut element?s ?x? and ?y? 
attributes
> values.

   So I don't see you getting any 'x' and 'y' attributes.  You get the
x and y of a mouse event but that doesn't necessarily have anything to do
with locating of 'BG_Rectangle' (which you get by getElementById).

> But I couldn?t get the exact position. It returns the normal
> position without zoomin/zoomout.

   So the question to ask here is what coordinate system are you
interested in getting the pt in?  Screen Pixels?  The Root Elements
coordinate system?  Some other Element/Group coordinate system?

> I am using the following way to get the ?x? and ?y? attributes.

   So the code below takes the 'x' and 'y' of a mouse event and
maps those 'screen' coordinates to the local coordinate system
of the rectangle.  I suspect you want to do the opposite, in which
case you should drop the 'mat.inverse()' line and just use 'mat',
and of course use 'x' and 'y' values that actually come from
BG_Rectangle...

> DOMMouseEvent elEvt = (DOMMouseEvent)event;
> String cName = ?BG_Rectangle?;
> Element cElement = canvas.getSVGDocument().getElementById(cName);
> SVGPoint cRect = localPt(cElement, (int)elEvt.getClientX(),
> (int)elEvt.getClientY());
> .
> .
> .
> private SVGPoint localPt(Element elem, int x, int y) {
>     SVGMatrix mat = ((SVGLocatable)elem).getScreenCTM();
>              SVGMatrix imat = mat.inverse();
>                 SVGPoint cPt =
> _svgGraphView.getSVGDocument().getRootElement().createSVGPoint();
>              cPt.setX(x);
>              cPt.setY(y);
>              cPt = cPt.matrixTransform(imat);
>              return cPt;
>    }
> 
> Please let me know, if there is any problem in my code to get the 
attributes
> values after ZoomIn/ZoomedOut?
> 
> Thanks,
> Selva
> -- 
> View this message in context: http://www.nabble.com/Finding-
> ZoomedIn-ZoomedOut-element%E2%80%99s-%E2%80%98x%E2%80%99-and-%E2%80%
> 98y%E2%80%99-attribute-tf3509394.html#a9802422
> Sent from the Batik - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> 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