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 Eli Gordon <el...@hotmail.com> on 2001/06/08 16:49:02 UTC

SVGDocument Transforms

(First of all, thank you to Keiron Liddle for your previous help, it was 
invaluable.)

Today's question is: how do I properly change the display size of my SVG 
graphics?

As I outlined in a previous post, I'm not using SVGCanvas, I'm just painting 
the image directly to my application's Graphics2D. Right now, I am already 
using AffineTransforms on my Graphics2D to support zooming and scrolling. 
Should I be using another AffineTransform for my root GraphicsNode in order 
to scale my SVG graphic? I tried this, and it seemed to work alright, 
however when I use the getOutline() method, it returns the shape at the 
original size.

A couple of auxiliary questions:
- What is the difference between setting the transform of the 
GraphicsNodeRenderContext as opposed to setting the transform of the 
GraphicsNode? Are there other places that I should consider setting it?

- Am I correct in assuming that the default (base) size of an SVG graphic is 
set within the SVG itself (the "width" and "height" tags of the root node)?

- Is there any way that I can display my graphic to be exactly m X n pixels, 
instead of having to specify a relative scaling factor. Or, rather, should I 
just perform some math by hand to acheive the same result?

Thank you very much!
-Eli

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


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


Re: SVGDocument Transforms

Posted by Thierry Kormann <tk...@sophia.inria.fr>.
On Friday 08 June 2001 16:49, Eli Gordon wrote:
> (First of all, thank you to Keiron Liddle for your previous help, it was
> invaluable.)
>
> Today's question is: how do I properly change the display size of my SVG
> graphics?
>
> As I outlined in a previous post, I'm not using SVGCanvas, I'm just
> painting the image directly to my application's Graphics2D. Right now, I am
> already using AffineTransforms on my Graphics2D to support zooming and
> scrolling. Should I be using another AffineTransform for my root
> GraphicsNode in order to scale my SVG graphic? I tried this, and it seemed
> to work alright, however when I use the getOutline() method, it returns the
> shape at the original size.
>
> A couple of auxiliary questions:
> - What is the difference between setting the transform of the
> GraphicsNodeRenderContext as opposed to setting the transform of the
> GraphicsNode? Are there other places that I should consider setting it?
>
> - Am I correct in assuming that the default (base) size of an SVG graphic
> is set within the SVG itself (the "width" and "height" tags of the root
> node)?
>
> - Is there any way that I can display my graphic to be exactly m X n
> pixels, instead of having to specify a relative scaling factor. Or, rather,
> should I just perform some math by hand to acheive the same result?


Sorry for the delay.
The best tip I can give you is to take a look at the ImageTranscoder class.
Scaling is done if needed or you can just skip that part if you don't need 
any scaling operation.

Thierry.



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


SVGDocument Transforms

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "EG" == Eli Gordon <el...@hotmail.com> writes:

EG> Today's question is: how do I properly change the display size of
EG> my SVG graphics?

EG> As I outlined in a previous post, I'm not using SVGCanvas, I'm
EG> just painting the image directly to my application's
EG> Graphics2D. Right now, I am already using AffineTransforms on my
EG> Graphics2D to support zooming and scrolling.  Should I be using
EG> another AffineTransform for my root GraphicsNode in order to scale
EG> my SVG graphic? I tried this, and it seemed to work alright,
EG> however when I use the getOutline() method, it returns the shape
EG> at the original size.

    getOutline() on what?  On the GraphicsNode?

EG> A couple of auxiliary questions: - What is the difference between
EG> setting the transform of the GraphicsNodeRenderContext as opposed
EG> to setting the transform of the GraphicsNode? Are there other
EG> places that I should consider setting it?

    In SVG and Graphics 2D there is a notion of an arbitrary User
Coordinate system.  This coordinate system can represent anything,
milliliters, kilometers, 1/72th of an inch, etc.  All geometry is
described in this arbitrary user coordinate system.  The user
coordinate system can also be changed from parent to child in the SVG
tree through the use of the 'transform' attribute.

    So the question then becomes how do you render this?

    This is where the user to device coordinate transform comes in.
This is an independent transform that is designed to transform your
arbitrary user coordinate system into a device (or pixel based)
coordinate system.  This transform usually varies with various devices
(say a 72dpi screen vs 600dpi printer).

    The transform on Graphics Node will adjust the user coordinate
system used at the top of the rendering tree, the transform in
GraphicsNodeRenderContext adjusts the transform from the root of the
rendering tree to the device coordinate system.  Thus either can be
used to achieve the same apparent effect, however which you _should_
use depends on what you are trying to do.

    So if you are trying to change the user coordinate system (for
example to place an element defined using millimeters in a document
defined using kilometers, or to resize an element to fit nicely in
another document) you probably want to adjust transforms on graphics
nodes.  If you are changing scaling for viewing purposes you probably
want to play with the transform in the render context.

EG> - Am I correct in assuming that the default (base) size of an SVG
EG> graphic is set within the SVG itself (the "width" and "height"
EG> tags of the root node)?

    Yes, these are taken as the default size of the graphic.

 EG> - Is there any way that I can display my graphic to be exactly m X
EG> n pixels, instead of having to specify a relative scaling
EG> factor. Or, rather, should I just perform some math by hand to
EG> acheive the same result?

    Are we talking programaticaly (ie. within Batik with Java code) or
in the SVG file.  The width and height can specify 'pt' which maps to
1/72nd of an inch which is typical of a pixel.  There are number of
unit specifiers which can help control the default user to device
transform on the root SVG element.  Others can probably talk about
this much more intelligently than I can.

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