Thanks for your help! I think the problem I am facing comes before this transformations you provided. The problem is that I cannot find a way to translate the drawing coordinates to the canvas coordinates. I'm hardly a expert in the graphics area, so let me try to explain with an example of what I'm trying to do.
I have an svg drawing file which contains the following line:
<svg width="400" height="200" viewBox="0 0 400 200">
...and I have a canvas sized to 800x600.
When I load the svg file into the canvas, the drawing expands to fill the canvas area.
Suppose I want to move center point (200, 100) of the _drawing the file_ to the point (0,0) of the canvas. To accomplish it, I discovered I need to apply a (-400, -200) translate transformation, not a (-200, -100), due to the scale previously applied to the drawing when loaded into the canvas. How can I find out that scale? Or, how can I get the coordinates translated?
Thanks!
Charles
On 4/27/06, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:
Hi Charles,
"Charles Abreu" < [EMAIL PROTECTED]> wrote on 04/26/2006 03:51:08 PM:
> I need to position a specified point of the displayed drawing on the
certer of
> the canvas (drawing area), regardless of the canvas size and the drawing
> scale. The point will be specified by a parameter. There is no mouse
clicked
> involved. Could anybody help me with a code snippet with the transforms
that
> must be applied?
I can't provide real code, but you should look at
batik.apps.svgbrowser.FindDialog this does essentially what you want
around line 350. You might need to do some extra manipulations
of the given point depending on the coordinate system you need the
point in.
But the basic idea is to move the point you want centered on
the screen to 0,0:
// translate the highlight region to (0, 0) in the canvas
coordinate
// system
AffineTransform Tx = AffineTransform.getTranslateInstance
(-gnb.getX()-gnb.getWidth()/2,
-gnb.getY()-gnb.getHeight()/2);
The move it to the center of the canvas:
Dimension canvasSize = svgCanvas.getSize ();
Tx.preConcatenate(AffineTransform.getTranslateInstance
(canvasSize.width/2, canvasSize.height/2));
In your case you will probably need to preConcatenate this with
the current rendering transform (the find dialog does a wholesale
replacement of the rendering transform).
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
