Hi Alan,
I answered this question recently.
Here is a snap of my source code :

        public void setSVGAffineTransformation(){

                AffineTransform tx = svgCanvas.getRenderingTransform();
                // Zoom Level
                tx.setToScale(zoomLevel(),zoomLevel());
                // The user want to rotate ???
                
if(Main.getFenetrePrincipale().getZoomControl().getAngleRotation() != 0){
                        // Sinus of Rotation angle
                        double sinA =
Math.sin(Main.getFenetrePrincipale().getZoomControl().getAngleRotation());

                        
                        // Do the rotation on the center of the picture
                
tx.rotate(Main.getFenetrePrincipale().getZoomControl().getAngleRotation(),
Main.getFenetrePrincipale().getFenetreManuscrit().getPaintCanvas().getImage().getWidth(null)
/2,
Main.getFenetrePrincipale().getFenetreManuscrit().getPaintCanvas().getImage().getHeight(null)/2);
                        // Do the translation, depend on the sinus
                        if(sinA == 1)

                        {

                                tx.translate(-sinA *
Main.getFenetrePrincipale().getFenetreManuscrit().getPaintCanvas().getRect().getX(),
-sinA *
Main.getFenetrePrincipale().getFenetreManuscrit().getPaintCanvas().getRect().getY());

                        }

                        else

                        {

                                tx.translate(sinA *
Main.getFenetrePrincipale().getFenetreManuscrit().getPaintCanvas().getRect().getX(),
sinA *
Main.getFenetrePrincipale().getFenetreManuscrit().getPaintCanvas().getRect().getY());

                        }

                }
                // set the rendering :)
                svgCanvas.setRenderingTransform(tx);

        }

The wrong position of the JSVGCanvas was due to a mathematical error :)
Check the translate method.

Hope this will help



Alan Deikman wrote:
> 
> Thomas Palfray wrote:
>> Thanks for your answer.
>>
>> thomas.dewe...@kodak.com a écrit :
>>>
>>> Hi Thomas,
>>>
>>> Thomas Palfray <thomas.palf...@gmail.com> wrote on 10/25/2008 
>>> 05:08:39 AM:
>>>
>>> > Well, i'm working on an application wich need to rotate a JSVGCanvas
>>> > (90°, 180°, 270°). I used AffineTransform and the method
>>> > setRenderingTransform like that :
>>>
>>>    If you only need to support 90, 180 & 270 deg rotations.
>>> I would suggest simply hard coding the correction factors.
>>> For 90deg it will be a translate in X by the height before rotation.
>>> for 180 deg it will be translate in X by the width and
>>> in Y by the height (both before rotation), for 270 a
>>> translate in Y by the width before rotation.
> I'm having the same problem -- I have a JSVGCanvas I want to paint in 
> different orientations.   I have tried the setRenderingTransform() 
> method with no success -- it just gets overwritten by some other logic 
> within batik with the identity transform when the component is resized.
> 
> Question: at what point can setRenderingTransform(at, true) be used or 
> is meaningful within the lifecycle of GVT rendering process?
> 
> Another question -- is there anything to read to understand the usage of 
> the different transforms in JSVGCanvas?   You have the initial 
> transform, rendering transform, viewing transform, viewbox transform, 
> and painting transform. 
> 
> Thanks in advance for any pointers.
> 
> -- 
> Alan Deikman
> ZNYX Networks
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/JSVGCanvas-Rotation-with-AffineTransform-tp20162475p22472250.html
Sent from the Batik - Users mailing list archive at Nabble.com.


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

Reply via email to