xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tacio Santos" <tacio.san...@gmail.com>
Subject Re: finding the transformed location of a svg group
Date Thu, 08 Mar 2007 09:22:08 GMT
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 <tonny@kiyut.com> 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: 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


Mime
View raw message