Login | Register
My pages Projects Community openCollabNet

Discussions > dev > Exporting a diagram to SVG > Reply to message

Reply to message

2020-04-07: This site is going to be decommissioned and shut down on 2020-07-01. Please copy and archive any data you wish to keep before that date.

* = Required fields
* Subject
* Body
Send reply to
Author (directly in email)
Please type the letters in the image above.

Original message

Author penyaskito
Full name Christian López Espínola
Date 2008-11-28 15:58:41 PST
Message Hi,

In the development of ArgoPrint, we need to export a diagram to SVG
and inline in into HTML. For this there is a helper method that use
GEF's SvgWriter.
There we use something like this:

            ByteArrayOutputStream buff = new ByteArrayOutputStream();
        Editor ce = Globals.curEditor();
        Layer layer = ce.getLayerManager()​.getActiveLayer();
        Rectangle drawingArea = layer.calcDrawingArea();
        try {
            SvgWriter writer = new SvgWriter(buff, drawingArea);
            if (writer != null) {
        } catch (IOException e) {
        } catch (Exception e) {
        return buff.toString();

But we get a NPE in LayerGrid:
 L169: Rectangle clip = g.getClipBounds();

g, of type Graphics, is the writer itself. It's obvious that there is
a bug here, but I'm not sure where it should be considered a bug:

Is fine that the getClipBounds method of a Graphics class returns
null? In terms of what I see in
it can occur.

Is the bug in SvgWriter, returning null in getClipBounds? Or in
LayerGrid, that doesn't check for null conditions?
Checking for null in LayerGrid seems to fix the problem, but I wanted
to be sure before commiting.


Christian López Espínola <penyaskito>