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);
..


On 3/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Hi Michael,
   The problem is that the groups have transforms so the bbox is in
the local coordinate system of the group, not the coordinate system of
the pebble.  So you need to transform the center of the 'target' group
from the groups coordinate system to the pebbel's coordinate system...

    the code you want looks something like:

    this.getUpdateManager().getUpdateRunnableQueue().invokeLater(
       new Runnable() {
    // Do everything in runnable otherwise someone might
    // be modifying objects while you look at them...
    SVGMatrix mat = dst_e.getTransformToElement(ellipse);
  SVGLocatable dst_loc = (SVGLocatable) dst_e;

    SVGPoint pt = svgRoot.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());
});


"Bishop, Michael W. CONTR J9C880" <[EMAIL PROTECTED]> wrote on
03/07/2007 03:34:52 PM:

> Right, but did you try printing out the values for dest_x and dest_y in
> your method to see if they're what you expect them to be?
>
> Michael Bishop
>
> -----Original Message-----
> From: Tacio Santos [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 07, 2007 3:20 PM
> To: [email protected]
> Subject: Re: finding the transformed location of a svg group
>
> Hi,
> dest_x and dest_y are the coordinates of the element I'm trying to
> place an ellipse over. I have a svg file representing a game board
> where the fields are defined by grouped elements. What I'm trying to
> achieve is to move a peeble (an ellipse) over the board.
> Tacio
>
>
> On 3/7/07, Bishop, Michael W. CONTR J9C880 <[EMAIL PROTECTED]>
> wrote:
> > ...ok, what are the values represented by dest_x and dest_y?
> >
> > Michael Bishop
> >
> > -----Original Message-----
> > From: Tacio Santos [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, March 07, 2007 1:43 PM
> > To: [email protected]
> > Subject: Re: finding the transformed location of a svg group
> >
> > In the resulting DOM I get for the ellipse cx=30 and cy=118 whereas it
> > should be at cx=160 and cy=200.
> >
> > On 3/7/07, Bishop, Michael W. CONTR J9C880
> <[EMAIL PROTECTED]>
> > wrote:
> > > I don't see anything blatantly wrong.  What kind of output are you
> > > getting?  What is the resulting DOM?
> > >
> > > Michael Bishop
> > >
> > > -----Original Message-----
> > > From: Tacio Santos [mailto:[EMAIL PROTECTED]
> > > Sent: Wednesday, March 07, 2007 12:23 PM
> > > To: [email protected]
> > > Subject: Re: finding the transformed location of a svg group
> > >
> > > oops, sorry, what I actually meant was:
> > >
> > > public void moveEllipseToPos( String ellipseId, String dstId ){
> > >    SVGDocument document = this.getSVGDocument();
> > >    final Element dst_e =  document.getElementById(dstId);
> > >    final Element ellipse = document.getElementById(ellipseId);
> > >    SVGLocatable dst_loc = (SVGLocatable) dst_e;
> > >
> > >    final double dest_x=dst_loc.getBBox().getX();
> > >    final double dest_y=dst_loc.getBBox().getY();
> > >    this.getUpdateManager().getUpdateRunnableQueue().invokeLater(
> > >       new Runnable() {
> > >          public void run() {
> > >          ellipse.setAttributeNS(null, "cx", "" +dest_x);
> > >          ellipse.setAttributeNS(null, "cy", "" +dest_y);
> > >       }});
> > > }
> > >
> > >
> > >
> > > On 3/7/07, Bishop, Michael W. CONTR J9C880
> > <[EMAIL PROTECTED]>
> > > wrote:
> > > > ...well, you're not doing anything with srcId; you never reference
> > > that
> > > > ID or the element it belongs to.
> > > >
> > > > Michael Bishop
> > > >
> > > > -----Original Message-----
> > > > From: Tacio Santos [mailto:[EMAIL PROTECTED]
> > > > Sent: Wednesday, March 07, 2007 11:04 AM
> > > > To: [email protected]
> > > > Subject: finding the transformed location of a svg group
> > > >
> > > > Hi,
> > > > I know this is certainly a basic question, but I'm having problems
> > > > getting the location of svg groups on the JSVGCanvas. What I want
> to
> > > > achieve is to move an ellipse (identified by srcId) over a svg
> group
> > > > (dstId). I've read that I may have somehow to use
> > > > getTransformToElement , but I don't know how. Could someone give
> me
> > > > some help?
> > > >
> > > > thanks in advance,
> > > > Tacio
> > > >
> > > > PS: this is what I'm curently doing
> > > >
> > > > public void moveEllipseToPos( String srcId, String dstId ){
> > > >    SVGDocument document = this.getSVGDocument();
> > > >    final Element dst_e = document.getElementById(dstId);
> > > >    SVGLocatable dst_loc = (SVGLocatable) dst_e;
> > > >    final double dest_x=dst_loc.getBBox().getX();
> > > >    final double dest_y=dst_loc.getBBox().getY();
> > > >    canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(
> > > >    new Runnable() {
> > > >       public void run() {
> > > >       dst_e.setAttributeNS(null, "cx", "" +dest_x);
> > > >       dst_e.setAttributeNS(null, "cy", "" +dest_y);
> > > >       }});
> > > > }
> > > >
> > > >
> > ---------------------------------------------------------------------
> > > > 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]
> > > >
> > > >
> > >
> > >
> ---------------------------------------------------------------------
> > > 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]
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > 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]
> >
> >
>
> ---------------------------------------------------------------------
> 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]
>


---------------------------------------------------------------------
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]

Reply via email to