Hi Selva,
I see the bug now:
SVGPoint cPt = _document.getRootElement().createSVGPoint();
// You never populate cPt with the point to transform.
cPt = cPt.matrixTransform(mat);
System.out.println("(" + cPt.getX() + "," + cPt.getY() + ")");
You need to add something like the following where my comment is:
SVGRect bbox = recLoc.getBBox();
cPt.setX(recLoc.getX() + rectLox.getWidth()/2);
cPt.setY(recLoc.getY() + rectLox.getHeight()/2);
Otherwise the point defaults to 0,0.
news <[EMAIL PROTECTED]> wrote on 04/26/2006 10:42:30 AM:
> I am again facing getting position problem. So Please clarify the
following
> problem.
>
> I am having one group element with 2 to 3 elements. While dragging the
> particular group element, I am trying to get center point of that
element. So
> I am getting it?s current ?x? and ?y? position and width of the element.
To
> get ?x? and ?y? position, I have used the following way.
>
> SVGLocatable recLoc = (SVGLocatable)selElement;
> SVGMatrix mat = recLoc.getTransformToElement((SVGElement)
> selElement.getParentNode());
> SVGPoint cPt = _document.getRootElement().createSVGPoint();
> cPt = cPt.matrixTransform(mat);
> System.out.println("(" + cPt.getX() + "," + cPt.getY() + ")");
>
> But it returns ?x? and ?y? position based on its old position which was
set
> while creating the Element.
>
> If I move to downward direction, it returns (0,1), (0,2) . . .
>
> If I move to upward direction, it returns (0,-1), (0,-2) . . .
> .
> .
> .
>
> Should i add it's position with element's old position?
> or
> Is there anyother way to get current position straightly?
>
> Thanks,
> Selva
>
>
> ---------------------------------------------------------------------
> 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]