Hi Peppe, Peppe <[EMAIL PROTECTED]> wrote on 01/08/2007 05:41:49 AM:
> So, i tried to understand how to convert coordinates system to another to > update bounding box position... > i would that you say me if this code that i wrote to map coordinates system > of bounding box is correct: > > DOMMouseEvent elEvt = (DOMMouseEvent)evt; > > SVGMatrix mat = ((SVGLocatable)shape).getScreenCTM(); > SVGMatrix imat = mat.inverse(); > bPt = doc.getRootElement().createSVGPoint(); > bPt.setX(elEvt.getClientX()); > bPt.setY(elEvt.getClientY()); Why are you using getClientX/Y instead of the corners of your BBox? > bPt = bPt.matrixTransform(imat); The basic code to map points looks good though. > then, when i release the button, i re-mapping the coordinate system of > bounding box to the shape coordinate system (the position of shape is > changed): > SVGMatrix rb = ((SVGLocatable)shape).getScreenCTM(); > bPt = bPt.matrixTransform(rb); Once again I would map the _current_ corners of the BBox (4 new points) instead of the same point you already mapped to screen coords above. But without a more complete example it's hard to know what you are trying to do. Also I would suggest that playing with this in JavaScript instead of java might help you since, re-running the javascript version is just 'reload' and takes less than a second. Once you have the jscript version running you can 'port' it back to java.