>>>>> "EG" == Eli Gordon <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]