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 Bastien DEBLAIS <bd...@iftechnologies.net> on 2005/07/07 10:55:27 UTC

new method to do a clipping

Hi thomas,

i found a method to do a clipping and save it into an other svgFile.
it's to change the value of the rootElement of the svgFile

but i have a problem lol : ) :i do a "setAttribut( )" but i dont change my attribut into the svgFile.
how can i change the value ?

.../...

//METHODE DE CLIPPING
        String svgURS = new File(rep+Sortie).toURL().toString();
        System.out.println("svgURS = "+ svgURS);
        UserAgent userAgent1 = new UserAgentAdapter();
        DocumentLoader docload1 = new DocumentLoader(userAgent1); 
        Document doc1 = docload1.loadDocument(svgURS); 
        
        String parser = XMLResourceDescriptor.getXMLParserClassName();
        SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
        Document doc = f.createDocument(svgURS);

                
        
        Element elt1 = doc1.getDocumentElement();
        Element elt = doc.getDocumentElement();
        
        boolean res1 = elt1.hasAttributeNS(null, "width");
        boolean res2 = elt.hasAttributeNS(null, "width");
        
        System.out.println("res1 = "+res1);
        System.out.println("res2 = "+res2);
        
        String res = elt1.getAttributeNS(null, "width");
        String res3 = elt.getAttributeNS(null, "width");
        
        System.out.println("width = " + res);
        System.out.println("width = " + res3);
        
        //elt1.removeAttributeNS(null, "width");
        
        
        //elt1.removeAttributeNS(null, "viewBox");
        elt1.setAttributeNS(null, "width", "250");
        res = elt1.getAttributeNS(null, "width");
        System.out.println("width = " + res);
        elt.setAttributeNS(null, "width", "250");
        res3 = elt.getAttributeNS(null, "width");
        System.out.println("width = " + res3);
        res3 = elt.getAttributeNS(null, "viewBox");
        System.out.println("width = " + res3);
        
        elt1.setAttributeNS(null, "viewBox", "100 100 100 100");
        
        GVTBuilder builder = new GVTBuilder();
        BridgeContext ctx = new BridgeContext(userAgent1,docload1);
        GraphicsNode gn = builder.build(ctx,elt1);
        

Re: new method to do a clipping

Posted by Bastien DEBLAIS <bd...@iftechnologies.net>.
ok thanks very much its works perfectely.
----- Original Message ----- 
From: "Thomas DeWeese" <Th...@Kodak.com>
Newsgroups: gmane.text.xml.batik.user
Sent: Thursday, July 07, 2005 1:58 PM
Subject: Re: new method to do a clipping


> Bastien DEBLAIS wrote:
>
> > i found a method to do a clipping and save it into an other svgFile.
> > it's to change the value of the rootElement of the svgFile
>
>    Ohh, you just want to set the initial view?  You don't want
> to actually clip the data to that view?  If the destination
> viewer is Batik you can actually do this with _no_ modifications
> to the content.  SVG supports 'viewBox linking' so you can have
> a URL that specifies the viewBox to be used in the fragment
> identifier:
>
> xlink:href="anne.svg#svgView(viewBox(125,125,100,100))"
>
>     Unfortunately I don't think this is supported by Adobe...
>
> > but i have a problem lol : ) :i do a "setAttribut( )" but i dont change
> > my attribut into the svgFile.
> > how can i change the value ?
>
>     If you need to rewrite the file you can use the static method:
>
> org.apache.batik.dom.util.DOMUtilities.writeDocument(Document, Writer)
>
>     Note that this will not make the file any smaller it will just
> change the portion that is visible when someone loads the document.




---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: new method to do a clipping

Posted by Bastien DEBLAIS <bd...@iftechnologies.net>.
Another kestion, i see you can write a document with a node.So  i try to
re-use your graphicsNode and the method clipping
but i write me that the convertion its impossible
how to return a graphicsNode or other Graphics to use the mode "setClip"
with a document or a element existing



----- Original Message ----- 
From: "Thomas DeWeese" <Th...@Kodak.com>
Newsgroups: gmane.text.xml.batik.user
Sent: Thursday, July 07, 2005 1:58 PM
Subject: Re: new method to do a clipping


> Bastien DEBLAIS wrote:
>
> > i found a method to do a clipping and save it into an other svgFile.
> > it's to change the value of the rootElement of the svgFile
>
>    Ohh, you just want to set the initial view?  You don't want
> to actually clip the data to that view?  If the destination
> viewer is Batik you can actually do this with _no_ modifications
> to the content.  SVG supports 'viewBox linking' so you can have
> a URL that specifies the viewBox to be used in the fragment
> identifier:
>
> xlink:href="anne.svg#svgView(viewBox(125,125,100,100))"
>
>     Unfortunately I don't think this is supported by Adobe...
>
> > but i have a problem lol : ) :i do a "setAttribut( )" but i dont change
> > my attribut into the svgFile.
> > how can i change the value ?
>
>     If you need to rewrite the file you can use the static method:
>
> org.apache.batik.dom.util.DOMUtilities.writeDocument(Document, Writer)
>
>     Note that this will not make the file any smaller it will just
> change the portion that is visible when someone loads the document.




---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: new method to do a clipping

Posted by Thomas DeWeese <Th...@Kodak.com>.
Bastien DEBLAIS wrote:

> i found a method to do a clipping and save it into an other svgFile.
> it's to change the value of the rootElement of the svgFile

   Ohh, you just want to set the initial view?  You don't want
to actually clip the data to that view?  If the destination
viewer is Batik you can actually do this with _no_ modifications
to the content.  SVG supports 'viewBox linking' so you can have
a URL that specifies the viewBox to be used in the fragment
identifier:

	xlink:href="anne.svg#svgView(viewBox(125,125,100,100))"

    Unfortunately I don't think this is supported by Adobe...

> but i have a problem lol : ) :i do a "setAttribut( )" but i dont change 
> my attribut into the svgFile.
> how can i change the value ?

    If you need to rewrite the file you can use the static method:

org.apache.batik.dom.util.DOMUtilities.writeDocument(Document, Writer)

    Note that this will not make the file any smaller it will just
change the portion that is visible when someone loads the document.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org