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 "guillaume.poissonnier@laposte.net" <gu...@laposte.net> on 2003/05/09 19:05:28 UTC

Problem with SVGGraphics2D

Hello,

I want to generate a SVG file from an other svg source file. So, I created a document from the source file. I tried to manipulate it after the creation and it works well. Then, I created an instance of SVGGraphics2D with this document in parameter and I used the stream method to see the result on the screen. And here appeared my problem : the output was an empty svg document.

My question is : is this the right method to reach my goal ?
If yes, wth's wrong in my code :

public void genererSVG(String nomFichier)
{
	try {
		String parser = XMLResourceDescriptor.getXMLParserClassName();
	    	SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
    	
		m_document = f.createDocument(new File(m_fondCarte).toURL().toString());
	} catch (IOException e) {
	      e.printStackTrace();
	}
   
	SVGGraphics2D svgGenerator = new SVGGraphics2D(m_document);
	
	try {
		//OutputStream output = new FileOutputStream(nomFichier) ;
		boolean useCSS = false; 
	      //Writer out = new OutputStreamWriter(output, "UTF-8");
 	      Writer out = new OutputStreamWriter(System.out, "UTF-8");
	      svgGenerator.stream(out, useCSS);
	} catch (IOException e) {
	      e.printStackTrace();
	}
}

-- 
Guillaume Poissonnier

Accédez au courrier électronique de La Poste : www.laposte.net ; 
3615 LAPOSTENET (0,34€/mn) ; tél : 08 92 68 13 50 (0,34€/mn)"




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


Re: Problem with SVGGraphics2D

Posted by Vincent Hardy <vi...@sun.com>.
Bonjour Guillaume,

The probleme with your code is that SVGGraphics2D does not populate the 
Document you pass in. The Document is only used as a factory to create a 
DOM branch which is not actually hooked to the Document. I think that 
having a look at the stream method in SVGGraphics2D will make it clear.

Good luck with your project,
Vincent.

guillaume.poissonnier@laposte.net wrote:

>Hello,
>
>I want to generate a SVG file from an other svg source file. So, I created a document from the source file. I tried to manipulate it after the creation and it works well. Then, I created an instance of SVGGraphics2D with this document in parameter and I used the stream method to see the result on the screen. And here appeared my problem : the output was an empty svg document.
>
>My question is : is this the right method to reach my goal ?
>If yes, wth's wrong in my code :
>
>public void genererSVG(String nomFichier)
>{
>	try {
>		String parser = XMLResourceDescriptor.getXMLParserClassName();
>	    	SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
>    	
>		m_document = f.createDocument(new File(m_fondCarte).toURL().toString());
>	} catch (IOException e) {
>	      e.printStackTrace();
>	}
>   
>	SVGGraphics2D svgGenerator = new SVGGraphics2D(m_document);
>	
>	try {
>		//OutputStream output = new FileOutputStream(nomFichier) ;
>		boolean useCSS = false; 
>	      //Writer out = new OutputStreamWriter(output, "UTF-8");
> 	      Writer out = new OutputStreamWriter(System.out, "UTF-8");
>	      svgGenerator.stream(out, useCSS);
>	} catch (IOException e) {
>	      e.printStackTrace();
>	}
>}
>
>  
>



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