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 Selva <se...@yahoo.co.in> on 2007/03/28 23:29:17 UTC

Translation problem

Hi All,

I am trying to translate the SVG content when I do the ZoomOut. So I have
calculated the translation value from the ZoomedOut transform. But when I
set this value in rendering transform, the translation is not happening
properly. Please see the following values.

AffineTransform rat = getRenderingTransform();
AffineTransform at = AffineTransform.getScaleInstance(scale, scale);
AffineTransform t = new AffineTransform(at);
t.concatenate(rat);

Rectangle r2d1 = rat.createTransformedShape(getViewBoxRect()).getBounds();
----(1)
Rectangle r2d2 = t.createTransformedShape(getViewBoxRect()).getBounds();   
----(2)

if(r2d1.x < 0) {
       double tx=Math.abs(r2d1.x)-Math.abs(r2d2.x);
       double ty=Math.abs(r2d1.y)-Math.abs(r2d2.y);
       t = AffineTransform.getTranslateInstance(tx, ty);
       t.preConcatenate(at);
       t.concatenate(rat);
}
setRenderingTransform(t);                                                                                    
----(3)

1 - java.awt.Rectangle[x=-4067,y=-2592,width=4792,height=3171]
2 - java.awt.Rectangle[x=-3661,y=-2333,width=4313,height=2854] 
3 - AffineTransform[[3.75952335247409, 0.0, -3294.9], [0.0,
3.75952335247409, -2099.7000000000003]]

In the above values, my expected tx and ty supposed to be  -3661 and -2333.
But my rendering transform is -3294.9 and 2099.7. So can anyone please
explain, how to calculate the correct translation value?

Thanks in advance.

Regards,
Selva

-- 
View this message in context: http://www.nabble.com/Translation-problem-tf3482861.html#a9722266
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: Translation problem

Posted by Selva <se...@yahoo.co.in>.
Hi All,

I have resolved the problem.  Please ignore this thread.

Thanks,
Selva


Selva wrote:
> 
> Hi All,
> 
> I am trying to translate the SVG content when I do the ZoomOut. So I have
> calculated the translation value from the ZoomedOut transform. But when I
> set this value in rendering transform, the translation is not happening
> properly. Please see the following values.
> 
> AffineTransform rat = getRenderingTransform();
> AffineTransform at = AffineTransform.getScaleInstance(scale, scale);
> AffineTransform t = new AffineTransform(at);
> t.concatenate(rat);
> 
> Rectangle r2d1 = rat.createTransformedShape(getViewBoxRect()).getBounds();
> ----(1)
> Rectangle r2d2 = t.createTransformedShape(getViewBoxRect()).getBounds();   
> ----(2)
> 
> if(r2d1.x < 0) {
>        double tx=Math.abs(r2d1.x)-Math.abs(r2d2.x);
>        double ty=Math.abs(r2d1.y)-Math.abs(r2d2.y);
>        t = AffineTransform.getTranslateInstance(tx, ty);
>        t.preConcatenate(at);
>        t.concatenate(rat);
> }
> setRenderingTransform(t);                                                                                    
> ----(3)
> 
> 1 - java.awt.Rectangle[x=-4067,y=-2592,width=4792,height=3171]
> 2 - java.awt.Rectangle[x=-3661,y=-2333,width=4313,height=2854] 
> 3 - AffineTransform[[3.75952335247409, 0.0, -3294.9], [0.0,
> 3.75952335247409, -2099.7000000000003]]
> 
> In the above values, my expected tx and ty supposed to be  -3661 and
> -2333. But my rendering transform is -3294.9 and 2099.7. So can anyone
> please explain, how to calculate the correct translation value?
> 
> Thanks in advance.
> 
> Regards,
> Selva
> 
> 

-- 
View this message in context: http://www.nabble.com/Translation-problem-tf3482861.html#a9763749
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