I don't see an example in the 1.5 sources called
samples/tests/spec/scripting/text_content.svg . I do have a directory called
text_content however.
Here is a java method that I wrote, but it doesn't work when the image has
been zoomed:
(I want to do a drawRect of the boundingBox of the element I clicked on)
SVGPoint getLocationOnElement(SVGDocument document, SVGLocatable elem,
org.w3c.dom.events.MouseEvent me)
{
SVGMatrix mat = elem.getScreenCTM();
SVGMatrix imat = mat.inverse(); // Go from screen to elem
SVGPoint pt = document.getRootElement().createSVGPoint();
pt.setX(me.getClientX());
pt.setY(me.getClientY());
pt = pt.matrixTransform(imat);
return pt;
}
Where is the point in relation to the element? Is it a corner of a bounding
box, or the center of
the element? For now I want to just click and draw the box, but ultimately,
my goal is to draw a rubber band rectangle on the screen at any zoom factor,
and determine what elements are contained/intersected by the rectangle.
Your help is greatly appreciated, thanks!
----- Original Message -----
From: "Thomas DeWeese" <[EMAIL PROTECTED]>
To: "Batik Users" <[EMAIL PROTECTED]>
Sent: Sunday, December 14, 2003 6:05 PM
Subject: Re: Still sttruggling with scaled/zoomed document
> Ron King wrote:
>
> > Could someone please tell me how to get a correct bbox from a zoomed
> > document?
>
> Hi Ron,
> You would probably find
> samples/tests/spec/scripting/text_content.svg useful.
>
> This makes use of getTransformToElement to transform the
> bbox points to another elements coordinate system. You probably
> want to use getScreenCTM which gives the transform to the 'screen'
> coordinate system, but other than getting a different transform the
> point manipulation code is the same.
>
> > I'm making a Batik based paint program, and I'm having some success.
> > I can draw a rubber band rectangle around a part of the document,
> > and then select all elements inside the rectangle. However, if I
> > have zoomed the document to get to the finer details, I can't figure
> > out how to capture the proper coordinates any more.
> >
> > When testing, I use getbbox to draw a rectangle around one element.
> > I can do this before I zoom, but after I have zoomed the box comes
> > up in the wrong location. I have seen people on the list discuss the
> > getbbox problem, but I haven't seen a straight-forward source code
> > solution presented.
>
>
>
>
>
> ---------------------------------------------------------------------
> 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]