Hi Randy,
[EMAIL PROTECTED] wrote on 04/17/2007 04:10:19 PM:
>
> I hope somebody can shed some light on this.
>
> Basically, I want to do in software what could be done with a
> control-drag-mousebutton1. Seems like there could be a simple
> interface to call to do this, but I haven't found it yet.
See batik.bridge.ViewBox
/**
* Parses the specified reference (from a URI) and returns the
appropriate
* transform.
*
* @param ref the reference of the URI that may specify additional
attribute
* values such as the viewBox, preserveAspectRatio or a
transform
* @param e the element interested in its view transform
* @param w the width of the effective viewport
* @param h The height of the effective viewport
* @param ctx The BridgeContext to use for error information
* @exception BridgeException if an error occured while computing the
* preserveAspectRatio transform
*/
public static AffineTransform getViewTransform(String ref,
Element e,
float w,
float h,
BridgeContext ctx) {
> I'm trying to implement what I call a "pre-zoomed" SVG file. In my
> SVG file, I have added an element <x:defaultpicturesize viewBox="x y w
h"/>.
You probably want to look at:
http://www.w3.org/TR/SVG11/linking.html#SVGFragmentIdentifiers
As this is more or less already built into Batik.
> Since I haven't found a call to "zoom it to this box", I tried using
> setRenderingTransform(). After loading the SVG file (and after
> gvtRenderingCompleted() is called), I look for this element. If I
> find one, I create an AffineTransform and call setRenderingTransform()
>
> The problem is that this thing does not do what I expect it to.
Affine transforms rarely do what you expect them to do unless
you have been working with them for quite a while. My guess is that
you aren't considering the viewBox transform which it sounds like may
be introducing a small scale and or translate.
> It is easy enough to center up the picture (if that's all I wanted
> to do). I simply calculate the difference between the center of the
> <svg:svg viewbox="..."> and the center of my desired viewbox. This
> is straightforward and produces a view that looks close to centered
> (but clearly is not exactly centered)
>
> When I apply a scaling transformation things go very off. First of
> all, scaling appears to happen based on the upper left-hand corner
> of the picture. For example, if I only scale (say 2x) what
> previously was in the upper left-hand corner now fills the entire
display.
>
> So I think, translate the upper left-hand corner of the desired
> viewbox to the x and y of the <svg:svg> viewbox and then scale.
> Still not right. Then I think, okay, it's scaling first so my
> translation values actually need to be multiplied by the scale
> factor - better but still not right.
>
> What am I missing here? Seems like this should be an easy thing to do.
>
> Regards,
> Randy
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]