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 Christoph Steinbeck <st...@ice.mpg.de> on 2000/12/06 14:41:12 UTC
Re: [Jchempaint-devel] Possible bug in Batik?
Thomas E Deweese wrote:
>
> >>>>> "EW" == Egon Willighagen <eg...@subdimension.com> writes:
>
> EW> cc: to JChemPaint developers maillist Hi all,
>
> EW> i am new to this list, but like your libs very much. I saw the
> EW> announcement of beta 1 and directly integrated it with JChemPaint,
> EW> a 2D chemical editor (in Java):
>
> EW> But, unfortunetely, the generated SVG code does not render in the
> EW> Batik SVGViewer.
>
> EW> The SVG source is in JChemPaint.java, of which fragments
> EW> below. (The complete code for this program can be found in the
> EW> SourceForge CVS.)
>
> [...]
>
> EW> Everything compiles and SVG code is generated. BUT the SVG code
> EW> gives this error when rendered with: java -jar batik-svgviewer.jar
>
> EW> "The attribute 'xlink:href' on <image> can not reference elements
> EW> within an SVG file"
>
> EW> The with JChemPaint generated SVG code is (2D structure of
> EW> caffeine, which seemed appropriate):
>
> The problem is that JChemPaint appears to draw an image as the
> first thing. The default ImageHandler class for the SVGGraphics2D
> simply sets the xlink:href to the result of 'toString()' on the image
> being drawn (a fairly bogus thing to do :). A more correct thing to
> do would be to write the image to a stream (using JPEG or PNG) then
> encode it as base64 data, and embed the result in the SVG file, then
> reference that in the href.
>
> We don't do that yet :)
>
> Even if we did do that I don't think you would really get what you
> are hoping for since the 'background' image would then be fixed at a
> particular resolution. If this is what you want, then in all
> likelyhood, we will eventually do this for you.
>
> In your case though I'm guessing you will want to dig a bit deeper
> and try to capture with the SVGGraphics2D the sequence of drawing
> commands that are used to build the 'background' image as well. If
> the background drawing code does not use Graphics2D (such as directly
> manipulating the contents of the BufferedImage), then you are probably
> out of luck as far as getting a 'pure' SVG file (meaning no embedded
> pixel data).
>
> Incidentally, if I comment out the <image [...] /> tag I do get
> the basic structure with The O's and N's and single and double bonds
> drawn in, however I'm guessing these are supposed to overlay a drawing
> of the atoms.
No, actually that's exactly what JChemPaint does. A line drawing of
single, double, triple bonds with, at least in this case, element
symbols of all heavy atoms except Carbon. So from, what you say, it
seems we are not so far away from our goal.
Cheers,
Chris
--
Dr. Christoph Steinbeck (http://www.ice.mpg.de/departments/ChemInf)
MPI of Chemical Ecology, Carl-Zeiss-Promenade 10, 07745 Jena, Germany
Tel: +49(0)3641 643644 - Fax: +49(0)3641 643665
What is man but that lofty spirit - that sense of enterprise.
... Kirk, "I, Mudd," stardate 4513.3..