public static SVGPoint elementCoordinatesFromEvent ( Document doc , Element tag , Event evt ) { try { DOMMouseEvent gnme = ( DOMMouseEvent ) evt ; SVGMatrix mat = ( ( SVGLocatable ) tag ) . getScreenCTM ( ) ; SVGMatrix imat = mat . inverse ( ) ; SVGPoint cPt = ( ( SVGDocument ) doc ) . getRootElement ( ) . createSVGPoint ( ) ; cPt . setX ( gnme . getClientX ( ) ) ; cPt . setY ( gnme . getClientY ( ) ) ; return cPt . matrixTransform ( imat ) ; } catch ( Exception e ) { LoggingUtil . warning ( "Error getting coordinates from SVG event." , e ) ; return null ; } }
Convert the coordinates of an DOM Event from screen into element coordinates .