xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas E Deweese <thomas.dewe...@kodak.com>
Subject RE: problems generating SVG
Date Wed, 11 Apr 2001 12:30:09 GMT

    Ok I'm committing 2 sins. 1 following up on myself, and 2 I've
bounced this back to Batik Users (sorry for any whiplash :).

>>>>> "TD" == Thomas E Deweese <thomas.deweese@kodak.com> writes:

>>>>> "PA" == Peter Armstrong <armstrong@intalio.com> writes:
PA> Looking at the Batik source, I see that on line 305 of
PA> JGVTComponent the following call is made:

PA> g2d.drawRenderedImage(image, null);

PA> So I assume that either:

PA> 1. This is a bug in either JGVTComponent or SVGGraphics2D.
PA> 2. JGVTComponents are not meant to be painted using SVGGraphics2D.
PA> 3. I've been sloppy and not set some variable that Batik needs.

PA> I'm hoping for #3, but I fear #1 or, even worse, #2.  Any
PA> suggestions would be *much* appreciated.

TD>     The answer is #1. SVGGraphics2D should check for xform==null.
TD> I've got a fix that I need to verify before committing.  I'll mail
TD> it to you (batik-dev will get it from the commit) when I've tested
TD> it.

    The reason is that the answer is really #1 _AND_ #2 :).

    Remember when I said:

TD>  2) having your paint method defer to an internal method myPaint
TD>     (what ever) and call that method directly when you want "just
TD>     the graphics".  This just helps to avoid any nonsense that
TD>     Swing/AWT might give you (like the not-so-helpful double
TD>     buffering in this case).

    Well swing isn't the only one trying to help you out :) 

    I realized as I walked out to my car last night, that while you
should be able to pass SVGGraphics2D into the paint method on a
JSVGComponent (hence #1, a bug in SVGGraphics2D), you still won't get
what you want (which is presumably some semblance of the original
SVG).  What you will get is one large PNG embedded in the SVG file
(hence #2, JSVGComponent really isn't meant to be painted with
SVGGraphics2D). The JSVGComponent does a lot of caching of image data
under the hood, and so it only ever draws a finished image to the
Graphics passed to it's paint method.

    What you need to do is call the 'paint' method on the root of of
the GraphicsNode tree.  This is slightly complicated by two things.

1) We don't give direct access to the root GraphicsNode from the
   JGVTComponent (base class for JSVGComponent).  I'm going to ask the
   rest of the development group if they think it is ok to do that
   (currently we have set methods but no get...).  You could work
   around this by creating a subclass (the member is protected).

2) The Paint method on GraphicsNode takes something called
   "GraphicsNodeRenderContext".  This isn't a trivial object to
   construct (and has important implications to the rendering, so be
   careful if you decide to build one yourself).  

   The easiest way to get a proper instance of this object is through
   the batik.gvt.renderer.StaticRendererFactory.getRenderContext()
   method (you will need to construct an instance of
   StaticRendererFactory first).

   This is forcing you to go at least one layer deeper in the
architecture than you should need to for what you are trying to
accomplish.  I'm considering some sort of 'short cut' paint method on
JSVGComponent that bypasses all the image caching stuff, but this is
something the dev team needs to discuss.

   Hope I haven't completely discouraged you.

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


Mime
View raw message