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 Tilo Behrmann <Be...@FastGmbh.de> on 2006/01/17 17:53:47 UTC

Center to a Point

Hi i hope anybody can help me.

My Problem is that i have some Points in my SVGDocument it is shown in one
of two JSVGCanvases. Now i click on the first Canvas on a Point and give the
SVG Dokument to the second Canvas. Thats work fine. But my problem is that
the point, that i have clicked on the first Canvas, must now shown in the
center of the second Canvas kan anybody post some code snipe thats will help
me to transform the position for my SVGDokument in the second Canvas.

Thanks


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


AW: Center to a Point

Posted by Tilo Behrmann <Be...@FastGmbh.de>.
Thanks Thomas for the tip.
Now i have coded this (see 1). But the next problem is how can i
scale thats the point is after the scaling in the center. I have try this
(see 2) but it not work.

1:
currendSize = getSVGDocument().getRootElement().getScreenCTM().getA();
centerX = getSVGDocument().getRootElement().getScreenCTM().getE();
centerY = getSVGDocument().getRootElement().getScreenCTM().getF();
double x = getSVGWidth() / 2 - currendSize * getPoint2D().getX() - centerX;
double y = getSVGHeight() / 2 - currendSize * getPoint2D().getY() - centerY;
AffineTransform at2 = getRenderingTransform();
at2.translate(x, y);
setRenderingTransform(at2);

2:
at2 = getRenderingTransform();
at2.scale(4,4);
at2.translate(-(centerX*(4-1)),-(centerY*(4-1)));
setRenderingTransform(at2);


-----Ursprüngliche Nachricht-----
Von: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com]
Gesendet: Mittwoch, 18. Januar 2006 12:12
An: batik-users@xmlgraphics.apache.org
Betreff: Re: Center to a Point


Hi Tilo,

"Tilo Behrmann" <Be...@FastGmbh.de> wrote on 01/17/2006 11:53:47 AM:

> My Problem is that i have some Points in my SVGDocument it is shown in
one
> of two JSVGCanvases. Now i click on the first Canvas on a Point and give
the
> SVG Dokument to the second Canvas. Thats work fine. But my problem is
that
> the point, that i have clicked on the first Canvas, must now shown in
the
> center of the second Canvas kan anybody post some code snipe thats will
help
> me to transform the position for my SVGDokument in the second Canvas.

   The basic tools you need are:
        'getBBox' to get the location of the point on the first canvas.
        'getScreenCTM' to map that location to the point to the screen
coordinate system.
        'canvas.setRenderingTransform' which allows you to pan the
document
            in the second canvas.

   I will leave it as an exercise to the reader to figure out all the
nonsense that is required for manipulating the Affine Transforms.


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


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


Re: Center to a Point

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

"Tilo Behrmann" <Be...@FastGmbh.de> wrote on 01/17/2006 11:53:47 AM:

> My Problem is that i have some Points in my SVGDocument it is shown in 
one
> of two JSVGCanvases. Now i click on the first Canvas on a Point and give 
the
> SVG Dokument to the second Canvas. Thats work fine. But my problem is 
that
> the point, that i have clicked on the first Canvas, must now shown in 
the
> center of the second Canvas kan anybody post some code snipe thats will 
help
> me to transform the position for my SVGDokument in the second Canvas.

   The basic tools you need are:
        'getBBox' to get the location of the point on the first canvas.
        'getScreenCTM' to map that location to the point to the screen 
coordinate system.
        'canvas.setRenderingTransform' which allows you to pan the 
document
            in the second canvas.

   I will leave it as an exercise to the reader to figure out all the
nonsense that is required for manipulating the Affine Transforms.


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