xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Helder Magalhães <helder.magalh...@gmail.com>
Subject Re: Merging one document with another in a JSVGCanvas
Date Sat, 28 Mar 2009 09:07:03 GMT
Hi Alan,


> However it has some drawbacks --
> the deal breaker for me was reconciling the coordinate systems and CTMs of
> both the parent and child objects so that the child showed up where I wanted
> it to in the right scale.   Further, the kbd/mouse interactors for both
> objects remain completely separate.

Yes, I recall a few related mailing list threads recently, with
complex math and quite a bit of code to make it work all together...
;-)


> So I learned how to do the following:
[code snippet]

So "the following" seems to be embedding a document within the other.
Generally it seems a good idea. :-)


> So what is the most efficient way to get "node" to appear exactly on top of
> "targetRect?"   I have gotten hopelessly confused over the various
> viewports, viewboxes, and transforms involved.
> I may also need to rotate node by 90 degrees.  Since node is an SVG element,
> it won't take a transform, so do I need to encapsulate it inside a G
> element?

Well, for a start I'd propose a slightly different approach, intending
to be more general:
 * Create a parent document to hold all the imported documents ("container");
 * Create a svg container [1] for each document being imported;
 * Adjust the dimension and aspect ratio [2] of the child documents.

The proposal would result in something like (untested code snippet):

<svg xmlns="http://www.w3.org/2000/svg" id="container">
  <svg preserveAspectRatio="xMaxYMax" width="$width" height="$height"
id="document1">
    <!-- document 1 contents -->
  </svg>
  <svg preserveAspectRatio="xMaxYMax" width="$width" height="$height"
id="document2">
    <!-- document 2 contents -->
  </svg>
  <!-- ... document N ... -->
</svg>

Note that "$width" and "$height" are variables to be replaced with
actual values which should be coherent with the target dimension.


Thing is, generally, the overlay approach may have a caveat: if the
proportions of the documents are not the same, the final look can be
weird. In the sample above, the documents are stretch to the target
dimension (aspect ratio isn't preserved), although you may try other
approaches (see the specification [2] for a nice sample).


> Much thanks for any help on this.

Hope this helps,
 Helder Magalhães


[1] http://www.w3.org/TR/SVG11/intro.html#TermContainerElement
[2] http://www.w3.org/TR/SVG11/coords.html#PreserveAspectRatioAttribute

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Mime
View raw message