Thanks Thomas for the quick answer.

Thomas DeWeese wrote :
> Hi Thomas,
> 
> 
> 
> Thomas Charbonnel wrote:
> > As views have their own units and coordinate
> > systems, my idea is to use the svg elements' viewBox to make the views
> > fit in their dedicated space on the sheet. 
> 
>     Yes, this is the correct thing to do.
> 
> > The thing is that to compute the viewBox, I need the document to
> > already have been rendered to take into account the space used by 
> > tick marks' labels. The problem is similar for text labels inside 
> > the rects and polygons. I need the text's bounding box to position 
> > and scale it in the rects and polygons.
> > 
> > I'm wondering where the best place would be to do this.
> 
>     The best thing to do is to register an 'onload' event handler
> with the root SVG element (do this before passing the document to
> the Canvas).  Your handler will be called after the document
> has been loaded but before any display has taken place.  You will
> have access to the full SVG DOM at this point so you can use
> methods like 'getBBox()' to calculate the extent of your document.
> 

The 'onload' event handler is not enough, because the user actions can
dynamically change the size and position of elements in the inlined svg.
I need to recompute the viewBox every time this happens.
What I do now is that I register an UpdateManagerListener, and when I
detect that the viewBox needs to be recomputed, I trigger the
computation from the updateCompleted() callback. As everything in the
inlined svg is under a <g> element, I just take its bounding box and set
the viewBox to match it. The problem is that is a two passes rendering.
It's suboptimal, and the UI doesn't feel responsive (the intermediary
state can be seen). Is there a way to do this in just one pass ?

> > I can think of a two passes rendering, registering an UpdateManager
> > listener and executing the remaining steps in the updateCompleted()
> > callback when needed, but it looks ugly and inefficient to me. My
> > feeling is that there must be a way to do this in one pass, but I
> > couldn't figure it out so far.
> > What's the recommended or commonly used way to do this ?
> > 
> > Regards,
> > Thomas
> > 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to