xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Deikman <Alan.Deik...@znyx.com>
Subject Re: JSVGCanvas Rotation with AffineTransform
Date Thu, 12 Mar 2009 17:28:07 GMT
Thomy wrote:
> I answered this question recently.
> Here is a snap of my source code :
>
>   
Thank you for answering -- I do something similar but it doesn't work.   
Here is an excerpt of my code, which executes in the UpdateManager's thread:

            if (display.position != null) {
                SVGRect bbox = display.position.getBBox();
                Point2D ul = new Point2D.Float(bbox.getX(), bbox.getY());
                Point2D lr = new Point2D.Float(bbox.getX() + 
bbox.getWidth(),
                        bbox.getY() + bbox.getHeight());
                AffineTransform t = getViewBoxTransform();               
                t.transform(ul, ul);
                t.transform(lr, lr);
                display.panel.setBounds((int) ul.getX(), (int) ul.getY(),
                        (int) (lr.getX() - ul.getX()),
                        (int) (lr.getY() - ul.getY()));
                if (isRotationNeeded(display.panel)) {
                    AffineTransform at = 
display.panel.getRenderingTransform();
                    at.rotate(Math.PI/2);
                    display.panel.setRenderingTransform(at);
                }
                
display.panel.setVisible(true);                                    
            }

Hopefully the definitions are clear from context.   In order to figure 
out what is going on, in the JSVGCanvas sub-class (display.panel in the 
example) I implemented the following overrides:

    @Override public void setRenderingTransform(AffineTransform t, 
boolean doRedraw) {
        System.out.println("setRenderingTransform: " + t.toString());
        super.setRenderingTransform(t, doRedraw);
    }

    @Override public void resize(int width, int height) {
        System.out.println("resize " + width + " " + height);
        super.resize(width, height);
    }

    @Override public void reshape(int x, int y, int width, int height) {
        System.out.println("reshape (" + x + ", " + y + ", " + width + 
", " + height + ")");
        super.reshape(x,y,width,height);
    }

This results in the following output:

setRenderingTransform: AffineTransform[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]
reshape (128, 0, 26, 296)
setRenderingTransform: AffineTransform[[0.0, -1.0, 0.0], [1.0, -0.0, 0.0]]
setRenderingTransform: AffineTransform[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]
gvtRenderingPrepare
gvtRenderingStart

The JSVGCanvas shows up in the right place in the right bounding box, 
but the image within is not rotated.  As the output shows, something 
overwrites the rotation transform with a new identity transform.  My 
question is at one point does the setRenderingTransform() /not/ get 
over-written this way?

-- 
Alan Deikman
ZNYX Networks


Mime
View raw message