xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas E Deweese <thomas.dewe...@kodak.com>
Subject RE: getCharNumAtPosition() and transformations
Date Wed, 02 Apr 2003 13:39:20 GMT
>>>>> "BR" == Baron, Randy {PRG~Basel} <RANDY.BARON@Roche.COM> writes:

BR> hi- I am using the getCharNumAtPosition() method from
BR> SVGOMTextContentElement
BR> <file:///C:\JavaDev\Other%20Packages\BATIK\batik-docs-1.5beta5\docs\java
BR> doc\org\apache\batik\dom\svg\SVGOMTextContentElement.html> .  

BR> The user clicks on some text on the SVG display, the program gets
BR> the element clicked on from the target of the event, uses the
BR> MouseEvent's getClientX() and getClientY() to pass the point to
BR> getCharNumAtPosition(). 

    getClientX/Y return the mouse click in the viewport coordinate
system (essentially screen pixel locations).  You need to transform it
to the text element's coordinate system.

    This can be done by calling 'getScreenCTM()' on the text element
you want to call 'getCharNumAtPosition()' on, get the inverse of that
affine transform and apply that transform to the getClientX/Y point.

    Take a look at:

    In particular the function 'mouseOver' does almost exactly what
you want.

BR> It works very well...up to a point.  I can get the index of a
BR> character at a given position in the string but if I zoom or pan
BR> or rotate the canvas, getCharNumAtPosition returns either a -1 or,
BR> in some cases, a number corresponding to a kind of virtual
BR> character that would have been on that location if the original
BR> display were still showing.  Does anyone know if this is the
BR> intended behavior?  Is it possible to have it continue finding the
BR> actual character that is clicked on after a transformation?

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

View raw message