Maik Sch�rer wrote:
Hi Thomas,
I have not found a solution for my problem up to now.

>In what coordinate system?
in SVG document coordinate system
further in text I mean with 'coordinates' always the SVG document coordinate system


 > You probably want to look at things like 'getScreenCTM' ...
for my problem it is not necessarry to convert to screen coordinates

No you want to convert _from_ screen coordinates.

> 'getViewPort()' ...
when I debug the viewPort of the rootElement I always get X/Y = 0/0 and width and height of the current canvas - independ on viewing the complete document or zoomed in a part of it !? Is this correct or did I something wrong ?

It is correct because the viewPort is (at least for the canvas) in screen coordinates. So unless you resize the canvas it should stay the same when you zoom/pan. But the screen CTM will change for the SVG element.

When I zoomed in, I expected to found X/Y > 0 and width/height smaller than my documents width/height...

I try to describe my problem by an example:
- my SVG is 2000x1000px
- I zoomed in, so now I see a part of the document starting on 600px/200px, 1000px wide and 500px high
- now I want to get these values: 600, 200, 1000 and 500, to know what is the currently visible part of the document...
(all coordinates in SVG document coordinate system)

Simply transform the viewPort to the outermost SVG element's coordinate system by using the inverse of the screen CTM for the outermost SVG element.


Thanks in advance for help and ideas Maik

Thomas DeWeese schrieb:

Maik Sch�rer wrote:

how can I get the coordinates/dimensions of the currently displayed piece of my SVG on SVGCanvas ?



In what coordinate system? In the screen coordinate system it's the components location and size - both easily obtainable from Swing ;) So I presume you mean somewhere inside your SVG document.

Example: my SVG is 2000x1000px and currently (because I zoomed in) a small piece of it is visible on SVGCanvas.
I want to know, what ist the coordinate of the upper left corner of this piece and its width and height...



You probably want to look at things like 'getScreenCTM' which will give you the transform to the screen coordinate system. Paired with 'getViewPort()' you will have the information needed to calculate this.

and a second question:
is it possible to detect, if the a SVG element (a text field e.g) is visible on the currently displayed piece of my SVG or if it is outside this area ?



You can use the intersection method or just do the simple check on the BBox of the text (you may need to use the getTransformToElement method to transform your BBOX to for example the root SVG element's user coordinate space).

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