thank you, for the archives the method I was looking for was:
public void movePebbleToPos( String ellipseId, String dstId ){
SVGDocument doc = this.getSVGDocument();
final SVGSVGElement root = doc.getRootElement();
final SVGElement dst_e = (SVGElement) doc.getElementById(dstId);
final SVGElement ellipse = (SVGElement)doc.getElementById(ellipseId);
this.getUpdateManager().getUpdateRunnableQueue().invokeLater(
new Runnable() {
public void run() {
SVGLocatable dst_loc = (SVGLocatable) dst_e;
SVGMatrix mat = dst_loc.getTransformToElement(ellipse);
SVGPoint pt = root.createSVGPoint();
SVGRect bbox = dst_loc.getBBox();
pt.setX(bbox.getX() + bbox.getWidth()/2);
pt.setY(bbox.getY() + bbox.getHeight()/2);
pt = pt.matrixTransform(mat);
ellipse.setAttribute("cx", ""+pt.getX());
ellipse.setAttribute("cy", ""+pt.getY());
}});
}
cheers,
Tacio
On 3/8/07, Tonny Kohar <[EMAIL PROTECTED]> wrote:
Hi,
On Thu, 2007-03-08 at 04:39 +0100, Tacio Santos wrote:
> thank you, but the problem I'm getting now it that "ellipse" (my
> pebble) doesn't implement SVGElement and dst_e doesn't implement
> SVGLocatable, i.e. I'm having some difficulties understanding how and
> when to cast/convert one element type to another.
>
> public void moveEllipseToPos( String ellipseId, String dstId ){
> SVGDocument document = this.getSVGDocument();
> final Element dst_e = document.getElementById(dstId);
> final Element ellipse = document.getElementById(ellipseId);
> ..
Try to cast into SVGElement
final SVGElement dst_e = (SVGElement)document.getElementById(dstId);
final SVGElement ellipse = (SVGElement)document.getElementById(ellipseId);
If I am not wrong SVGElement implement SVGLocatable, please check the SVG DOM
API spec.
Regards
Tonny Kohar
--
Sketsa
SVG Graphics Editor
http://www.kiyut.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]