You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by "V. de Weger" <ba...@beno-delft.nl> on 2007/02/01 15:53:29 UTC

how to get correct render transform on multiple screens

One of our customers uses 'preset keys'. They can save a zoomed and panned
SVG and reload that in a later run of the application. This has been
implemented by saving the rendering transform to a file and apply that
transform the second run.  
As long as they do this on the same PC it works fine. When they reload on a
machine with either less virtual screens (usually they use machines with 4
screens in a 2x2 setup), or with different screen resolutions the SVG is
reloaded on a different pan position.

(1) What is the best way to do this? I guess whe have to use the
getViewing/getRendering/getViewBox api's in some order/configuration, but we
can't figure out the correct way. 
(2) Do we have to set the aspect ratio to a specific value?

Vincent
-- 
View this message in context: http://www.nabble.com/how-to-get-correct-render-transform-on-multiple-screens-tf3155275.html#a8749538
Sent from the Batik - Users mailing list archive at Nabble.com.


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


Re: how to get correct render transform on multiple screens

Posted by th...@kodak.com.
Hi Vincent,

"V. de Weger" <ba...@beno-delft.nl> wrote on 02/05/2007 09:39:19 AM:

> Just my luck: I have to rotate!
> 
> I've got the save part working, but how do I zoom/pan/rotate after 
loading
> the saved viewport?

   There are a large number of approaches to solve this problem.  My
suggestion would be to map three of your points through the 'current'
ScreenCTM.  This will give you three points in screen space s0,s1,s2. 
Now what you want to do is calculate the Affine Matrix that will map 
those three points (say top-left, bottom-left, top-right) to the 
windows corners w0, w1, w2.  Now an affine matrix has six values, 
and with three points you have six equations (x & y for each).  Now 
it's just a matter of doing a little algebra.

   s0.x*sx  + s0.y*shy + tx = w0.x
   s0.x*shy + s0.y*sy  + ty = w0.y
[...]

   When you calculate that transform then just preConcatenate
it with the current Rendering Transform and set the result as the
new rendering transform.


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


Re: how to get correct render transform on multiple screens

Posted by "V. de Weger" <ba...@beno-delft.nl>.

Just my luck: I have to rotate!

I've got the save part working, but how do I zoom/pan/rotate after loading
the saved viewport?

Vincent
-- 
View this message in context: http://www.nabble.com/how-to-get-correct-render-transform-on-multiple-screens-tf3155275.html#a8807407
Sent from the Batik - Users mailing list archive at Nabble.com.


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


Re: how to get correct render transform on multiple screens

Posted by th...@kodak.com.
Hi Vincent,

"V. de Weger" <ba...@beno-delft.nl> wrote on 02/01/2007 09:53:29 AM:

> One of our customers uses 'preset keys'. They can save a zoomed and 
panned
> SVG and reload that in a later run of the application. This has been
> implemented by saving the rendering transform to a file and apply that
> transform the second run. 
> As long as they do this on the same PC it works fine. When they reload 
on a
> machine with either less virtual screens (usually they use machines with 
4
> screens in a 2x2 setup), or with different screen resolutions the SVG is
> reloaded on a different pan position.

   Is it really a different pan position?  I would expect that the
upper left corner would be the same, is that not the case?

> (1) What is the best way to do this? I guess whe have to use the
> getViewing/getRendering/getViewBox api's in some order/configuration, 
but we
> can't figure out the correct way. 

   You probably need to figure out the region of the document that is
"actually" displayed.  This is best done by using 'getScreenCTM' on the
root SVG element [M], taking the inverse of that matrix [I], then mapping
the corners of the JSVGCanvas through the [I] matrix.  This is probably
the information you want to record for later playback.

   Then once the document is loaded, you will want to use the current
getScreenCTM to calculate a 'delta' transform to apply to the current
rendering transform in order to make the recorded corner points visible
(this will take into account the different 'viewing transform' established
by the viewbox and the new canvas size).

   If you don't need to worry about rotation you can do something like
get the screen CTM map the upper left corner to 'display' space the
result is the "location" of the previous upper left corner on the screen
(which might not be on the screen any more).  You then want to create a
transform with the negative of that coordinate as the translate (this
will 'pan' the document so that corner is at 0,0 on the screen).

   Then you can map the lower right corner through the screen CTM.
This will allow you to calculate the size of the original view on the
screen with the current screen CTM.  This can then be used to calculate
a scale factor to apply (after the translate).

> (2) Do we have to set the aspect ratio to a specific value?

   When you get the size of the old screen on the new screen
you can notice that the aspect ratios don't match.  At this point
you can choose one of two basic strategies, fit or slice.  If you
choose fit, then you select your scale so the relatively larger
of the two dimensions set's your scale (essentially selecting the
smaller scale factor) - this will lead to some extra content being
seen in the other dimension (probably fine for a mapping application),
slice uses the relatively smaller of the two dimension (essentially
selecting the larger scale factor) - this will lead to some cropping.

   In either of these two cases you will probably need to tweak the 
transform's translate to keep stuff centered.


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