pivot-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Brown <gkbr...@mac.com>
Subject Re: SVG Salamander vs. org.apache.pivot.wtk.media.drawing
Date Fri, 01 Oct 2010 19:55:24 GMT
Another option that just occurred to me is to simply replace the Drawing class with the SVGImage
class from the prototype, and rename SVGImageSerializer to DrawingSerializer. These classes
could live in org.apache.pivot.wtk.media as always, but Drawing would wrap an SVG Salamander
SVGDiagram instead of an org.apache.pivot.wtk.medie.drawing.Canvas. It would be similar to
how Picture currently wraps an AWT BufferedImage.

This would of course entail a dependency on SVG Salamander, but only if callers tried to use
the Drawing class. The benefit of this approach is that applications wouldn't need to explicitly
add the SVGImageSerializer to BXMLSerializer's MIME map - Drawings could be loaded by Image.LoadTask,
as is currently done for Pictures, so instead of this:

<ImageView>
    <image>
        <bxml:include src="foo.svg"/>
    </image>
</ImageView>

we could do this:

<ImageView image="@foo.svg"/>

which I think is much nicer.

Thoughts?

G


On Oct 1, 2010, at 12:41 PM, Greg Brown wrote:

> Honestly, even if we can't get dynamic updates working, I still think it is worth dropping
the shape DOM classes. We'd still be able to use SVG diagrams as image assets, which is arguably
where they will be most valuable in a Pivot app anyways.
> 
> There's just a lot of code in the org.apache.pivot.wtk.media.drawing package that hardly
ever gets exercised, and a major release like 2.0 is probably the best time to make a change
like this. 
> 
> 
> On Oct 1, 2010, at 12:36 PM, Greg Brown wrote:
> 
>> OK, I have some dynamic updates working. I ported the "add circle" logic from Mark's
dynamic SVG sample app to the Pivot demo and it seems to work. However, I still have a couple
of questions:
>> 
>> 1) Is it possible to trigger a repaint of only those elements that have changed,
or do you need to repaint the entire diagram every time you change any element? The comments
in the dynamic SVG example are a little confusing: they say that calling update() on the Circle
won't update the parent, but calling update on the Group does appear to have some impact on
its own parent, since the Group isn't the root element. I'm not sure what the rules are, so
I'm simply calling update() (or updateTime()) on the diagram itself. Is there a better (i.e.
more efficient) way?
>> 
>> 2) I'm having some trouble resizing the image. I set the "width" and "height" attributes
of the root object as follows:
>> 
>>   SVGRoot root = diagram.getRoot();
>>   try {
>>       root.setAttribute("width", AnimationElement.AT_XML, Integer.toString(width));
>>       root.setAttribute("height", AnimationElement.AT_XML, Integer.toString(height));
>>   } catch (SVGElementException exception) {
>>       throw new RuntimeException(exception);
>>   }
>> 
>>   try {
>>       diagram.updateTime(0.0);
>>   } catch (SVGException exception) {
>>       throw new RuntimeException(exception);
>>   }
>> 
>> However, the changes don't appear to take effect until the second time I call this
code. You can see what I mean if you run the demo.
>> 
>> Any help would be much appreciated. 
>> 
>> Thanks,
>> Greg
>> 
>> <pivot_svgsalamander.zip>
>> 
>> On Oct 1, 2010, at 10:49 AM, Greg Brown wrote:
>> 
>>> FYI, Mark has explained to me how repaints are triggered. Once I get something
working in a Pivot app, I'll post an update.
>>> 
>>> On Oct 1, 2010, at 7:39 AM, Greg Brown wrote:
>>> 
>>>>> So then there are two ways to work with SVG then: as serialized file
resources (the demo today) and also building a SVGDiagram from code. I just wanted to confirm
this.
>>>> 
>>>> Yes, but we'll still need clarification from Mark on how repaints can be
triggered when an SVGDiagram is modified. Mark, can you share any insight here? How does this
work in a Swing app, for example?
>>>> 
>>> 
>> 
> 


Mime
View raw message