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]

Reply via email to