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 David Smith <Da...@aeroint.com> on 2001/12/12 17:15:13 UTC

Immediate translation of object

I have a graph making tool in batik and am trying to center the created
graph on the JSVGCanvas
by applying a translate function.  However I cannot get it to work.

My code is similar to:

SVGDocument graph = GraphBuilder.createGraph(..)

canvas.setSVGDocument(graph);

// calculate translation co-ordinates, x and y..

AffineTransform at = new AffineTransform()
at.translate(x,y);  // translate to the correct position

 if(canvas.getRenderingTransform() != null)
      at.concatenate(canvas.getRenderingTransform());
 c.setRenderingTransform(at);


This has no effect at all on the graph, though if I call the same transform
function from a menu item once the
graph is loaded, it works fine.
Does anyone have any idea?  Is there a better way of performing the
translation (eg setting an x/y offset on the canvas)?

************************************************************************
This Internet E-mail is intended solely for the person to whom it is addressed. It may contain confidential or privileged information. If you have received it in error please notify us immediately by telephone and destroy the transmission. You must not copy, distribute or take any action in reliance on it.

Aerosystems International               Phone: +44 (0)1935 443000
                                        Fax  : +44 (0)1935 443111
                                        Web  : www.aeroint.com
************************************************************************

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


Immediate translation of object

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "DS" == David Smith <Da...@aeroint.com> writes:

DS> I have a graph making tool in batik and am trying to center the
DS> created graph on the JSVGCanvas by applying a translate function.
DS> However I cannot get it to work.

DS> My code is similar to:

DS> SVGDocument graph = GraphBuilder.createGraph(..)

DS> canvas.setSVGDocument(graph);

DS> // calculate translation co-ordinates, x and y..

DS> AffineTransform at = new AffineTransform() at.translate(x,y); //
DS> translate to the correct position

DS>  if(canvas.getRenderingTransform() != null)
DS> at.concatenate(canvas.getRenderingTransform());
DS> c.setRenderingTransform(at);


DS> This has no effect at all on the graph, though if I call the same
DS> transform function from a menu item once the graph is loaded, it
DS> works fine.  Does anyone have any idea?  Is there a better way of
DS> performing the translation (eg setting an x/y offset on the
DS> canvas)?

    You probably want to look at the viewbox and width and height
attributes on the SVG element in the SVG specification.  Unless you
are trying to do something much more complicated than I think you are
you should be able to get the behaviour you want by setting these
attributes appropriately for the Graph.

    The actual problem you are having is that you need to wait until
the 'internal tree' is built before trying to set the rendering
transform.

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