Login | Register
My pages Projects Community openCollabNet

Discussions > dev > Re: [gef-dev] Exporting a diagram to SVG

gef
Discussion topic

Back to topic list

Re: [gef-dev] Exporting a diagram to SVG

Reply

Author penyaskito
Full name Christian López Espínola
Date 2008-11-29 05:48:06 PST
Message Hi,

On Sat, Nov 29, 2008 at 2:19 PM, Bob Tarling <bob dot tarling at gmail dot com> wrote:
> I'm not sure how much help I can be here. But I'm surprised that
> LayerGrid is being called to createa a diagram image. I'd have thought
> for generating any kind of diagram image that this would want to be
> ignored.

I was surprised too. BTW, I haven't checked the logic behind this.
AFAIK, there is a (set/get)PaintActiveOnly flag in the layers that
checks if it should paint all the layers, but it isn't referenced in
all the code.
BTW, I committed the patch that checks for null.

> The other thing I've been considering is to use batik to create the SVG.
>
> Upside - we leave SVG to the experts and remove some of our code base.
>
> Downside - if there is a defect we can no longer resolve it ourselves.

I'm +1 on delegating to other libraries.
Are you thinking about using batik in GEF? or just dropping our
support for exporting images and let the applications care of this?

> Bob
>
> 2008/11/28 Christian López Espínola <penyaskito at gmail dot com>:
>> 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) {
>> ce.print(writer);
>> writer.dispose();
>> }
>> } catch (IOException e) {
>> e.printStackTrace();
>> } catch (Exception e) {
>> e.printStackTrace();
>> }
>> 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
>> http://java.sun.com/​j2se/1.4.2/docs/api/​java/awt/Graphics.ht​ml#getClipBounds()
>> 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.
>>
>>
>>
>> --
>> Cheers,
>>
>> Christian López Espínola <penyaskito>
>>
>
> --------------------​--------------------​--------------------​---------
> To unsubscribe, e-mail: dev-unsubscribe at gef dot tigris dot org
> For additional commands, e-mail: dev-help at gef dot tigris dot org
>
>



--
Cheers,

Christian López Espínola <penyaskito>

« Previous message in topic | 3 of 4 | Next message in topic »

Messages

Show all messages in topic

Exporting a diagram to SVG penyaskito Christian López Espínola 2008-11-28 15:58:41 PST
     Re: [gef-dev] Exporting a diagram to SVG bobtarling Bob Tarling 2008-11-29 05:19:40 PST
         Re: [gef-dev] Exporting a diagram to SVG penyaskito Christian López Espínola 2008-11-29 05:48:06 PST
             Re: [gef-dev] Exporting a diagram to SVG bobtarling Bob Tarling 2008-11-30 16:07:56 PST
Messages per page: