You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Greg Brown <gk...@mac.com> on 2010/10/01 13:48:21 UTC

Re: Pivot/SVG Salamander

> I would consider adding SVGImage to SVGSalamander.  Since it would depend
> on the pivot binaries, I'd want to put it into a separate jar.

You could do that, though it shouldn't be a problem to include everything in the same JAR. The Pivot dependency wouldn't be an issue unless someone tried to use SVGImage or SVGImageSerializer, which they presumably would only be doing if they were actually building a Pivot app (and hence already had the Pivot JARs on the classpath).

> SVGImage looks quite similar to SVGIcon, which is Salamander's custom
> extension of Icon for decorating Swing buttons.  Does Pivot handle AWT
> Icons?  If so, this might be an even easier way to render SVGSalamander
> content in Pivot without having to extend either library.

We could potentially write a Pivot Image wrapper for the Swing Icon class. However, there are a couple of issues with that approach:

1) Pivot doesn't currently have any dependency on Swing, and we would prefer to keep it that way if possible.

2) The serialization support provided by SVGImageSerializer just as important as SVGImage itself. The serializer is what allows us to embed an SVG image in a BXML file. We could theoretically write an SVGIconSerializer class, but then we're right back where we started - needing to add at least one additional class to your project.

Thanks for your help,
Greg




Re: Pivot/SVG Salamander

Posted by JLEIngenieros <jl...@gmail.com>.
Hi.

At first, I know that the post is quite old, and apologize for my english.

At second, pardon my boldness to enter into a post without invitation, but
i've a question:

In the posted code, I think that 'image logo.src' is directly inserted on
ImageView, so it's only an normal 'image', not a SVGImage.

    <ImageView styles="{verticalAlignment:'top'}">
        <image>
            <bxml:include src="logo.svg"/>
        </image>
    </ImageView>

It's possible (and correct)  to rewrite the'bxml' and 'SVGImageDemo.java'
files with anything as this?:

1. In bxml file, delete the <bxml:include src="logo.svg"/> and add a
bxml:id, as this:

    <ImageView bxml:id="myPicture" styles="{verticalAlignment:'top'}">
        <image>
            <bxml:include src="logo.svg"/>
        </image>
    </ImageView>

2. Rewrite as this (for example):
 
    //An ImageView to serialize with bxml
    ImageView myImage;        
   
    //Uri for working with svg path, string or anything else    
    URI uri = null;
   
    //Reading the svg path...
    StringReader reader = new StringReader(---any svg string, file or
similar---);
   
    //Setting the URI
    uri = SVGCache.getSVGUniverse().loadSVG(reader, "titleOf...");
   
    //Getting the SVGdiagram
    SVGDiagram myDiagram = SVGCache.getSVGUniverse().getDiagram(uri);
       
    //Getting SVGImage from SVGdiagram
    SVGImage myGetImage =new SVGImage(myDiagram);
       
    //Serializing from bxml
    myImage= (ImageView) bxmlSerializer.getNamespace().get("myPicture");
       
    //Setting the image for to work
    myImage.setImage(myGetImage);

I think that, after doing this, we can work programatically with myImage as
SVG graphic.

Thank you for comments.
Javier 



--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Pivot-SVG-Salamander-tp1609653p4022814.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.